@statsig/session-replay 3.16.2 → 3.17.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 +2 -2
- package/src/SessionReplay.js +8 -0
- package/src/SessionReplayBase.d.ts +5 -0
- package/src/SessionReplayBase.js +44 -3
- package/src/SessionReplayUtils.d.ts +1 -0
- package/src/SessionReplayUtils.js +2 -1
- package/src/TriggeredSessionReplay.d.ts +7 -5
- package/src/TriggeredSessionReplay.js +67 -60
- package/src/index.d.ts +3 -2
- package/src/index.js +11 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@statsig/session-replay",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.17.1",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"homepage": "https://github.com/statsig-io/js-client-monorepo",
|
|
6
6
|
"repository": {
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"rrweb": "2.0.0-alpha.14",
|
|
13
|
-
"@statsig/client-core": "3.
|
|
13
|
+
"@statsig/client-core": "3.17.1"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"@rrweb/types": "2.0.0-alpha.14"
|
package/src/SessionReplay.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.SessionReplay = exports.runStatsigSessionReplay = exports.StatsigSessionReplayPlugin = void 0;
|
|
4
4
|
const client_core_1 = require("@statsig/client-core");
|
|
5
5
|
const SessionReplayBase_1 = require("./SessionReplayBase");
|
|
6
|
+
const SessionReplayUtils_1 = require("./SessionReplayUtils");
|
|
6
7
|
class StatsigSessionReplayPlugin {
|
|
7
8
|
constructor(options) {
|
|
8
9
|
this.options = options;
|
|
@@ -34,7 +35,14 @@ class SessionReplay extends SessionReplayBase_1.SessionReplayBase {
|
|
|
34
35
|
}
|
|
35
36
|
_attemptToStartRecording(force = false) {
|
|
36
37
|
var _a, _b;
|
|
38
|
+
if (this._totalLogs >= SessionReplayUtils_1.MAX_LOGS) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
37
41
|
const values = this._client.getContext().values;
|
|
42
|
+
if ((values === null || values === void 0 ? void 0 : values.recording_blocked) === true) {
|
|
43
|
+
this._shutdown();
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
38
46
|
if (!force && (values === null || values === void 0 ? void 0 : values.can_record_session) !== true) {
|
|
39
47
|
this._shutdown();
|
|
40
48
|
return;
|
|
@@ -5,6 +5,9 @@ type SessionReplayOptions = {
|
|
|
5
5
|
forceRecording?: boolean;
|
|
6
6
|
};
|
|
7
7
|
export type EndReason = 'is_leaving_page' | 'session_expired';
|
|
8
|
+
export declare function stopRecording(sdkKey?: string): void;
|
|
9
|
+
export declare function startRecording(sdkKey?: string): void;
|
|
10
|
+
export declare function forceStartRecording(sdkKey?: string): void;
|
|
8
11
|
export declare abstract class SessionReplayBase {
|
|
9
12
|
protected _sessionData: ReplaySessionData;
|
|
10
13
|
protected _events: ReplayEvent[];
|
|
@@ -15,9 +18,11 @@ export declare abstract class SessionReplayBase {
|
|
|
15
18
|
protected _replayer: SessionReplayClient;
|
|
16
19
|
protected _wasStopped: boolean;
|
|
17
20
|
protected _currentEventIndex: number;
|
|
21
|
+
protected _totalLogs: number;
|
|
18
22
|
constructor(client: PrecomputedEvaluationsInterface, options?: SessionReplayOptions);
|
|
19
23
|
forceStartRecording(): void;
|
|
20
24
|
stopRecording(): void;
|
|
25
|
+
startRecording(): void;
|
|
21
26
|
isRecording(): boolean;
|
|
22
27
|
protected abstract _attemptToStartRecording(force?: boolean): void;
|
|
23
28
|
protected _logRecording(endReason?: EndReason): void;
|
package/src/SessionReplayBase.js
CHANGED
|
@@ -1,10 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SessionReplayBase = void 0;
|
|
3
|
+
exports.SessionReplayBase = exports.forceStartRecording = exports.startRecording = exports.stopRecording = void 0;
|
|
4
4
|
const client_core_1 = require("@statsig/client-core");
|
|
5
5
|
const SessionReplayClient_1 = require("./SessionReplayClient");
|
|
6
6
|
const SessionReplayUtils_1 = require("./SessionReplayUtils");
|
|
7
7
|
const SizeOf_1 = require("./SizeOf");
|
|
8
|
+
function stopRecording(sdkKey) {
|
|
9
|
+
var _a;
|
|
10
|
+
(_a = _getInstanceFromSdkKey(sdkKey)) === null || _a === void 0 ? void 0 : _a.stopRecording();
|
|
11
|
+
}
|
|
12
|
+
exports.stopRecording = stopRecording;
|
|
13
|
+
function startRecording(sdkKey) {
|
|
14
|
+
var _a;
|
|
15
|
+
(_a = _getInstanceFromSdkKey(sdkKey)) === null || _a === void 0 ? void 0 : _a.startRecording();
|
|
16
|
+
}
|
|
17
|
+
exports.startRecording = startRecording;
|
|
18
|
+
function forceStartRecording(sdkKey) {
|
|
19
|
+
var _a;
|
|
20
|
+
(_a = _getInstanceFromSdkKey(sdkKey)) === null || _a === void 0 ? void 0 : _a.forceStartRecording();
|
|
21
|
+
}
|
|
22
|
+
exports.forceStartRecording = forceStartRecording;
|
|
23
|
+
function _getInstanceFromSdkKey(sdkKey) {
|
|
24
|
+
var _a, _b;
|
|
25
|
+
const inst = sdkKey == null
|
|
26
|
+
? (0, client_core_1._getStatsigGlobal)().firstSRInstance
|
|
27
|
+
: (_b = (_a = (0, client_core_1._getStatsigGlobal)()) === null || _a === void 0 ? void 0 : _a.srInstances) === null || _b === void 0 ? void 0 : _b[sdkKey];
|
|
28
|
+
return inst instanceof SessionReplayBase ? inst : null;
|
|
29
|
+
}
|
|
8
30
|
class SessionReplayBase {
|
|
9
31
|
constructor(client, options) {
|
|
10
32
|
this._sessionData = {
|
|
@@ -15,6 +37,7 @@ class SessionReplayBase {
|
|
|
15
37
|
this._events = [];
|
|
16
38
|
this._wasStopped = false;
|
|
17
39
|
this._currentEventIndex = 0;
|
|
40
|
+
this._totalLogs = 0;
|
|
18
41
|
this._client = client;
|
|
19
42
|
this._options = options;
|
|
20
43
|
const { sdkKey, errorBoundary } = this._client.getContext();
|
|
@@ -28,6 +51,9 @@ class SessionReplayBase {
|
|
|
28
51
|
if (!(0, client_core_1._isServerEnv)()) {
|
|
29
52
|
const statsigGlobal = (0, client_core_1._getStatsigGlobal)();
|
|
30
53
|
statsigGlobal.srInstances = Object.assign(Object.assign({}, statsigGlobal.srInstances), { [sdkKey]: this });
|
|
54
|
+
if (!statsigGlobal.firstSRInstance) {
|
|
55
|
+
statsigGlobal.firstSRInstance = this;
|
|
56
|
+
}
|
|
31
57
|
}
|
|
32
58
|
this._currentSessionID = this._getSessionIdFromClient();
|
|
33
59
|
this._subscribeToVisibilityChanged();
|
|
@@ -40,6 +66,11 @@ class SessionReplayBase {
|
|
|
40
66
|
this._wasStopped = true;
|
|
41
67
|
this._shutdown();
|
|
42
68
|
}
|
|
69
|
+
startRecording() {
|
|
70
|
+
var _a;
|
|
71
|
+
this._wasStopped = false;
|
|
72
|
+
this._attemptToStartRecording((_a = this._options) === null || _a === void 0 ? void 0 : _a.forceRecording);
|
|
73
|
+
}
|
|
43
74
|
isRecording() {
|
|
44
75
|
return this._replayer.isRecording();
|
|
45
76
|
}
|
|
@@ -87,6 +118,7 @@ class SessionReplayBase {
|
|
|
87
118
|
if (endReason) {
|
|
88
119
|
event.metadata[endReason] = 'true';
|
|
89
120
|
}
|
|
121
|
+
this._totalLogs++;
|
|
90
122
|
this._client.logEvent(event);
|
|
91
123
|
if (slicedID != null) {
|
|
92
124
|
this._client.flush().catch((e) => {
|
|
@@ -95,6 +127,9 @@ class SessionReplayBase {
|
|
|
95
127
|
}
|
|
96
128
|
}
|
|
97
129
|
this._events = [];
|
|
130
|
+
if (this._totalLogs > SessionReplayUtils_1.MAX_LOGS) {
|
|
131
|
+
this._shutdown();
|
|
132
|
+
}
|
|
98
133
|
}
|
|
99
134
|
_bumpSessionIdleTimerAndLogRecording() {
|
|
100
135
|
this._getSessionIdFromClient();
|
|
@@ -104,8 +139,10 @@ class SessionReplayBase {
|
|
|
104
139
|
return this._client.getContext().session.data.sessionID;
|
|
105
140
|
}
|
|
106
141
|
_shutdownImpl(endReason) {
|
|
107
|
-
this._replayer.
|
|
108
|
-
|
|
142
|
+
if (this._replayer.isRecording()) {
|
|
143
|
+
this._replayer.stop();
|
|
144
|
+
client_core_1.StatsigMetadataProvider.add({ isRecordingSession: 'false' });
|
|
145
|
+
}
|
|
109
146
|
if (this._events.length === 0) {
|
|
110
147
|
// only reset if session expired otherwise we might start recording again
|
|
111
148
|
if (endReason === 'session_expired') {
|
|
@@ -134,6 +171,10 @@ class SessionReplayBase {
|
|
|
134
171
|
this._shutdown('session_expired');
|
|
135
172
|
return;
|
|
136
173
|
}
|
|
174
|
+
if (this._totalLogs >= SessionReplayUtils_1.MAX_LOGS) {
|
|
175
|
+
this._shutdown();
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
137
178
|
event.eventIndex = this._currentEventIndex++;
|
|
138
179
|
// Update the session data
|
|
139
180
|
this._sessionData.clickCount += data.clickCount;
|
|
@@ -16,6 +16,7 @@ export type RRWebPayload = {
|
|
|
16
16
|
};
|
|
17
17
|
export declare const REPLAY_ENQUEUE_TRIGGER_BYTES: number;
|
|
18
18
|
export declare const MAX_INDIVIDUAL_EVENT_BYTES: number;
|
|
19
|
+
export declare const MAX_LOGS = 10000;
|
|
19
20
|
export declare function _makeLoggableRrwebEvent(slice: string, payload: string, sessionID: string, data: ReplaySessionData): StatsigEvent & {
|
|
20
21
|
metadata: RRWebPayload;
|
|
21
22
|
};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports._appendSlicedMetadata = exports._slicePayload = exports._makeLoggableRrwebEvent = exports.MAX_INDIVIDUAL_EVENT_BYTES = exports.REPLAY_ENQUEUE_TRIGGER_BYTES = void 0;
|
|
3
|
+
exports._appendSlicedMetadata = exports._slicePayload = exports._makeLoggableRrwebEvent = exports.MAX_LOGS = exports.MAX_INDIVIDUAL_EVENT_BYTES = exports.REPLAY_ENQUEUE_TRIGGER_BYTES = void 0;
|
|
4
4
|
const client_core_1 = require("@statsig/client-core");
|
|
5
5
|
const REPLAY_SLICE_BYTES = 1024 * 1024; // 1 MB
|
|
6
6
|
exports.REPLAY_ENQUEUE_TRIGGER_BYTES = 1024 * 10; // 10 KB
|
|
7
7
|
exports.MAX_INDIVIDUAL_EVENT_BYTES = 1024 * 1024 * 10; // 10 MB
|
|
8
|
+
exports.MAX_LOGS = 10000; // 10K logs
|
|
8
9
|
function _makeLoggableRrwebEvent(slice, payload, sessionID, data) {
|
|
9
10
|
const metadata = {
|
|
10
11
|
session_start_ts: String(data.startTime),
|
|
@@ -15,15 +15,17 @@ export declare class StatsigTriggeredSessionReplayPlugin implements StatsigPlugi
|
|
|
15
15
|
constructor(options?: TriggeredSessionReplayOptions | undefined);
|
|
16
16
|
bind(client: PrecomputedEvaluationsInterface): void;
|
|
17
17
|
}
|
|
18
|
-
export declare function
|
|
19
|
-
export declare function startRecording(sdkKey: string): void;
|
|
20
|
-
export declare function forceStartRecording(sdkKey: string): void;
|
|
21
|
-
export declare function stopRecording(sdkKey: string): void;
|
|
18
|
+
export declare function runStatsigTriggeredSessionReplay(client: PrecomputedEvaluationsInterface, options?: SessionReplayOptions): void;
|
|
22
19
|
export declare class TriggeredSessionReplay extends SessionReplayBase {
|
|
23
20
|
private _runningEventData;
|
|
24
21
|
private _isActiveRecording;
|
|
25
22
|
constructor(client: PrecomputedEvaluationsInterface, options?: TriggeredSessionReplayOptions);
|
|
26
|
-
|
|
23
|
+
private _subscribeToClientEvents;
|
|
24
|
+
private _subscribeToValuesUpdated;
|
|
25
|
+
private _subscribeToLogEventCalled;
|
|
26
|
+
private _subscribeToGateEvaluation;
|
|
27
|
+
private _subscribeToExperimentEvaluation;
|
|
28
|
+
private _tryStartExposureRecording;
|
|
27
29
|
forceStartRecording(): void;
|
|
28
30
|
stopRecording(): void;
|
|
29
31
|
private _handleStartActiveRecording;
|
|
@@ -1,52 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TriggeredSessionReplay = exports.
|
|
3
|
+
exports.TriggeredSessionReplay = exports.runStatsigTriggeredSessionReplay = exports.StatsigTriggeredSessionReplayPlugin = void 0;
|
|
4
4
|
const client_core_1 = require("@statsig/client-core");
|
|
5
5
|
const SessionReplayBase_1 = require("./SessionReplayBase");
|
|
6
|
+
const SessionReplayUtils_1 = require("./SessionReplayUtils");
|
|
6
7
|
class StatsigTriggeredSessionReplayPlugin {
|
|
7
8
|
constructor(options) {
|
|
8
9
|
this.options = options;
|
|
9
10
|
this.__plugin = 'triggered-session-replay';
|
|
10
11
|
}
|
|
11
12
|
bind(client) {
|
|
12
|
-
|
|
13
|
+
runStatsigTriggeredSessionReplay(client, this.options);
|
|
13
14
|
}
|
|
14
15
|
}
|
|
15
16
|
exports.StatsigTriggeredSessionReplayPlugin = StatsigTriggeredSessionReplayPlugin;
|
|
16
|
-
function
|
|
17
|
+
function runStatsigTriggeredSessionReplay(client, options) {
|
|
17
18
|
new TriggeredSessionReplay(client, options);
|
|
18
19
|
}
|
|
19
|
-
exports.
|
|
20
|
-
function startRecording(sdkKey) {
|
|
21
|
-
var _a, _b;
|
|
22
|
-
const inst = (_b = (_a = (0, client_core_1._getStatsigGlobal)()) === null || _a === void 0 ? void 0 : _a.srInstances) === null || _b === void 0 ? void 0 : _b[sdkKey];
|
|
23
|
-
if (inst instanceof TriggeredSessionReplay) {
|
|
24
|
-
inst.startRecording();
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
exports.startRecording = startRecording;
|
|
28
|
-
function forceStartRecording(sdkKey) {
|
|
29
|
-
var _a, _b;
|
|
30
|
-
const inst = (_b = (_a = (0, client_core_1._getStatsigGlobal)()) === null || _a === void 0 ? void 0 : _a.srInstances) === null || _b === void 0 ? void 0 : _b[sdkKey];
|
|
31
|
-
if (inst instanceof TriggeredSessionReplay) {
|
|
32
|
-
inst.forceStartRecording();
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
exports.forceStartRecording = forceStartRecording;
|
|
36
|
-
function stopRecording(sdkKey) {
|
|
37
|
-
var _a, _b;
|
|
38
|
-
const inst = (_b = (_a = (0, client_core_1._getStatsigGlobal)()) === null || _a === void 0 ? void 0 : _a.srInstances) === null || _b === void 0 ? void 0 : _b[sdkKey];
|
|
39
|
-
if (inst instanceof TriggeredSessionReplay) {
|
|
40
|
-
inst.stopRecording();
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
exports.stopRecording = stopRecording;
|
|
20
|
+
exports.runStatsigTriggeredSessionReplay = runStatsigTriggeredSessionReplay;
|
|
44
21
|
class TriggeredSessionReplay extends SessionReplayBase_1.SessionReplayBase {
|
|
45
22
|
constructor(client, options) {
|
|
46
23
|
var _a;
|
|
47
24
|
super(client, options);
|
|
48
25
|
this._runningEventData = [];
|
|
49
26
|
this._isActiveRecording = false;
|
|
27
|
+
this._subscribeToClientEvents(options);
|
|
28
|
+
if (options === null || options === void 0 ? void 0 : options.autoStartRecording) {
|
|
29
|
+
this._attemptToStartRecording((_a = this._options) === null || _a === void 0 ? void 0 : _a.forceRecording);
|
|
30
|
+
}
|
|
31
|
+
else if (options === null || options === void 0 ? void 0 : options.keepRollingWindow) {
|
|
32
|
+
this._attemptToStartRollingWindow();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
_subscribeToClientEvents(options) {
|
|
36
|
+
this._subscribeToValuesUpdated(options);
|
|
37
|
+
this._subscribeToLogEventCalled();
|
|
38
|
+
this._subscribeToGateEvaluation();
|
|
39
|
+
this._subscribeToExperimentEvaluation();
|
|
40
|
+
}
|
|
41
|
+
_subscribeToValuesUpdated(options) {
|
|
50
42
|
this._client.$on('values_updated', () => {
|
|
51
43
|
var _a;
|
|
52
44
|
if (!this._wasStopped) {
|
|
@@ -58,6 +50,8 @@ class TriggeredSessionReplay extends SessionReplayBase_1.SessionReplayBase {
|
|
|
58
50
|
}
|
|
59
51
|
}
|
|
60
52
|
});
|
|
53
|
+
}
|
|
54
|
+
_subscribeToLogEventCalled() {
|
|
61
55
|
this._client.$on('log_event_called', (event) => {
|
|
62
56
|
var _a;
|
|
63
57
|
if (this._wasStopped) {
|
|
@@ -73,6 +67,9 @@ class TriggeredSessionReplay extends SessionReplayBase_1.SessionReplayBase {
|
|
|
73
67
|
if (trigger == null) {
|
|
74
68
|
return;
|
|
75
69
|
}
|
|
70
|
+
if (trigger.passes_sampling === false) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
76
73
|
const targetValues = trigger.values;
|
|
77
74
|
if (targetValues == null) {
|
|
78
75
|
this._attemptToStartRecording(true);
|
|
@@ -83,42 +80,45 @@ class TriggeredSessionReplay extends SessionReplayBase_1.SessionReplayBase {
|
|
|
83
80
|
return;
|
|
84
81
|
}
|
|
85
82
|
});
|
|
83
|
+
}
|
|
84
|
+
_subscribeToGateEvaluation() {
|
|
86
85
|
this._client.$on('gate_evaluation', (event) => {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
(values === null || values === void 0 ? void 0 : values.session_recording_exposure_triggers) == null) {
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
const trigger = (_a = values.session_recording_exposure_triggers[event.gate.name]) !== null && _a !== void 0 ? _a : values.session_recording_exposure_triggers[(0, client_core_1._DJB2)(event.gate.name)];
|
|
98
|
-
if (trigger == null) {
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
const targetValues = trigger.values;
|
|
102
|
-
if (targetValues == null) {
|
|
103
|
-
this._attemptToStartRecording(true);
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
if (targetValues.includes(String((_b = event.gate.value) !== null && _b !== void 0 ? _b : false))) {
|
|
107
|
-
this._attemptToStartRecording(true);
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
86
|
+
this._tryStartExposureRecording(event.gate.name, String(event.gate.value));
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
_subscribeToExperimentEvaluation() {
|
|
90
|
+
this._client.$on('experiment_evaluation', (event) => {
|
|
91
|
+
var _a;
|
|
92
|
+
this._tryStartExposureRecording(event.experiment.name, (_a = event.experiment.groupName) !== null && _a !== void 0 ? _a : '');
|
|
110
93
|
});
|
|
111
|
-
if (options === null || options === void 0 ? void 0 : options.autoStartRecording) {
|
|
112
|
-
this._attemptToStartRecording((_a = this._options) === null || _a === void 0 ? void 0 : _a.forceRecording);
|
|
113
|
-
}
|
|
114
|
-
else if (options === null || options === void 0 ? void 0 : options.keepRollingWindow) {
|
|
115
|
-
this._attemptToStartRollingWindow();
|
|
116
|
-
}
|
|
117
94
|
}
|
|
118
|
-
|
|
95
|
+
_tryStartExposureRecording(name, value) {
|
|
119
96
|
var _a;
|
|
120
|
-
this._wasStopped
|
|
121
|
-
|
|
97
|
+
if (this._wasStopped) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
const values = this._client.getContext().values;
|
|
101
|
+
const passedTargeting = values === null || values === void 0 ? void 0 : values.passes_session_recording_targeting;
|
|
102
|
+
if (passedTargeting === false ||
|
|
103
|
+
(values === null || values === void 0 ? void 0 : values.session_recording_exposure_triggers) == null) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
const trigger = (_a = values.session_recording_exposure_triggers[name]) !== null && _a !== void 0 ? _a : values.session_recording_exposure_triggers[(0, client_core_1._DJB2)(name)];
|
|
107
|
+
if (trigger == null) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
if (trigger.passes_sampling === false) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
const targetValues = trigger.values;
|
|
114
|
+
if (targetValues == null) {
|
|
115
|
+
this._attemptToStartRecording(true);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
if (targetValues.includes(value)) {
|
|
119
|
+
this._attemptToStartRecording(true);
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
122
|
}
|
|
123
123
|
forceStartRecording() {
|
|
124
124
|
super.forceStartRecording();
|
|
@@ -200,7 +200,14 @@ class TriggeredSessionReplay extends SessionReplayBase_1.SessionReplayBase {
|
|
|
200
200
|
}
|
|
201
201
|
_attemptToStartRecording(force = false) {
|
|
202
202
|
var _a, _b;
|
|
203
|
+
if (this._totalLogs >= SessionReplayUtils_1.MAX_LOGS) {
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
203
206
|
const values = this._client.getContext().values;
|
|
207
|
+
if ((values === null || values === void 0 ? void 0 : values.recording_blocked) === true) {
|
|
208
|
+
this._shutdown();
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
204
211
|
if (!force && (values === null || values === void 0 ? void 0 : values.can_record_session) !== true) {
|
|
205
212
|
this._shutdown();
|
|
206
213
|
return;
|
package/src/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { SessionReplay, StatsigSessionReplayPlugin, runStatsigSessionReplay } from './SessionReplay';
|
|
2
|
+
import { forceStartRecording, startRecording, stopRecording } from './SessionReplayBase';
|
|
2
3
|
import { SessionReplayClient } from './SessionReplayClient';
|
|
3
|
-
import { StatsigTriggeredSessionReplayPlugin,
|
|
4
|
+
import { StatsigTriggeredSessionReplayPlugin, runStatsigTriggeredSessionReplay } from './TriggeredSessionReplay';
|
|
4
5
|
export type { ReplaySessionData as ReplayData, ReplayEvent, } from './SessionReplayClient';
|
|
5
|
-
export { SessionReplayClient, SessionReplay, runStatsigSessionReplay, StatsigSessionReplayPlugin, StatsigTriggeredSessionReplayPlugin, startRecording, stopRecording, forceStartRecording, };
|
|
6
|
+
export { SessionReplayClient, SessionReplay, runStatsigSessionReplay, runStatsigTriggeredSessionReplay, StatsigSessionReplayPlugin, StatsigTriggeredSessionReplayPlugin, startRecording, stopRecording, forceStartRecording, };
|
package/src/index.js
CHANGED
|
@@ -1,21 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.forceStartRecording = exports.stopRecording = exports.startRecording = exports.StatsigTriggeredSessionReplayPlugin = exports.StatsigSessionReplayPlugin = exports.runStatsigSessionReplay = exports.SessionReplay = exports.SessionReplayClient = void 0;
|
|
3
|
+
exports.forceStartRecording = exports.stopRecording = exports.startRecording = exports.StatsigTriggeredSessionReplayPlugin = exports.StatsigSessionReplayPlugin = exports.runStatsigTriggeredSessionReplay = exports.runStatsigSessionReplay = exports.SessionReplay = exports.SessionReplayClient = void 0;
|
|
4
4
|
const client_core_1 = require("@statsig/client-core");
|
|
5
5
|
const SessionReplay_1 = require("./SessionReplay");
|
|
6
6
|
Object.defineProperty(exports, "SessionReplay", { enumerable: true, get: function () { return SessionReplay_1.SessionReplay; } });
|
|
7
7
|
Object.defineProperty(exports, "StatsigSessionReplayPlugin", { enumerable: true, get: function () { return SessionReplay_1.StatsigSessionReplayPlugin; } });
|
|
8
8
|
Object.defineProperty(exports, "runStatsigSessionReplay", { enumerable: true, get: function () { return SessionReplay_1.runStatsigSessionReplay; } });
|
|
9
|
+
const SessionReplayBase_1 = require("./SessionReplayBase");
|
|
10
|
+
Object.defineProperty(exports, "forceStartRecording", { enumerable: true, get: function () { return SessionReplayBase_1.forceStartRecording; } });
|
|
11
|
+
Object.defineProperty(exports, "startRecording", { enumerable: true, get: function () { return SessionReplayBase_1.startRecording; } });
|
|
12
|
+
Object.defineProperty(exports, "stopRecording", { enumerable: true, get: function () { return SessionReplayBase_1.stopRecording; } });
|
|
9
13
|
const SessionReplayClient_1 = require("./SessionReplayClient");
|
|
10
14
|
Object.defineProperty(exports, "SessionReplayClient", { enumerable: true, get: function () { return SessionReplayClient_1.SessionReplayClient; } });
|
|
11
15
|
const TriggeredSessionReplay_1 = require("./TriggeredSessionReplay");
|
|
12
16
|
Object.defineProperty(exports, "StatsigTriggeredSessionReplayPlugin", { enumerable: true, get: function () { return TriggeredSessionReplay_1.StatsigTriggeredSessionReplayPlugin; } });
|
|
13
|
-
Object.defineProperty(exports, "
|
|
14
|
-
Object.defineProperty(exports, "startRecording", { enumerable: true, get: function () { return TriggeredSessionReplay_1.startRecording; } });
|
|
15
|
-
Object.defineProperty(exports, "stopRecording", { enumerable: true, get: function () { return TriggeredSessionReplay_1.stopRecording; } });
|
|
17
|
+
Object.defineProperty(exports, "runStatsigTriggeredSessionReplay", { enumerable: true, get: function () { return TriggeredSessionReplay_1.runStatsigTriggeredSessionReplay; } });
|
|
16
18
|
Object.assign((0, client_core_1._getStatsigGlobal)(), {
|
|
17
19
|
SessionReplayClient: SessionReplayClient_1.SessionReplayClient,
|
|
18
20
|
SessionReplay: SessionReplay_1.SessionReplay,
|
|
19
21
|
runStatsigSessionReplay: SessionReplay_1.runStatsigSessionReplay,
|
|
22
|
+
runStatsigTriggeredSessionReplay: TriggeredSessionReplay_1.runStatsigTriggeredSessionReplay,
|
|
20
23
|
StatsigSessionReplayPlugin: SessionReplay_1.StatsigSessionReplayPlugin,
|
|
24
|
+
StatsigTriggeredSessionReplayPlugin: TriggeredSessionReplay_1.StatsigTriggeredSessionReplayPlugin,
|
|
25
|
+
startRecording: SessionReplayBase_1.startRecording,
|
|
26
|
+
stopRecording: SessionReplayBase_1.stopRecording,
|
|
27
|
+
forceStartRecording: SessionReplayBase_1.forceStartRecording,
|
|
21
28
|
});
|