@jwiedeman/gtm-kit 1.2.0 → 1.2.2
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/README.md +4 -0
- package/dist/index.cjs +15 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +15 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -227,6 +227,10 @@ While `@jwiedeman/gtm-kit` works standalone, we provide framework-specific adapt
|
|
|
227
227
|
| Vue 3 | `@jwiedeman/gtm-kit-vue` | `npm install @jwiedeman/gtm-kit @jwiedeman/gtm-kit-vue` |
|
|
228
228
|
| Nuxt 3 | `@jwiedeman/gtm-kit-nuxt` | `npm install @jwiedeman/gtm-kit @jwiedeman/gtm-kit-nuxt` |
|
|
229
229
|
| Next.js | `@jwiedeman/gtm-kit-next` | `npm install @jwiedeman/gtm-kit @jwiedeman/gtm-kit-next` |
|
|
230
|
+
| Svelte | `@jwiedeman/gtm-kit-svelte` | `npm install @jwiedeman/gtm-kit @jwiedeman/gtm-kit-svelte` |
|
|
231
|
+
| SolidJS | `@jwiedeman/gtm-kit-solid` | `npm install @jwiedeman/gtm-kit @jwiedeman/gtm-kit-solid` |
|
|
232
|
+
| Remix | `@jwiedeman/gtm-kit-remix` | `npm install @jwiedeman/gtm-kit @jwiedeman/gtm-kit-remix` |
|
|
233
|
+
| Astro | `@jwiedeman/gtm-kit-astro` | `npm install @jwiedeman/gtm-kit @jwiedeman/gtm-kit-astro` |
|
|
230
234
|
|
|
231
235
|
---
|
|
232
236
|
|
package/dist/index.cjs
CHANGED
|
@@ -670,9 +670,11 @@ var ScriptManager = class {
|
|
|
670
670
|
delay
|
|
671
671
|
});
|
|
672
672
|
this.retryCounters.set(containerId, currentAttempt + 1);
|
|
673
|
-
setTimeout(() => {
|
|
673
|
+
const timerId = setTimeout(() => {
|
|
674
|
+
this.activeTimeouts.delete(containerId);
|
|
674
675
|
this.loadScript(container, targetParent);
|
|
675
676
|
}, delay);
|
|
677
|
+
this.activeTimeouts.set(containerId, timerId);
|
|
676
678
|
}
|
|
677
679
|
/**
|
|
678
680
|
* Handle final failure after all retries exhausted.
|
|
@@ -731,6 +733,11 @@ var ScriptManager = class {
|
|
|
731
733
|
const stringValue = String(value);
|
|
732
734
|
if (key === "nonce") {
|
|
733
735
|
script.nonce = stringValue;
|
|
736
|
+
continue;
|
|
737
|
+
}
|
|
738
|
+
const lowerKey = key.toLowerCase();
|
|
739
|
+
if (lowerKey === "src" || lowerKey.startsWith("on")) {
|
|
740
|
+
continue;
|
|
734
741
|
}
|
|
735
742
|
script.setAttribute(key, stringValue);
|
|
736
743
|
}
|
|
@@ -810,11 +817,9 @@ var ScriptManager = class {
|
|
|
810
817
|
this.insertedScripts.delete(script);
|
|
811
818
|
this.scheduleRetry(container, targetParent);
|
|
812
819
|
} else {
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
state.error = `Script load timeout (${this.scriptTimeout}ms)`;
|
|
817
|
-
}
|
|
820
|
+
settled = true;
|
|
821
|
+
this.clearContainerTimeout(containerId);
|
|
822
|
+
this.handleFinalFailure(containerId, url, `Script load timeout (${this.scriptTimeout}ms)`, true);
|
|
818
823
|
}
|
|
819
824
|
}
|
|
820
825
|
}, this.scriptTimeout);
|
|
@@ -1193,6 +1198,7 @@ var GtmClientImpl = class {
|
|
|
1193
1198
|
this.logger.debug("GTM client already initialized; skipping.");
|
|
1194
1199
|
return;
|
|
1195
1200
|
}
|
|
1201
|
+
this.initialized = true;
|
|
1196
1202
|
this.logger.info("Initializing GTM client.", {
|
|
1197
1203
|
containers: this.containers.map((container) => container.id),
|
|
1198
1204
|
dataLayerName: this.resolvedDataLayerName
|
|
@@ -1235,7 +1241,6 @@ var GtmClientImpl = class {
|
|
|
1235
1241
|
this.pushStartEvent();
|
|
1236
1242
|
this.flushQueue();
|
|
1237
1243
|
this.scriptManager.ensure(this.containers);
|
|
1238
|
-
this.initialized = true;
|
|
1239
1244
|
}
|
|
1240
1245
|
/**
|
|
1241
1246
|
* Pushes a value to the GTM dataLayer.
|
|
@@ -1302,9 +1307,8 @@ var GtmClientImpl = class {
|
|
|
1302
1307
|
}
|
|
1303
1308
|
setConsentDefaults(state, options) {
|
|
1304
1309
|
if (this.initialized) {
|
|
1305
|
-
|
|
1306
|
-
"setConsentDefaults() called
|
|
1307
|
-
{ state, options }
|
|
1310
|
+
throw new Error(
|
|
1311
|
+
"setConsentDefaults() must be called BEFORE init(). Google requires consent defaults to be set before GTM loads to ensure proper tag behavior. Move your setConsentDefaults() call before client.init()."
|
|
1308
1312
|
);
|
|
1309
1313
|
}
|
|
1310
1314
|
if ((options == null ? void 0 : options.waitForUpdate) !== void 0) {
|
|
@@ -1693,7 +1697,7 @@ var GtmClientImpl = class {
|
|
|
1693
1697
|
criticalIndices.add(i);
|
|
1694
1698
|
}
|
|
1695
1699
|
}
|
|
1696
|
-
const targetTrimCount = Math.max(1, excess
|
|
1700
|
+
const targetTrimCount = Math.max(1, excess);
|
|
1697
1701
|
let trimmedCount = 0;
|
|
1698
1702
|
let index = 0;
|
|
1699
1703
|
while (trimmedCount < targetTrimCount && index < dataLayer.length) {
|