@konfiqo/storefront-react 0.6.0 → 0.6.1

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.d.cts CHANGED
@@ -556,7 +556,10 @@ declare function configurePixels(next: AdPixels | undefined, isGranted: boolean,
556
556
  hostOnly?: boolean;
557
557
  currency?: string;
558
558
  }): void;
559
- /** Reports `e` to every enabled platform; a no-op without a grant. */
559
+ /**
560
+ * Reports `e` to every enabled platform; a no-op without a grant. Before
561
+ * the page's first `configurePixels`, the newest 20 events are held for it.
562
+ */
560
563
  declare function firePixel(e: PixelEvent): void;
561
564
 
562
565
  /** Props of {@link AdPixelsLoader}. */
package/dist/index.d.ts CHANGED
@@ -556,7 +556,10 @@ declare function configurePixels(next: AdPixels | undefined, isGranted: boolean,
556
556
  hostOnly?: boolean;
557
557
  currency?: string;
558
558
  }): void;
559
- /** Reports `e` to every enabled platform; a no-op without a grant. */
559
+ /**
560
+ * Reports `e` to every enabled platform; a no-op without a grant. Before
561
+ * the page's first `configurePixels`, the newest 20 events are held for it.
562
+ */
560
563
  declare function firePixel(e: PixelEvent): void;
561
564
 
562
565
  /** Props of {@link AdPixelsLoader}. */
package/dist/index.js CHANGED
@@ -1438,12 +1438,17 @@ var pixels;
1438
1438
  var currency = DEFAULT_CURRENCY;
1439
1439
  var granted = false;
1440
1440
  var loaded = /* @__PURE__ */ new Set();
1441
+ var configured = false;
1442
+ var MAX_EARLY = 20;
1443
+ var early = [];
1441
1444
  function resetPixels() {
1442
1445
  pixels = void 0;
1443
1446
  currency = DEFAULT_CURRENCY;
1444
1447
  granted = false;
1445
1448
  optedOut = false;
1446
1449
  loaded.clear();
1450
+ configured = false;
1451
+ early.length = 0;
1447
1452
  }
1448
1453
  var major = (minor) => minor / 100;
1449
1454
  function addScript(src) {
@@ -1663,6 +1668,8 @@ function optIn(p) {
1663
1668
  }
1664
1669
  }
1665
1670
  function configurePixels(next, isGranted, opts = {}) {
1671
+ const held = configured ? [] : early.splice(0);
1672
+ configured = true;
1666
1673
  try {
1667
1674
  pixels = next;
1668
1675
  currency = opts.currency ?? DEFAULT_CURRENCY;
@@ -1679,6 +1686,7 @@ function configurePixels(next, isGranted, opts = {}) {
1679
1686
  writeMarker(false);
1680
1687
  }
1681
1688
  }
1689
+ for (const e of held) send2(e);
1682
1690
  } catch {
1683
1691
  }
1684
1692
  }
@@ -1696,6 +1704,15 @@ function markPurchased(orderId) {
1696
1704
  }
1697
1705
  }
1698
1706
  function firePixel(e) {
1707
+ if (!configured) {
1708
+ if (typeof window === "undefined" || onSecretPage()) return;
1709
+ early.push(e);
1710
+ if (early.length > MAX_EARLY) early.shift();
1711
+ return;
1712
+ }
1713
+ send2(e);
1714
+ }
1715
+ function send2(e) {
1699
1716
  try {
1700
1717
  if (!granted || !pixels || onSecretPage()) return;
1701
1718
  loadAll(pixels);