@stackonward/google-tag-manager-nuxt 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
package/dist/module.json
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { GoogleTagManagerNuxtRuntimeConfig, GoogleTagManagerScriptOptions } from "./types.js";
|
|
2
|
+
export interface GoogleTagManagerScriptInput {
|
|
3
|
+
readonly id: string;
|
|
4
|
+
readonly l: string;
|
|
5
|
+
readonly defaultConsent: GoogleTagManagerNuxtRuntimeConfig["defaultConsent"];
|
|
6
|
+
readonly scriptOptions: GoogleTagManagerScriptOptions & {
|
|
7
|
+
readonly trigger: "manual";
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
/** 将模块配置投影到 Nuxt Scripts 的 registry 输入契约。 */
|
|
11
|
+
export declare function createGoogleTagManagerScriptInput(config: GoogleTagManagerNuxtRuntimeConfig): GoogleTagManagerScriptInput;
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
import { useScriptGoogleTagManager } from "#imports";
|
|
5
5
|
import { defineNuxtPlugin, useNuxtApp, useRuntimeConfig } from "nuxt/app";
|
|
6
6
|
import { createGoogleTagManagerLifecycleParticipant } from "../google-tag-manager-lifecycle.js";
|
|
7
|
+
import { createGoogleTagManagerScriptInput } from "../google-tag-manager-script.js";
|
|
7
8
|
export default defineNuxtPlugin({
|
|
8
9
|
name: "stackonward:google-tag-manager",
|
|
9
10
|
dependsOn: ["stackonward:analytics"],
|
|
@@ -14,13 +15,7 @@ export default defineNuxtPlugin({
|
|
|
14
15
|
if (!analytics) {
|
|
15
16
|
throw new Error("Google Tag Manager requires @stackonward/analytics-nuxt");
|
|
16
17
|
}
|
|
17
|
-
const script = useScriptGoogleTagManager(
|
|
18
|
-
id: config.id,
|
|
19
|
-
l: config.dataLayerName,
|
|
20
|
-
defaultConsent: config.defaultConsent,
|
|
21
|
-
trigger: "manual",
|
|
22
|
-
...config.script
|
|
23
|
-
});
|
|
18
|
+
const script = useScriptGoogleTagManager(createGoogleTagManagerScriptInput(config));
|
|
24
19
|
analytics.registerLifecycleParticipant(
|
|
25
20
|
createGoogleTagManagerLifecycleParticipant({
|
|
26
21
|
script,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stackonward/google-tag-manager-nuxt",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "Consent-aware Google Tag Manager transport and analytics composition module for Nuxt",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/module.mjs",
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"license": "MIT",
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"zod": "^3.24.0",
|
|
38
|
-
"@stackonward/analytics-nuxt": "^0.1.2",
|
|
39
38
|
"@stackonward/google-tag-manager": "^0.1.1",
|
|
39
|
+
"@stackonward/analytics-nuxt": "^0.1.2",
|
|
40
40
|
"@stackonward/analytics-core": "^0.2.1"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|