@statsig/session-replay 3.30.2 → 3.31.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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@statsig/session-replay",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.31.0",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"homepage": "https://github.com/statsig-io/js-client-monorepo",
|
|
6
6
|
"repository": {
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"rrweb": "2.0.0-alpha.17",
|
|
13
13
|
"@rrweb/record": "2.0.0-alpha.17",
|
|
14
|
-
"@statsig/client-core": "3.
|
|
14
|
+
"@statsig/client-core": "3.31.0"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
17
|
"@rrweb/types": "2.0.0-alpha.16"
|
package/src/SessionReplay.js
CHANGED
|
@@ -24,15 +24,20 @@ function runStatsigSessionReplay(client, options) {
|
|
|
24
24
|
exports.runStatsigSessionReplay = runStatsigSessionReplay;
|
|
25
25
|
class SessionReplay extends SessionReplayBase_1.SessionReplayBase {
|
|
26
26
|
constructor(client, options) {
|
|
27
|
-
var _a;
|
|
28
|
-
|
|
27
|
+
var _a, _b;
|
|
28
|
+
let newOptions = options;
|
|
29
|
+
const privacySettings = (_a = client.getContext().values) === null || _a === void 0 ? void 0 : _a.session_recording_privacy_settings;
|
|
30
|
+
if (privacySettings) {
|
|
31
|
+
newOptions = (0, SessionReplayUtils_1.getNewOptionsWithPrivacySettings)(newOptions !== null && newOptions !== void 0 ? newOptions : {}, privacySettings);
|
|
32
|
+
}
|
|
33
|
+
super(client, newOptions);
|
|
29
34
|
this._client.$on('values_updated', () => {
|
|
30
35
|
var _a;
|
|
31
36
|
if (!this._wasStopped) {
|
|
32
37
|
this._attemptToStartRecording((_a = this._options) === null || _a === void 0 ? void 0 : _a.forceRecording);
|
|
33
38
|
}
|
|
34
39
|
});
|
|
35
|
-
this._attemptToStartRecording((
|
|
40
|
+
this._attemptToStartRecording((_b = this._options) === null || _b === void 0 ? void 0 : _b.forceRecording);
|
|
36
41
|
}
|
|
37
42
|
_shutdown(endReason) {
|
|
38
43
|
super._shutdownImpl(endReason);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { StatsigEvent } from '@statsig/client-core';
|
|
1
|
+
import { SessionReplayPrivacySettings, StatsigEvent } from '@statsig/client-core';
|
|
2
2
|
import { ReplaySessionData } from './SessionReplayClient';
|
|
3
|
+
import { SessionReplayOptions } from './TriggeredSessionReplay';
|
|
3
4
|
export type RRWebPayload = {
|
|
4
5
|
session_start_ts: string;
|
|
5
6
|
session_end_ts: string;
|
|
@@ -23,3 +24,4 @@ export declare function _makeLoggableRrwebEvent(slice: string, payload: string,
|
|
|
23
24
|
};
|
|
24
25
|
export declare function _slicePayload(payload: string): string[];
|
|
25
26
|
export declare function _appendSlicedMetadata(metadata: RRWebPayload, slicedID: string, sliceIndex: number, sliceCount: number, sliceByteSize: number): void;
|
|
27
|
+
export declare function getNewOptionsWithPrivacySettings(originalOptions: SessionReplayOptions, privacySettings: SessionReplayPrivacySettings): SessionReplayOptions;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports._appendSlicedMetadata = exports._slicePayload = exports._makeLoggableRrwebEvent = exports.MAX_LOGS = exports.MAX_INDIVIDUAL_EVENT_BYTES = exports.REPLAY_ENQUEUE_TRIGGER_BYTES = void 0;
|
|
3
|
+
exports.getNewOptionsWithPrivacySettings = 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
|
|
@@ -38,3 +38,30 @@ function _appendSlicedMetadata(metadata, slicedID, sliceIndex, sliceCount, slice
|
|
|
38
38
|
metadata.slice_byte_size = String(sliceByteSize);
|
|
39
39
|
}
|
|
40
40
|
exports._appendSlicedMetadata = _appendSlicedMetadata;
|
|
41
|
+
function getNewOptionsWithPrivacySettings(originalOptions, privacySettings) {
|
|
42
|
+
const maskValue = (value) => {
|
|
43
|
+
return value.replace(/./g, '*');
|
|
44
|
+
};
|
|
45
|
+
const blockSelector = privacySettings.blocked_elements
|
|
46
|
+
? privacySettings.blocked_elements.join(', ')
|
|
47
|
+
: undefined;
|
|
48
|
+
const maskTextSelector = privacySettings.masked_elements
|
|
49
|
+
? privacySettings.masked_elements.join(', ')
|
|
50
|
+
: undefined;
|
|
51
|
+
const maskInputFn = (value, element) => {
|
|
52
|
+
var _a, _b;
|
|
53
|
+
if ((_a = privacySettings.masked_elements) === null || _a === void 0 ? void 0 : _a.some((sel) => element.closest(sel))) {
|
|
54
|
+
return maskValue(value);
|
|
55
|
+
}
|
|
56
|
+
if ((_b = privacySettings.unmasked_elements) === null || _b === void 0 ? void 0 : _b.some((sel) => element.closest(sel))) {
|
|
57
|
+
return value;
|
|
58
|
+
}
|
|
59
|
+
return privacySettings.privacy_mode === 'max' ||
|
|
60
|
+
privacySettings.privacy_mode === 'input'
|
|
61
|
+
? maskValue(value)
|
|
62
|
+
: value;
|
|
63
|
+
};
|
|
64
|
+
return Object.assign(Object.assign({}, originalOptions), { rrwebConfig: Object.assign(Object.assign({}, originalOptions === null || originalOptions === void 0 ? void 0 : originalOptions.rrwebConfig), { maskTextFn: maskValue, maskInputFn,
|
|
65
|
+
maskTextSelector, maskAllInputs: true, maskInputOptions: undefined, blockSelector }) });
|
|
66
|
+
}
|
|
67
|
+
exports.getNewOptionsWithPrivacySettings = getNewOptionsWithPrivacySettings;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PrecomputedEvaluationsInterface, StatsigPlugin } from '@statsig/client-core';
|
|
2
2
|
import { EndReason, SessionReplayBase } from './SessionReplayBase';
|
|
3
3
|
import { RRWebConfig, ReplayEvent, ReplaySessionData } from './SessionReplayClient';
|
|
4
|
-
type SessionReplayOptions = {
|
|
4
|
+
export type SessionReplayOptions = {
|
|
5
5
|
rrwebConfig?: RRWebConfig;
|
|
6
6
|
forceRecording?: boolean;
|
|
7
7
|
};
|
|
@@ -15,7 +15,7 @@ export declare class StatsigTriggeredSessionReplayPlugin implements StatsigPlugi
|
|
|
15
15
|
constructor(options?: TriggeredSessionReplayOptions | undefined);
|
|
16
16
|
bind(client: PrecomputedEvaluationsInterface): void;
|
|
17
17
|
}
|
|
18
|
-
export declare function runStatsigTriggeredSessionReplay(client: PrecomputedEvaluationsInterface, options?:
|
|
18
|
+
export declare function runStatsigTriggeredSessionReplay(client: PrecomputedEvaluationsInterface, options?: TriggeredSessionReplayOptions): void;
|
|
19
19
|
export declare class TriggeredSessionReplay extends SessionReplayBase {
|
|
20
20
|
private _runningEventData;
|
|
21
21
|
private _isActiveRecording;
|
|
@@ -34,4 +34,3 @@ export declare class TriggeredSessionReplay extends SessionReplayBase {
|
|
|
34
34
|
protected _attemptToStartRollingWindow(): void;
|
|
35
35
|
protected _attemptToStartRecording(force?: boolean): void;
|
|
36
36
|
}
|
|
37
|
-
export {};
|
|
@@ -22,15 +22,20 @@ function runStatsigTriggeredSessionReplay(client, options) {
|
|
|
22
22
|
exports.runStatsigTriggeredSessionReplay = runStatsigTriggeredSessionReplay;
|
|
23
23
|
class TriggeredSessionReplay extends SessionReplayBase_1.SessionReplayBase {
|
|
24
24
|
constructor(client, options) {
|
|
25
|
-
var _a;
|
|
26
|
-
|
|
25
|
+
var _a, _b;
|
|
26
|
+
let newOptions = options;
|
|
27
|
+
const privacySettings = (_a = client.getContext().values) === null || _a === void 0 ? void 0 : _a.session_recording_privacy_settings;
|
|
28
|
+
if (privacySettings) {
|
|
29
|
+
newOptions = (0, SessionReplayUtils_1.getNewOptionsWithPrivacySettings)(newOptions !== null && newOptions !== void 0 ? newOptions : {}, privacySettings);
|
|
30
|
+
}
|
|
31
|
+
super(client, newOptions);
|
|
27
32
|
this._runningEventData = [];
|
|
28
33
|
this._isActiveRecording = false;
|
|
29
|
-
this._subscribeToClientEvents(
|
|
30
|
-
if (
|
|
31
|
-
this._attemptToStartRecording((
|
|
34
|
+
this._subscribeToClientEvents(newOptions);
|
|
35
|
+
if (newOptions === null || newOptions === void 0 ? void 0 : newOptions.autoStartRecording) {
|
|
36
|
+
this._attemptToStartRecording((_b = this._options) === null || _b === void 0 ? void 0 : _b.forceRecording);
|
|
32
37
|
}
|
|
33
|
-
else if (
|
|
38
|
+
else if (newOptions === null || newOptions === void 0 ? void 0 : newOptions.keepRollingWindow) {
|
|
34
39
|
this._attemptToStartRollingWindow();
|
|
35
40
|
}
|
|
36
41
|
}
|