@hifilabs/pixel 0.1.1 → 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.
Files changed (2) hide show
  1. package/dist/index.esm.js +17 -15
  2. package/package.json +1 -1
package/dist/index.esm.js CHANGED
@@ -371,7 +371,7 @@ function useBalanceIdentify() {
371
371
  }
372
372
 
373
373
  // src/react/GTMProvider.tsx
374
- import React3, { useEffect as useEffect4 } from "react";
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
478
  return /* @__PURE__ */ React3.createElement(React3.Fragment, null, children);
493
479
  }
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
+ `;
494
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",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hifilabs/pixel",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "BALANCE Pixel - Lightweight browser tracking script for artist fan analytics",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.esm.js",