@hifilabs/pixel 0.1.0 → 0.1.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/dist/index.esm.js +22 -20
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -7,7 +7,7 @@ var __publicField = (obj, key, value) => {
|
|
|
7
7
|
};
|
|
8
8
|
|
|
9
9
|
// src/react/BalanceAnalytics.tsx
|
|
10
|
-
import
|
|
10
|
+
import React, { useEffect, useRef, Suspense } from "react";
|
|
11
11
|
import { usePathname, useSearchParams } from "next/navigation";
|
|
12
12
|
function BalanceAnalyticsInner() {
|
|
13
13
|
const pathname = usePathname();
|
|
@@ -37,7 +37,7 @@ function BalanceAnalyticsInner() {
|
|
|
37
37
|
return null;
|
|
38
38
|
}
|
|
39
39
|
function BalanceAnalytics() {
|
|
40
|
-
return /* @__PURE__ */
|
|
40
|
+
return /* @__PURE__ */ React.createElement(Suspense, { fallback: null }, /* @__PURE__ */ React.createElement(BalanceAnalyticsInner, null));
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
// src/react/useBalanceIdentify.ts
|
|
@@ -371,7 +371,7 @@ function useBalanceIdentify() {
|
|
|
371
371
|
}
|
|
372
372
|
|
|
373
373
|
// src/react/GTMProvider.tsx
|
|
374
|
-
import
|
|
374
|
+
import React3 from "react";
|
|
375
375
|
import Script from "next/script";
|
|
376
376
|
|
|
377
377
|
// src/react/useGTMConsent.ts
|
|
@@ -471,27 +471,29 @@ var DEFAULT_GTM_CONSENT = {
|
|
|
471
471
|
function GTMProvider({ gtmId, children, debug = false }) {
|
|
472
472
|
const resolvedGtmId = gtmId || process.env.NEXT_PUBLIC_GTM_ID;
|
|
473
473
|
useGTMConsent({ debug });
|
|
474
|
-
useEffect4(() => {
|
|
475
|
-
if (typeof window === "undefined" || !resolvedGtmId)
|
|
476
|
-
return;
|
|
477
|
-
window.dataLayer = window.dataLayer || [];
|
|
478
|
-
if (typeof window.gtag !== "function") {
|
|
479
|
-
window.gtag = function gtag(...args) {
|
|
480
|
-
window.dataLayer.push(args);
|
|
481
|
-
};
|
|
482
|
-
}
|
|
483
|
-
window.gtag("consent", "default", DEFAULT_GTM_CONSENT);
|
|
484
|
-
if (debug) {
|
|
485
|
-
console.log("[GTMProvider] Initialized with default consent:", DEFAULT_GTM_CONSENT);
|
|
486
|
-
}
|
|
487
|
-
}, [resolvedGtmId, debug]);
|
|
488
474
|
if (!resolvedGtmId) {
|
|
489
475
|
if (debug) {
|
|
490
476
|
console.log("[GTMProvider] No GTM ID configured, skipping GTM initialization");
|
|
491
477
|
}
|
|
492
|
-
return /* @__PURE__ */
|
|
478
|
+
return /* @__PURE__ */ React3.createElement(React3.Fragment, null, children);
|
|
493
479
|
}
|
|
494
|
-
|
|
480
|
+
const consentJson = JSON.stringify(DEFAULT_GTM_CONSENT);
|
|
481
|
+
const consentScript = `
|
|
482
|
+
window.dataLayer = window.dataLayer || [];
|
|
483
|
+
function gtag(){dataLayer.push(arguments);}
|
|
484
|
+
window.gtag = gtag;
|
|
485
|
+
gtag('consent', 'default', ${consentJson});
|
|
486
|
+
gtag('set', 'wait_for_update', 500);
|
|
487
|
+
${debug ? "console.log('[GTM] Default consent initialized (denied)');" : ""}
|
|
488
|
+
`;
|
|
489
|
+
return /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement(
|
|
490
|
+
Script,
|
|
491
|
+
{
|
|
492
|
+
id: "gtm-consent-default",
|
|
493
|
+
strategy: "beforeInteractive",
|
|
494
|
+
dangerouslySetInnerHTML: { __html: consentScript }
|
|
495
|
+
}
|
|
496
|
+
), /* @__PURE__ */ React3.createElement(
|
|
495
497
|
Script,
|
|
496
498
|
{
|
|
497
499
|
id: "gtm-script",
|
|
@@ -506,7 +508,7 @@ function GTMProvider({ gtmId, children, debug = false }) {
|
|
|
506
508
|
`
|
|
507
509
|
}
|
|
508
510
|
}
|
|
509
|
-
), /* @__PURE__ */
|
|
511
|
+
), /* @__PURE__ */ React3.createElement("noscript", null, /* @__PURE__ */ React3.createElement(
|
|
510
512
|
"iframe",
|
|
511
513
|
{
|
|
512
514
|
src: `https://www.googletagmanager.com/ns.html?id=${resolvedGtmId}`,
|