From d8d1948c1dbd45b704a9e62b2e958acfc56b115a Mon Sep 17 00:00:00 2001 From: Leo Nicolle Date: Sat, 2 Mar 2024 18:57:26 +0100 Subject: [PATCH 1/2] 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"; From 191120af88a97341bbaf258759f05aeddecbe5b5 Mon Sep 17 00:00:00 2001 From: Leo Nicolle Date: Sun, 3 Mar 2024 14:44:24 +0100 Subject: [PATCH 2/2] telemetry --- client/src/components/ExportButton.vue | 4 ++-- client/src/components/forms/BannedWords.vue | 13 +++---------- client/src/components/forms/Words.vue | 3 +++ client/src/components/modals/ExportModal.vue | 3 ++- client/src/components/modals/GridCopyModal.vue | 2 -- client/src/js/{plausible.ts => telemetry.ts} | 8 ++++---- client/src/main.ts | 1 - client/src/router/index.ts | 2 +- client/src/views/Book.vue | 5 +++++ client/src/views/Books.vue | 3 +++ client/src/views/Fonts.vue | 3 ++- client/src/views/Styles.vue | 3 +++ client/src/views/Words.vue | 3 +++ nginx-proxy.conf | 5 +++-- 14 files changed, 34 insertions(+), 24 deletions(-) rename client/src/js/{plausible.ts => telemetry.ts} (68%) diff --git a/client/src/components/ExportButton.vue b/client/src/components/ExportButton.vue index 945d6cc..f0b1f40 100644 --- a/client/src/components/ExportButton.vue +++ b/client/src/components/ExportButton.vue @@ -8,7 +8,7 @@