@active-reach/web-sdk 1.52.0 → 1.54.0

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.
@@ -1,3 +1,4 @@
1
+ import { r as redactUrl, i as isPreviewPage, S as Storage } from "./storage-D5jp9bO-.mjs";
1
2
  const DEFAULT_CONFIG = {
2
3
  workspace_id: null,
3
4
  batch_size: 10,
@@ -1507,190 +1508,6 @@ class EventQueue {
1507
1508
  this.flush();
1508
1509
  }
1509
1510
  }
1510
- const STORAGE_PREFIX = "aegis_";
1511
- class Storage {
1512
- constructor(options = {}) {
1513
- this.options = options;
1514
- this.useLocalStorage = this.isLocalStorageAvailable();
1515
- }
1516
- isLocalStorageAvailable() {
1517
- try {
1518
- const test = "__aegis_test__";
1519
- localStorage.setItem(test, test);
1520
- localStorage.removeItem(test);
1521
- return true;
1522
- } catch {
1523
- return false;
1524
- }
1525
- }
1526
- set(key, value, expiryDays = 365) {
1527
- const fullKey = STORAGE_PREFIX + key;
1528
- if (this.useLocalStorage) {
1529
- try {
1530
- const item = {
1531
- value,
1532
- expiry: Date.now() + expiryDays * 24 * 60 * 60 * 1e3
1533
- };
1534
- localStorage.setItem(fullKey, JSON.stringify(item));
1535
- } catch (error) {
1536
- console.warn("[Active Reach Storage] localStorage.setItem failed:", error);
1537
- }
1538
- }
1539
- this.setCookie(fullKey, value, expiryDays);
1540
- }
1541
- get(key) {
1542
- const fullKey = STORAGE_PREFIX + key;
1543
- if (this.useLocalStorage) {
1544
- try {
1545
- const itemStr = localStorage.getItem(fullKey);
1546
- if (itemStr) {
1547
- const item = JSON.parse(itemStr);
1548
- if (Date.now() < item.expiry) {
1549
- return item.value;
1550
- } else {
1551
- localStorage.removeItem(fullKey);
1552
- }
1553
- }
1554
- } catch (error) {
1555
- console.warn("[Active Reach Storage] localStorage.getItem failed:", error);
1556
- }
1557
- }
1558
- return this.getCookie(fullKey);
1559
- }
1560
- remove(key) {
1561
- const fullKey = STORAGE_PREFIX + key;
1562
- if (this.useLocalStorage) {
1563
- try {
1564
- localStorage.removeItem(fullKey);
1565
- } catch (error) {
1566
- console.warn("[Active Reach Storage] localStorage.removeItem failed:", error);
1567
- }
1568
- }
1569
- this.deleteCookie(fullKey);
1570
- }
1571
- clear() {
1572
- if (this.useLocalStorage) {
1573
- try {
1574
- const keys = Object.keys(localStorage);
1575
- keys.forEach((key) => {
1576
- if (key.startsWith(STORAGE_PREFIX)) {
1577
- localStorage.removeItem(key);
1578
- }
1579
- });
1580
- } catch (error) {
1581
- console.warn("[Active Reach Storage] localStorage.clear failed:", error);
1582
- }
1583
- }
1584
- const cookies = document.cookie.split(";");
1585
- cookies.forEach((cookie) => {
1586
- const key = cookie.split("=")[0].trim();
1587
- if (key.startsWith(STORAGE_PREFIX)) {
1588
- this.deleteCookie(key);
1589
- }
1590
- });
1591
- }
1592
- setCookie(name, value, days) {
1593
- try {
1594
- const date = /* @__PURE__ */ new Date();
1595
- date.setTime(date.getTime() + days * 24 * 60 * 60 * 1e3);
1596
- const expires = `expires=${date.toUTCString()}`;
1597
- let cookieStr = `${name}=${value};${expires};path=/`;
1598
- if (this.options.secureCookie && window.location.protocol === "https:") {
1599
- cookieStr += ";Secure";
1600
- }
1601
- cookieStr += ";SameSite=Lax";
1602
- if (this.options.cookieDomain) {
1603
- cookieStr += `;domain=${this.options.cookieDomain}`;
1604
- } else if (this.options.crossDomain) {
1605
- const domain = this.getRootDomain();
1606
- if (domain) {
1607
- cookieStr += `;domain=${domain}`;
1608
- }
1609
- }
1610
- document.cookie = cookieStr;
1611
- } catch (error) {
1612
- console.warn("[Active Reach Storage] setCookie failed:", error);
1613
- }
1614
- }
1615
- getCookie(name) {
1616
- try {
1617
- const nameEQ = name + "=";
1618
- const ca = document.cookie.split(";");
1619
- for (let i = 0; i < ca.length; i++) {
1620
- let c = ca[i];
1621
- while (c.charAt(0) === " ") {
1622
- c = c.substring(1, c.length);
1623
- }
1624
- if (c.indexOf(nameEQ) === 0) {
1625
- return c.substring(nameEQ.length, c.length);
1626
- }
1627
- }
1628
- } catch (error) {
1629
- console.warn("[Active Reach Storage] getCookie failed:", error);
1630
- }
1631
- return null;
1632
- }
1633
- deleteCookie(name) {
1634
- try {
1635
- let cookieStr = `${name}=;expires=Thu, 01 Jan 1970 00:00:00 UTC;path=/`;
1636
- if (this.options.cookieDomain) {
1637
- cookieStr += `;domain=${this.options.cookieDomain}`;
1638
- } else if (this.options.crossDomain) {
1639
- const domain = this.getRootDomain();
1640
- if (domain) {
1641
- cookieStr += `;domain=${domain}`;
1642
- }
1643
- }
1644
- document.cookie = cookieStr;
1645
- } catch (error) {
1646
- console.warn("[Active Reach Storage] deleteCookie failed:", error);
1647
- }
1648
- }
1649
- getRootDomain() {
1650
- try {
1651
- const hostname = window.location.hostname;
1652
- if (/^(\d{1,3}\.){3}\d{1,3}$/.test(hostname)) {
1653
- return null;
1654
- }
1655
- if (hostname === "localhost") {
1656
- return null;
1657
- }
1658
- const parts = hostname.split(".");
1659
- if (parts.length <= 2) {
1660
- return `.${hostname}`;
1661
- }
1662
- return `.${parts.slice(-2).join(".")}`;
1663
- } catch (error) {
1664
- console.warn("[Active Reach Storage] getRootDomain failed:", error);
1665
- return null;
1666
- }
1667
- }
1668
- }
1669
- const CREDENTIAL_URL_PARAMS = [
1670
- "t",
1671
- "k",
1672
- "code",
1673
- "session_code",
1674
- "aegis_pair",
1675
- "u",
1676
- // The Shopify CarrierService callback token (2026-09-18). Server-to-server
1677
- // today, so the SDK never sees one — it is here because the two lists are
1678
- // ONE rule, and a list that is only correct for today's callers is not.
1679
- "carrier_token"
1680
- ];
1681
- const REDACTED = "REDACTED";
1682
- const CREDENTIAL_PARAM_PATTERN = new RegExp(
1683
- `([?&])(${CREDENTIAL_URL_PARAMS.join("|")})=([^&#\\s"'<>]+)`,
1684
- "g"
1685
- );
1686
- function redactUrl(value) {
1687
- if (typeof value !== "string" || value.length === 0) return value;
1688
- try {
1689
- return value.replace(CREDENTIAL_PARAM_PATTERN, `$1$2=${REDACTED}`);
1690
- } catch {
1691
- return value;
1692
- }
1693
- }
1694
1511
  function parseUTMParameters(url) {
1695
1512
  try {
1696
1513
  const searchParams = url ? new URL(url).searchParams : new URLSearchParams(window.location.search);
@@ -2266,27 +2083,6 @@ class ConsentManager {
2266
2083
  updateGoogleConsent();
2267
2084
  }
2268
2085
  }
2269
- const MAX_TOKEN_LENGTH = 600;
2270
- function previewAsOfToken() {
2271
- if (typeof window === "undefined" || !window.location) return null;
2272
- try {
2273
- const v = new URLSearchParams(window.location.search || "").get("preview_as_of");
2274
- return v && v.length <= MAX_TOKEN_LENGTH ? v : null;
2275
- } catch {
2276
- return null;
2277
- }
2278
- }
2279
- function hasEditorPreviewMarker(search) {
2280
- return search.has("preview_as_of") || search.get("section_names") === "1" || search.has("preview_store") || search.has("campaign_preview") || search.get("preview") === "admin";
2281
- }
2282
- function isPreviewPage() {
2283
- if (typeof window === "undefined" || !window.location) return false;
2284
- try {
2285
- return hasEditorPreviewMarker(new URLSearchParams(window.location.search || ""));
2286
- } catch {
2287
- return false;
2288
- }
2289
- }
2290
2086
  const ITEM_TOUCH_KEY = "aegis_inapp_item_touch";
2291
2087
  const ITEM_TOUCH_TTL_MS = 30 * 60 * 1e3;
2292
2088
  function store() {
@@ -4136,15 +3932,11 @@ export {
4136
3932
  EcommerceTracker as E,
4137
3933
  NameGovernor as N,
4138
3934
  RateLimiter as R,
4139
- Storage as S,
4140
3935
  UserNamespace as U,
4141
- recordInAppItemTouch as a,
4142
3936
  ensureFbc as e,
4143
3937
  generateUUID as g,
4144
- isPreviewPage as i,
4145
3938
  logger as l,
4146
3939
  murmurhash3_x86_32 as m,
4147
- previewAsOfToken as p,
4148
- redactUrl as r
3940
+ recordInAppItemTouch as r
4149
3941
  };
4150
- //# sourceMappingURL=analytics-DMY0Q0rI.mjs.map
3942
+ //# sourceMappingURL=analytics-CM31xECy.mjs.map