@datalyr/web 1.6.0 → 1.6.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.
- package/dist/datalyr.cjs.js +23 -7
- package/dist/datalyr.cjs.js.map +1 -1
- package/dist/datalyr.esm.js +20 -7
- package/dist/datalyr.esm.js.map +1 -1
- package/dist/datalyr.esm.min.js +1 -1
- package/dist/datalyr.esm.min.js.map +1 -1
- package/dist/datalyr.js +27 -9
- package/dist/datalyr.js.map +1 -1
- package/dist/datalyr.min.js +1 -1
- package/dist/datalyr.min.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/storage.d.ts +1 -1
- package/dist/storage.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/datalyr.cjs.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @datalyr/web v1.6.
|
|
2
|
+
* @datalyr/web v1.6.2
|
|
3
3
|
* Datalyr Web SDK - Modern attribution tracking for web applications
|
|
4
4
|
* (c) 2026 Datalyr Inc.
|
|
5
5
|
* Released under the MIT License
|
|
6
6
|
*/
|
|
7
7
|
'use strict';
|
|
8
8
|
|
|
9
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
10
|
+
|
|
9
11
|
/******************************************************************************
|
|
10
12
|
Copyright (c) Microsoft Corporation.
|
|
11
13
|
|
|
@@ -245,15 +247,21 @@ class SafeStorage {
|
|
|
245
247
|
this.prefix = 'dl_';
|
|
246
248
|
// Test if storage is available
|
|
247
249
|
try {
|
|
250
|
+
if (!storage)
|
|
251
|
+
throw new Error('no storage'); // server / SSR
|
|
248
252
|
const testKey = 'dl_test__' + Math.random();
|
|
249
253
|
storage.setItem(testKey, '1');
|
|
250
254
|
storage.removeItem(testKey);
|
|
251
255
|
this.storage = storage;
|
|
252
256
|
}
|
|
253
257
|
catch (_a) {
|
|
254
|
-
// Storage not available (Safari private mode, etc.)
|
|
258
|
+
// Storage not available (server-side render, Safari private mode, etc.)
|
|
255
259
|
this.storage = null;
|
|
256
|
-
|
|
260
|
+
// Only warn in the browser — on the server there's intentionally no
|
|
261
|
+
// storage and the SDK does no real work until init() runs client-side.
|
|
262
|
+
if (typeof window !== 'undefined') {
|
|
263
|
+
console.warn('[Datalyr] Storage not available, using memory fallback');
|
|
264
|
+
}
|
|
257
265
|
}
|
|
258
266
|
}
|
|
259
267
|
get(key, defaultValue = null) {
|
|
@@ -562,9 +570,16 @@ class CookieStorage {
|
|
|
562
570
|
return '';
|
|
563
571
|
}
|
|
564
572
|
}
|
|
565
|
-
// Export singleton instances for storage
|
|
566
|
-
|
|
567
|
-
|
|
573
|
+
// Export singleton instances for storage.
|
|
574
|
+
// Guard the browser globals so importing the SDK on the server (SSR / Node)
|
|
575
|
+
// doesn't throw `window is not defined`. On the server these fall back to
|
|
576
|
+
// in-memory storage; real storage is wired when the module re-evaluates in the
|
|
577
|
+
// browser. (Without this, any static `import` of the SDK in a Next.js client
|
|
578
|
+
// component crashes server rendering.)
|
|
579
|
+
const browserLocalStorage = typeof window !== 'undefined' ? window.localStorage : undefined;
|
|
580
|
+
const browserSessionStorage = typeof window !== 'undefined' ? window.sessionStorage : undefined;
|
|
581
|
+
const storage = new SafeStorage(browserLocalStorage);
|
|
582
|
+
new SafeStorage(browserSessionStorage);
|
|
568
583
|
// Default cookie instance for backwards compatibility
|
|
569
584
|
const cookies = new CookieStorage();
|
|
570
585
|
|
|
@@ -4321,5 +4336,6 @@ if (typeof window !== 'undefined') {
|
|
|
4321
4336
|
window.datalyr = datalyr;
|
|
4322
4337
|
}
|
|
4323
4338
|
|
|
4324
|
-
|
|
4339
|
+
exports.datalyr = datalyr;
|
|
4340
|
+
exports.default = datalyr;
|
|
4325
4341
|
//# sourceMappingURL=datalyr.cjs.js.map
|