@simpleapps-com/augur-web 0.2.14 → 0.2.16
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/dist/chunk-PTAWV5SA.js +29 -0
- package/dist/chunk-PTAWV5SA.js.map +1 -0
- package/dist/chunk-VT4JLAIE.cjs +29 -0
- package/dist/chunk-VT4JLAIE.cjs.map +1 -0
- package/dist/financing-widget.cjs +47 -0
- package/dist/financing-widget.cjs.map +1 -0
- package/dist/financing-widget.d.cts +45 -0
- package/dist/financing-widget.d.ts +45 -0
- package/dist/financing-widget.js +47 -0
- package/dist/financing-widget.js.map +1 -0
- package/dist/form-select.cjs +2 -2
- package/dist/form-select.cjs.map +1 -1
- package/dist/form-select.js +3 -3
- package/dist/gtm.cjs +22 -19
- package/dist/gtm.cjs.map +1 -1
- package/dist/gtm.d.cts +37 -17
- package/dist/gtm.d.ts +37 -17
- package/dist/gtm.js +21 -18
- package/dist/gtm.js.map +1 -1
- package/dist/price-format.cjs +8 -0
- package/dist/price-format.cjs.map +1 -0
- package/dist/price-format.d.cts +17 -0
- package/dist/price-format.d.ts +17 -0
- package/dist/price-format.js +8 -0
- package/dist/price-format.js.map +1 -0
- package/dist/price.cjs +90 -0
- package/dist/price.cjs.map +1 -0
- package/dist/price.d.cts +61 -0
- package/dist/price.d.ts +61 -0
- package/dist/price.js +90 -0
- package/dist/price.js.map +1 -0
- package/dist/session-replay.cjs +59 -0
- package/dist/session-replay.cjs.map +1 -0
- package/dist/session-replay.d.cts +44 -0
- package/dist/session-replay.d.ts +44 -0
- package/dist/session-replay.js +59 -0
- package/dist/session-replay.js.map +1 -0
- package/package.json +21 -1
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/price-format.ts
|
|
4
|
+
var formatDefaults = {
|
|
5
|
+
currency: "USD",
|
|
6
|
+
locale: "en-US",
|
|
7
|
+
precision: 2
|
|
8
|
+
};
|
|
9
|
+
function createFormatPrice(config = {}) {
|
|
10
|
+
const { currency, locale, precision: defaultPrecision } = {
|
|
11
|
+
...formatDefaults,
|
|
12
|
+
...config
|
|
13
|
+
};
|
|
14
|
+
return function formatPrice(value, options) {
|
|
15
|
+
const p = options?.precision ?? defaultPrecision;
|
|
16
|
+
const displayValue = options?.quantity !== void 0 ? value * options.quantity : value;
|
|
17
|
+
return new Intl.NumberFormat(locale, {
|
|
18
|
+
style: "currency",
|
|
19
|
+
currency,
|
|
20
|
+
minimumFractionDigits: p,
|
|
21
|
+
maximumFractionDigits: p
|
|
22
|
+
}).format(displayValue);
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export {
|
|
27
|
+
createFormatPrice
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=chunk-PTAWV5SA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/price-format.ts"],"sourcesContent":["// ---------------------------------------------------------------------------\n// Pure formatting logic — no React, no \"use client\".\n// Safe to import in server components.\n// ---------------------------------------------------------------------------\n\nexport interface PriceFormatConfig {\n /** ISO 4217 currency code. Default: `\"USD\"`. */\n currency?: string;\n /** BCP 47 locale. Default: `\"en-US\"`. */\n locale?: string;\n /** Decimal places. Default: `2`. */\n precision?: number;\n}\n\nexport interface FormatPriceOptions {\n /** Override precision for this call. */\n precision?: number;\n /** Multiply value by quantity before formatting. */\n quantity?: number;\n}\n\nconst formatDefaults: Required<PriceFormatConfig> = {\n currency: \"USD\",\n locale: \"en-US\",\n precision: 2,\n};\n\nexport function createFormatPrice(\n config: PriceFormatConfig = {},\n): (value: number, options?: FormatPriceOptions) => string {\n const { currency, locale, precision: defaultPrecision } = {\n ...formatDefaults,\n ...config,\n };\n\n return function formatPrice(\n value: number,\n options?: FormatPriceOptions,\n ): string {\n const p = options?.precision ?? defaultPrecision;\n const displayValue =\n options?.quantity !== undefined ? value * options.quantity : value;\n return new Intl.NumberFormat(locale, {\n style: \"currency\",\n currency,\n minimumFractionDigits: p,\n maximumFractionDigits: p,\n }).format(displayValue);\n };\n}\n"],"mappings":";;;AAqBA,IAAM,iBAA8C;AAAA,EAClD,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,WAAW;AACb;AAEO,SAAS,kBACd,SAA4B,CAAC,GAC4B;AACzD,QAAM,EAAE,UAAU,QAAQ,WAAW,iBAAiB,IAAI;AAAA,IACxD,GAAG;AAAA,IACH,GAAG;AAAA,EACL;AAEA,SAAO,SAAS,YACd,OACA,SACQ;AACR,UAAM,IAAI,SAAS,aAAa;AAChC,UAAM,eACJ,SAAS,aAAa,SAAY,QAAQ,QAAQ,WAAW;AAC/D,WAAO,IAAI,KAAK,aAAa,QAAQ;AAAA,MACnC,OAAO;AAAA,MACP;AAAA,MACA,uBAAuB;AAAA,MACvB,uBAAuB;AAAA,IACzB,CAAC,EAAE,OAAO,YAAY;AAAA,EACxB;AACF;","names":[]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }"use client";
|
|
2
|
+
|
|
3
|
+
// src/price-format.ts
|
|
4
|
+
var formatDefaults = {
|
|
5
|
+
currency: "USD",
|
|
6
|
+
locale: "en-US",
|
|
7
|
+
precision: 2
|
|
8
|
+
};
|
|
9
|
+
function createFormatPrice(config = {}) {
|
|
10
|
+
const { currency, locale, precision: defaultPrecision } = {
|
|
11
|
+
...formatDefaults,
|
|
12
|
+
...config
|
|
13
|
+
};
|
|
14
|
+
return function formatPrice(value, options) {
|
|
15
|
+
const p = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _ => _.precision]), () => ( defaultPrecision));
|
|
16
|
+
const displayValue = _optionalChain([options, 'optionalAccess', _2 => _2.quantity]) !== void 0 ? value * options.quantity : value;
|
|
17
|
+
return new Intl.NumberFormat(locale, {
|
|
18
|
+
style: "currency",
|
|
19
|
+
currency,
|
|
20
|
+
minimumFractionDigits: p,
|
|
21
|
+
maximumFractionDigits: p
|
|
22
|
+
}).format(displayValue);
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
exports.createFormatPrice = createFormatPrice;
|
|
29
|
+
//# sourceMappingURL=chunk-VT4JLAIE.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/augur-packages/augur-packages/packages/augur-web/dist/chunk-VT4JLAIE.cjs","../src/price-format.ts"],"names":[],"mappings":"AAAA,6rBAAY;AACZ;AACA;ACmBA,IAAM,eAAA,EAA8C;AAAA,EAClD,QAAA,EAAU,KAAA;AAAA,EACV,MAAA,EAAQ,OAAA;AAAA,EACR,SAAA,EAAW;AACb,CAAA;AAEO,SAAS,iBAAA,CACd,OAAA,EAA4B,CAAC,CAAA,EAC4B;AACzD,EAAA,MAAM,EAAE,QAAA,EAAU,MAAA,EAAQ,SAAA,EAAW,iBAAiB,EAAA,EAAI;AAAA,IACxD,GAAG,cAAA;AAAA,IACH,GAAG;AAAA,EACL,CAAA;AAEA,EAAA,OAAO,SAAS,WAAA,CACd,KAAA,EACA,OAAA,EACQ;AACR,IAAA,MAAM,EAAA,mCAAI,OAAA,2BAAS,WAAA,UAAa,kBAAA;AAChC,IAAA,MAAM,aAAA,kBACJ,OAAA,6BAAS,WAAA,IAAa,KAAA,EAAA,EAAY,MAAA,EAAQ,OAAA,CAAQ,SAAA,EAAW,KAAA;AAC/D,IAAA,OAAO,IAAI,IAAA,CAAK,YAAA,CAAa,MAAA,EAAQ;AAAA,MACnC,KAAA,EAAO,UAAA;AAAA,MACP,QAAA;AAAA,MACA,qBAAA,EAAuB,CAAA;AAAA,MACvB,qBAAA,EAAuB;AAAA,IACzB,CAAC,CAAA,CAAE,MAAA,CAAO,YAAY,CAAA;AAAA,EACxB,CAAA;AACF;ADzBA;AACA;AACE;AACF,8CAAC","file":"/home/runner/work/augur-packages/augur-packages/packages/augur-web/dist/chunk-VT4JLAIE.cjs","sourcesContent":[null,"// ---------------------------------------------------------------------------\n// Pure formatting logic — no React, no \"use client\".\n// Safe to import in server components.\n// ---------------------------------------------------------------------------\n\nexport interface PriceFormatConfig {\n /** ISO 4217 currency code. Default: `\"USD\"`. */\n currency?: string;\n /** BCP 47 locale. Default: `\"en-US\"`. */\n locale?: string;\n /** Decimal places. Default: `2`. */\n precision?: number;\n}\n\nexport interface FormatPriceOptions {\n /** Override precision for this call. */\n precision?: number;\n /** Multiply value by quantity before formatting. */\n quantity?: number;\n}\n\nconst formatDefaults: Required<PriceFormatConfig> = {\n currency: \"USD\",\n locale: \"en-US\",\n precision: 2,\n};\n\nexport function createFormatPrice(\n config: PriceFormatConfig = {},\n): (value: number, options?: FormatPriceOptions) => string {\n const { currency, locale, precision: defaultPrecision } = {\n ...formatDefaults,\n ...config,\n };\n\n return function formatPrice(\n value: number,\n options?: FormatPriceOptions,\n ): string {\n const p = options?.precision ?? defaultPrecision;\n const displayValue =\n options?.quantity !== undefined ? value * options.quantity : value;\n return new Intl.NumberFormat(locale, {\n style: \"currency\",\n currency,\n minimumFractionDigits: p,\n maximumFractionDigits: p,\n }).format(displayValue);\n };\n}\n"]}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }"use client";
|
|
2
|
+
"use client";
|
|
3
|
+
|
|
4
|
+
// src/financing-widget.tsx
|
|
5
|
+
var _react = require('react');
|
|
6
|
+
function injectTimePayment(vendorCode, onLoad) {
|
|
7
|
+
if (typeof document === "undefined") return;
|
|
8
|
+
if (document.getElementById("financing-script")) return;
|
|
9
|
+
const script = document.createElement("script");
|
|
10
|
+
script.id = "financing-script";
|
|
11
|
+
script.src = `https://app.timepayment.com/js/apply-button.js?vendor=${encodeURIComponent(vendorCode)}`;
|
|
12
|
+
script.async = true;
|
|
13
|
+
script.defer = true;
|
|
14
|
+
if (onLoad) {
|
|
15
|
+
script.onload = onLoad;
|
|
16
|
+
}
|
|
17
|
+
document.head.appendChild(script);
|
|
18
|
+
}
|
|
19
|
+
var injectors = {
|
|
20
|
+
timepayment: injectTimePayment
|
|
21
|
+
};
|
|
22
|
+
function FinancingWidget({
|
|
23
|
+
provider,
|
|
24
|
+
vendorCode,
|
|
25
|
+
disabled = false,
|
|
26
|
+
onLoad
|
|
27
|
+
}) {
|
|
28
|
+
const injectedRef = _react.useRef.call(void 0, false);
|
|
29
|
+
const stableOnLoad = _react.useCallback.call(void 0, () => {
|
|
30
|
+
_optionalChain([onLoad, 'optionalCall', _ => _()]);
|
|
31
|
+
}, [onLoad]);
|
|
32
|
+
_react.useEffect.call(void 0, () => {
|
|
33
|
+
if (disabled || injectedRef.current) return;
|
|
34
|
+
injectedRef.current = true;
|
|
35
|
+
const inject = injectors[provider];
|
|
36
|
+
if (typeof requestIdleCallback === "function") {
|
|
37
|
+
requestIdleCallback(() => inject(vendorCode, stableOnLoad));
|
|
38
|
+
} else {
|
|
39
|
+
setTimeout(() => inject(vendorCode, stableOnLoad), 0);
|
|
40
|
+
}
|
|
41
|
+
}, [provider, vendorCode, disabled, stableOnLoad]);
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
exports.FinancingWidget = FinancingWidget;
|
|
47
|
+
//# sourceMappingURL=financing-widget.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/augur-packages/augur-packages/packages/augur-web/dist/financing-widget.cjs","../src/financing-widget.tsx"],"names":[],"mappings":"AAAA,ylBAAY;AACZ,YAAY;AACZ;AACA;ACDA,8BAA+C;AAyC/C,SAAS,iBAAA,CACP,UAAA,EACA,MAAA,EACM;AACN,EAAA,GAAA,CAAI,OAAO,SAAA,IAAa,WAAA,EAAa,MAAA;AACrC,EAAA,GAAA,CAAI,QAAA,CAAS,cAAA,CAAe,kBAAkB,CAAA,EAAG,MAAA;AAEjD,EAAA,MAAM,OAAA,EAAS,QAAA,CAAS,aAAA,CAAc,QAAQ,CAAA;AAC9C,EAAA,MAAA,CAAO,GAAA,EAAK,kBAAA;AACZ,EAAA,MAAA,CAAO,IAAA,EAAM,CAAA,sDAAA,EAAyD,kBAAA,CAAmB,UAAU,CAAC,CAAA,CAAA;AACrF,EAAA;AACA,EAAA;AACH,EAAA;AACM,IAAA;AAClB,EAAA;AACgC,EAAA;AAClC;AAKI;AACW,EAAA;AACf;AAyBgC;AAC9B,EAAA;AACA,EAAA;AACW,EAAA;AACX,EAAA;AACuB;AACS,EAAA;AAEO,EAAA;AAC5B,oBAAA;AACA,EAAA;AAEK,EAAA;AACuB,IAAA;AACf,IAAA;AAEW,IAAA;AAGc,IAAA;AACa,MAAA;AACrD,IAAA;AAC+C,MAAA;AACtD,IAAA;AAC+C,EAAA;AAE1C,EAAA;AACT;AD3EuG;AACA;AACA","file":"/home/runner/work/augur-packages/augur-packages/packages/augur-web/dist/financing-widget.cjs","sourcesContent":[null,"\"use client\";\n\nimport { useEffect, useRef, useCallback } from \"react\";\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\n/** Supported financing providers. */\nexport type FinancingProvider = \"timepayment\";\n\nexport interface FinancingWidgetProps {\n /** Financing provider. */\n provider: FinancingProvider;\n /** Vendor/merchant code from the provider. */\n vendorCode: string;\n /** Disable loading. Default: false. */\n disabled?: boolean;\n /** Called when the financing script has loaded. */\n onLoad?: () => void;\n}\n\nexport interface UseFinancingResult {\n /** Whether the financing script has loaded. */\n isLoaded: boolean;\n}\n\n// ---------------------------------------------------------------------------\n// Globals\n// ---------------------------------------------------------------------------\n\ndeclare global {\n interface Window {\n TimePayment?: {\n apply: (vendorCode: string) => void;\n };\n }\n}\n\n// ---------------------------------------------------------------------------\n// Script injectors\n// ---------------------------------------------------------------------------\n\nfunction injectTimePayment(\n vendorCode: string,\n onLoad?: () => void,\n): void {\n if (typeof document === \"undefined\") return;\n if (document.getElementById(\"financing-script\")) return;\n\n const script = document.createElement(\"script\");\n script.id = \"financing-script\";\n script.src = `https://app.timepayment.com/js/apply-button.js?vendor=${encodeURIComponent(vendorCode)}`;\n script.async = true;\n script.defer = true;\n if (onLoad) {\n script.onload = onLoad;\n }\n document.head.appendChild(script);\n}\n\nconst injectors: Record<\n FinancingProvider,\n (vendorCode: string, onLoad?: () => void) => void\n> = {\n timepayment: injectTimePayment,\n};\n\n// ---------------------------------------------------------------------------\n// Component\n// ---------------------------------------------------------------------------\n\n/**\n * Loads a financing widget script on the pages where it's needed.\n * Renders nothing — this is a side-effect-only leaf component.\n *\n * Place this on product or checkout pages, NOT in the global layout.\n *\n * @example\n * ```tsx\n * // On a product page\n * <FinancingWidget provider=\"timepayment\" vendorCode=\"PVD5P\" />\n *\n * // With load callback\n * <FinancingWidget\n * provider=\"timepayment\"\n * vendorCode=\"PVD5P\"\n * onLoad={() => console.log(\"Financing ready\")}\n * />\n * ```\n */\nexport function FinancingWidget({\n provider,\n vendorCode,\n disabled = false,\n onLoad,\n}: FinancingWidgetProps) {\n const injectedRef = useRef(false);\n\n const stableOnLoad = useCallback(() => {\n onLoad?.();\n }, [onLoad]);\n\n useEffect(() => {\n if (disabled || injectedRef.current) return;\n injectedRef.current = true;\n\n const inject = injectors[provider];\n\n // Load during idle time\n if (typeof requestIdleCallback === \"function\") {\n requestIdleCallback(() => inject(vendorCode, stableOnLoad));\n } else {\n setTimeout(() => inject(vendorCode, stableOnLoad), 0);\n }\n }, [provider, vendorCode, disabled, stableOnLoad]);\n\n return null;\n}\n"]}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/** Supported financing providers. */
|
|
2
|
+
type FinancingProvider = "timepayment";
|
|
3
|
+
interface FinancingWidgetProps {
|
|
4
|
+
/** Financing provider. */
|
|
5
|
+
provider: FinancingProvider;
|
|
6
|
+
/** Vendor/merchant code from the provider. */
|
|
7
|
+
vendorCode: string;
|
|
8
|
+
/** Disable loading. Default: false. */
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
/** Called when the financing script has loaded. */
|
|
11
|
+
onLoad?: () => void;
|
|
12
|
+
}
|
|
13
|
+
interface UseFinancingResult {
|
|
14
|
+
/** Whether the financing script has loaded. */
|
|
15
|
+
isLoaded: boolean;
|
|
16
|
+
}
|
|
17
|
+
declare global {
|
|
18
|
+
interface Window {
|
|
19
|
+
TimePayment?: {
|
|
20
|
+
apply: (vendorCode: string) => void;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Loads a financing widget script on the pages where it's needed.
|
|
26
|
+
* Renders nothing — this is a side-effect-only leaf component.
|
|
27
|
+
*
|
|
28
|
+
* Place this on product or checkout pages, NOT in the global layout.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```tsx
|
|
32
|
+
* // On a product page
|
|
33
|
+
* <FinancingWidget provider="timepayment" vendorCode="PVD5P" />
|
|
34
|
+
*
|
|
35
|
+
* // With load callback
|
|
36
|
+
* <FinancingWidget
|
|
37
|
+
* provider="timepayment"
|
|
38
|
+
* vendorCode="PVD5P"
|
|
39
|
+
* onLoad={() => console.log("Financing ready")}
|
|
40
|
+
* />
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
declare function FinancingWidget({ provider, vendorCode, disabled, onLoad, }: FinancingWidgetProps): null;
|
|
44
|
+
|
|
45
|
+
export { type FinancingProvider, FinancingWidget, type FinancingWidgetProps, type UseFinancingResult };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/** Supported financing providers. */
|
|
2
|
+
type FinancingProvider = "timepayment";
|
|
3
|
+
interface FinancingWidgetProps {
|
|
4
|
+
/** Financing provider. */
|
|
5
|
+
provider: FinancingProvider;
|
|
6
|
+
/** Vendor/merchant code from the provider. */
|
|
7
|
+
vendorCode: string;
|
|
8
|
+
/** Disable loading. Default: false. */
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
/** Called when the financing script has loaded. */
|
|
11
|
+
onLoad?: () => void;
|
|
12
|
+
}
|
|
13
|
+
interface UseFinancingResult {
|
|
14
|
+
/** Whether the financing script has loaded. */
|
|
15
|
+
isLoaded: boolean;
|
|
16
|
+
}
|
|
17
|
+
declare global {
|
|
18
|
+
interface Window {
|
|
19
|
+
TimePayment?: {
|
|
20
|
+
apply: (vendorCode: string) => void;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Loads a financing widget script on the pages where it's needed.
|
|
26
|
+
* Renders nothing — this is a side-effect-only leaf component.
|
|
27
|
+
*
|
|
28
|
+
* Place this on product or checkout pages, NOT in the global layout.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```tsx
|
|
32
|
+
* // On a product page
|
|
33
|
+
* <FinancingWidget provider="timepayment" vendorCode="PVD5P" />
|
|
34
|
+
*
|
|
35
|
+
* // With load callback
|
|
36
|
+
* <FinancingWidget
|
|
37
|
+
* provider="timepayment"
|
|
38
|
+
* vendorCode="PVD5P"
|
|
39
|
+
* onLoad={() => console.log("Financing ready")}
|
|
40
|
+
* />
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
declare function FinancingWidget({ provider, vendorCode, disabled, onLoad, }: FinancingWidgetProps): null;
|
|
44
|
+
|
|
45
|
+
export { type FinancingProvider, FinancingWidget, type FinancingWidgetProps, type UseFinancingResult };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use client";
|
|
3
|
+
|
|
4
|
+
// src/financing-widget.tsx
|
|
5
|
+
import { useEffect, useRef, useCallback } from "react";
|
|
6
|
+
function injectTimePayment(vendorCode, onLoad) {
|
|
7
|
+
if (typeof document === "undefined") return;
|
|
8
|
+
if (document.getElementById("financing-script")) return;
|
|
9
|
+
const script = document.createElement("script");
|
|
10
|
+
script.id = "financing-script";
|
|
11
|
+
script.src = `https://app.timepayment.com/js/apply-button.js?vendor=${encodeURIComponent(vendorCode)}`;
|
|
12
|
+
script.async = true;
|
|
13
|
+
script.defer = true;
|
|
14
|
+
if (onLoad) {
|
|
15
|
+
script.onload = onLoad;
|
|
16
|
+
}
|
|
17
|
+
document.head.appendChild(script);
|
|
18
|
+
}
|
|
19
|
+
var injectors = {
|
|
20
|
+
timepayment: injectTimePayment
|
|
21
|
+
};
|
|
22
|
+
function FinancingWidget({
|
|
23
|
+
provider,
|
|
24
|
+
vendorCode,
|
|
25
|
+
disabled = false,
|
|
26
|
+
onLoad
|
|
27
|
+
}) {
|
|
28
|
+
const injectedRef = useRef(false);
|
|
29
|
+
const stableOnLoad = useCallback(() => {
|
|
30
|
+
onLoad?.();
|
|
31
|
+
}, [onLoad]);
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
if (disabled || injectedRef.current) return;
|
|
34
|
+
injectedRef.current = true;
|
|
35
|
+
const inject = injectors[provider];
|
|
36
|
+
if (typeof requestIdleCallback === "function") {
|
|
37
|
+
requestIdleCallback(() => inject(vendorCode, stableOnLoad));
|
|
38
|
+
} else {
|
|
39
|
+
setTimeout(() => inject(vendorCode, stableOnLoad), 0);
|
|
40
|
+
}
|
|
41
|
+
}, [provider, vendorCode, disabled, stableOnLoad]);
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
export {
|
|
45
|
+
FinancingWidget
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=financing-widget.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/financing-widget.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useRef, useCallback } from \"react\";\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\n/** Supported financing providers. */\nexport type FinancingProvider = \"timepayment\";\n\nexport interface FinancingWidgetProps {\n /** Financing provider. */\n provider: FinancingProvider;\n /** Vendor/merchant code from the provider. */\n vendorCode: string;\n /** Disable loading. Default: false. */\n disabled?: boolean;\n /** Called when the financing script has loaded. */\n onLoad?: () => void;\n}\n\nexport interface UseFinancingResult {\n /** Whether the financing script has loaded. */\n isLoaded: boolean;\n}\n\n// ---------------------------------------------------------------------------\n// Globals\n// ---------------------------------------------------------------------------\n\ndeclare global {\n interface Window {\n TimePayment?: {\n apply: (vendorCode: string) => void;\n };\n }\n}\n\n// ---------------------------------------------------------------------------\n// Script injectors\n// ---------------------------------------------------------------------------\n\nfunction injectTimePayment(\n vendorCode: string,\n onLoad?: () => void,\n): void {\n if (typeof document === \"undefined\") return;\n if (document.getElementById(\"financing-script\")) return;\n\n const script = document.createElement(\"script\");\n script.id = \"financing-script\";\n script.src = `https://app.timepayment.com/js/apply-button.js?vendor=${encodeURIComponent(vendorCode)}`;\n script.async = true;\n script.defer = true;\n if (onLoad) {\n script.onload = onLoad;\n }\n document.head.appendChild(script);\n}\n\nconst injectors: Record<\n FinancingProvider,\n (vendorCode: string, onLoad?: () => void) => void\n> = {\n timepayment: injectTimePayment,\n};\n\n// ---------------------------------------------------------------------------\n// Component\n// ---------------------------------------------------------------------------\n\n/**\n * Loads a financing widget script on the pages where it's needed.\n * Renders nothing — this is a side-effect-only leaf component.\n *\n * Place this on product or checkout pages, NOT in the global layout.\n *\n * @example\n * ```tsx\n * // On a product page\n * <FinancingWidget provider=\"timepayment\" vendorCode=\"PVD5P\" />\n *\n * // With load callback\n * <FinancingWidget\n * provider=\"timepayment\"\n * vendorCode=\"PVD5P\"\n * onLoad={() => console.log(\"Financing ready\")}\n * />\n * ```\n */\nexport function FinancingWidget({\n provider,\n vendorCode,\n disabled = false,\n onLoad,\n}: FinancingWidgetProps) {\n const injectedRef = useRef(false);\n\n const stableOnLoad = useCallback(() => {\n onLoad?.();\n }, [onLoad]);\n\n useEffect(() => {\n if (disabled || injectedRef.current) return;\n injectedRef.current = true;\n\n const inject = injectors[provider];\n\n // Load during idle time\n if (typeof requestIdleCallback === \"function\") {\n requestIdleCallback(() => inject(vendorCode, stableOnLoad));\n } else {\n setTimeout(() => inject(vendorCode, stableOnLoad), 0);\n }\n }, [provider, vendorCode, disabled, stableOnLoad]);\n\n return null;\n}\n"],"mappings":";;;;AAEA,SAAS,WAAW,QAAQ,mBAAmB;AAyC/C,SAAS,kBACP,YACA,QACM;AACN,MAAI,OAAO,aAAa,YAAa;AACrC,MAAI,SAAS,eAAe,kBAAkB,EAAG;AAEjD,QAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,SAAO,KAAK;AACZ,SAAO,MAAM,yDAAyD,mBAAmB,UAAU,CAAC;AACpG,SAAO,QAAQ;AACf,SAAO,QAAQ;AACf,MAAI,QAAQ;AACV,WAAO,SAAS;AAAA,EAClB;AACA,WAAS,KAAK,YAAY,MAAM;AAClC;AAEA,IAAM,YAGF;AAAA,EACF,aAAa;AACf;AAyBO,SAAS,gBAAgB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA,WAAW;AAAA,EACX;AACF,GAAyB;AACvB,QAAM,cAAc,OAAO,KAAK;AAEhC,QAAM,eAAe,YAAY,MAAM;AACrC,aAAS;AAAA,EACX,GAAG,CAAC,MAAM,CAAC;AAEX,YAAU,MAAM;AACd,QAAI,YAAY,YAAY,QAAS;AACrC,gBAAY,UAAU;AAEtB,UAAM,SAAS,UAAU,QAAQ;AAGjC,QAAI,OAAO,wBAAwB,YAAY;AAC7C,0BAAoB,MAAM,OAAO,YAAY,YAAY,CAAC;AAAA,IAC5D,OAAO;AACL,iBAAW,MAAM,OAAO,YAAY,YAAY,GAAG,CAAC;AAAA,IACtD;AAAA,EACF,GAAG,CAAC,UAAU,YAAY,UAAU,YAAY,CAAC;AAEjD,SAAO;AACT;","names":[]}
|
package/dist/form-select.cjs
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
"use client";
|
|
3
3
|
|
|
4
4
|
|
|
5
|
+
var _chunkVMOQCPK5cjs = require('./chunk-VMOQCPK5.cjs');
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
|
|
9
|
-
var _chunkQ6H6D3ANcjs = require('./chunk-Q6H6D3AN.cjs');
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _chunkQ6H6D3ANcjs = require('./chunk-Q6H6D3AN.cjs');
|
|
13
13
|
require('./chunk-CK53LO3J.cjs');
|
|
14
14
|
|
|
15
15
|
// src/form-select.tsx
|
package/dist/form-select.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/augur-packages/augur-packages/packages/augur-web/dist/form-select.cjs","../src/form-select.tsx"],"names":[],"mappings":"AAAA,uWAAY;AACZ,YAAY;AACZ;AACE;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/augur-packages/augur-packages/packages/augur-web/dist/form-select.cjs","../src/form-select.tsx"],"names":[],"mappings":"AAAA,uWAAY;AACZ,YAAY;AACZ;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B;AACA;ACZA,2EAAuB;AACvB,sDAAmB;AA+CX,+CAAA;AAxBR,IAAM,WAAA,EAAmB,KAAA,CAAA,UAAA;AAAA,EACvB,CACE;AAAA,IACE,KAAA;AAAA,IACA,KAAA;AAAA,IACA,QAAA;AAAA,IACA,IAAA;AAAA,IACA,KAAA;AAAA,IACA,aAAA;AAAA,IACA,OAAA;AAAA,IACA,WAAA;AAAA,IACA,SAAA;AAAA,IACA;AAAA,EACF,CAAA,EACA,GAAA,EAAA,GACG;AACH,IAAA,uBACE,6BAAA;AAAA,MAAC,2BAAA;AAAA,MAAA;AAAA,QACC,KAAA;AAAA,QACA,OAAA,EAAS,IAAA;AAAA,QACT,QAAA;AAAA,QACA,KAAA;AAAA,QACA,SAAA,EAAW,qBAAA,SAAY,CAAA;AAAA,QAEvB,QAAA,kBAAA,8BAAA;AAAA,UAAC,wBAAA;AAAA,UAAA;AAAA,YACC,IAAA;AAAA,YACA,KAAA;AAAA,YACA,aAAA;AAAA,YACA,QAAA;AAAA,YAEA,QAAA,EAAA;AAAA,8BAAA,6BAAA,+BAAC,EAAA,EAAc,GAAA,EAAU,EAAA,EAAI,IAAA,EAC3B,QAAA,kBAAA,6BAAA,6BAAC,EAAA,EAAY,YAAA,CAA0B,EAAA,CACzC,CAAA;AAAA,8BACA,6BAAA,+BAAC,EAAA,EACE,QAAA,EAAA,OAAA,CAAQ,GAAA,CAAI,CAAC,MAAA,EAAA,mBACZ,6BAAA,4BAAC,EAAA,EAA8B,KAAA,EAAO,MAAA,CAAO,KAAA,EAC1C,QAAA,EAAA,MAAA,CAAO,MAAA,CAAA,EADO,MAAA,CAAO,KAExB,CACD,EAAA,CACH;AAAA,YAAA;AAAA,UAAA;AAAA,QACF;AAAA,MAAA;AAAA,IACF,CAAA;AAAA,EAEJ;AACF,CAAA;AACA,UAAA,CAAW,YAAA,EAAc,YAAA;ADdzB;AACE;AACF,gCAAC","file":"/home/runner/work/augur-packages/augur-packages/packages/augur-web/dist/form-select.cjs","sourcesContent":[null,"\"use client\";\n\nimport * as React from \"react\";\nimport { cn } from \"@simpleapps-com/augur-utils/web\";\nimport { FormField } from \"./form-field\";\nimport {\n Select,\n SelectTrigger,\n SelectValue,\n SelectContent,\n SelectItem,\n} from \"./select\";\n\nexport interface FormSelectProps {\n label: string;\n error?: string;\n required?: boolean;\n name: string;\n value?: string;\n onValueChange?: (value: string) => void;\n options: { label: string; value: string }[];\n placeholder?: string;\n className?: string;\n disabled?: boolean;\n}\n\nconst FormSelect = React.forwardRef<HTMLButtonElement, FormSelectProps>(\n (\n {\n label,\n error,\n required,\n name,\n value,\n onValueChange,\n options,\n placeholder,\n className,\n disabled,\n },\n ref,\n ) => {\n return (\n <FormField\n label={label}\n htmlFor={name}\n required={required}\n error={error}\n className={cn(className)}\n >\n <Select\n name={name}\n value={value}\n onValueChange={onValueChange}\n disabled={disabled}\n >\n <SelectTrigger ref={ref} id={name}>\n <SelectValue placeholder={placeholder} />\n </SelectTrigger>\n <SelectContent>\n {options.map((option) => (\n <SelectItem key={option.value} value={option.value}>\n {option.label}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </FormField>\n );\n },\n);\nFormSelect.displayName = \"FormSelect\";\n\nexport { FormSelect };\n"]}
|
package/dist/form-select.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
"use client";
|
|
3
|
+
import {
|
|
4
|
+
FormField
|
|
5
|
+
} from "./chunk-GPDD67CJ.js";
|
|
3
6
|
import {
|
|
4
7
|
Select,
|
|
5
8
|
SelectContent,
|
|
@@ -7,9 +10,6 @@ import {
|
|
|
7
10
|
SelectTrigger,
|
|
8
11
|
SelectValue
|
|
9
12
|
} from "./chunk-ND6U4UQQ.js";
|
|
10
|
-
import {
|
|
11
|
-
FormField
|
|
12
|
-
} from "./chunk-GPDD67CJ.js";
|
|
13
13
|
import "./chunk-FHS7SJEQ.js";
|
|
14
14
|
|
|
15
15
|
// src/form-select.tsx
|
package/dist/gtm.cjs
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
var _react = require('react');
|
|
13
13
|
var _jsxruntime = require('react/jsx-runtime');
|
|
14
|
-
var
|
|
14
|
+
var AnalyticsContext = _react.createContext.call(void 0, null);
|
|
15
15
|
function getDataLayer() {
|
|
16
16
|
if (typeof window === "undefined") return [];
|
|
17
17
|
if (!window.dataLayer) window.dataLayer = [];
|
|
@@ -28,15 +28,12 @@ function injectGtmScript(gtmId, strategy) {
|
|
|
28
28
|
if (strategy === "lazyOnload") {
|
|
29
29
|
script.async = true;
|
|
30
30
|
script.defer = true;
|
|
31
|
-
} else if (strategy === "worker") {
|
|
32
|
-
script.type = "text/partytown";
|
|
33
|
-
script.async = true;
|
|
34
31
|
} else {
|
|
35
32
|
script.async = true;
|
|
36
33
|
}
|
|
37
34
|
document.head.appendChild(script);
|
|
38
35
|
}
|
|
39
|
-
function
|
|
36
|
+
function AnalyticsProvider({
|
|
40
37
|
gtmId,
|
|
41
38
|
strategy = "afterInteractive",
|
|
42
39
|
consentRequired = false,
|
|
@@ -67,22 +64,22 @@ function GtmProvider({
|
|
|
67
64
|
if (hasConsent && !injectedRef.current && typeof window !== "undefined") {
|
|
68
65
|
loadGtm();
|
|
69
66
|
}
|
|
70
|
-
const
|
|
67
|
+
const trackEvent = _react.useCallback.call(void 0,
|
|
71
68
|
(event, params) => {
|
|
72
69
|
const entry = { event, ...params };
|
|
73
70
|
if (debug) {
|
|
74
|
-
console.log("[
|
|
71
|
+
console.log("[Analytics]", entry);
|
|
75
72
|
}
|
|
76
73
|
getDataLayer().push(entry);
|
|
77
74
|
},
|
|
78
75
|
[debug]
|
|
79
76
|
);
|
|
80
|
-
const
|
|
77
|
+
const trackEcommerceEvent = _react.useCallback.call(void 0,
|
|
81
78
|
(event, params) => {
|
|
82
79
|
getDataLayer().push({ ecommerce: null });
|
|
83
80
|
const entry = { event, ecommerce: params };
|
|
84
81
|
if (debug) {
|
|
85
|
-
console.log("[
|
|
82
|
+
console.log("[Analytics ecommerce]", entry);
|
|
86
83
|
}
|
|
87
84
|
getDataLayer().push(entry);
|
|
88
85
|
},
|
|
@@ -97,32 +94,32 @@ function GtmProvider({
|
|
|
97
94
|
}, []);
|
|
98
95
|
const value = _react.useMemo.call(void 0,
|
|
99
96
|
() => ({
|
|
100
|
-
|
|
101
|
-
|
|
97
|
+
trackEvent,
|
|
98
|
+
trackEcommerceEvent,
|
|
102
99
|
grantConsent,
|
|
103
100
|
revokeConsent,
|
|
104
101
|
hasConsent,
|
|
105
102
|
isLoaded
|
|
106
103
|
}),
|
|
107
104
|
[
|
|
108
|
-
|
|
109
|
-
|
|
105
|
+
trackEvent,
|
|
106
|
+
trackEcommerceEvent,
|
|
110
107
|
grantConsent,
|
|
111
108
|
revokeConsent,
|
|
112
109
|
hasConsent,
|
|
113
110
|
isLoaded
|
|
114
111
|
]
|
|
115
112
|
);
|
|
116
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
113
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AnalyticsContext.Provider, { value, children });
|
|
117
114
|
}
|
|
118
|
-
function
|
|
119
|
-
const context = _react.useContext.call(void 0,
|
|
115
|
+
function useAnalytics() {
|
|
116
|
+
const context = _react.useContext.call(void 0, AnalyticsContext);
|
|
120
117
|
if (!context) {
|
|
121
|
-
throw new Error("
|
|
118
|
+
throw new Error("useAnalytics must be used within an <AnalyticsProvider>");
|
|
122
119
|
}
|
|
123
120
|
return context;
|
|
124
121
|
}
|
|
125
|
-
function
|
|
122
|
+
function AnalyticsNoscript({ gtmId }) {
|
|
126
123
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "noscript", { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
127
124
|
"iframe",
|
|
128
125
|
{
|
|
@@ -134,9 +131,15 @@ function GtmNoscript({ gtmId }) {
|
|
|
134
131
|
}
|
|
135
132
|
) });
|
|
136
133
|
}
|
|
134
|
+
var GtmProvider = AnalyticsProvider;
|
|
135
|
+
var useGtm = useAnalytics;
|
|
136
|
+
var GtmNoscript = AnalyticsNoscript;
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
|
|
137
140
|
|
|
138
141
|
|
|
139
142
|
|
|
140
143
|
|
|
141
|
-
exports.GtmNoscript = GtmNoscript; exports.GtmProvider = GtmProvider; exports.useGtm = useGtm;
|
|
144
|
+
exports.AnalyticsNoscript = AnalyticsNoscript; exports.AnalyticsProvider = AnalyticsProvider; exports.GtmNoscript = GtmNoscript; exports.GtmProvider = GtmProvider; exports.useAnalytics = useAnalytics; exports.useGtm = useGtm;
|
|
142
145
|
//# sourceMappingURL=gtm.cjs.map
|
package/dist/gtm.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/augur-packages/augur-packages/packages/augur-web/dist/gtm.cjs","../src/gtm.tsx"],"names":[],"mappings":"AAAA,qFAAY;AACZ,YAAY;AACZ;AACA;ACDA;AACE;AACA;AACA;AACA;AACA;AACA;AAAA,8BACK;AAiOE,+CAAA;AA1IT,IAAM,WAAA,EAAa,kCAAA,IAA0C,CAAA;AAY7D,SAAS,YAAA,CAAA,EAA0C;AACjD,EAAA,GAAA,CAAI,OAAO,OAAA,IAAW,WAAA,EAAa,OAAO,CAAC,CAAA;AAC3C,EAAA,GAAA,CAAI,CAAC,MAAA,CAAO,SAAA,EAAW,MAAA,CAAO,UAAA,EAAY,CAAC,CAAA;AAC3C,EAAA,OAAO,MAAA,CAAO,SAAA;AAChB;AAEA,SAAS,eAAA,CAAgB,KAAA,EAAe,QAAA,EAA6B;AACnE,EAAA,GAAA,CAAI,OAAO,SAAA,IAAa,WAAA,EAAa,MAAA;AAGrC,EAAA,GAAA,CAAI,QAAA,CAAS,cAAA,CAAe,YAAY,CAAA,EAAG,MAAA;AAE3C,EAAA,MAAM,UAAA,EAAY,YAAA,CAAa,CAAA;AAC/B,EAAA,SAAA,CAAU,IAAA,CAAK,EAAE,WAAA,EAAA,iBAAa,IAAI,IAAA,CAAK,CAAA,CAAA,CAAE,OAAA,CAAQ,CAAA,EAAG,KAAA,EAAO,SAAS,CAAC,CAAA;AAErE,EAAA,MAAM,OAAA,EAAS,QAAA,CAAS,aAAA,CAAc,QAAQ,CAAA;AAC9C,EAAA,MAAA,CAAO,GAAA,EAAK,YAAA;AACZ,EAAA,MAAA,CAAO,IAAA,EAAM,CAAA,2CAAA,EAA8C,kBAAA,CAAmB,KAAK,CAAC,CAAA,CAAA;AAErD,EAAA;AACd,IAAA;AACA,IAAA;AACiB,EAAA;AAClB,IAAA;AACC,IAAA;AACV,EAAA;AAEU,IAAA;AACjB,EAAA;AAEgC,EAAA;AAClC;AAM4B;AAC1B,EAAA;AACW,EAAA;AACO,EAAA;AACV,EAAA;AACR,EAAA;AACmB;AAC0C,EAAA;AACf,EAAA;AACd,EAAA;AAEE,EAAA;AACP,IAAA;AACH,IAAA;AAEsD,IAAA;AAChD,MAAA;AACO,QAAA;AACf,QAAA;AACjB,MAAA;AACyC,IAAA;AAEzB,MAAA;AACgB,QAAA;AACf,QAAA;AACd,MAAA;AACC,IAAA;AAC0B,MAAA;AACf,MAAA;AAClB,IAAA;AACkB,EAAA;AAGqD,EAAA;AAC/D,IAAA;AACV,EAAA;AAEkB,EAAA;AACqC,IAAA;AAClB,MAAA;AACtB,MAAA;AACiB,QAAA;AAC5B,MAAA;AACyB,MAAA;AAC3B,IAAA;AACM,IAAA;AACR,EAAA;AAE2B,EAAA;AACiC,IAAA;AAEjB,MAAA;AACE,MAAA;AAC9B,MAAA;AAC2B,QAAA;AACtC,MAAA;AACyB,MAAA;AAC3B,IAAA;AACM,IAAA;AACR,EAAA;AAEuC,EAAA;AACnB,IAAA;AACV,IAAA;AACE,EAAA;AAE4B,EAAA;AACnB,IAAA;AAChB,EAAA;AAES,EAAA;AACL,IAAA;AACL,MAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACF,IAAA;AACA,IAAA;AACE,MAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACF,IAAA;AACF,EAAA;AAEoD,EAAA;AACtD;AAM0C;AACH,EAAA;AACvB,EAAA;AACgD,IAAA;AAC9D,EAAA;AACO,EAAA;AACT;AAWyD;AAGnD,EAAA;AAAC,IAAA;AAAA,IAAA;AAC8E,MAAA;AACtE,MAAA;AACD,MAAA;AACyC,MAAA;AACzC,MAAA;AAAA,IAAA;AAEV,EAAA;AAEJ;ADtIuF;AACA;AACA;AACA;AACA","file":"/home/runner/work/augur-packages/augur-packages/packages/augur-web/dist/gtm.cjs","sourcesContent":[null,"\"use client\";\n\nimport {\n createContext,\n useCallback,\n useContext,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport type { ReactNode } from \"react\";\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\n/** GTM script loading strategy. */\nexport type GtmStrategy =\n | \"default\"\n | \"afterInteractive\"\n | \"lazyOnload\"\n | \"worker\";\n\n/** GA4 standard e-commerce event names. */\nexport type GtmEcommerceEvent =\n | \"view_item\"\n | \"view_item_list\"\n | \"select_item\"\n | \"add_to_cart\"\n | \"remove_from_cart\"\n | \"view_cart\"\n | \"begin_checkout\"\n | \"add_shipping_info\"\n | \"add_payment_info\"\n | \"purchase\"\n | \"refund\";\n\n/** GA4 e-commerce item shape. */\nexport interface GtmItem {\n item_id: string;\n item_name?: string;\n item_brand?: string;\n item_category?: string;\n item_variant?: string;\n price?: number;\n quantity?: number;\n index?: number;\n [key: string]: unknown;\n}\n\n/** Parameters for e-commerce events. */\nexport interface GtmEcommerceParams {\n currency?: string;\n value?: number;\n items?: GtmItem[];\n transaction_id?: string;\n shipping?: number;\n tax?: number;\n coupon?: string;\n [key: string]: unknown;\n}\n\nexport interface GtmProviderProps {\n /** GTM container ID (e.g. \"GTM-XXXXX\"). */\n gtmId: string;\n /** Script loading strategy. Default: \"afterInteractive\". */\n strategy?: GtmStrategy;\n /** Delay GTM loading until consent is granted. Default: false. */\n consentRequired?: boolean;\n /** Log dataLayer pushes to console. Default: false. */\n debug?: boolean;\n children: ReactNode;\n}\n\nexport interface GtmContextValue {\n /** Push a custom event to the dataLayer. */\n pushEvent: (event: string, params?: Record<string, unknown>) => void;\n /** Push a GA4 e-commerce event to the dataLayer. */\n pushEcommerceEvent: (\n event: GtmEcommerceEvent,\n params: GtmEcommerceParams,\n ) => void;\n /** Grant consent — loads GTM if consentRequired was true. */\n grantConsent: () => void;\n /** Revoke consent. Does not unload GTM (scripts can't be unloaded). */\n revokeConsent: () => void;\n /** Whether consent has been granted. */\n hasConsent: boolean;\n /** Whether the GTM script has been injected. */\n isLoaded: boolean;\n}\n\n// ---------------------------------------------------------------------------\n// Context\n// ---------------------------------------------------------------------------\n\nconst GtmContext = createContext<GtmContextValue | null>(null);\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\ndeclare global {\n interface Window {\n dataLayer?: Record<string, unknown>[];\n }\n}\n\nfunction getDataLayer(): Record<string, unknown>[] {\n if (typeof window === \"undefined\") return [];\n if (!window.dataLayer) window.dataLayer = [];\n return window.dataLayer;\n}\n\nfunction injectGtmScript(gtmId: string, strategy: GtmStrategy): void {\n if (typeof document === \"undefined\") return;\n\n // Prevent double-injection\n if (document.getElementById(\"gtm-script\")) return;\n\n const dataLayer = getDataLayer();\n dataLayer.push({ \"gtm.start\": new Date().getTime(), event: \"gtm.js\" });\n\n const script = document.createElement(\"script\");\n script.id = \"gtm-script\";\n script.src = `https://www.googletagmanager.com/gtm.js?id=${encodeURIComponent(gtmId)}`;\n\n if (strategy === \"lazyOnload\") {\n script.async = true;\n script.defer = true;\n } else if (strategy === \"worker\") {\n script.type = \"text/partytown\";\n script.async = true;\n } else {\n // \"default\" and \"afterInteractive\"\n script.async = true;\n }\n\n document.head.appendChild(script);\n}\n\n// ---------------------------------------------------------------------------\n// Provider\n// ---------------------------------------------------------------------------\n\nexport function GtmProvider({\n gtmId,\n strategy = \"afterInteractive\",\n consentRequired = false,\n debug = false,\n children,\n}: GtmProviderProps) {\n const [hasConsent, setHasConsent] = useState(!consentRequired);\n const [isLoaded, setIsLoaded] = useState(false);\n const injectedRef = useRef(false);\n\n const loadGtm = useCallback(() => {\n if (injectedRef.current) return;\n injectedRef.current = true;\n\n if (strategy === \"lazyOnload\" && typeof requestIdleCallback === \"function\") {\n requestIdleCallback(() => {\n injectGtmScript(gtmId, strategy);\n setIsLoaded(true);\n });\n } else if (strategy === \"afterInteractive\") {\n // Defer to after hydration\n setTimeout(() => {\n injectGtmScript(gtmId, strategy);\n setIsLoaded(true);\n }, 0);\n } else {\n injectGtmScript(gtmId, strategy);\n setIsLoaded(true);\n }\n }, [gtmId, strategy]);\n\n // Auto-load when consent is not required or already granted\n if (hasConsent && !injectedRef.current && typeof window !== \"undefined\") {\n loadGtm();\n }\n\n const pushEvent = useCallback(\n (event: string, params?: Record<string, unknown>) => {\n const entry = { event, ...params };\n if (debug) {\n console.log(\"[GTM]\", entry);\n }\n getDataLayer().push(entry);\n },\n [debug],\n );\n\n const pushEcommerceEvent = useCallback(\n (event: GtmEcommerceEvent, params: GtmEcommerceParams) => {\n // Clear previous ecommerce data per GA4 best practices\n getDataLayer().push({ ecommerce: null });\n const entry = { event, ecommerce: params };\n if (debug) {\n console.log(\"[GTM ecommerce]\", entry);\n }\n getDataLayer().push(entry);\n },\n [debug],\n );\n\n const grantConsent = useCallback(() => {\n setHasConsent(true);\n loadGtm();\n }, [loadGtm]);\n\n const revokeConsent = useCallback(() => {\n setHasConsent(false);\n }, []);\n\n const value = useMemo<GtmContextValue>(\n () => ({\n pushEvent,\n pushEcommerceEvent,\n grantConsent,\n revokeConsent,\n hasConsent,\n isLoaded,\n }),\n [\n pushEvent,\n pushEcommerceEvent,\n grantConsent,\n revokeConsent,\n hasConsent,\n isLoaded,\n ],\n );\n\n return <GtmContext.Provider value={value}>{children}</GtmContext.Provider>;\n}\n\n// ---------------------------------------------------------------------------\n// Hook\n// ---------------------------------------------------------------------------\n\nexport function useGtm(): GtmContextValue {\n const context = useContext(GtmContext);\n if (!context) {\n throw new Error(\"useGtm must be used within a <GtmProvider>\");\n }\n return context;\n}\n\n// ---------------------------------------------------------------------------\n// Noscript\n// ---------------------------------------------------------------------------\n\nexport interface GtmNoscriptProps {\n /** GTM container ID (must match GtmProvider). */\n gtmId: string;\n}\n\nexport function GtmNoscript({ gtmId }: GtmNoscriptProps) {\n return (\n <noscript>\n <iframe\n src={`https://www.googletagmanager.com/ns.html?id=${encodeURIComponent(gtmId)}`}\n height=\"0\"\n width=\"0\"\n style={{ display: \"none\", visibility: \"hidden\" }}\n title=\"Google Tag Manager\"\n />\n </noscript>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/augur-packages/augur-packages/packages/augur-web/dist/gtm.cjs","../src/gtm.tsx"],"names":[],"mappings":"AAAA,qFAAY;AACZ,YAAY;AACZ;AACA;ACDA;AACE;AACA;AACA;AACA;AACA;AACA;AAAA,8BACK;AA8NH,+CAAA;AA3IJ,IAAM,iBAAA,EAAmB,kCAAA,IAAgD,CAAA;AAYzE,SAAS,YAAA,CAAA,EAA0C;AACjD,EAAA,GAAA,CAAI,OAAO,OAAA,IAAW,WAAA,EAAa,OAAO,CAAC,CAAA;AAC3C,EAAA,GAAA,CAAI,CAAC,MAAA,CAAO,SAAA,EAAW,MAAA,CAAO,UAAA,EAAY,CAAC,CAAA;AAC3C,EAAA,OAAO,MAAA,CAAO,SAAA;AAChB;AAEA,SAAS,eAAA,CACP,KAAA,EACA,QAAA,EACM;AACN,EAAA,GAAA,CAAI,OAAO,SAAA,IAAa,WAAA,EAAa,MAAA;AAGrC,EAAA,GAAA,CAAI,QAAA,CAAS,cAAA,CAAe,YAAY,CAAA,EAAG,MAAA;AAE3C,EAAA,MAAM,UAAA,EAAY,YAAA,CAAa,CAAA;AAC/B,EAAA,SAAA,CAAU,IAAA,CAAK,EAAE,WAAA,EAAA,iBAAa,IAAI,IAAA,CAAK,CAAA,CAAA,CAAE,OAAA,CAAQ,CAAA,EAAG,KAAA,EAAO,SAAS,CAAC,CAAA;AAErE,EAAA,MAAM,OAAA,EAAS,QAAA,CAAS,aAAA,CAAc,QAAQ,CAAA;AAC9C,EAAA,MAAA,CAAO,GAAA,EAAK,YAAA;AACZ,EAAA,MAAA,CAAO,IAAA,EAAM,CAAA,2CAAA,EAA8C,kBAAA,CAAmB,KAAK,CAAC,CAAA,CAAA;AAErD,EAAA;AACd,IAAA;AACA,IAAA;AACV,EAAA;AAEU,IAAA;AACjB,EAAA;AAEgC,EAAA;AAClC;AAMkC;AAChC,EAAA;AACW,EAAA;AACO,EAAA;AACV,EAAA;AACR,EAAA;AACyB;AACoC,EAAA;AACf,EAAA;AACd,EAAA;AAEE,EAAA;AACP,IAAA;AACH,IAAA;AAEsD,IAAA;AAChD,MAAA;AACO,QAAA;AACf,QAAA;AACjB,MAAA;AACyC,IAAA;AAEzB,MAAA;AACgB,QAAA;AACf,QAAA;AACd,MAAA;AACC,IAAA;AAC0B,MAAA;AACf,MAAA;AAClB,IAAA;AACkB,EAAA;AAGqD,EAAA;AAC/D,IAAA;AACV,EAAA;AAEmB,EAAA;AACoC,IAAA;AAClB,MAAA;AACtB,MAAA;AACuB,QAAA;AAClC,MAAA;AACyB,MAAA;AAC3B,IAAA;AACM,IAAA;AACR,EAAA;AAE4B,EAAA;AAC0B,IAAA;AAEX,MAAA;AACE,MAAA;AAC9B,MAAA;AACiC,QAAA;AAC5C,MAAA;AACyB,MAAA;AAC3B,IAAA;AACM,IAAA;AACR,EAAA;AAEuC,EAAA;AACnB,IAAA;AACV,IAAA;AACE,EAAA;AAE4B,EAAA;AACnB,IAAA;AAChB,EAAA;AAES,EAAA;AACL,IAAA;AACL,MAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACF,IAAA;AACA,IAAA;AACE,MAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACF,IAAA;AACF,EAAA;AAKE,EAAA;AAEJ;AAMsD;AACT,EAAA;AAC7B,EAAA;AAC6D,IAAA;AAC3E,EAAA;AACO,EAAA;AACT;AAWqE;AAG/D,EAAA;AAAC,IAAA;AAAA,IAAA;AAC8E,MAAA;AACtE,MAAA;AACD,MAAA;AACyC,MAAA;AACzC,MAAA;AAAA,IAAA;AAEV,EAAA;AAEJ;AAsB2B;AAEL;AAEK;ADhK4D;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/augur-packages/augur-packages/packages/augur-web/dist/gtm.cjs","sourcesContent":[null,"\"use client\";\n\nimport {\n createContext,\n useCallback,\n useContext,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport type { ReactNode } from \"react\";\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\n/** Script loading strategy. */\nexport type AnalyticsStrategy = \"default\" | \"afterInteractive\" | \"lazyOnload\";\n\n/** GA4 standard e-commerce event names. */\nexport type EcommerceEvent =\n | \"view_item\"\n | \"view_item_list\"\n | \"select_item\"\n | \"add_to_cart\"\n | \"remove_from_cart\"\n | \"view_cart\"\n | \"begin_checkout\"\n | \"add_shipping_info\"\n | \"add_payment_info\"\n | \"purchase\"\n | \"refund\";\n\n/** GA4 e-commerce item shape. */\nexport interface EcommerceItem {\n item_id: string;\n item_name?: string;\n item_brand?: string;\n item_category?: string;\n item_variant?: string;\n price?: number;\n quantity?: number;\n index?: number;\n [key: string]: unknown;\n}\n\n/** Parameters for e-commerce events. */\nexport interface EcommerceParams {\n currency?: string;\n value?: number;\n items?: EcommerceItem[];\n transaction_id?: string;\n shipping?: number;\n tax?: number;\n coupon?: string;\n [key: string]: unknown;\n}\n\nexport interface AnalyticsProviderProps {\n /** GTM container ID (e.g. \"GTM-XXXXX\"). */\n gtmId: string;\n /** Script loading strategy. Default: \"afterInteractive\". */\n strategy?: AnalyticsStrategy;\n /** Delay GTM loading until consent is granted. Default: false. */\n consentRequired?: boolean;\n /** Log dataLayer pushes to console. Default: false. */\n debug?: boolean;\n children: ReactNode;\n}\n\nexport interface AnalyticsContextValue {\n /** Push a custom event to the dataLayer. */\n trackEvent: (event: string, params?: Record<string, unknown>) => void;\n /** Push a GA4 e-commerce event to the dataLayer. */\n trackEcommerceEvent: (\n event: EcommerceEvent,\n params: EcommerceParams,\n ) => void;\n /** Grant consent — loads GTM if consentRequired was true. */\n grantConsent: () => void;\n /** Revoke consent. Does not unload GTM (scripts can't be unloaded). */\n revokeConsent: () => void;\n /** Whether consent has been granted. */\n hasConsent: boolean;\n /** Whether the GTM script has been injected. */\n isLoaded: boolean;\n}\n\n// ---------------------------------------------------------------------------\n// Context\n// ---------------------------------------------------------------------------\n\nconst AnalyticsContext = createContext<AnalyticsContextValue | null>(null);\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\ndeclare global {\n interface Window {\n dataLayer?: Record<string, unknown>[];\n }\n}\n\nfunction getDataLayer(): Record<string, unknown>[] {\n if (typeof window === \"undefined\") return [];\n if (!window.dataLayer) window.dataLayer = [];\n return window.dataLayer;\n}\n\nfunction injectGtmScript(\n gtmId: string,\n strategy: AnalyticsStrategy,\n): void {\n if (typeof document === \"undefined\") return;\n\n // Prevent double-injection\n if (document.getElementById(\"gtm-script\")) return;\n\n const dataLayer = getDataLayer();\n dataLayer.push({ \"gtm.start\": new Date().getTime(), event: \"gtm.js\" });\n\n const script = document.createElement(\"script\");\n script.id = \"gtm-script\";\n script.src = `https://www.googletagmanager.com/gtm.js?id=${encodeURIComponent(gtmId)}`;\n\n if (strategy === \"lazyOnload\") {\n script.async = true;\n script.defer = true;\n } else {\n // \"default\" and \"afterInteractive\"\n script.async = true;\n }\n\n document.head.appendChild(script);\n}\n\n// ---------------------------------------------------------------------------\n// Provider\n// ---------------------------------------------------------------------------\n\nexport function AnalyticsProvider({\n gtmId,\n strategy = \"afterInteractive\",\n consentRequired = false,\n debug = false,\n children,\n}: AnalyticsProviderProps) {\n const [hasConsent, setHasConsent] = useState(!consentRequired);\n const [isLoaded, setIsLoaded] = useState(false);\n const injectedRef = useRef(false);\n\n const loadGtm = useCallback(() => {\n if (injectedRef.current) return;\n injectedRef.current = true;\n\n if (strategy === \"lazyOnload\" && typeof requestIdleCallback === \"function\") {\n requestIdleCallback(() => {\n injectGtmScript(gtmId, strategy);\n setIsLoaded(true);\n });\n } else if (strategy === \"afterInteractive\") {\n // Defer to after hydration\n setTimeout(() => {\n injectGtmScript(gtmId, strategy);\n setIsLoaded(true);\n }, 0);\n } else {\n injectGtmScript(gtmId, strategy);\n setIsLoaded(true);\n }\n }, [gtmId, strategy]);\n\n // Auto-load when consent is not required or already granted\n if (hasConsent && !injectedRef.current && typeof window !== \"undefined\") {\n loadGtm();\n }\n\n const trackEvent = useCallback(\n (event: string, params?: Record<string, unknown>) => {\n const entry = { event, ...params };\n if (debug) {\n console.log(\"[Analytics]\", entry);\n }\n getDataLayer().push(entry);\n },\n [debug],\n );\n\n const trackEcommerceEvent = useCallback(\n (event: EcommerceEvent, params: EcommerceParams) => {\n // Clear previous ecommerce data per GA4 best practices\n getDataLayer().push({ ecommerce: null });\n const entry = { event, ecommerce: params };\n if (debug) {\n console.log(\"[Analytics ecommerce]\", entry);\n }\n getDataLayer().push(entry);\n },\n [debug],\n );\n\n const grantConsent = useCallback(() => {\n setHasConsent(true);\n loadGtm();\n }, [loadGtm]);\n\n const revokeConsent = useCallback(() => {\n setHasConsent(false);\n }, []);\n\n const value = useMemo<AnalyticsContextValue>(\n () => ({\n trackEvent,\n trackEcommerceEvent,\n grantConsent,\n revokeConsent,\n hasConsent,\n isLoaded,\n }),\n [\n trackEvent,\n trackEcommerceEvent,\n grantConsent,\n revokeConsent,\n hasConsent,\n isLoaded,\n ],\n );\n\n return (\n <AnalyticsContext.Provider value={value}>\n {children}\n </AnalyticsContext.Provider>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Hook\n// ---------------------------------------------------------------------------\n\nexport function useAnalytics(): AnalyticsContextValue {\n const context = useContext(AnalyticsContext);\n if (!context) {\n throw new Error(\"useAnalytics must be used within an <AnalyticsProvider>\");\n }\n return context;\n}\n\n// ---------------------------------------------------------------------------\n// Noscript\n// ---------------------------------------------------------------------------\n\nexport interface AnalyticsNoscriptProps {\n /** GTM container ID (must match AnalyticsProvider). */\n gtmId: string;\n}\n\nexport function AnalyticsNoscript({ gtmId }: AnalyticsNoscriptProps) {\n return (\n <noscript>\n <iframe\n src={`https://www.googletagmanager.com/ns.html?id=${encodeURIComponent(gtmId)}`}\n height=\"0\"\n width=\"0\"\n style={{ display: \"none\", visibility: \"hidden\" }}\n title=\"Google Tag Manager\"\n />\n </noscript>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Backward-compatible aliases (from #59 GtmProvider)\n// ---------------------------------------------------------------------------\n\n/** @deprecated Use `AnalyticsStrategy` instead. */\nexport type GtmStrategy = AnalyticsStrategy;\n/** @deprecated Use `EcommerceEvent` instead. */\nexport type GtmEcommerceEvent = EcommerceEvent;\n/** @deprecated Use `EcommerceItem` instead. */\nexport type GtmItem = EcommerceItem;\n/** @deprecated Use `EcommerceParams` instead. */\nexport type GtmEcommerceParams = EcommerceParams;\n/** @deprecated Use `AnalyticsProviderProps` instead. */\nexport type GtmProviderProps = AnalyticsProviderProps;\n/** @deprecated Use `AnalyticsContextValue` instead. */\nexport type GtmContextValue = AnalyticsContextValue;\n/** @deprecated Use `AnalyticsNoscriptProps` instead. */\nexport type GtmNoscriptProps = AnalyticsNoscriptProps;\n\n/** @deprecated Use `AnalyticsProvider` instead. */\nexport const GtmProvider = AnalyticsProvider;\n/** @deprecated Use `useAnalytics` instead. */\nexport const useGtm = useAnalytics;\n/** @deprecated Use `AnalyticsNoscript` instead. */\nexport const GtmNoscript = AnalyticsNoscript;\n"]}
|
package/dist/gtm.d.cts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
type
|
|
4
|
+
/** Script loading strategy. */
|
|
5
|
+
type AnalyticsStrategy = "default" | "afterInteractive" | "lazyOnload";
|
|
6
6
|
/** GA4 standard e-commerce event names. */
|
|
7
|
-
type
|
|
7
|
+
type EcommerceEvent = "view_item" | "view_item_list" | "select_item" | "add_to_cart" | "remove_from_cart" | "view_cart" | "begin_checkout" | "add_shipping_info" | "add_payment_info" | "purchase" | "refund";
|
|
8
8
|
/** GA4 e-commerce item shape. */
|
|
9
|
-
interface
|
|
9
|
+
interface EcommerceItem {
|
|
10
10
|
item_id: string;
|
|
11
11
|
item_name?: string;
|
|
12
12
|
item_brand?: string;
|
|
@@ -18,32 +18,32 @@ interface GtmItem {
|
|
|
18
18
|
[key: string]: unknown;
|
|
19
19
|
}
|
|
20
20
|
/** Parameters for e-commerce events. */
|
|
21
|
-
interface
|
|
21
|
+
interface EcommerceParams {
|
|
22
22
|
currency?: string;
|
|
23
23
|
value?: number;
|
|
24
|
-
items?:
|
|
24
|
+
items?: EcommerceItem[];
|
|
25
25
|
transaction_id?: string;
|
|
26
26
|
shipping?: number;
|
|
27
27
|
tax?: number;
|
|
28
28
|
coupon?: string;
|
|
29
29
|
[key: string]: unknown;
|
|
30
30
|
}
|
|
31
|
-
interface
|
|
31
|
+
interface AnalyticsProviderProps {
|
|
32
32
|
/** GTM container ID (e.g. "GTM-XXXXX"). */
|
|
33
33
|
gtmId: string;
|
|
34
34
|
/** Script loading strategy. Default: "afterInteractive". */
|
|
35
|
-
strategy?:
|
|
35
|
+
strategy?: AnalyticsStrategy;
|
|
36
36
|
/** Delay GTM loading until consent is granted. Default: false. */
|
|
37
37
|
consentRequired?: boolean;
|
|
38
38
|
/** Log dataLayer pushes to console. Default: false. */
|
|
39
39
|
debug?: boolean;
|
|
40
40
|
children: ReactNode;
|
|
41
41
|
}
|
|
42
|
-
interface
|
|
42
|
+
interface AnalyticsContextValue {
|
|
43
43
|
/** Push a custom event to the dataLayer. */
|
|
44
|
-
|
|
44
|
+
trackEvent: (event: string, params?: Record<string, unknown>) => void;
|
|
45
45
|
/** Push a GA4 e-commerce event to the dataLayer. */
|
|
46
|
-
|
|
46
|
+
trackEcommerceEvent: (event: EcommerceEvent, params: EcommerceParams) => void;
|
|
47
47
|
/** Grant consent — loads GTM if consentRequired was true. */
|
|
48
48
|
grantConsent: () => void;
|
|
49
49
|
/** Revoke consent. Does not unload GTM (scripts can't be unloaded). */
|
|
@@ -58,12 +58,32 @@ declare global {
|
|
|
58
58
|
dataLayer?: Record<string, unknown>[];
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
declare function
|
|
62
|
-
declare function
|
|
63
|
-
interface
|
|
64
|
-
/** GTM container ID (must match
|
|
61
|
+
declare function AnalyticsProvider({ gtmId, strategy, consentRequired, debug, children, }: AnalyticsProviderProps): react_jsx_runtime.JSX.Element;
|
|
62
|
+
declare function useAnalytics(): AnalyticsContextValue;
|
|
63
|
+
interface AnalyticsNoscriptProps {
|
|
64
|
+
/** GTM container ID (must match AnalyticsProvider). */
|
|
65
65
|
gtmId: string;
|
|
66
66
|
}
|
|
67
|
-
declare function
|
|
67
|
+
declare function AnalyticsNoscript({ gtmId }: AnalyticsNoscriptProps): react_jsx_runtime.JSX.Element;
|
|
68
|
+
/** @deprecated Use `AnalyticsStrategy` instead. */
|
|
69
|
+
type GtmStrategy = AnalyticsStrategy;
|
|
70
|
+
/** @deprecated Use `EcommerceEvent` instead. */
|
|
71
|
+
type GtmEcommerceEvent = EcommerceEvent;
|
|
72
|
+
/** @deprecated Use `EcommerceItem` instead. */
|
|
73
|
+
type GtmItem = EcommerceItem;
|
|
74
|
+
/** @deprecated Use `EcommerceParams` instead. */
|
|
75
|
+
type GtmEcommerceParams = EcommerceParams;
|
|
76
|
+
/** @deprecated Use `AnalyticsProviderProps` instead. */
|
|
77
|
+
type GtmProviderProps = AnalyticsProviderProps;
|
|
78
|
+
/** @deprecated Use `AnalyticsContextValue` instead. */
|
|
79
|
+
type GtmContextValue = AnalyticsContextValue;
|
|
80
|
+
/** @deprecated Use `AnalyticsNoscriptProps` instead. */
|
|
81
|
+
type GtmNoscriptProps = AnalyticsNoscriptProps;
|
|
82
|
+
/** @deprecated Use `AnalyticsProvider` instead. */
|
|
83
|
+
declare const GtmProvider: typeof AnalyticsProvider;
|
|
84
|
+
/** @deprecated Use `useAnalytics` instead. */
|
|
85
|
+
declare const useGtm: typeof useAnalytics;
|
|
86
|
+
/** @deprecated Use `AnalyticsNoscript` instead. */
|
|
87
|
+
declare const GtmNoscript: typeof AnalyticsNoscript;
|
|
68
88
|
|
|
69
|
-
export { type GtmContextValue, type GtmEcommerceEvent, type GtmEcommerceParams, type GtmItem, GtmNoscript, type GtmNoscriptProps, GtmProvider, type GtmProviderProps, type GtmStrategy, useGtm };
|
|
89
|
+
export { type AnalyticsContextValue, AnalyticsNoscript, type AnalyticsNoscriptProps, AnalyticsProvider, type AnalyticsProviderProps, type AnalyticsStrategy, type EcommerceEvent, type EcommerceItem, type EcommerceParams, type GtmContextValue, type GtmEcommerceEvent, type GtmEcommerceParams, type GtmItem, GtmNoscript, type GtmNoscriptProps, GtmProvider, type GtmProviderProps, type GtmStrategy, useAnalytics, useGtm };
|