@devskin/browser-sdk 1.0.4 → 1.0.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/devskin.cjs.js +17 -5
- package/dist/devskin.cjs.js.map +1 -1
- package/dist/devskin.esm.js +17 -5
- package/dist/devskin.esm.js.map +1 -1
- package/dist/devskin.umd.js +17 -5
- package/dist/devskin.umd.js.map +1 -1
- package/dist/devskin.umd.min.js +2 -2
- package/dist/devskin.umd.min.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/types.d.ts +2 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/devskin.esm.js
CHANGED
|
@@ -5276,6 +5276,7 @@ class DevSkinSDK {
|
|
|
5276
5276
|
this.sessionId = null;
|
|
5277
5277
|
this.userId = null;
|
|
5278
5278
|
this.anonymousId = null;
|
|
5279
|
+
this.sessionStartTime = 0;
|
|
5279
5280
|
this.initialized = false;
|
|
5280
5281
|
// Collectors
|
|
5281
5282
|
this.deviceCollector = null;
|
|
@@ -5305,12 +5306,12 @@ class DevSkinSDK {
|
|
|
5305
5306
|
this.transport = new Transport(this.config);
|
|
5306
5307
|
// Generate anonymous ID if not exists
|
|
5307
5308
|
this.anonymousId = this.getOrCreateAnonymousId();
|
|
5308
|
-
//
|
|
5309
|
-
this.startSession();
|
|
5310
|
-
// Initialize collectors
|
|
5309
|
+
// Initialize collectors BEFORE starting session (so getContextData works)
|
|
5311
5310
|
this.deviceCollector = new DeviceCollector(this.config);
|
|
5312
5311
|
this.locationCollector = new LocationCollector(this.config);
|
|
5313
5312
|
this.browserCollector = new BrowserCollector(this.config);
|
|
5313
|
+
// Start session (will now include device/browser/location data)
|
|
5314
|
+
this.startSession();
|
|
5314
5315
|
if (this.config.captureWebVitals) {
|
|
5315
5316
|
this.performanceCollector = new PerformanceCollector(this.config, this.transport);
|
|
5316
5317
|
this.performanceCollector.start();
|
|
@@ -5470,6 +5471,7 @@ class DevSkinSDK {
|
|
|
5470
5471
|
startSession() {
|
|
5471
5472
|
var _a;
|
|
5472
5473
|
this.sessionId = this.generateId();
|
|
5474
|
+
this.sessionStartTime = Date.now();
|
|
5473
5475
|
const sessionData = Object.assign({ session_id: this.sessionId, user_id: this.userId || undefined, anonymous_id: this.anonymousId, started_at: new Date().toISOString() }, this.getContextData());
|
|
5474
5476
|
(_a = this.transport) === null || _a === void 0 ? void 0 : _a.startSession(sessionData);
|
|
5475
5477
|
}
|
|
@@ -5509,10 +5511,20 @@ class DevSkinSDK {
|
|
|
5509
5511
|
}
|
|
5510
5512
|
setupUnloadTracking() {
|
|
5511
5513
|
window.addEventListener('beforeunload', () => {
|
|
5512
|
-
var _a;
|
|
5514
|
+
var _a, _b;
|
|
5513
5515
|
this.track('page_unload');
|
|
5516
|
+
// Send session end update with duration
|
|
5517
|
+
if (this.sessionId && this.sessionStartTime) {
|
|
5518
|
+
const endedAt = new Date();
|
|
5519
|
+
const durationMs = Date.now() - this.sessionStartTime;
|
|
5520
|
+
(_a = this.transport) === null || _a === void 0 ? void 0 : _a.startSession({
|
|
5521
|
+
session_id: this.sessionId,
|
|
5522
|
+
ended_at: endedAt.toISOString(),
|
|
5523
|
+
duration_ms: durationMs,
|
|
5524
|
+
});
|
|
5525
|
+
}
|
|
5514
5526
|
// Send any pending data
|
|
5515
|
-
(
|
|
5527
|
+
(_b = this.transport) === null || _b === void 0 ? void 0 : _b.flush(true); // Use beacon for reliability
|
|
5516
5528
|
});
|
|
5517
5529
|
}
|
|
5518
5530
|
}
|