@statsig/session-replay 0.0.1-beta.29 → 0.0.1-beta.31
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/README.md +4 -8
- package/package.json +2 -2
- package/src/SessionReplay.d.ts +2 -2
- package/src/SessionReplay.js +11 -10
package/README.md
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Statsig Session Replay
|
|
2
2
|
|
|
3
|
-
This
|
|
3
|
+
Session Replay allows you to record users using your website or product, and play back those recorded sessions. This allows you to better understand how users use your service or website, diagnose problems, and uncover insights that help improve conversion and the overall user experience.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Getting Started
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
## Running unit tests
|
|
10
|
-
|
|
11
|
-
Run `nx test session-replay` to execute the unit tests via [Jest](https://jestjs.io).
|
|
7
|
+
Read through the [Documentation](https://docs.statsig.com/session-replay/overview) or check out the [Samples](https://github.com/statsig-io/js-client-monorepo/tree/main/samples).
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@statsig/session-replay",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
3
|
+
"version": "0.0.1-beta.31",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"rrweb": "2.0.0-alpha.12",
|
|
6
|
-
"@statsig/client-core": "0.0.1-beta.
|
|
6
|
+
"@statsig/client-core": "0.0.1-beta.31"
|
|
7
7
|
},
|
|
8
8
|
"devDependencies": {
|
|
9
9
|
"@rrweb/types": "2.0.0-alpha.12"
|
package/src/SessionReplay.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PrecomputedEvaluationsInterface
|
|
1
|
+
import { PrecomputedEvaluationsInterface } from '@statsig/client-core';
|
|
2
2
|
export declare function runStatsigSessionReplay(client: PrecomputedEvaluationsInterface): void;
|
|
3
3
|
export declare class SessionReplay {
|
|
4
4
|
private _client;
|
|
@@ -8,7 +8,7 @@ export declare class SessionReplay {
|
|
|
8
8
|
private _events;
|
|
9
9
|
private _sessionID;
|
|
10
10
|
constructor(_client: PrecomputedEvaluationsInterface);
|
|
11
|
-
|
|
11
|
+
private _onVisibilityChanged;
|
|
12
12
|
private _onRecordingEvent;
|
|
13
13
|
private _attemptToStartRecording;
|
|
14
14
|
private _shutdown;
|
package/src/SessionReplay.js
CHANGED
|
@@ -10,7 +10,6 @@ function runStatsigSessionReplay(client) {
|
|
|
10
10
|
exports.runStatsigSessionReplay = runStatsigSessionReplay;
|
|
11
11
|
class SessionReplay {
|
|
12
12
|
constructor(_client) {
|
|
13
|
-
var _a;
|
|
14
13
|
this._client = _client;
|
|
15
14
|
this._sessionData = null;
|
|
16
15
|
this._events = [];
|
|
@@ -18,10 +17,8 @@ class SessionReplay {
|
|
|
18
17
|
const { sdkKey } = _client.getContext();
|
|
19
18
|
this._errorBoundary = new client_core_1.ErrorBoundary(sdkKey);
|
|
20
19
|
(0, client_core_1.monitorClass)(this._errorBoundary, this);
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
instances[sdkKey] = this;
|
|
24
|
-
__STATSIG__.srInstances = instances;
|
|
20
|
+
const statsigGlobal = (0, client_core_1._getStatsigGlobal)();
|
|
21
|
+
statsigGlobal.srInstances = Object.assign(Object.assign({}, statsigGlobal.srInstances), { [sdkKey]: this });
|
|
25
22
|
this._replayer = new SessionReplayClient_1.SessionReplayClient();
|
|
26
23
|
this._client.__on('pre_shutdown', () => this._shutdown());
|
|
27
24
|
this._client.__on('values_updated', () => this._attemptToStartRecording());
|
|
@@ -38,7 +35,7 @@ class SessionReplay {
|
|
|
38
35
|
client_core_1.Log.error(err);
|
|
39
36
|
});
|
|
40
37
|
});
|
|
41
|
-
client_core_1.
|
|
38
|
+
(0, client_core_1._subscribeToVisiblityChanged)(this._onVisibilityChanged.bind(this));
|
|
42
39
|
this._client
|
|
43
40
|
.getAsyncContext()
|
|
44
41
|
.then((context) => {
|
|
@@ -49,7 +46,7 @@ class SessionReplay {
|
|
|
49
46
|
client_core_1.Log.error(err);
|
|
50
47
|
});
|
|
51
48
|
}
|
|
52
|
-
|
|
49
|
+
_onVisibilityChanged(visibility) {
|
|
53
50
|
if (visibility === 'background') {
|
|
54
51
|
this._flushWithSessionID(this._sessionID);
|
|
55
52
|
this._client.flush().catch((e) => {
|
|
@@ -62,7 +59,12 @@ class SessionReplay {
|
|
|
62
59
|
this._events.push(event);
|
|
63
60
|
const payload = JSON.stringify(this._events);
|
|
64
61
|
if (payload.length > MAX_REPLAY_PAYLOAD_BYTES) {
|
|
65
|
-
|
|
62
|
+
if ((0, client_core_1._isCurrentlyVisible)()) {
|
|
63
|
+
this._flushAndRefreshSessionID();
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
this._flushWithSessionID(this._sessionID);
|
|
67
|
+
}
|
|
66
68
|
}
|
|
67
69
|
}
|
|
68
70
|
_attemptToStartRecording() {
|
|
@@ -92,7 +94,6 @@ class SessionReplay {
|
|
|
92
94
|
this._logRecordingEvent(sessionID);
|
|
93
95
|
}
|
|
94
96
|
_logRecordingEvent(sessionID) {
|
|
95
|
-
const { sdkVersion } = client_core_1.StatsigMetadataProvider.get();
|
|
96
97
|
const data = this._sessionData;
|
|
97
98
|
if (data === null || this._events.length === 0) {
|
|
98
99
|
return;
|
|
@@ -106,7 +107,7 @@ class SessionReplay {
|
|
|
106
107
|
session_end_ts: String(data.endTime),
|
|
107
108
|
clicks_captured_cumulative: String(data.clickCount),
|
|
108
109
|
rrweb_events: payload,
|
|
109
|
-
session_replay_sdk_version:
|
|
110
|
+
session_replay_sdk_version: client_core_1.SDK_VERSION,
|
|
110
111
|
},
|
|
111
112
|
});
|
|
112
113
|
this._events = [];
|