@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.umd.js
CHANGED
|
@@ -5282,6 +5282,7 @@
|
|
|
5282
5282
|
this.sessionId = null;
|
|
5283
5283
|
this.userId = null;
|
|
5284
5284
|
this.anonymousId = null;
|
|
5285
|
+
this.sessionStartTime = 0;
|
|
5285
5286
|
this.initialized = false;
|
|
5286
5287
|
// Collectors
|
|
5287
5288
|
this.deviceCollector = null;
|
|
@@ -5311,12 +5312,12 @@
|
|
|
5311
5312
|
this.transport = new Transport(this.config);
|
|
5312
5313
|
// Generate anonymous ID if not exists
|
|
5313
5314
|
this.anonymousId = this.getOrCreateAnonymousId();
|
|
5314
|
-
//
|
|
5315
|
-
this.startSession();
|
|
5316
|
-
// Initialize collectors
|
|
5315
|
+
// Initialize collectors BEFORE starting session (so getContextData works)
|
|
5317
5316
|
this.deviceCollector = new DeviceCollector(this.config);
|
|
5318
5317
|
this.locationCollector = new LocationCollector(this.config);
|
|
5319
5318
|
this.browserCollector = new BrowserCollector(this.config);
|
|
5319
|
+
// Start session (will now include device/browser/location data)
|
|
5320
|
+
this.startSession();
|
|
5320
5321
|
if (this.config.captureWebVitals) {
|
|
5321
5322
|
this.performanceCollector = new PerformanceCollector(this.config, this.transport);
|
|
5322
5323
|
this.performanceCollector.start();
|
|
@@ -5476,6 +5477,7 @@
|
|
|
5476
5477
|
startSession() {
|
|
5477
5478
|
var _a;
|
|
5478
5479
|
this.sessionId = this.generateId();
|
|
5480
|
+
this.sessionStartTime = Date.now();
|
|
5479
5481
|
const sessionData = Object.assign({ session_id: this.sessionId, user_id: this.userId || undefined, anonymous_id: this.anonymousId, started_at: new Date().toISOString() }, this.getContextData());
|
|
5480
5482
|
(_a = this.transport) === null || _a === void 0 ? void 0 : _a.startSession(sessionData);
|
|
5481
5483
|
}
|
|
@@ -5515,10 +5517,20 @@
|
|
|
5515
5517
|
}
|
|
5516
5518
|
setupUnloadTracking() {
|
|
5517
5519
|
window.addEventListener('beforeunload', () => {
|
|
5518
|
-
var _a;
|
|
5520
|
+
var _a, _b;
|
|
5519
5521
|
this.track('page_unload');
|
|
5522
|
+
// Send session end update with duration
|
|
5523
|
+
if (this.sessionId && this.sessionStartTime) {
|
|
5524
|
+
const endedAt = new Date();
|
|
5525
|
+
const durationMs = Date.now() - this.sessionStartTime;
|
|
5526
|
+
(_a = this.transport) === null || _a === void 0 ? void 0 : _a.startSession({
|
|
5527
|
+
session_id: this.sessionId,
|
|
5528
|
+
ended_at: endedAt.toISOString(),
|
|
5529
|
+
duration_ms: durationMs,
|
|
5530
|
+
});
|
|
5531
|
+
}
|
|
5520
5532
|
// Send any pending data
|
|
5521
|
-
(
|
|
5533
|
+
(_b = this.transport) === null || _b === void 0 ? void 0 : _b.flush(true); // Use beacon for reliability
|
|
5522
5534
|
});
|
|
5523
5535
|
}
|
|
5524
5536
|
}
|