Skip to content

Commit 0d149ed

Browse files
Merge pull request #9 from plentymarkets/chore/shop_core_1.4.0
chore: shop-core 1.4.0, register cookie on server side
2 parents c24f761 + c0e7c16 commit 0d149ed

File tree

5 files changed

+71
-28
lines changed

5 files changed

+71
-28
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@plentymarkets/shop-module-gtag",
33
"type": "module",
4-
"version": "1.1.1",
4+
"version": "1.1.2",
55
"packageManager": "pnpm@9.15.4",
66
"description": "Google Tag nuxt module integration for PlentyONE Shop",
77
"license": "BSD-3-Clause",
@@ -35,7 +35,7 @@
3535
"release": "bumpp"
3636
},
3737
"dependencies": {
38-
"@plentymarkets/shop-core": "^1.1.1",
38+
"@plentymarkets/shop-core": "^1.4.0",
3939
"@nuxt/kit": "3.13.2",
4040
"defu": "^6.1.4",
4141
"pathe": "^2.0.1",

pnpm-lock.yaml

Lines changed: 32 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/module.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,9 @@ export default defineNuxtModule<ModuleOptions>({
7777
src: resolve('runtime/plugins/plugin.client'),
7878
mode: 'client',
7979
})
80+
addPlugin({
81+
src: resolve('runtime/plugins/plugin.server'),
82+
mode: 'server',
83+
})
8084
},
8185
})

src/runtime/plugins/plugin.client.ts

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {
55
defineNuxtPlugin,
66
useCookieConsent,
77
usePlentyEvent,
8-
useRegisterCookie,
98
useRuntimeConfig,
109
watch,
1110
} from '#imports'
@@ -140,21 +139,5 @@ export default defineNuxtPlugin({
140139
})
141140
}
142141
})
143-
144-
// Cookie Registration
145-
const { add } = useRegisterCookie()
146-
const optOut = options.cookieOptOut || options.cookieGroup === 'CookieBar.essentials.label'
147-
148-
if (options.cookieGroup) {
149-
add({
150-
name: CookieName,
151-
Provider: 'CookieBar.moduleGoogleAnalytics.provider',
152-
Status: 'CookieBar.moduleGoogleAnalytics.status',
153-
PrivacyPolicy: 'https://policies.google.com/privacy',
154-
Lifespan: 'Session',
155-
cookieNames: ['/^_ga/', '_ga', '_gid', '_gat'],
156-
accepted: optOut,
157-
}, options.cookieGroup)
158-
}
159142
},
160143
})
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Expose plugin types
2+
import type {} from 'nuxt/app'
3+
import type { ModuleOptions } from '../../module'
4+
import {
5+
defineNuxtPlugin,
6+
useRegisterCookie,
7+
useRuntimeConfig,
8+
} from '#imports'
9+
import { CookieName } from '../utils'
10+
11+
export default defineNuxtPlugin({
12+
parallel: true,
13+
setup() {
14+
const options = useRuntimeConfig().public.pwa_module_gtag as ModuleOptions
15+
if (!options.id) return
16+
17+
// Cookie Registration
18+
const { add } = useRegisterCookie()
19+
const optOut = options.cookieOptOut || options.cookieGroup === 'CookieBar.essentials.label'
20+
21+
if (options.cookieGroup) {
22+
add({
23+
name: CookieName,
24+
Provider: 'CookieBar.moduleGoogleAnalytics.provider',
25+
Status: 'CookieBar.moduleGoogleAnalytics.status',
26+
PrivacyPolicy: 'https://policies.google.com/privacy',
27+
Lifespan: 'Session',
28+
cookieNames: ['/^_ga/', '_ga', '_gid', '_gat'],
29+
accepted: optOut,
30+
}, options.cookieGroup)
31+
}
32+
},
33+
})

0 commit comments

Comments
 (0)