aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Corentin Thomasset <corentin.thomasset74@gmail.com> 2022-04-16 11:51:20 +0200
committerGravatar Corentin Thomasset <corentin.thomasset74@gmail.com> 2022-04-16 11:51:20 +0200
commit0808920951b55c938537f33353a37ece96b04084 (patch)
tree29698750206ea163c8e780debae702ccb04c46d7
parent3f038503dd705ba3a5562a1e8f85a3b0e7d0be5b (diff)
downloadit-tools-0808920951b55c938537f33353a37ece96b04084.tar.gz
it-tools-0808920951b55c938537f33353a37ece96b04084.tar.zst
it-tools-0808920951b55c938537f33353a37ece96b04084.zip
feat: added plausible tracker
-rw-r--r--env.d.ts2
-rw-r--r--package-lock.json14
-rw-r--r--package.json1
-rw-r--r--src/main.ts2
-rw-r--r--src/plugins/plausible.plugin.ts17
5 files changed, 36 insertions, 0 deletions
diff --git a/env.d.ts b/env.d.ts
index 25a0ba9..53d0520 100644
--- a/env.d.ts
+++ b/env.d.ts
@@ -2,6 +2,8 @@
/// <reference types="vite-svg-loader" />
interface ImportMetaEnv {
+ VITE_PLAUSIBLE_API_HOST: string;
+ VITE_PLAUSIBLE_DOMAIN: string;
PACKAGE_VERSION: string;
PROD: boolean;
}
diff --git a/package-lock.json b/package-lock.json
index 67a1c99..7d597d7 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -22,6 +22,7 @@
"lodash": "^4.17.21",
"naive-ui": "^2.28.0",
"pinia": "^2.0.11",
+ "plausible-tracker": "^0.3.5",
"qrcode": "^1.5.0",
"randombytes": "^2.1.0",
"uuid": "^8.3.2",
@@ -8187,6 +8188,14 @@
}
}
},
+ "node_modules/plausible-tracker": {
+ "version": "0.3.5",
+ "resolved": "https://registry.npmjs.org/plausible-tracker/-/plausible-tracker-0.3.5.tgz",
+ "integrity": "sha512-6c6VPdPtI9KmIsfr8zLBViIDMt369eeaNA1J8JrAmAtrpSkeJWvjwcJ+cLn7gVJn5AtQWC8NgSEee2d/5RNytA==",
+ "engines": {
+ "node": ">=10"
+ }
+ },
"node_modules/pngjs": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/pngjs/-/pngjs-5.0.0.tgz",
@@ -16898,6 +16907,11 @@
}
}
},
+ "plausible-tracker": {
+ "version": "0.3.5",
+ "resolved": "https://registry.npmjs.org/plausible-tracker/-/plausible-tracker-0.3.5.tgz",
+ "integrity": "sha512-6c6VPdPtI9KmIsfr8zLBViIDMt369eeaNA1J8JrAmAtrpSkeJWvjwcJ+cLn7gVJn5AtQWC8NgSEee2d/5RNytA=="
+ },
"pngjs": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/pngjs/-/pngjs-5.0.0.tgz",
diff --git a/package.json b/package.json
index cf65d8d..b5c29c0 100644
--- a/package.json
+++ b/package.json
@@ -28,6 +28,7 @@
"lodash": "^4.17.21",
"naive-ui": "^2.28.0",
"pinia": "^2.0.11",
+ "plausible-tracker": "^0.3.5",
"qrcode": "^1.5.0",
"randombytes": "^2.1.0",
"uuid": "^8.3.2",
diff --git a/src/main.ts b/src/main.ts
index 8de1ca5..fe0b02f 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -2,6 +2,7 @@ import { createApp } from 'vue';
import { createPinia } from 'pinia';
import { createHead } from '@vueuse/head';
import { registerSW } from 'virtual:pwa-register';
+import { plausible } from './plugins/plausible.plugin';
registerSW();
@@ -16,5 +17,6 @@ app.use(createPinia());
app.use(createHead());
app.use(router);
app.use(naive);
+app.use(plausible);
app.mount('#app');
diff --git a/src/plugins/plausible.plugin.ts b/src/plugins/plausible.plugin.ts
new file mode 100644
index 0000000..7acfe02
--- /dev/null
+++ b/src/plugins/plausible.plugin.ts
@@ -0,0 +1,17 @@
+import Plausible, { type PlausibleOptions } from 'plausible-tracker';
+import type { App } from 'vue';
+
+const options: PlausibleOptions = {
+ domain: import.meta.env.VITE_PLAUSIBLE_DOMAIN ,
+ apiHost: import.meta.env.VITE_PLAUSIBLE_API_HOST,
+ trackLocalhost: false,
+};
+
+export const plausible = {
+ install: (app: App) => {
+ const plausible = Plausible(options);
+ plausible.enableAutoPageviews();
+
+ app.config.globalProperties.$plausible = plausible;
+ },
+};