Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | 17x 17x 17x | // GTM dataLayer helper.
//
// Safe push to the GTM dataLayer for bundled (module) call sites. No-op-safe
// when GTM is absent (local dev, Lighthouse audits) — the push just queues
// onto an array nothing consumes. GTM (when loaded) drains it; otherwise it's
// harmless. See `apps/marketplace/CLAUDE.md` §Analytics for the GTM/GA4 setup.
//
// `is:inline` scripts (e.g. the `ho:auth-success` block in Layout.astro) cannot
// import this and inline the equivalent push directly.
declare global {
interface Window {
dataLayer?: Array<Record<string, unknown>>;
}
}
export function pushDataLayerEvent(
event: string,
params: Record<string, unknown> = {},
): void {
Iif (typeof window === "undefined") return;
window.dataLayer = window.dataLayer ?? [];
window.dataLayer.push({ event, ...params });
}
|