File tree Expand file tree Collapse file tree 6 files changed +35
-33
lines changed Expand file tree Collapse file tree 6 files changed +35
-33
lines changed Original file line number Diff line number Diff line change 1515 "vue-command" : " ^35.2.1" ,
1616 "vue-cookie-law" : " github:elasticdotventures/vue-cookie-law" ,
1717 "vue-cookie-next" : " ^1.3.0" ,
18- "vue-gtag" : " ^2.0.1 "
18+ "vue-gtag-next " : " ^1.14.0 "
1919 },
2020 "devDependencies" : {
2121 "@vitejs/plugin-vue" : " ^4.5.0" ,
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ const commands = {
2424<template >
2525 <div class =" cli-container" >
2626 <vue-command :commands =" commands" :hide-buttons =" true" :show-help =" true" :cursor-position =" 0" :is-fullscreen =" true" >
27- <template #title >Command Line Interface v0.1 -- type "help" for instructions</template >
27+ <template #title >Command Line Interface v0.2 -- type "help" for instructions</template >
2828 <template #prompt >
2929 <span class =" prompt" >
3030 <span class =" prompt-user" >guest</span >
Original file line number Diff line number Diff line change 1010</template >
1111
1212<script lang="ts">
13- import useCookies from ' ../useCookies' ;
14- import { defineComponent , getCurrentInstance } from ' vue' ;
13+ import { defineComponent } from ' vue' ;
1514import { useMainStore } from ' ../store' ;
15+ import { useState } from ' vue-gtag-next' ;
1616
1717export default defineComponent ({
1818 setup() {
19- const instance = getCurrentInstance ();
20- const gtag = instance ?.appContext .config .globalProperties .$gtag ;
2119 const mainStore = useMainStore ();
22-
23- const { allowCookies } = useCookies (gtag );
20+ const { isEnabled } = useState ();
2421
2522 const handleConsent = () => {
26- allowCookies .value = true ;
2723 mainStore .setCookieConsent (' accepted' );
28- if (gtag ) {
29- gtag . optIn ();
24+ if (isEnabled ) {
25+ isEnabled . value = true ; // Enable tracking
3026 }
3127 };
3228
3329 const handleReject = () => {
34- allowCookies .value = false ;
3530 mainStore .setCookieConsent (' rejected' );
36- if (gtag ) {
37- gtag . optOut ();
31+ if (isEnabled ) {
32+ isEnabled . value = false ; // Disable tracking
3833 }
3934 };
4035
@@ -97,4 +92,4 @@ export default defineComponent({
9792.reject-button :hover {
9893 background-color : darkgrey ;
9994}
100- </style >
95+ </style >
Original file line number Diff line number Diff line change @@ -4,26 +4,33 @@ import { createApp } from 'vue'
44import './style.css'
55import App from './App.vue'
66// https://matteo-gabriele.gitbook.io/vue-gtag/
7- import VueGtag from "vue-gtag" ;
7+ import VueGtag from "vue-gtag-next " ;
88import { VueCookieNext } from 'vue-cookie-next' ;
99import { createPinia } from 'pinia'
1010
11- // An application instance won't render anything until its .mount() method is called
11+ // // An application instance won't render anything until its .mount() method is called
1212const app = createApp ( App ) ;
13- const pinia = createPinia ( )
14-
15- app
16- . use ( pinia )
17- . use ( VueCookieNext )
18- . use ( VueGtag , {
19- config : {
20- id : "G-XP9X9LHTDV" ,
21- params : {
22- anonymize_ip : true
23- }
24- } ,
25- enabled : false
26- } )
27- . provide ( 'gtag' , app . config . globalProperties . $gtag )
28- . mount ( '#app' )
13+
14+ app . use ( createPinia ( ) ) ;
15+
16+ app . use ( VueCookieNext ) ;
17+
18+ // app.use(VueGtag, {
19+ // config: {
20+ // id: "G-XP9X9LHTDV",
21+ // params: {
22+ // anonymize_ip: true
23+ // }
24+ // },
25+ // enabled: false
26+ // })
27+ // .provide('gtag', app.config.globalProperties.$gtag);
28+
29+ app . use ( VueGtag , {
30+ property : { id : "G-XP9X9LHTDV" } ,
31+ isEnabled : false ,
32+ } ) ;
33+
34+ app . mount ( '#app' ) ;
35+
2936
You can’t perform that action at this time.
0 commit comments