24 lines
1.0 KiB
TypeScript
24 lines
1.0 KiB
TypeScript
import type { ConsentState } from './categories.js';
|
|
declare global {
|
|
interface Window {
|
|
dataLayer?: unknown[];
|
|
}
|
|
}
|
|
/**
|
|
* Mirrors Google's canonical snippet: `function gtag(){dataLayer.push(arguments)}`.
|
|
*
|
|
* Pushing `arguments` rather than a plain array is not a stylistic detail.
|
|
* Google's tags recognise a consent command by the Arguments object it arrives
|
|
* in; a real array lands in the dataLayer as ordinary data and the command is
|
|
* silently ignored — the tag loads, but consent never updates and analytics
|
|
* stays denied. The rest parameter exists only to type the call sites.
|
|
*
|
|
* Exported for the analytics module (which needs `js`/`config` commands) —
|
|
* intentionally not re-exported from the package's public API.
|
|
*/
|
|
export declare function gtag(..._args: unknown[]): void;
|
|
/** Sets the default consent state (call before Google tags load). */
|
|
export declare function setDefaultConsent(state: ConsentState): void;
|
|
/** Updates consent after the user decides. */
|
|
export declare function updateConsent(state: ConsentState): void;
|