@dargmuesli/nuxt-vio 11.0.0-beta.4 → 11.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/components/vio/_/VioApp.vue +1 -13
- package/composables/useVioGtag.ts +42 -0
- package/nuxt.config.ts +24 -2
- package/package.json +12 -12
- package/utils/constants.ts +1 -0
- package/plugins/gtag.client.ts +0 -21
@@ -20,7 +20,6 @@ const ogImageComponentProp = toRef(() => props.ogImageComponent)
|
|
20
20
|
|
21
21
|
const { $dayjs } = useNuxtApp()
|
22
22
|
const { locale } = useI18n()
|
23
|
-
const cookieControl = useCookieControl()
|
24
23
|
const siteConfig = useSiteConfig()
|
25
24
|
|
26
25
|
const { loadingIds, indicateLoadingDone } = useLoadingDoneIndicator('app')
|
@@ -46,18 +45,6 @@ const isLoading = computed(() => !!loadingIds.value.length)
|
|
46
45
|
|
47
46
|
// lifecycle
|
48
47
|
onMounted(() => indicateLoadingDone())
|
49
|
-
watch(
|
50
|
-
() => cookieControl.cookiesEnabledIds.value,
|
51
|
-
(current, previous) => {
|
52
|
-
if (
|
53
|
-
(!previous?.includes('ga') && current?.includes('ga')) ||
|
54
|
-
(previous?.includes('ga') && !current?.includes('ga'))
|
55
|
-
) {
|
56
|
-
window.location.reload()
|
57
|
-
}
|
58
|
-
},
|
59
|
-
{ deep: true },
|
60
|
-
)
|
61
48
|
|
62
49
|
// initialization
|
63
50
|
defineOgImageComponent(
|
@@ -77,5 +64,6 @@ useSchemaOrg([
|
|
77
64
|
description: siteConfig.description,
|
78
65
|
}),
|
79
66
|
])
|
67
|
+
useVioGtag()
|
80
68
|
init()
|
81
69
|
</script>
|
@@ -0,0 +1,42 @@
|
|
1
|
+
import { GOOGLE_ANALYTICS_COOKIE_NAME } from '../utils/constants'
|
2
|
+
|
3
|
+
export const useVioGtag = () => {
|
4
|
+
const {
|
5
|
+
gtag,
|
6
|
+
initialize: initializeGtag,
|
7
|
+
disableAnalytics,
|
8
|
+
enableAnalytics,
|
9
|
+
} = useGtag()
|
10
|
+
const cookieControl = useCookieControl()
|
11
|
+
|
12
|
+
if (
|
13
|
+
cookieControl.cookiesEnabledIds.value?.includes(
|
14
|
+
GOOGLE_ANALYTICS_COOKIE_NAME,
|
15
|
+
)
|
16
|
+
) {
|
17
|
+
initializeGtag()
|
18
|
+
}
|
19
|
+
|
20
|
+
watch(cookieControl.cookiesEnabledIds, (current, previous) => {
|
21
|
+
if (
|
22
|
+
!previous?.includes(GOOGLE_ANALYTICS_COOKIE_NAME) &&
|
23
|
+
current?.includes(GOOGLE_ANALYTICS_COOKIE_NAME)
|
24
|
+
) {
|
25
|
+
initializeGtag()
|
26
|
+
enableAnalytics()
|
27
|
+
gtag('consent', 'update', {
|
28
|
+
ad_user_data: 'granted',
|
29
|
+
ad_personalization: 'granted',
|
30
|
+
ad_storage: 'granted',
|
31
|
+
analytics_storage: 'granted',
|
32
|
+
})
|
33
|
+
}
|
34
|
+
|
35
|
+
if (
|
36
|
+
previous?.includes(GOOGLE_ANALYTICS_COOKIE_NAME) &&
|
37
|
+
!current?.includes(GOOGLE_ANALYTICS_COOKIE_NAME)
|
38
|
+
) {
|
39
|
+
disableAnalytics()
|
40
|
+
}
|
41
|
+
})
|
42
|
+
}
|
package/nuxt.config.ts
CHANGED
@@ -7,6 +7,7 @@ import {
|
|
7
7
|
SITE_URL,
|
8
8
|
SITE_NAME,
|
9
9
|
TIMEZONE_COOKIE_NAME,
|
10
|
+
GOOGLE_ANALYTICS_COOKIE_NAME,
|
10
11
|
VIO_NUXT_BASE_CONFIG,
|
11
12
|
} from './utils/constants'
|
12
13
|
|
@@ -45,6 +46,7 @@ export default defineNuxtConfig(
|
|
45
46
|
'@nuxtjs/seo',
|
46
47
|
'@nuxtjs/tailwindcss',
|
47
48
|
'@pinia/nuxt',
|
49
|
+
'nuxt-gtag',
|
48
50
|
// nuxt-security: remove invalid `'none'`s and duplicates
|
49
51
|
(_options, nuxt) => {
|
50
52
|
const nuxtConfigSecurity = nuxt.options.security
|
@@ -90,7 +92,6 @@ export default defineNuxtConfig(
|
|
90
92
|
: { baseUrl: SITE_URL }),
|
91
93
|
},
|
92
94
|
vio: {
|
93
|
-
googleAnalyticsId: '',
|
94
95
|
isInProduction: process.env.NODE_ENV === 'production',
|
95
96
|
isTesting: false,
|
96
97
|
},
|
@@ -144,7 +145,7 @@ export default defineNuxtConfig(
|
|
144
145
|
de: 'Die Cookies vom Drittanbieter Google ermöglichen die Analyse von Nutzerverhalten. Diese Analyse hilft uns unsere Dienste zu verbessern, indem wir verstehen, wie diese Webseite genutzt wird.',
|
145
146
|
en: 'The third-party cookies by Google enable the analysis of user behavior. This analysis helps us to improve our services by understanding how this website is used.',
|
146
147
|
},
|
147
|
-
id:
|
148
|
+
id: GOOGLE_ANALYTICS_COOKIE_NAME,
|
148
149
|
links: {
|
149
150
|
'https://policies.google.com/privacy': 'Google Privacy Policy',
|
150
151
|
'https://policies.google.com/terms': 'Google Terms of Service',
|
@@ -156,6 +157,27 @@ export default defineNuxtConfig(
|
|
156
157
|
},
|
157
158
|
locales: ['en', 'de'],
|
158
159
|
},
|
160
|
+
gtag: {
|
161
|
+
config: {
|
162
|
+
cookie_flags: `samesite=strict${
|
163
|
+
process.env.NODE_ENV === 'production' ? ';secure' : ''
|
164
|
+
}`,
|
165
|
+
},
|
166
|
+
enabled: false,
|
167
|
+
initCommands: [
|
168
|
+
[
|
169
|
+
'consent',
|
170
|
+
'default',
|
171
|
+
{
|
172
|
+
ad_user_data: 'denied',
|
173
|
+
ad_personalization: 'denied',
|
174
|
+
ad_storage: 'denied',
|
175
|
+
analytics_storage: 'denied',
|
176
|
+
wait_for_update: 500,
|
177
|
+
},
|
178
|
+
],
|
179
|
+
],
|
180
|
+
},
|
159
181
|
htmlValidator: {
|
160
182
|
// failOnError: true, // TODO: enable once headers match requirements (https://github.com/unjs/unhead/issues/199#issuecomment-1815728703)
|
161
183
|
logLevel: 'warning',
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@dargmuesli/nuxt-vio",
|
3
|
-
"version": "11.0.0
|
3
|
+
"version": "11.0.0",
|
4
4
|
"repository": {
|
5
5
|
"type": "git",
|
6
6
|
"url": "git+https://github.com/dargmuesli/vio.git"
|
@@ -12,7 +12,7 @@
|
|
12
12
|
"engines": {
|
13
13
|
"node": "20"
|
14
14
|
},
|
15
|
-
"packageManager": "pnpm@8.15.
|
15
|
+
"packageManager": "pnpm@8.15.5",
|
16
16
|
"files": [
|
17
17
|
"assets",
|
18
18
|
"components",
|
@@ -34,12 +34,12 @@
|
|
34
34
|
],
|
35
35
|
"main": "nuxt.config.ts",
|
36
36
|
"dependencies": {
|
37
|
-
"@dargmuesli/nuxt-cookie-control": "8.0.0-beta.
|
37
|
+
"@dargmuesli/nuxt-cookie-control": "8.0.0-beta.3",
|
38
38
|
"@heroicons/vue": "2.1.1",
|
39
39
|
"@http-util/status-i18n": "0.8.1",
|
40
40
|
"@nuxt/devtools": "1.0.8",
|
41
41
|
"@nuxt/image": "1.4.0",
|
42
|
-
"@nuxtjs/color-mode": "3.3.
|
42
|
+
"@nuxtjs/color-mode": "3.3.3",
|
43
43
|
"@nuxtjs/html-validator": "1.6.0",
|
44
44
|
"@nuxtjs/i18n": "8.2.0",
|
45
45
|
"@nuxtjs/seo": "2.0.0-rc.9",
|
@@ -54,16 +54,16 @@
|
|
54
54
|
"clipboardy": "4.0.0",
|
55
55
|
"dayjs": "2.0.0-alpha.4",
|
56
56
|
"jose": "5.2.3",
|
57
|
+
"nuxt-gtag": "2.0.5",
|
57
58
|
"nuxt-security": "1.2.2",
|
58
|
-
"sweetalert2": "11.10.6"
|
59
|
-
"vue-gtag": "2.0.1"
|
59
|
+
"sweetalert2": "11.10.6"
|
60
60
|
},
|
61
61
|
"devDependencies": {
|
62
62
|
"@axe-core/playwright": "4.8.5",
|
63
63
|
"@intlify/eslint-plugin-vue-i18n": "3.0.0-next.7",
|
64
64
|
"@nuxtjs/eslint-config-typescript": "12.1.0",
|
65
65
|
"@playwright/test": "1.42.1",
|
66
|
-
"@unhead/vue": "1.8.
|
66
|
+
"@unhead/vue": "1.8.20",
|
67
67
|
"@urql/devtools": "2.0.3",
|
68
68
|
"@urql/exchange-graphcache": "6.5.0",
|
69
69
|
"@urql/vue": "1.1.2",
|
@@ -76,12 +76,12 @@
|
|
76
76
|
"eslint-plugin-compat": "4.2.0",
|
77
77
|
"eslint-plugin-nuxt": "4.0.0",
|
78
78
|
"eslint-plugin-prettier": "5.1.3",
|
79
|
-
"eslint-plugin-yml": "1.
|
79
|
+
"eslint-plugin-yml": "1.13.1",
|
80
80
|
"h3": "1.11.1",
|
81
81
|
"jiti": "1.21.0",
|
82
82
|
"lint-staged": "15.2.2",
|
83
83
|
"lodash-es": "4.17.21",
|
84
|
-
"nuxt": "3.
|
84
|
+
"nuxt": "3.11.1",
|
85
85
|
"pinia": "2.1.7",
|
86
86
|
"prettier": "3.2.5",
|
87
87
|
"prettier-plugin-tailwindcss": "0.5.12",
|
@@ -91,14 +91,14 @@
|
|
91
91
|
"stylelint-config-standard": "36.0.0",
|
92
92
|
"stylelint-no-unsupported-browser-features": "8.0.1",
|
93
93
|
"tailwindcss": "3.4.1",
|
94
|
-
"ufo": "1.
|
95
|
-
"unhead": "1.8.
|
94
|
+
"ufo": "1.5.2",
|
95
|
+
"unhead": "1.8.20",
|
96
96
|
"vue": "3.4.21",
|
97
97
|
"vue-router": "4.3.0",
|
98
98
|
"vue-tsc": "2.0.6"
|
99
99
|
},
|
100
100
|
"peerDependencies": {
|
101
|
-
"nuxt": "3.
|
101
|
+
"nuxt": "3.11.1",
|
102
102
|
"playwright-core": "1.42.1",
|
103
103
|
"vue": "3.4.21",
|
104
104
|
"vue-router": "4.3.0"
|
package/utils/constants.ts
CHANGED
@@ -13,6 +13,7 @@ export const CACHE_VERSION = 'bOXMwoKlJr'
|
|
13
13
|
export const COOKIE_PREFIX = SITE_NAME.toLocaleLowerCase()
|
14
14
|
export const COOKIE_SEPARATOR = '_'
|
15
15
|
export const FETCH_RETRY_AMOUNT = 3
|
16
|
+
export const GOOGLE_ANALYTICS_COOKIE_NAME = 'ga'
|
16
17
|
export const I18N_MODULE_CONFIG = {
|
17
18
|
langDir: 'locales',
|
18
19
|
lazy: true,
|
package/plugins/gtag.client.ts
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
import VueGtag from 'vue-gtag'
|
2
|
-
|
3
|
-
export default defineNuxtPlugin((nuxtApp) => {
|
4
|
-
const config = useRuntimeConfig()
|
5
|
-
const router = useRouter()
|
6
|
-
const cookieControl = useCookieControl()
|
7
|
-
|
8
|
-
nuxtApp.vueApp.use(
|
9
|
-
VueGtag,
|
10
|
-
{
|
11
|
-
bootstrap: !!cookieControl.cookiesEnabledIds.value?.includes('ga'),
|
12
|
-
config: {
|
13
|
-
id: config.public.vio.googleAnalyticsId,
|
14
|
-
params: {
|
15
|
-
cookie_flags: 'secure;samesite=strict',
|
16
|
-
},
|
17
|
-
},
|
18
|
-
},
|
19
|
-
router,
|
20
|
-
)
|
21
|
-
})
|