feat: added plausible tracker

This commit is contained in:
Corentin Thomasset 2022-04-16 11:51:20 +02:00
parent 3f038503dd
commit 0808920951
No known key found for this signature in database
GPG key ID: DBD997E935996158
5 changed files with 36 additions and 0 deletions

2
env.d.ts vendored
View file

@ -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;
}

14
package-lock.json generated
View file

@ -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",

View file

@ -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",

View file

@ -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');

View file

@ -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;
},
};