Skip to content

Commit

Permalink
chore: connect to backend through relative paths (#170)
Browse files Browse the repository at this point in the history
  • Loading branch information
rmoesbergen authored Feb 26, 2025
1 parent 58b8b6e commit ed75510
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
5 changes: 0 additions & 5 deletions .env

This file was deleted.

17 changes: 11 additions & 6 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,9 @@ jobs:
if: github.ref_type == 'branch'
run: |
cat << EOF > .env
VITE_BACKEND_URL="https://testleaphyeasybloqs.com"
VITE_MATOMO_URL="https://leaphyeasybloqs.com/matomo/"
VITE_MATOMO_SITE_ID="2"
VITE_BACKEND_URL=""
VITE_SENTRY_DSN="${{ secrets.VITE_SENTRY_DSN }}"
VITE_SENTRY_SAMPLE_RATE="1.0"
VITE_SENTRY_SAMPLE_RATE="0.0"
VITE_RECORDINGS_API="https://recordings.leaphyeasybloqs.com"
VITE_RECORDINGS_ADDRESS=".testleaphyeasybloqs.com"
EOF
Expand All @@ -46,8 +44,8 @@ jobs:
if: github.ref_type == 'tag'
run: |
cat << EOF > .env
VITE_BACKEND_URL="https://leaphyeasybloqs.com"
VITE_MATOMO_URL="https://leaphyeasybloqs.com/matomo/"
VITE_BACKEND_URL=""
VITE_MATOMO_URL="/matomo/"
VITE_MATOMO_SITE_ID="1"
VITE_SENTRY_DSN="${{ secrets.VITE_SENTRY_DSN }}"
VITE_SENTRY_SAMPLE_RATE="0.0"
Expand All @@ -66,6 +64,13 @@ jobs:
yarn --frozen-lockfile --prefer-offline
yarn build
- name: Upload build files
if: github.ref_type == 'tag'
uses: actions/upload-artifact@v4
with:
name: leaphyeasybloqs-${{ github.ref_name }}
path: ./dist

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ node_modules
dist
dist-ssr
*.local
.env

# Editor directories and files
.vscode/*
Expand All @@ -26,4 +27,4 @@ dist-ssr
/blob-report/
/playwright/.cache/

vite.config.ts.timestamp*.mjs
vite.config.ts.timestamp*.mjs
9 changes: 4 additions & 5 deletions src/lib/matomo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,20 @@ declare global {
function initMatomo() {
// Always create the _paq array so dev code works
const _paq = (window._paq = window._paq || []);
// Only track prod builds
if (!import.meta.env.PROD) return;
const url = import.meta.env.VITE_MATOMO_URL;
if (!url) return;

const u = import.meta.env.VITE_MATOMO_URL;
_paq.push(["trackPageView"]);
_paq.push(["enableLinkTracking"]);
_paq.push(["setTrackerUrl", `${u}matomo.php`]);
_paq.push(["setTrackerUrl", `${url}matomo.php`]);
_paq.push(["setSiteId", import.meta.env.VITE_MATOMO_SITE_ID]);

const d = document;
const g = d.createElement("script");
const s = d.getElementsByTagName("script")[0];
g.type = "text/javascript";
g.async = true;
g.src = `${u}matomo.js`;
g.src = `${url}matomo.js`;
s.parentNode.insertBefore(g, s);
}

Expand Down

0 comments on commit ed75510

Please sign in to comment.