@statsig/session-replay 3.14.1 → 3.15.1
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/package.json +9 -2
- package/src/SessionReplay.js +11 -20
package/package.json
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@statsig/session-replay",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.15.1",
|
|
4
|
+
"license": "ISC",
|
|
5
|
+
"homepage": "https://github.com/statsig-io/js-client-monorepo",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "github:statsig-io/js-client-monorepo",
|
|
9
|
+
"directory": "packages/session-replay"
|
|
10
|
+
},
|
|
4
11
|
"dependencies": {
|
|
5
12
|
"rrweb": "2.0.0-alpha.14",
|
|
6
|
-
"@statsig/client-core": "3.
|
|
13
|
+
"@statsig/client-core": "3.15.1"
|
|
7
14
|
},
|
|
8
15
|
"devDependencies": {
|
|
9
16
|
"@rrweb/types": "2.0.0-alpha.14"
|
package/src/SessionReplay.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.SessionReplay = exports.runStatsigSessionReplay = exports.StatsigSessionReplayPlugin = void 0;
|
|
13
4
|
const client_core_1 = require("@statsig/client-core");
|
|
@@ -52,7 +43,6 @@ class SessionReplay {
|
|
|
52
43
|
this._replayer.stop();
|
|
53
44
|
client_core_1.StatsigMetadataProvider.add({ isRecordingSession: 'false' });
|
|
54
45
|
this._logRecording('session_expired');
|
|
55
|
-
this._currentSessionID = this._getSessionIdFromClient();
|
|
56
46
|
});
|
|
57
47
|
this._subscribeToVisibilityChanged();
|
|
58
48
|
this._attemptToStartRecording((_a = this._options) === null || _a === void 0 ? void 0 : _a.forceRecording);
|
|
@@ -81,6 +71,13 @@ class SessionReplay {
|
|
|
81
71
|
});
|
|
82
72
|
}
|
|
83
73
|
_onRecordingEvent(event, data) {
|
|
74
|
+
// The session has expired so we should stop recording
|
|
75
|
+
if (this._currentSessionID !== this._getSessionIdFromClient()) {
|
|
76
|
+
this._replayer.stop();
|
|
77
|
+
client_core_1.StatsigMetadataProvider.add({ isRecordingSession: 'false' });
|
|
78
|
+
this._logRecording('session_expired');
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
84
81
|
this._sessionData = data;
|
|
85
82
|
const eventApproxSize = (0, SizeOf_1._fastApproxSizeOf)(event, MAX_INDIVIDUAL_EVENT_BYTES);
|
|
86
83
|
if (eventApproxSize > MAX_INDIVIDUAL_EVENT_BYTES) {
|
|
@@ -119,18 +116,14 @@ class SessionReplay {
|
|
|
119
116
|
if (this._events.length === 0 || this._sessionData == null) {
|
|
120
117
|
return;
|
|
121
118
|
}
|
|
122
|
-
this.
|
|
119
|
+
this._logRecording();
|
|
123
120
|
}
|
|
124
121
|
_logRecording(endReason) {
|
|
125
122
|
if (this._events.length === 0 || this._sessionData == null) {
|
|
126
123
|
return;
|
|
127
124
|
}
|
|
128
125
|
endReason = (0, client_core_1._isUnloading)() ? 'is_leaving_page' : endReason;
|
|
129
|
-
this._currentSessionID
|
|
130
|
-
.then((sessionID) => this._logRecordingWithSessionID(sessionID, endReason))
|
|
131
|
-
.catch((err) => {
|
|
132
|
-
this._errorBoundary.logError('SR::flush', err);
|
|
133
|
-
});
|
|
126
|
+
this._logRecordingWithSessionID(this._currentSessionID, endReason);
|
|
134
127
|
}
|
|
135
128
|
_logRecordingWithSessionID(sessionID, endReason) {
|
|
136
129
|
const data = this._sessionData;
|
|
@@ -159,13 +152,11 @@ class SessionReplay {
|
|
|
159
152
|
this._events = [];
|
|
160
153
|
}
|
|
161
154
|
_bumpSessionIdleTimerAndLogRecording() {
|
|
162
|
-
this.
|
|
155
|
+
this._getSessionIdFromClient();
|
|
163
156
|
this._logRecording();
|
|
164
157
|
}
|
|
165
158
|
_getSessionIdFromClient() {
|
|
166
|
-
return
|
|
167
|
-
return this._client.getContext().session.data.sessionID;
|
|
168
|
-
});
|
|
159
|
+
return this._client.getContext().session.data.sessionID;
|
|
169
160
|
}
|
|
170
161
|
}
|
|
171
162
|
exports.SessionReplay = SessionReplay;
|