mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-05-08 23:25:03 -04:00
Merge branch 'CorentinTh:main' into main
This commit is contained in:
commit
7563def348
3 changed files with 32 additions and 3 deletions
|
@ -72,8 +72,6 @@ const menuOptions = computed(() =>
|
||||||
);
|
);
|
||||||
|
|
||||||
const themeVars = useThemeVars();
|
const themeVars = useThemeVars();
|
||||||
|
|
||||||
console.log(themeVars.value);
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="less">
|
<style scoped lang="less">
|
||||||
|
|
|
@ -29,6 +29,12 @@ export const config = figue({
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
plausible: {
|
plausible: {
|
||||||
|
isTrackerEnabled: {
|
||||||
|
doc: 'Is the tracker enabled',
|
||||||
|
format: 'boolean',
|
||||||
|
default: false,
|
||||||
|
env: 'VITE_TRACKER_ENABLED',
|
||||||
|
},
|
||||||
domain: {
|
domain: {
|
||||||
doc: 'Plausible current domain',
|
doc: 'Plausible current domain',
|
||||||
format: 'string',
|
format: 'string',
|
||||||
|
|
|
@ -1,11 +1,36 @@
|
||||||
import { config } from '@/config';
|
import { config } from '@/config';
|
||||||
|
import { noop } from 'lodash';
|
||||||
|
|
||||||
import Plausible from 'plausible-tracker';
|
import Plausible from 'plausible-tracker';
|
||||||
import type { App } from 'vue';
|
import type { App } from 'vue';
|
||||||
|
|
||||||
|
function createFakePlausibleInstance(): Pick<ReturnType<typeof Plausible>, 'trackEvent' | 'enableAutoPageviews'> {
|
||||||
|
return {
|
||||||
|
trackEvent: noop,
|
||||||
|
enableAutoPageviews: () => noop,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function createPlausibleInstance({
|
||||||
|
config,
|
||||||
|
}: {
|
||||||
|
config: {
|
||||||
|
isTrackerEnabled: boolean;
|
||||||
|
domain: string;
|
||||||
|
apiHost: string;
|
||||||
|
trackLocalhost: boolean;
|
||||||
|
};
|
||||||
|
}) {
|
||||||
|
if (config.isTrackerEnabled) {
|
||||||
|
return Plausible(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
return createFakePlausibleInstance();
|
||||||
|
}
|
||||||
|
|
||||||
export const plausible = {
|
export const plausible = {
|
||||||
install: (app: App) => {
|
install: (app: App) => {
|
||||||
const plausible = Plausible(config.plausible);
|
const plausible = createPlausibleInstance({ config: config.plausible });
|
||||||
plausible.enableAutoPageviews();
|
plausible.enableAutoPageviews();
|
||||||
|
|
||||||
app.provide('plausible', plausible);
|
app.provide('plausible', plausible);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue