@statsig/session-replay 3.17.0 → 3.17.2

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.17.0",
3
+ "version": "3.17.2",
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.17.0"
13
+ "@statsig/client-core": "3.17.2"
14
14
  },
15
15
  "devDependencies": {
16
16
  "@rrweb/types": "2.0.0-alpha.14"
@@ -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[];
@@ -19,6 +22,7 @@ export declare abstract class SessionReplayBase {
19
22
  constructor(client: PrecomputedEvaluationsInterface, options?: SessionReplayOptions);
20
23
  forceStartRecording(): void;
21
24
  stopRecording(): void;
25
+ startRecording(): void;
22
26
  isRecording(): boolean;
23
27
  protected abstract _attemptToStartRecording(force?: boolean): void;
24
28
  protected _logRecording(endReason?: EndReason): void;
@@ -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 = {
@@ -29,6 +51,9 @@ class SessionReplayBase {
29
51
  if (!(0, client_core_1._isServerEnv)()) {
30
52
  const statsigGlobal = (0, client_core_1._getStatsigGlobal)();
31
53
  statsigGlobal.srInstances = Object.assign(Object.assign({}, statsigGlobal.srInstances), { [sdkKey]: this });
54
+ if (!statsigGlobal.firstSRInstance) {
55
+ statsigGlobal.firstSRInstance = this;
56
+ }
32
57
  }
33
58
  this._currentSessionID = this._getSessionIdFromClient();
34
59
  this._subscribeToVisibilityChanged();
@@ -41,6 +66,11 @@ class SessionReplayBase {
41
66
  this._wasStopped = true;
42
67
  this._shutdown();
43
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
+ }
44
74
  isRecording() {
45
75
  return this._replayer.isRecording();
46
76
  }
@@ -15,10 +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 runStatsigSessionReplay(client: PrecomputedEvaluationsInterface, options?: SessionReplayOptions): void;
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;
@@ -29,7 +26,6 @@ export declare class TriggeredSessionReplay extends SessionReplayBase {
29
26
  private _subscribeToGateEvaluation;
30
27
  private _subscribeToExperimentEvaluation;
31
28
  private _tryStartExposureRecording;
32
- startRecording(): void;
33
29
  forceStartRecording(): void;
34
30
  stopRecording(): void;
35
31
  private _handleStartActiveRecording;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TriggeredSessionReplay = exports.stopRecording = exports.forceStartRecording = exports.startRecording = exports.runStatsigSessionReplay = exports.StatsigTriggeredSessionReplayPlugin = void 0;
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
6
  const SessionReplayUtils_1 = require("./SessionReplayUtils");
@@ -10,38 +10,14 @@ class StatsigTriggeredSessionReplayPlugin {
10
10
  this.__plugin = 'triggered-session-replay';
11
11
  }
12
12
  bind(client) {
13
- runStatsigSessionReplay(client, this.options);
13
+ runStatsigTriggeredSessionReplay(client, this.options);
14
14
  }
15
15
  }
16
16
  exports.StatsigTriggeredSessionReplayPlugin = StatsigTriggeredSessionReplayPlugin;
17
- function runStatsigSessionReplay(client, options) {
17
+ function runStatsigTriggeredSessionReplay(client, options) {
18
18
  new TriggeredSessionReplay(client, options);
19
19
  }
20
- exports.runStatsigSessionReplay = runStatsigSessionReplay;
21
- function startRecording(sdkKey) {
22
- var _a, _b;
23
- 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];
24
- if (inst instanceof TriggeredSessionReplay) {
25
- inst.startRecording();
26
- }
27
- }
28
- exports.startRecording = startRecording;
29
- function forceStartRecording(sdkKey) {
30
- var _a, _b;
31
- 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];
32
- if (inst instanceof TriggeredSessionReplay) {
33
- inst.forceStartRecording();
34
- }
35
- }
36
- exports.forceStartRecording = forceStartRecording;
37
- function stopRecording(sdkKey) {
38
- var _a, _b;
39
- 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];
40
- if (inst instanceof TriggeredSessionReplay) {
41
- inst.stopRecording();
42
- }
43
- }
44
- exports.stopRecording = stopRecording;
20
+ exports.runStatsigTriggeredSessionReplay = runStatsigTriggeredSessionReplay;
45
21
  class TriggeredSessionReplay extends SessionReplayBase_1.SessionReplayBase {
46
22
  constructor(client, options) {
47
23
  var _a;
@@ -144,11 +120,6 @@ class TriggeredSessionReplay extends SessionReplayBase_1.SessionReplayBase {
144
120
  return;
145
121
  }
146
122
  }
147
- startRecording() {
148
- var _a;
149
- this._wasStopped = false;
150
- this._attemptToStartRecording((_a = this._options) === null || _a === void 0 ? void 0 : _a.forceRecording);
151
- }
152
123
  forceStartRecording() {
153
124
  super.forceStartRecording();
154
125
  }
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, forceStartRecording, startRecording, stopRecording } from './TriggeredSessionReplay';
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, "forceStartRecording", { enumerable: true, get: function () { return TriggeredSessionReplay_1.forceStartRecording; } });
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
  });