@cross-deck/web 1.10.3 → 1.11.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.
@@ -106,6 +106,20 @@ interface CrossdeckOptions {
106
106
  storage?: KeyValueStorage;
107
107
  /** Storage key prefix for the SDK's persisted state. Default "crossdeck:". */
108
108
  storagePrefix?: string;
109
+ /**
110
+ * Cross-subdomain identity. The anonymous-ID cookie is scoped to this domain so
111
+ * a visitor is ONE person across every subdomain — your marketing site
112
+ * (`example.com`) and your app (`app.example.com`) share one identity, so
113
+ * first-touch source, journey, and conversion stitch into one timeline.
114
+ *
115
+ * - `"auto"` (default) — the registrable domain (eTLD+1), detected safely.
116
+ * - a domain string (`".example.com"` / `"example.com"`) — set it explicitly.
117
+ * - `"none"` — host-only (each subdomain is its own identity; pre-1.11 behaviour).
118
+ *
119
+ * No effect in Node/native — cookies + subdomains are browser-only. Cross-*device*
120
+ * / cross-platform identity is resolved server-side by email/userId, not here.
121
+ */
122
+ cookieDomain?: string;
109
123
  /**
110
124
  * Send a heartbeat to /v1/sdk/heartbeat on start(). Default true.
111
125
  * Disable for high-frequency boot scenarios where the heartbeat is
@@ -106,6 +106,20 @@ interface CrossdeckOptions {
106
106
  storage?: KeyValueStorage;
107
107
  /** Storage key prefix for the SDK's persisted state. Default "crossdeck:". */
108
108
  storagePrefix?: string;
109
+ /**
110
+ * Cross-subdomain identity. The anonymous-ID cookie is scoped to this domain so
111
+ * a visitor is ONE person across every subdomain — your marketing site
112
+ * (`example.com`) and your app (`app.example.com`) share one identity, so
113
+ * first-touch source, journey, and conversion stitch into one timeline.
114
+ *
115
+ * - `"auto"` (default) — the registrable domain (eTLD+1), detected safely.
116
+ * - a domain string (`".example.com"` / `"example.com"`) — set it explicitly.
117
+ * - `"none"` — host-only (each subdomain is its own identity; pre-1.11 behaviour).
118
+ *
119
+ * No effect in Node/native — cookies + subdomains are browser-only. Cross-*device*
120
+ * / cross-platform identity is resolved server-side by email/userId, not here.
121
+ */
122
+ cookieDomain?: string;
109
123
  /**
110
124
  * Send a heartbeat to /v1/sdk/heartbeat on start(). Default true.
111
125
  * Disable for high-frequency boot scenarios where the heartbeat is
package/dist/vue.cjs CHANGED
@@ -97,7 +97,7 @@ function typeMapForStatus(status) {
97
97
  }
98
98
 
99
99
  // src/_version.ts
100
- var SDK_VERSION = "1.10.3";
100
+ var SDK_VERSION = "1.11.2";
101
101
  var SDK_NAME = "@cross-deck/web";
102
102
 
103
103
  // src/http.ts
@@ -1325,6 +1325,7 @@ var CookieStorage = class {
1325
1325
  this.maxAgeSec = options?.maxAgeSec ?? 63072e3;
1326
1326
  this.secure = options?.secure ?? defaultSecure();
1327
1327
  this.sameSite = options?.sameSite ?? "Lax";
1328
+ this.domain = options?.domain || void 0;
1328
1329
  }
1329
1330
  getItem(key) {
1330
1331
  if (!hasDocument()) return null;
@@ -1351,6 +1352,7 @@ var CookieStorage = class {
1351
1352
  `Max-Age=${this.maxAgeSec}`,
1352
1353
  `SameSite=${this.sameSite}`
1353
1354
  ];
1355
+ if (this.domain) parts.push(`Domain=${this.domain}`);
1354
1356
  if (this.secure) parts.push("Secure");
1355
1357
  try {
1356
1358
  doc.cookie = parts.join("; ");
@@ -1366,6 +1368,7 @@ var CookieStorage = class {
1366
1368
  "Max-Age=0",
1367
1369
  `SameSite=${this.sameSite}`
1368
1370
  ];
1371
+ if (this.domain) parts.push(`Domain=${this.domain}`);
1369
1372
  if (this.secure) parts.push("Secure");
1370
1373
  try {
1371
1374
  doc.cookie = parts.join("; ");
@@ -1373,6 +1376,34 @@ var CookieStorage = class {
1373
1376
  }
1374
1377
  }
1375
1378
  };
1379
+ function resolveCookieDomain(config) {
1380
+ if (config === void 0 || config === "none" || config === "") return void 0;
1381
+ if (config !== "auto") {
1382
+ const d = config.trim().toLowerCase();
1383
+ return d.startsWith(".") ? d : `.${d}`;
1384
+ }
1385
+ if (!hasDocument()) return void 0;
1386
+ const doc = globalThis.document;
1387
+ const loc = globalThis.location;
1388
+ const host = (loc?.hostname ?? "").toLowerCase();
1389
+ if (!host || host === "localhost" || /^\d{1,3}(\.\d{1,3}){3}$/.test(host) || host.indexOf(".") === -1) {
1390
+ return void 0;
1391
+ }
1392
+ const labels = host.split(".");
1393
+ for (let i = labels.length - 2; i >= 0; i--) {
1394
+ const candidate = "." + labels.slice(i).join(".");
1395
+ const testKey = "__cd_domain_probe";
1396
+ try {
1397
+ doc.cookie = `${testKey}=1; Domain=${candidate}; Path=/; SameSite=Lax`;
1398
+ const accepted = doc.cookie.indexOf(`${testKey}=1`) !== -1;
1399
+ doc.cookie = `${testKey}=; Domain=${candidate}; Path=/; Max-Age=0; SameSite=Lax`;
1400
+ if (accepted) return candidate;
1401
+ } catch {
1402
+ return void 0;
1403
+ }
1404
+ }
1405
+ return void 0;
1406
+ }
1376
1407
  function detectDefaultStorage() {
1377
1408
  try {
1378
1409
  const ls = globalThis.localStorage;
@@ -2705,7 +2736,7 @@ var BreadcrumbBuffer = class {
2705
2736
 
2706
2737
  // src/_diagnostic-telemetry.ts
2707
2738
  var DIAGNOSTIC_TELEMETRY_ENDPOINT = "https://api.cross-deck.com/v1/events";
2708
- var DIAGNOSTIC_TELEMETRY_PUBLISHABLE_KEY = "cd_pub_live_9490e7aa029c432abf";
2739
+ var DIAGNOSTIC_TELEMETRY_PUBLISHABLE_KEY = "cd_pub_live_eea2f84dbb834a45b7";
2709
2740
  function isDiagnosticTelemetryEnabled() {
2710
2741
  return !DIAGNOSTIC_TELEMETRY_PUBLISHABLE_KEY.startsWith(
2711
2742
  "cd_pub_RELIABILITY_PLACEHOLDER"
@@ -4652,7 +4683,7 @@ var CrossdeckClient = class {
4652
4683
  const effectiveStorage = persistIdentity ? storage : new MemoryStorage();
4653
4684
  const useCookieRedundancy = persistIdentity && !options.storage && // honour caller's adapter choice
4654
4685
  typeof globalThis.document !== "undefined";
4655
- const cookieStore = useCookieRedundancy ? new CookieStorage() : void 0;
4686
+ const cookieStore = useCookieRedundancy ? new CookieStorage({ domain: resolveCookieDomain(options.cookieDomain ?? "auto") }) : void 0;
4656
4687
  const identity = new IdentityStore(effectiveStorage, opts.storagePrefix, cookieStore);
4657
4688
  const entitlements = new EntitlementCache(
4658
4689
  effectiveStorage,
@@ -5602,7 +5633,7 @@ var CrossdeckClient = class {
5602
5633
  }
5603
5634
  }
5604
5635
  this.state.autoTracker?.uninstall();
5605
- this.state.identity.reset();
5636
+ if (this.state.developerUserId) this.state.identity.reset();
5606
5637
  bridgeReadCost({ actor: void 0 });
5607
5638
  this.state.entitlements.clearAll();
5608
5639
  this.state.events.reset();