@datalyr/web 1.7.4 → 1.7.5

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/datalyr.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @datalyr/web v1.7.4
2
+ * @datalyr/web v1.7.5
3
3
  * Datalyr Web SDK - Modern attribution tracking for web applications
4
4
  * (c) 2026 Datalyr Inc.
5
5
  * Released under the MIT License
@@ -2301,16 +2301,22 @@ var Datalyr = (function (exports) {
2301
2301
  // so only request it when the body is safely under the cap; oversized batches go via
2302
2302
  // a normal fetch (no cap) and succeed.
2303
2303
  const useKeepalive = new Blob([body]).size <= 60000;
2304
+ // First-party endpoint (the customer's own tracking host, never *.datalyr.com — set
2305
+ // by the script-origin auto-derive): send the cookie cross-subdomain so the edge can
2306
+ // read/refresh the server-set, ITP-durable visitor_id. Legacy datalyr.com endpoints
2307
+ // stay credential-less — unchanged behavior for every existing install.
2308
+ let firstPartyEndpoint = false;
2304
2309
  try {
2305
- const response = yield fetch(currentEndpoint, {
2306
- method: 'POST',
2307
- headers: {
2310
+ firstPartyEndpoint = !/(^|\.)datalyr\.com$/i.test(new URL(currentEndpoint).hostname);
2311
+ }
2312
+ catch (_a) {
2313
+ /* malformed endpoint — leave false */
2314
+ }
2315
+ try {
2316
+ const response = yield fetch(currentEndpoint, Object.assign({ method: 'POST', headers: {
2308
2317
  'Content-Type': 'application/json',
2309
2318
  'X-Batch-Size': events.length.toString()
2310
- },
2311
- body,
2312
- keepalive: useKeepalive
2313
- });
2319
+ }, body, keepalive: useKeepalive }, (firstPartyEndpoint ? { credentials: 'include' } : {})));
2314
2320
  if (!response.ok) {
2315
2321
  // Handle rate limiting
2316
2322
  if (response.status === 429) {