From d8d1948c1dbd45b704a9e62b2e958acfc56b115a Mon Sep 17 00:00:00 2001 From: Leo Nicolle Date: Sat, 2 Mar 2024 18:57:26 +0100 Subject: [PATCH] do not use auto track, use manual track --- .github/workflows/deploy.yml | 1 + client/src/main.ts | 3 +-- client/src/router/index.ts | 24 ++++++++++++++++++------ nginx-proxy.conf | 4 ++-- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 5bbca78..f357297 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -4,6 +4,7 @@ on: push: branches: - master + - plausible jobs: deploy: diff --git a/client/src/main.ts b/client/src/main.ts index c4d7ec0..df2c844 100644 --- a/client/src/main.ts +++ b/client/src/main.ts @@ -13,5 +13,4 @@ const app = createApp(App) .use(naive) .use(i18n); -app.mount('#app'); -plausible.enableAutoPageviews(); \ No newline at end of file +app.mount('#app'); \ No newline at end of file diff --git a/client/src/router/index.ts b/client/src/router/index.ts index e825f74..ae99237 100644 --- a/client/src/router/index.ts +++ b/client/src/router/index.ts @@ -1,5 +1,6 @@ import { createRouter, createWebHashHistory, createWebHistory, RouteRecordRaw } from 'vue-router'; import { api } from '../api'; +import { trackPageview } from '../js/plausible'; const routes: Array = [ { @@ -117,13 +118,24 @@ const router = createRouter({ }); router.beforeEach(async (to, from) => { + + try { + if (to.name) { + trackPageview({ + url: to.name + }); + } + } catch (e) { + console.error(e); + } + const isSignedin = await api.isSignedIn(); - // if ( - // !isSignedin && - // to.meta.requiresAuth !== false - // ) { - // return { name: 'login', query: { redirect: to.name } }; - // } + if ( + !isSignedin && + to.meta.requiresAuth !== false + ) { + return { name: 'login', query: { redirect: to.name } }; + } }); export default router; diff --git a/nginx-proxy.conf b/nginx-proxy.conf index 790b6c6..0cc7249 100644 --- a/nginx-proxy.conf +++ b/nginx-proxy.conf @@ -25,7 +25,7 @@ add_header Cross-Origin-Embedder-Policy require-corp; } - location /plausible { + location = /plausible/api/event { add_header X-Cache $upstream_cache_status; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; @@ -34,7 +34,7 @@ proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_max_temp_file_size 0; - proxy_pass http://localhost:51000; + proxy_pass http://localhost:51000/api/event; proxy_redirect off; proxy_read_timeout 240s; add_header Access-Control-Allow-Origin "http://motsflex.com";