@devskin/browser-sdk 1.0.24 → 1.0.26
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 +54 -27
- package/dist/devskin.cjs.js.map +1 -1
- package/dist/devskin.esm.js +54 -27
- package/dist/devskin.esm.js.map +1 -1
- package/dist/devskin.umd.js +54 -27
- 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.map +1 -1
- package/package.json +1 -1
- package/dist/recorder/session.d.ts +0 -18
- package/dist/recorder/session.d.ts.map +0 -1
package/dist/devskin.umd.js
CHANGED
|
@@ -13873,7 +13873,7 @@
|
|
|
13873
13873
|
* Initialize the DevSkin SDK
|
|
13874
13874
|
*/
|
|
13875
13875
|
init(config) {
|
|
13876
|
-
var _a
|
|
13876
|
+
var _a;
|
|
13877
13877
|
if (this.initialized) {
|
|
13878
13878
|
console.warn('[DevSkin] SDK already initialized');
|
|
13879
13879
|
return;
|
|
@@ -13909,24 +13909,20 @@
|
|
|
13909
13909
|
this.networkCollector = new NetworkCollector(this.config, this.transport);
|
|
13910
13910
|
this.networkCollector.start();
|
|
13911
13911
|
}
|
|
13912
|
-
// Initialize heatmap collector
|
|
13913
|
-
//
|
|
13914
|
-
const
|
|
13915
|
-
|
|
13916
|
-
|
|
13917
|
-
|
|
13918
|
-
|
|
13919
|
-
|
|
13920
|
-
|
|
13921
|
-
|
|
13922
|
-
|
|
13923
|
-
this.screenshotCollector.captureAndSend(this.sessionId, window.location.href);
|
|
13924
|
-
if (this.config.debug) {
|
|
13925
|
-
console.log('[DevSkin] Heatmap collection enabled', ((_c = this.config.sessionRecording) === null || _c === void 0 ? void 0 : _c.enabled) ? '(auto-enabled with session recording)' : '');
|
|
13926
|
-
}
|
|
13912
|
+
// Initialize heatmap collector - SEMPRE habilitado
|
|
13913
|
+
// Merge default heatmap config with user config
|
|
13914
|
+
const heatmapConfig = Object.assign({ enabled: true, trackClicks: true, trackScroll: true, trackMouseMovement: true, mouseMoveSampling: 0.1 }, this.config.heatmapOptions);
|
|
13915
|
+
this.config.heatmapOptions = heatmapConfig;
|
|
13916
|
+
this.heatmapCollector = new HeatmapCollector(this.config, this.transport);
|
|
13917
|
+
this.heatmapCollector.start();
|
|
13918
|
+
// Initialize screenshot collector and capture page
|
|
13919
|
+
this.screenshotCollector = new ScreenshotCollector(this.config, this.transport);
|
|
13920
|
+
this.screenshotCollector.captureAndSend(this.sessionId, window.location.href);
|
|
13921
|
+
if (this.config.debug) {
|
|
13922
|
+
console.log('[DevSkin] Heatmap collection enabled (always on)');
|
|
13927
13923
|
}
|
|
13928
13924
|
// Initialize session recording with rrweb
|
|
13929
|
-
if ((
|
|
13925
|
+
if ((_a = this.config.sessionRecording) === null || _a === void 0 ? void 0 : _a.enabled) {
|
|
13930
13926
|
// Use RRWebRecorder for complete DOM recording
|
|
13931
13927
|
this.rrwebRecorder = new RRWebRecorder(this.sessionId, {
|
|
13932
13928
|
enabled: true,
|
|
@@ -14070,11 +14066,32 @@
|
|
|
14070
14066
|
* Private methods
|
|
14071
14067
|
*/
|
|
14072
14068
|
startSession() {
|
|
14073
|
-
var _a;
|
|
14069
|
+
var _a, _b, _c;
|
|
14070
|
+
// Check if there's an active session (stored in sessionStorage to persist across page navigations)
|
|
14071
|
+
const existingSessionId = sessionStorage.getItem('devskin_session_id');
|
|
14072
|
+
const existingSessionStart = sessionStorage.getItem('devskin_session_start');
|
|
14073
|
+
if (existingSessionId && existingSessionStart) {
|
|
14074
|
+
// Resume existing session
|
|
14075
|
+
this.sessionId = existingSessionId;
|
|
14076
|
+
this.sessionStartTime = parseInt(existingSessionStart, 10);
|
|
14077
|
+
if ((_a = this.config) === null || _a === void 0 ? void 0 : _a.debug) {
|
|
14078
|
+
console.log('[DevSkin] Resuming existing session:', this.sessionId);
|
|
14079
|
+
}
|
|
14080
|
+
// Send page view but DON'T create a new session
|
|
14081
|
+
// The session is already created, just continue it
|
|
14082
|
+
return;
|
|
14083
|
+
}
|
|
14084
|
+
// Create new session
|
|
14074
14085
|
this.sessionId = this.generateId();
|
|
14075
14086
|
this.sessionStartTime = Date.now();
|
|
14087
|
+
// Store in sessionStorage (persists across page navigations in same tab)
|
|
14088
|
+
sessionStorage.setItem('devskin_session_id', this.sessionId);
|
|
14089
|
+
sessionStorage.setItem('devskin_session_start', this.sessionStartTime.toString());
|
|
14076
14090
|
const sessionData = Object.assign({ session_id: this.sessionId, user_id: this.userId || undefined, anonymous_id: this.anonymousId, started_at: new Date().toISOString() }, this.getContextData());
|
|
14077
|
-
(
|
|
14091
|
+
(_b = this.transport) === null || _b === void 0 ? void 0 : _b.startSession(sessionData);
|
|
14092
|
+
if ((_c = this.config) === null || _c === void 0 ? void 0 : _c.debug) {
|
|
14093
|
+
console.log('[DevSkin] New session created:', this.sessionId);
|
|
14094
|
+
}
|
|
14078
14095
|
}
|
|
14079
14096
|
getContextData() {
|
|
14080
14097
|
const context = {};
|
|
@@ -14111,16 +14128,26 @@
|
|
|
14111
14128
|
});
|
|
14112
14129
|
}
|
|
14113
14130
|
setupUnloadTracking() {
|
|
14114
|
-
|
|
14131
|
+
// Use pagehide event which is more reliable than beforeunload
|
|
14132
|
+
window.addEventListener('pagehide', (event) => {
|
|
14115
14133
|
var _a, _b;
|
|
14116
|
-
|
|
14117
|
-
//
|
|
14118
|
-
|
|
14119
|
-
|
|
14120
|
-
|
|
14121
|
-
|
|
14134
|
+
// Only end session if tab is actually closing (not just navigating)
|
|
14135
|
+
// persisted = false means the page is going into bfcache (navigation)
|
|
14136
|
+
// persisted = true OR event doesn't exist means actual close
|
|
14137
|
+
const isActualClose = !event.persisted;
|
|
14138
|
+
if (isActualClose) {
|
|
14139
|
+
this.track('page_unload');
|
|
14140
|
+
// Only send session end if tab is actually closing
|
|
14141
|
+
if (this.sessionId && this.sessionStartTime) {
|
|
14142
|
+
const endedAt = new Date();
|
|
14143
|
+
const durationMs = Date.now() - this.sessionStartTime;
|
|
14144
|
+
(_a = this.transport) === null || _a === void 0 ? void 0 : _a.startSession(Object.assign({ session_id: this.sessionId, user_id: this.userId || undefined, anonymous_id: this.anonymousId, ended_at: endedAt.toISOString(), duration_ms: durationMs }, this.getContextData()));
|
|
14145
|
+
// Clear session storage since session is ending
|
|
14146
|
+
sessionStorage.removeItem('devskin_session_id');
|
|
14147
|
+
sessionStorage.removeItem('devskin_session_start');
|
|
14148
|
+
}
|
|
14122
14149
|
}
|
|
14123
|
-
//
|
|
14150
|
+
// Always flush pending data (whether navigation or close)
|
|
14124
14151
|
(_b = this.transport) === null || _b === void 0 ? void 0 : _b.flush(true); // Use beacon for reliability
|
|
14125
14152
|
});
|
|
14126
14153
|
}
|