@usequeek/theme-kit 0.1.32 → 0.1.33

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.
Files changed (2) hide show
  1. package/apps/gtag.ts +21 -6
  2. package/package.json +1 -1
package/apps/gtag.ts CHANGED
@@ -6,14 +6,29 @@ declare global {
6
6
  }
7
7
  }
8
8
 
9
+ type GtagParams = Record<string, unknown>;
10
+
9
11
  /**
10
- * Pushes straight to `dataLayer` rather than calling `window.gtag()` directly —
11
- * this queues correctly even before gtag.js has finished loading (the same
12
- * mechanism the inline bootstrap snippet in analytics.tsx relies on), so
13
- * callers never need to guard on load order.
12
+ * Pushes to `dataLayer` rather than calling `window.gtag()` directly — this
13
+ * queues correctly even before gtag.js has finished loading (the same
14
+ * mechanism the inline bootstrap snippet in the storefront's analytics host
15
+ * relies on), so callers never need to guard on load order.
16
+ *
17
+ * It MUST push the function's `arguments` object, never an array built from it.
18
+ * gtag.js only processes `arguments` objects found on `dataLayer`; Google's own
19
+ * snippet is `function gtag(){dataLayer.push(arguments);}` for exactly that
20
+ * reason, and a plain array is silently ignored (the event is never sent). That
21
+ * is why this is a non-arrow `function` with no rest parameter: the overloads
22
+ * below carry the types, and the implementation forwards `arguments` untouched.
14
23
  */
15
- export function gtagPush(...args: unknown[]): void {
24
+ export function gtagPush(command: 'js', date: Date): void;
25
+ export function gtagPush(command: 'config', targetId: string, params?: GtagParams): void;
26
+ export function gtagPush(command: 'set', params: GtagParams): void;
27
+ export function gtagPush(command: 'event', eventName: string, params?: GtagParams): void;
28
+ export function gtagPush(command: 'consent', action: 'default' | 'update', params: GtagParams): void;
29
+ export function gtagPush(): void {
16
30
  if (typeof window === 'undefined') return;
17
31
  window.dataLayer = window.dataLayer || [];
18
- window.dataLayer.push(args);
32
+ // eslint-disable-next-line prefer-rest-params -- gtag.js reads only `arguments` objects (see above)
33
+ window.dataLayer.push(arguments);
19
34
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usequeek/theme-kit",
3
- "version": "0.1.32",
3
+ "version": "0.1.33",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "description": "The runtime a Queek storefront theme is built on: hooks, stores, page renderer, navigation, shared blocks and locale strings.",