@statsig/session-replay 1.5.0 → 1.7.0
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 +2 -2
- package/src/SessionReplay.d.ts +2 -0
- package/src/SessionReplay.js +8 -4
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@statsig/session-replay",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"rrweb": "2.0.0-alpha.12",
|
|
6
|
-
"@statsig/client-core": "1.
|
|
6
|
+
"@statsig/client-core": "1.7.0"
|
|
7
7
|
},
|
|
8
8
|
"devDependencies": {
|
|
9
9
|
"@rrweb/types": "2.0.0-alpha.12"
|
package/src/SessionReplay.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { PrecomputedEvaluationsInterface } from '@statsig/client-core';
|
|
|
2
2
|
import { RRWebConfig } from './SessionReplayClient';
|
|
3
3
|
type SessionReplayOptions = {
|
|
4
4
|
rrwebConfig?: RRWebConfig;
|
|
5
|
+
forceRecording?: boolean;
|
|
5
6
|
};
|
|
6
7
|
export declare function runStatsigSessionReplay(client: PrecomputedEvaluationsInterface, options?: SessionReplayOptions): void;
|
|
7
8
|
export declare class SessionReplay {
|
|
@@ -14,6 +15,7 @@ export declare class SessionReplay {
|
|
|
14
15
|
private _errorBoundary;
|
|
15
16
|
constructor(_client: PrecomputedEvaluationsInterface, _options?: SessionReplayOptions | undefined);
|
|
16
17
|
private _subscribeToVisibilityChanged;
|
|
18
|
+
forceStartRecording(): void;
|
|
17
19
|
private _onVisibilityChanged;
|
|
18
20
|
private _onRecordingEvent;
|
|
19
21
|
private _attemptToStartRecording;
|
package/src/SessionReplay.js
CHANGED
|
@@ -19,6 +19,7 @@ function runStatsigSessionReplay(client, options) {
|
|
|
19
19
|
exports.runStatsigSessionReplay = runStatsigSessionReplay;
|
|
20
20
|
class SessionReplay {
|
|
21
21
|
constructor(_client, _options) {
|
|
22
|
+
var _a;
|
|
22
23
|
this._client = _client;
|
|
23
24
|
this._options = _options;
|
|
24
25
|
this._sessionData = null;
|
|
@@ -33,7 +34,7 @@ class SessionReplay {
|
|
|
33
34
|
this._currentSessionID = this._getSessionIdFromClient();
|
|
34
35
|
this._replayer = new SessionReplayClient_1.SessionReplayClient();
|
|
35
36
|
this._client.$on('pre_shutdown', () => this._shutdown());
|
|
36
|
-
this._client.$on('values_updated', () => this._attemptToStartRecording());
|
|
37
|
+
this._client.$on('values_updated', () => { var _a; return this._attemptToStartRecording((_a = this._options) === null || _a === void 0 ? void 0 : _a.forceRecording); });
|
|
37
38
|
this._client.on('session_expired', () => {
|
|
38
39
|
this._replayer.stop();
|
|
39
40
|
client_core_1.StatsigMetadataProvider.add({ isRecordingSession: 'false' });
|
|
@@ -41,7 +42,7 @@ class SessionReplay {
|
|
|
41
42
|
this._currentSessionID = this._getSessionIdFromClient();
|
|
42
43
|
});
|
|
43
44
|
this._subscribeToVisibilityChanged();
|
|
44
|
-
this._attemptToStartRecording();
|
|
45
|
+
this._attemptToStartRecording((_a = this._options) === null || _a === void 0 ? void 0 : _a.forceRecording);
|
|
45
46
|
}
|
|
46
47
|
_subscribeToVisibilityChanged() {
|
|
47
48
|
// Note: this exists as a separate function to ensure closure scope only contains `sdkKey`
|
|
@@ -54,6 +55,9 @@ class SessionReplay {
|
|
|
54
55
|
}
|
|
55
56
|
});
|
|
56
57
|
}
|
|
58
|
+
forceStartRecording() {
|
|
59
|
+
this._attemptToStartRecording(true);
|
|
60
|
+
}
|
|
57
61
|
_onVisibilityChanged(visibility) {
|
|
58
62
|
if (visibility !== 'background') {
|
|
59
63
|
return;
|
|
@@ -76,10 +80,10 @@ class SessionReplay {
|
|
|
76
80
|
}
|
|
77
81
|
}
|
|
78
82
|
}
|
|
79
|
-
_attemptToStartRecording() {
|
|
83
|
+
_attemptToStartRecording(force = false) {
|
|
80
84
|
var _a, _b;
|
|
81
85
|
const values = this._client.getContext().values;
|
|
82
|
-
if ((values === null || values === void 0 ? void 0 : values.can_record_session) !== true) {
|
|
86
|
+
if (!force && (values === null || values === void 0 ? void 0 : values.can_record_session) !== true) {
|
|
83
87
|
this._shutdown();
|
|
84
88
|
return;
|
|
85
89
|
}
|