@hifilabs/pixel 0.1.6 → 0.1.7

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.js CHANGED
@@ -426,7 +426,7 @@ var import_script = __toESM(require("next/script"));
426
426
  // src/react/useGTMConsent.ts
427
427
  var import_react3 = require("react");
428
428
  function useGTMConsent(options = {}) {
429
- const { pollInterval = 1e3, debug = false } = options;
429
+ const { pollInterval = 1e3, debug = false, enabled = true } = options;
430
430
  const lastConsentRef = (0, import_react3.useRef)("");
431
431
  const log = (0, import_react3.useCallback)(
432
432
  (...args) => {
@@ -480,7 +480,7 @@ function useGTMConsent(options = {}) {
480
480
  }
481
481
  }, [mapPixelConsentToGTM, updateGTMConsent]);
482
482
  (0, import_react3.useEffect)(() => {
483
- if (typeof window === "undefined")
483
+ if (typeof window === "undefined" || !enabled)
484
484
  return;
485
485
  syncConsent();
486
486
  const intervalId = setInterval(syncConsent, pollInterval);
@@ -495,7 +495,7 @@ function useGTMConsent(options = {}) {
495
495
  clearInterval(intervalId);
496
496
  window.removeEventListener("storage", handleStorageChange);
497
497
  };
498
- }, [syncConsent, pollInterval, log]);
498
+ }, [syncConsent, pollInterval, log, enabled]);
499
499
  return {
500
500
  /**
501
501
  * Manually trigger a consent sync
@@ -519,7 +519,7 @@ var DEFAULT_GTM_CONSENT = {
519
519
  // src/react/GTMProvider.tsx
520
520
  function GTMProvider({ gtmId, children, debug = false }) {
521
521
  const resolvedGtmId = gtmId || process.env.NEXT_PUBLIC_GTM_ID;
522
- useGTMConsent({ debug });
522
+ useGTMConsent({ debug, enabled: !!resolvedGtmId });
523
523
  if (!resolvedGtmId) {
524
524
  if (debug) {
525
525
  console.log("[GTMProvider] No GTM ID configured, skipping GTM initialization");
package/dist/index.mjs CHANGED
@@ -377,7 +377,7 @@ import Script from "next/script";
377
377
  // src/react/useGTMConsent.ts
378
378
  import { useEffect as useEffect3, useRef as useRef3, useCallback as useCallback2 } from "react";
379
379
  function useGTMConsent(options = {}) {
380
- const { pollInterval = 1e3, debug = false } = options;
380
+ const { pollInterval = 1e3, debug = false, enabled = true } = options;
381
381
  const lastConsentRef = useRef3("");
382
382
  const log = useCallback2(
383
383
  (...args) => {
@@ -431,7 +431,7 @@ function useGTMConsent(options = {}) {
431
431
  }
432
432
  }, [mapPixelConsentToGTM, updateGTMConsent]);
433
433
  useEffect3(() => {
434
- if (typeof window === "undefined")
434
+ if (typeof window === "undefined" || !enabled)
435
435
  return;
436
436
  syncConsent();
437
437
  const intervalId = setInterval(syncConsent, pollInterval);
@@ -446,7 +446,7 @@ function useGTMConsent(options = {}) {
446
446
  clearInterval(intervalId);
447
447
  window.removeEventListener("storage", handleStorageChange);
448
448
  };
449
- }, [syncConsent, pollInterval, log]);
449
+ }, [syncConsent, pollInterval, log, enabled]);
450
450
  return {
451
451
  /**
452
452
  * Manually trigger a consent sync
@@ -470,7 +470,7 @@ var DEFAULT_GTM_CONSENT = {
470
470
  // src/react/GTMProvider.tsx
471
471
  function GTMProvider({ gtmId, children, debug = false }) {
472
472
  const resolvedGtmId = gtmId || process.env.NEXT_PUBLIC_GTM_ID;
473
- useGTMConsent({ debug });
473
+ useGTMConsent({ debug, enabled: !!resolvedGtmId });
474
474
  if (!resolvedGtmId) {
475
475
  if (debug) {
476
476
  console.log("[GTMProvider] No GTM ID configured, skipping GTM initialization");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hifilabs/pixel",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "BALANCE Pixel - Lightweight browser tracking script for artist fan analytics",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",