From ed755105cc299d13b28a5b64d3f78086ee804371 Mon Sep 17 00:00:00 2001 From: Ronald Moesbergen Date: Wed, 26 Feb 2025 13:55:46 +0100 Subject: [PATCH] chore: connect to backend through relative paths (#170) --- .env | 5 ----- .github/workflows/deploy.yaml | 17 +++++++++++------ .gitignore | 3 ++- src/lib/matomo.ts | 9 ++++----- 4 files changed, 17 insertions(+), 17 deletions(-) delete mode 100644 .env diff --git a/.env b/.env deleted file mode 100644 index 5d1a799..0000000 --- a/.env +++ /dev/null @@ -1,5 +0,0 @@ -VITE_MATOMO_URL="https://leaphyeasybloqs.com/matomo/" -VITE_MATOMO_SITE_ID="1" -VITE_BACKEND_URL="https://leaphyeasybloqs.com" -VITE_RECORDINGS_API="https://recordings.leaphyeasybloqs.com" -VITE_RECORDINGS_ADDRESS=".leaphyeasybloqs.com" diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 48c5e7a..dc4504c 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -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 @@ -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" @@ -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: diff --git a/.gitignore b/.gitignore index 784299c..8562ab8 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ node_modules dist dist-ssr *.local +.env # Editor directories and files .vscode/* @@ -26,4 +27,4 @@ dist-ssr /blob-report/ /playwright/.cache/ -vite.config.ts.timestamp*.mjs \ No newline at end of file +vite.config.ts.timestamp*.mjs diff --git a/src/lib/matomo.ts b/src/lib/matomo.ts index af3374a..a2cc3f4 100644 --- a/src/lib/matomo.ts +++ b/src/lib/matomo.ts @@ -7,13 +7,12 @@ 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; @@ -21,7 +20,7 @@ function initMatomo() { 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); }