@amplitude/session-replay-browser 1.48.3 → 1.49.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/README.md +15 -2
- package/lib/cjs/index.d.ts +1 -1
- package/lib/cjs/index.d.ts.map +1 -1
- package/lib/cjs/index.js +2 -2
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/session-replay-factory.d.ts.map +1 -1
- package/lib/cjs/session-replay-factory.js +2 -0
- package/lib/cjs/session-replay-factory.js.map +1 -1
- package/lib/cjs/session-replay.d.ts +22 -0
- package/lib/cjs/session-replay.d.ts.map +1 -1
- package/lib/cjs/session-replay.js +111 -35
- package/lib/cjs/session-replay.js.map +1 -1
- package/lib/cjs/typings/session-replay.d.ts +11 -0
- package/lib/cjs/typings/session-replay.d.ts.map +1 -1
- package/lib/cjs/typings/session-replay.js.map +1 -1
- package/lib/cjs/version.d.ts +1 -1
- package/lib/cjs/version.js +1 -1
- package/lib/cjs/version.js.map +1 -1
- package/lib/esm/index.d.ts +1 -1
- package/lib/esm/index.d.ts.map +1 -1
- package/lib/esm/index.js +1 -1
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/session-replay-factory.d.ts.map +1 -1
- package/lib/esm/session-replay-factory.js +2 -0
- package/lib/esm/session-replay-factory.js.map +1 -1
- package/lib/esm/session-replay.d.ts +22 -0
- package/lib/esm/session-replay.d.ts.map +1 -1
- package/lib/esm/session-replay.js +111 -35
- package/lib/esm/session-replay.js.map +1 -1
- package/lib/esm/typings/session-replay.d.ts +11 -0
- package/lib/esm/typings/session-replay.d.ts.map +1 -1
- package/lib/esm/typings/session-replay.js.map +1 -1
- package/lib/esm/version.d.ts +1 -1
- package/lib/esm/version.js +1 -1
- package/lib/esm/version.js.map +1 -1
- package/lib/scripts/index-min.js +1 -1
- package/lib/scripts/index-min.js.gz +0 -0
- package/lib/scripts/index-min.js.map +1 -1
- package/lib/scripts/session-replay-browser-esm.js +1 -1
- package/lib/scripts/session-replay-browser-esm.js.gz +0 -0
- package/lib/scripts/session-replay-browser-min.js +1 -1
- package/lib/scripts/session-replay-browser-min.js.gz +0 -0
- package/lib/scripts/session-replay-browser-min.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -77,8 +77,21 @@ You can optionally pass a new device id as a second argument as well:
|
|
|
77
77
|
sessionReplay.setSessionId(UNIX_TIMESTAMP, deviceId)
|
|
78
78
|
```
|
|
79
79
|
|
|
80
|
-
### 6.
|
|
81
|
-
|
|
80
|
+
### 6. Start and stop recording (optional)
|
|
81
|
+
Use `stop()` to pause capture without tearing down the SDK (session id, config, and event listeners stay in place). Call `start()` to resume. Sampling, targeting, and opt-out still apply — `start()` will not record a session that is opted out, not sampled, or excluded by targeting.
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
// Pause capture, for example on a sensitive screen
|
|
85
|
+
sessionReplay.stop()
|
|
86
|
+
|
|
87
|
+
// Resume capture
|
|
88
|
+
sessionReplay.start()
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
`stop()` flushes any events already captured. Events while recording is stopped are not tagged with session replay properties.
|
|
92
|
+
|
|
93
|
+
### 7. Shutdown (optional)
|
|
94
|
+
If at any point you would like to discontinue collection of session replays, for example in a part of your application where you would not like sessions to be collected, you can use the following method to stop collection and remove collection event listeners. After `shutdown()`, call `init()` again to restart — `start()` alone is not enough because listeners have been removed.
|
|
82
95
|
```typescript
|
|
83
96
|
sessionReplay.shutdown()
|
|
84
97
|
```
|
package/lib/cjs/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const init: (apiKey: string, options: import("./typings/session-replay").SessionReplayOptions) => import("@amplitude/analytics-core").AmplitudeReturn<void>, setSessionId: (sessionId: string | number, deviceId?: string | undefined) => import("@amplitude/analytics-core").AmplitudeReturn<void>, getSessionId: () => string | number | undefined, getSessionReplayProperties: () => {
|
|
2
2
|
[key: string]: string | boolean | null;
|
|
3
|
-
}, flush: (useRetry: boolean) => Promise<void>, shutdown: () => void, evaluateTargetingAndCapture: (targetingParams: import("./typings/session-replay").SessionReplayTargetingInput, isInit?: boolean | undefined, forceRestart?: boolean | undefined, forceTargetingReevaluation?: boolean | undefined) => Promise<void>;
|
|
3
|
+
}, flush: (useRetry: boolean) => Promise<void>, start: () => import("@amplitude/analytics-core").AmplitudeReturn<void>, stop: () => void, shutdown: () => void, evaluateTargetingAndCapture: (targetingParams: import("./typings/session-replay").SessionReplayTargetingInput, isInit?: boolean | undefined, forceRestart?: boolean | undefined, forceTargetingReevaluation?: boolean | undefined) => Promise<void>;
|
|
4
4
|
export { SessionReplayOptions, StoreType } from './typings/session-replay';
|
|
5
5
|
export { SafeLoggerProvider } from './logger';
|
|
6
6
|
export { AmplitudeSessionReplay } from './typings/session-replay';
|
package/lib/cjs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,eAAO,MACL,IAAI,mJACJ,YAAY,4HACZ,YAAY,qCACZ,0BAA0B;;GAC1B,KAAK,wCACL,QAAQ,cACR,2BAA2B,wNACZ,CAAC;AAClB,OAAO,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,8BAA8B,EAC9B,+BAA+B,GAChC,MAAM,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,eAAO,MACL,IAAI,mJACJ,YAAY,4HACZ,YAAY,qCACZ,0BAA0B;;GAC1B,KAAK,wCACL,KAAK,mEACL,IAAI,cACJ,QAAQ,cACR,2BAA2B,wNACZ,CAAC;AAClB,OAAO,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,8BAA8B,EAC9B,+BAA+B,GAChC,MAAM,gBAAgB,CAAC"}
|
package/lib/cjs/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SafeLoggerProvider = exports.evaluateTargetingAndCapture = exports.shutdown = exports.flush = exports.getSessionReplayProperties = exports.getSessionId = exports.setSessionId = exports.init = void 0;
|
|
3
|
+
exports.SafeLoggerProvider = exports.evaluateTargetingAndCapture = exports.shutdown = exports.stop = exports.start = exports.flush = exports.getSessionReplayProperties = exports.getSessionId = exports.setSessionId = exports.init = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var session_replay_factory_1 = tslib_1.__importDefault(require("./session-replay-factory"));
|
|
6
|
-
exports.init = session_replay_factory_1.default.init, exports.setSessionId = session_replay_factory_1.default.setSessionId, exports.getSessionId = session_replay_factory_1.default.getSessionId, exports.getSessionReplayProperties = session_replay_factory_1.default.getSessionReplayProperties, exports.flush = session_replay_factory_1.default.flush, exports.shutdown = session_replay_factory_1.default.shutdown, exports.evaluateTargetingAndCapture = session_replay_factory_1.default.evaluateTargetingAndCapture;
|
|
6
|
+
exports.init = session_replay_factory_1.default.init, exports.setSessionId = session_replay_factory_1.default.setSessionId, exports.getSessionId = session_replay_factory_1.default.getSessionId, exports.getSessionReplayProperties = session_replay_factory_1.default.getSessionReplayProperties, exports.flush = session_replay_factory_1.default.flush, exports.start = session_replay_factory_1.default.start, exports.stop = session_replay_factory_1.default.stop, exports.shutdown = session_replay_factory_1.default.shutdown, exports.evaluateTargetingAndCapture = session_replay_factory_1.default.evaluateTargetingAndCapture;
|
|
7
7
|
var logger_1 = require("./logger");
|
|
8
8
|
Object.defineProperty(exports, "SafeLoggerProvider", { enumerable: true, get: function () { return logger_1.SafeLoggerProvider; } });
|
|
9
9
|
//# sourceMappingURL=index.js.map
|
package/lib/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;AAAA,4FAAqD;AAEnD,QAAA,IAAI,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;AAAA,4FAAqD;AAEnD,QAAA,IAAI,GASF,gCAAa,OARf,QAAA,YAAY,GAQV,gCAAa,eAPf,QAAA,YAAY,GAOV,gCAAa,eANf,QAAA,0BAA0B,GAMxB,gCAAa,6BALf,QAAA,KAAK,GAKH,gCAAa,QAJf,QAAA,KAAK,GAIH,gCAAa,QAHf,QAAA,IAAI,GAGF,gCAAa,OAFf,QAAA,QAAQ,GAEN,gCAAa,WADf,QAAA,2BAA2B,GACzB,gCAAa,6BAAC;AAElB,mCAA8C;AAArC,4GAAA,kBAAkB,OAAA","sourcesContent":["import sessionReplay from './session-replay-factory';\nexport const {\n init,\n setSessionId,\n getSessionId,\n getSessionReplayProperties,\n flush,\n start,\n stop,\n shutdown,\n evaluateTargetingAndCapture,\n} = sessionReplay;\nexport { SessionReplayOptions, StoreType } from './typings/session-replay';\nexport { SafeLoggerProvider } from './logger';\nexport { AmplitudeSessionReplay } from './typings/session-replay';\nexport {\n SendEventsRequest,\n FetchConfigRequest,\n SessionReplaySendEventsHandler,\n SessionReplayFetchConfigHandler,\n} from './config/types';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-replay-factory.d.ts","sourceRoot":"","sources":["../../src/session-replay-factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAEpE,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE,eAAO,MAAM,YAAY,kBAAmB,aAAa,WAAS,SAOjE,CAAC;;
|
|
1
|
+
{"version":3,"file":"session-replay-factory.d.ts","sourceRoot":"","sources":["../../src/session-replay-factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAEpE,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE,eAAO,MAAM,YAAY,kBAAmB,aAAa,WAAS,SAOjE,CAAC;;AAiCF,wBAAgC"}
|
|
@@ -22,6 +22,8 @@ var createInstance = function () {
|
|
|
22
22
|
getSessionId: (0, analytics_core_1.debugWrapper)(sessionReplay.getSessionId.bind(sessionReplay), 'getSessionId', (0, exports.getLogConfig)(sessionReplay)),
|
|
23
23
|
getSessionReplayProperties: (0, analytics_core_1.debugWrapper)(sessionReplay.getSessionReplayProperties.bind(sessionReplay), 'getSessionReplayProperties', (0, exports.getLogConfig)(sessionReplay)),
|
|
24
24
|
flush: (0, analytics_core_1.debugWrapper)(sessionReplay.flush.bind(sessionReplay), 'flush', (0, exports.getLogConfig)(sessionReplay)),
|
|
25
|
+
start: (0, analytics_core_1.debugWrapper)(sessionReplay.start.bind(sessionReplay), 'start', (0, exports.getLogConfig)(sessionReplay)),
|
|
26
|
+
stop: (0, analytics_core_1.debugWrapper)(sessionReplay.stop.bind(sessionReplay), 'stop', (0, exports.getLogConfig)(sessionReplay)),
|
|
25
27
|
shutdown: (0, analytics_core_1.debugWrapper)(sessionReplay.shutdown.bind(sessionReplay), 'shutdown', (0, exports.getLogConfig)(sessionReplay)),
|
|
26
28
|
};
|
|
27
29
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-replay-factory.js","sour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,IAAA,6BAAY,EAAC,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,OAAO,EAAE,IAAA,oBAAY,EAAC,aAAa,CAAC,CAAC;QAClG,QAAQ,EAAE,IAAA,6BAAY,EAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,UAAU,EAAE,IAAA,oBAAY,EAAC,aAAa,CAAC,CAAC;KAC5G,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,cAAc,EAAE,CAAC","sourcesContent":["import { debugWrapper, LogConfig } from '@amplitude/analytics-core';\nimport { getDefaultConfig } from './config/local-config';\nimport { SessionReplay } from './session-replay';\nimport { AmplitudeSessionReplay } from './typings/session-replay';\n\nexport const getLogConfig = (sessionReplay: SessionReplay) => (): LogConfig => {\n const { config } = sessionReplay;\n const { loggerProvider: logger, logLevel } = config || getDefaultConfig();\n return {\n logger,\n logLevel,\n };\n};\n\nconst createInstance: () => AmplitudeSessionReplay = () => {\n const sessionReplay = new SessionReplay();\n return {\n init: debugWrapper(sessionReplay.init.bind(sessionReplay), 'init', getLogConfig(sessionReplay)),\n evaluateTargetingAndCapture: debugWrapper(\n sessionReplay.evaluateTargetingAndCapture.bind(sessionReplay),\n 'evaluateTargetingAndRecord',\n getLogConfig(sessionReplay),\n ),\n setSessionId: debugWrapper(\n sessionReplay.setSessionId.bind(sessionReplay),\n 'setSessionId',\n getLogConfig(sessionReplay),\n ),\n getSessionId: debugWrapper(\n sessionReplay.getSessionId.bind(sessionReplay),\n 'getSessionId',\n getLogConfig(sessionReplay),\n ),\n getSessionReplayProperties: debugWrapper(\n sessionReplay.getSessionReplayProperties.bind(sessionReplay),\n 'getSessionReplayProperties',\n getLogConfig(sessionReplay),\n ),\n flush: debugWrapper(sessionReplay.flush.bind(sessionReplay), 'flush', getLogConfig(sessionReplay)),\n shutdown: debugWrapper(sessionReplay.shutdown.bind(sessionReplay), 'shutdown', getLogConfig(sessionReplay)),\n };\n};\n\nexport default createInstance();\n"]}
|
|
1
|
+
{"version":3,"file":"session-replay-factory.js","sourceRoot":"","sources":["../../src/session-replay-factory.ts"],"names":[],"mappings":";;;AAAA,4DAAoE;AACpE,sDAAyD;AACzD,mDAAiD;AAG1C,IAAM,YAAY,GAAG,UAAC,aAA4B,IAAK,OAAA;IACpD,IAAA,MAAM,GAAK,aAAa,OAAlB,CAAmB;IAC3B,IAAA,KAAuC,MAAM,IAAI,IAAA,+BAAgB,GAAE,EAAjD,MAAM,oBAAA,EAAE,QAAQ,cAAiC,CAAC;IAC1E,OAAO;QACL,MAAM,QAAA;QACN,QAAQ,UAAA;KACT,CAAC;AACJ,CAAC,EAP6D,CAO7D,CAAC;AAPW,QAAA,YAAY,gBAOvB;AAEF,IAAM,cAAc,GAAiC;IACnD,IAAM,aAAa,GAAG,IAAI,8BAAa,EAAE,CAAC;IAC1C,OAAO;QACL,IAAI,EAAE,IAAA,6BAAY,EAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,MAAM,EAAE,IAAA,oBAAY,EAAC,aAAa,CAAC,CAAC;QAC/F,2BAA2B,EAAE,IAAA,6BAAY,EACvC,aAAa,CAAC,2BAA2B,CAAC,IAAI,CAAC,aAAa,CAAC,EAC7D,4BAA4B,EAC5B,IAAA,oBAAY,EAAC,aAAa,CAAC,CAC5B;QACD,YAAY,EAAE,IAAA,6BAAY,EACxB,aAAa,CAAC,YAAY,CAAC,IAAI,CAAC,aAAa,CAAC,EAC9C,cAAc,EACd,IAAA,oBAAY,EAAC,aAAa,CAAC,CAC5B;QACD,YAAY,EAAE,IAAA,6BAAY,EACxB,aAAa,CAAC,YAAY,CAAC,IAAI,CAAC,aAAa,CAAC,EAC9C,cAAc,EACd,IAAA,oBAAY,EAAC,aAAa,CAAC,CAC5B;QACD,0BAA0B,EAAE,IAAA,6BAAY,EACtC,aAAa,CAAC,0BAA0B,CAAC,IAAI,CAAC,aAAa,CAAC,EAC5D,4BAA4B,EAC5B,IAAA,oBAAY,EAAC,aAAa,CAAC,CAC5B;QACD,KAAK,EAAE,IAAA,6BAAY,EAAC,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,OAAO,EAAE,IAAA,oBAAY,EAAC,aAAa,CAAC,CAAC;QAClG,KAAK,EAAE,IAAA,6BAAY,EAAC,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,OAAO,EAAE,IAAA,oBAAY,EAAC,aAAa,CAAC,CAAC;QAClG,IAAI,EAAE,IAAA,6BAAY,EAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,MAAM,EAAE,IAAA,oBAAY,EAAC,aAAa,CAAC,CAAC;QAC/F,QAAQ,EAAE,IAAA,6BAAY,EAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,UAAU,EAAE,IAAA,oBAAY,EAAC,aAAa,CAAC,CAAC;KAC5G,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,cAAc,EAAE,CAAC","sourcesContent":["import { debugWrapper, LogConfig } from '@amplitude/analytics-core';\nimport { getDefaultConfig } from './config/local-config';\nimport { SessionReplay } from './session-replay';\nimport { AmplitudeSessionReplay } from './typings/session-replay';\n\nexport const getLogConfig = (sessionReplay: SessionReplay) => (): LogConfig => {\n const { config } = sessionReplay;\n const { loggerProvider: logger, logLevel } = config || getDefaultConfig();\n return {\n logger,\n logLevel,\n };\n};\n\nconst createInstance: () => AmplitudeSessionReplay = () => {\n const sessionReplay = new SessionReplay();\n return {\n init: debugWrapper(sessionReplay.init.bind(sessionReplay), 'init', getLogConfig(sessionReplay)),\n evaluateTargetingAndCapture: debugWrapper(\n sessionReplay.evaluateTargetingAndCapture.bind(sessionReplay),\n 'evaluateTargetingAndRecord',\n getLogConfig(sessionReplay),\n ),\n setSessionId: debugWrapper(\n sessionReplay.setSessionId.bind(sessionReplay),\n 'setSessionId',\n getLogConfig(sessionReplay),\n ),\n getSessionId: debugWrapper(\n sessionReplay.getSessionId.bind(sessionReplay),\n 'getSessionId',\n getLogConfig(sessionReplay),\n ),\n getSessionReplayProperties: debugWrapper(\n sessionReplay.getSessionReplayProperties.bind(sessionReplay),\n 'getSessionReplayProperties',\n getLogConfig(sessionReplay),\n ),\n flush: debugWrapper(sessionReplay.flush.bind(sessionReplay), 'flush', getLogConfig(sessionReplay)),\n start: debugWrapper(sessionReplay.start.bind(sessionReplay), 'start', getLogConfig(sessionReplay)),\n stop: debugWrapper(sessionReplay.stop.bind(sessionReplay), 'stop', getLogConfig(sessionReplay)),\n shutdown: debugWrapper(sessionReplay.shutdown.bind(sessionReplay), 'shutdown', getLogConfig(sessionReplay)),\n };\n};\n\nexport default createInstance();\n"]}
|
|
@@ -35,6 +35,24 @@ export declare class SessionReplay implements AmplitudeSessionReplay {
|
|
|
35
35
|
private metadata;
|
|
36
36
|
private recordFunction;
|
|
37
37
|
private recordEventsInFlight;
|
|
38
|
+
/**
|
|
39
|
+
* When false, capture is paused by a customer `stop()` (or `shutdown()`) call.
|
|
40
|
+
* Focus/targeting/session-change paths still invoke `recordEvents()`, but
|
|
41
|
+
* `getShouldRecord()` will refuse to start rrweb until `start()` or a new `init()`.
|
|
42
|
+
*/
|
|
43
|
+
private recordingEnabled;
|
|
44
|
+
/**
|
|
45
|
+
* Bumped by `stop()` / `shutdown()` so an in-flight `_recordEvents()` that already
|
|
46
|
+
* passed `getShouldRecord()` cannot start rrweb after capture was paused.
|
|
47
|
+
*/
|
|
48
|
+
private recordingGeneration;
|
|
49
|
+
/**
|
|
50
|
+
* Set by customer `start()` so coordinated child iframes self-start instead of
|
|
51
|
+
* waiting for a parent signal that may never be resent. Kept until recording
|
|
52
|
+
* actually starts so a gated `start()` (targeting, sampling, remote capture)
|
|
53
|
+
* still self-starts when those gates later pass.
|
|
54
|
+
*/
|
|
55
|
+
private startChildRecordingOnSetup;
|
|
38
56
|
private pendingEmitEvents;
|
|
39
57
|
/** Current page URL, kept in sync with SPA navigations for URL-based masking */
|
|
40
58
|
private currentPageUrl;
|
|
@@ -94,6 +112,7 @@ export declare class SessionReplay implements AmplitudeSessionReplay {
|
|
|
94
112
|
getRecordingPlugins(loggingConfig: LoggingConfig | undefined): Promise<(import("@amplitude/rrweb-types").RecordPlugin<import("./plugins/url-tracking-plugin").URLTrackingPluginOptions> | import("@amplitude/rrweb-types").RecordPlugin<unknown>)[] | undefined>;
|
|
95
113
|
private getRecordFunction;
|
|
96
114
|
recordEvents(shouldLogMetadata?: boolean): Promise<void>;
|
|
115
|
+
private shouldAbandonRecordStart;
|
|
97
116
|
private _recordEvents;
|
|
98
117
|
private buildRRWebRecordOptions;
|
|
99
118
|
private _recordEventsInChildMode;
|
|
@@ -103,6 +122,9 @@ export declare class SessionReplay implements AmplitudeSessionReplay {
|
|
|
103
122
|
stopRecordingEvents: () => void;
|
|
104
123
|
getDeviceId(): string | undefined;
|
|
105
124
|
getSessionId(): string | number | undefined;
|
|
125
|
+
start(): import("@amplitude/analytics-core").AmplitudeReturn<void>;
|
|
126
|
+
private _start;
|
|
127
|
+
stop(): void;
|
|
106
128
|
flush(useRetry?: boolean): Promise<void | undefined>;
|
|
107
129
|
shutdown(): void;
|
|
108
130
|
private mapSDKType;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-replay.d.ts","sourceRoot":"","sources":["../../src/session-replay.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,OAAO,EASR,MAAM,2BAA2B,CAAC;AAKnC,OAAO,EACL,aAAa,EACb,yBAAyB,EACzB,kCAAkC,EAInC,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAEL,gBAAgB,EASjB,MAAM,aAAa,CAAC;AAWrB,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAuB,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAavF,OAAO,EACL,sBAAsB,EACtB,0BAA0B,IAAI,mCAAmC,EAIjE,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AAC,wBAAwB;IAkChC,mBAAmB,cACN,gBAAgB;;kDAmC3B;IAEF,mBAAmB,aAgBjB;IAEF,WAAW;IAIX,YAAY;IAIZ,KAAK;YAIS,MAAM;IAMpB,IAAI;IAQE,KAAK,CAAC,QAAQ,UAAQ;IAS5B,QAAQ;IAYR,OAAO,CAAC,UAAU;IAYlB,OAAO,CAAC,WAAW;YAyBL,0BAA0B;CAUzC"}
|
|
@@ -44,6 +44,24 @@ var SessionReplay = /** @class */ (function () {
|
|
|
44
44
|
// Cache the dynamically imported record function
|
|
45
45
|
this.recordFunction = null;
|
|
46
46
|
this.recordEventsInFlight = false;
|
|
47
|
+
/**
|
|
48
|
+
* When false, capture is paused by a customer `stop()` (or `shutdown()`) call.
|
|
49
|
+
* Focus/targeting/session-change paths still invoke `recordEvents()`, but
|
|
50
|
+
* `getShouldRecord()` will refuse to start rrweb until `start()` or a new `init()`.
|
|
51
|
+
*/
|
|
52
|
+
this.recordingEnabled = true;
|
|
53
|
+
/**
|
|
54
|
+
* Bumped by `stop()` / `shutdown()` so an in-flight `_recordEvents()` that already
|
|
55
|
+
* passed `getShouldRecord()` cannot start rrweb after capture was paused.
|
|
56
|
+
*/
|
|
57
|
+
this.recordingGeneration = 0;
|
|
58
|
+
/**
|
|
59
|
+
* Set by customer `start()` so coordinated child iframes self-start instead of
|
|
60
|
+
* waiting for a parent signal that may never be resent. Kept until recording
|
|
61
|
+
* actually starts so a gated `start()` (targeting, sampling, remote capture)
|
|
62
|
+
* still self-starts when those gates later pass.
|
|
63
|
+
*/
|
|
64
|
+
this.startChildRecordingOnSetup = false;
|
|
47
65
|
this.pendingEmitEvents = [];
|
|
48
66
|
/** Current page URL, kept in sync with SPA navigations for URL-based masking */
|
|
49
67
|
this.currentPageUrl = '';
|
|
@@ -80,6 +98,9 @@ var SessionReplay = /** @class */ (function () {
|
|
|
80
98
|
};
|
|
81
99
|
this.focusListener = function () {
|
|
82
100
|
var _a;
|
|
101
|
+
if (!_this.recordingEnabled) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
83
104
|
if (_this.recordCancelCallback && _this.recordFunction) {
|
|
84
105
|
// Recording is already active. The on-focus full snapshot is tunable: when
|
|
85
106
|
// `captureFullSnapshotOnFocus` is false we skip it entirely so high focus-churn pages
|
|
@@ -335,6 +356,9 @@ var SessionReplay = /** @class */ (function () {
|
|
|
335
356
|
// Re-init should always tear down any previous URL-change subscription, even when the
|
|
336
357
|
// next config has no targeting config and we don't subscribe again.
|
|
337
358
|
(_a = this.urlChangeCleanup) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
359
|
+
// A new init always allows capture again. `stop()` only pauses the current instance.
|
|
360
|
+
this.recordingEnabled = true;
|
|
361
|
+
this.startChildRecordingOnSetup = false;
|
|
338
362
|
this.loggerProvider = new logger_1.SafeLoggerProvider(options.loggerProvider || new analytics_core_1.Logger());
|
|
339
363
|
Object.prototype.hasOwnProperty.call(options, 'logLevel') &&
|
|
340
364
|
this.loggerProvider.enable(options.logLevel);
|
|
@@ -696,6 +720,10 @@ var SessionReplay = /** @class */ (function () {
|
|
|
696
720
|
this.loggerProvider.warn("Session is not being recorded due to lack of config, please call sessionReplay.init.");
|
|
697
721
|
return false;
|
|
698
722
|
}
|
|
723
|
+
if (!this.recordingEnabled) {
|
|
724
|
+
this.loggerProvider.log("Session ".concat(this.identifiers.sessionId, " not being captured because recording was stopped."));
|
|
725
|
+
return false;
|
|
726
|
+
}
|
|
699
727
|
if (!this.config.captureEnabled) {
|
|
700
728
|
this.loggerProvider.log("Session ".concat(this.identifiers.sessionId, " not being captured due to capture being disabled for project or because the remote config could not be fetched."));
|
|
701
729
|
return false;
|
|
@@ -888,15 +916,17 @@ var SessionReplay = /** @class */ (function () {
|
|
|
888
916
|
});
|
|
889
917
|
});
|
|
890
918
|
};
|
|
919
|
+
SessionReplay.prototype.shouldAbandonRecordStart = function (generation) {
|
|
920
|
+
return !this.recordingEnabled || generation !== this.recordingGeneration;
|
|
921
|
+
};
|
|
891
922
|
SessionReplay.prototype._recordEvents = function (shouldLogMetadata) {
|
|
892
923
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
893
924
|
if (shouldLogMetadata === void 0) { shouldLogMetadata = true; }
|
|
894
925
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
895
|
-
var config, shouldRecord, sessionId, recordFunction, networkLoggingConfig, trackUrl, ignoredUrls, interactionConfig, loggingConfig, hooks, ugcFilterRules, crossOriginIframesEnabled, coordinateChildren, childMode,
|
|
896
|
-
var _m;
|
|
926
|
+
var config, shouldRecord, sessionId, generation, recordFunction, networkLoggingConfig, trackUrl, ignoredUrls, interactionConfig, loggingConfig, hooks, ugcFilterRules, crossOriginIframesEnabled, coordinateChildren, childMode, plugins, error_5;
|
|
897
927
|
var _this = this;
|
|
898
|
-
return tslib_1.__generator(this, function (
|
|
899
|
-
switch (
|
|
928
|
+
return tslib_1.__generator(this, function (_j) {
|
|
929
|
+
switch (_j.label) {
|
|
900
930
|
case 0:
|
|
901
931
|
config = this.config;
|
|
902
932
|
shouldRecord = this.getShouldRecord();
|
|
@@ -905,16 +935,20 @@ var SessionReplay = /** @class */ (function () {
|
|
|
905
935
|
return [2 /*return*/];
|
|
906
936
|
}
|
|
907
937
|
this.stopRecordingEvents();
|
|
938
|
+
generation = this.recordingGeneration;
|
|
908
939
|
return [4 /*yield*/, this.getRecordFunction()];
|
|
909
940
|
case 1:
|
|
910
|
-
recordFunction =
|
|
941
|
+
recordFunction = _j.sent();
|
|
911
942
|
// May be undefined if cannot import rrweb-record
|
|
912
|
-
if (!recordFunction) {
|
|
943
|
+
if (!recordFunction || this.shouldAbandonRecordStart(generation)) {
|
|
913
944
|
return [2 /*return*/];
|
|
914
945
|
}
|
|
915
946
|
return [4 /*yield*/, this.initializeNetworkObservers()];
|
|
916
947
|
case 2:
|
|
917
|
-
|
|
948
|
+
_j.sent();
|
|
949
|
+
if (this.shouldAbandonRecordStart(generation)) {
|
|
950
|
+
return [2 /*return*/];
|
|
951
|
+
}
|
|
918
952
|
networkLoggingConfig = (_b = config.loggingConfig) === null || _b === void 0 ? void 0 : _b.network;
|
|
919
953
|
trackUrl = (0, helpers_1.getServerUrl)(config.serverZone, config.trackServerUrl);
|
|
920
954
|
ignoredUrls = [constants_1.SESSION_REPLAY_SERVER_URL, constants_1.SESSION_REPLAY_EU_URL, constants_1.SESSION_REPLAY_STAGING_URL, trackUrl];
|
|
@@ -940,9 +974,9 @@ var SessionReplay = /** @class */ (function () {
|
|
|
940
974
|
: {};
|
|
941
975
|
ugcFilterRules = (interactionConfig === null || interactionConfig === void 0 ? void 0 : interactionConfig.enabled) && interactionConfig.ugcFilterRules ? interactionConfig.ugcFilterRules : [];
|
|
942
976
|
this.loggerProvider.log("Session Replay capture beginning for ".concat(sessionId, "."));
|
|
943
|
-
|
|
977
|
+
_j.label = 3;
|
|
944
978
|
case 3:
|
|
945
|
-
|
|
979
|
+
_j.trys.push([3, 5, , 6]);
|
|
946
980
|
crossOriginIframesEnabled = !!((_g = config.crossOriginIframes) === null || _g === void 0 ? void 0 : _g.enabled);
|
|
947
981
|
coordinateChildren = ((_h = config.crossOriginIframes) === null || _h === void 0 ? void 0 : _h.coordinateChildren) !== false;
|
|
948
982
|
childMode = crossOriginIframesEnabled && (0, cross_origin_iframes_1.isInIframe)();
|
|
@@ -950,7 +984,12 @@ var SessionReplay = /** @class */ (function () {
|
|
|
950
984
|
// Child mode: don't self-start; wait for a start signal from the parent.
|
|
951
985
|
// (The previous listener, if any, was already removed by stopRecordingEvents above.)
|
|
952
986
|
this.crossOriginParentSignalCleanup = (0, cross_origin_iframes_1.listenForParentSignals)({
|
|
953
|
-
onStart: function () {
|
|
987
|
+
onStart: function () {
|
|
988
|
+
if (!_this.recordingEnabled) {
|
|
989
|
+
return;
|
|
990
|
+
}
|
|
991
|
+
_this._recordEventsInChildMode(recordFunction, sessionId, config, hooks);
|
|
992
|
+
},
|
|
954
993
|
onStop: function () {
|
|
955
994
|
try {
|
|
956
995
|
// Only cancel the rrweb recording — do NOT call stopRecordingEvents() here,
|
|
@@ -965,34 +1004,43 @@ var SessionReplay = /** @class */ (function () {
|
|
|
965
1004
|
}
|
|
966
1005
|
},
|
|
967
1006
|
});
|
|
1007
|
+
// Customer start() must not wait for a parent signal: the parent may already
|
|
1008
|
+
// be recording and will not send another start. Init still waits.
|
|
1009
|
+
if (this.startChildRecordingOnSetup) {
|
|
1010
|
+
this.startChildRecordingOnSetup = false;
|
|
1011
|
+
this._recordEventsInChildMode(recordFunction, sessionId, config, hooks);
|
|
1012
|
+
}
|
|
968
1013
|
return [2 /*return*/];
|
|
969
1014
|
}
|
|
970
|
-
|
|
971
|
-
_k = recordFunction;
|
|
972
|
-
_l = [tslib_1.__assign({}, this.buildRRWebRecordOptions(config, hooks, function (event) {
|
|
973
|
-
if (_this.shouldOptOut()) {
|
|
974
|
-
_this.loggerProvider.log("Opting session ".concat(sessionId, " out of recording due to optOut config."));
|
|
975
|
-
_this.stopRecordingEvents();
|
|
976
|
-
_this.sendEvents();
|
|
977
|
-
return;
|
|
978
|
-
}
|
|
979
|
-
if (event.type === rrweb_types_1.EventType.Meta) {
|
|
980
|
-
event.data.href = (0, helpers_1.getPageUrl)(event.data.href, ugcFilterRules);
|
|
981
|
-
}
|
|
982
|
-
if (_this.eventCompressor) {
|
|
983
|
-
// Schedule processing during idle time if the browser supports requestIdleCallback
|
|
984
|
-
_this.eventCompressor.enqueueEvent(event, sessionId);
|
|
985
|
-
}
|
|
986
|
-
else {
|
|
987
|
-
// eventCompressor is not yet ready (concurrent call racing _init()).
|
|
988
|
-
// Buffer the event so it can be flushed once the compressor is initialized.
|
|
989
|
-
_this.pendingEmitEvents.push({ event: event, sessionId: sessionId });
|
|
990
|
-
}
|
|
991
|
-
}, 'Error while capturing replay: '))];
|
|
992
|
-
_m = {};
|
|
1015
|
+
this.startChildRecordingOnSetup = false;
|
|
993
1016
|
return [4 /*yield*/, this.getRecordingPlugins(loggingConfig)];
|
|
994
1017
|
case 4:
|
|
995
|
-
|
|
1018
|
+
plugins = _j.sent();
|
|
1019
|
+
if (this.shouldAbandonRecordStart(generation)) {
|
|
1020
|
+
return [2 /*return*/];
|
|
1021
|
+
}
|
|
1022
|
+
this.recordCancelCallback = recordFunction(tslib_1.__assign(tslib_1.__assign({}, this.buildRRWebRecordOptions(config, hooks, function (event) {
|
|
1023
|
+
if (_this.shouldOptOut() || !_this.recordingEnabled) {
|
|
1024
|
+
_this.loggerProvider.log(_this.shouldOptOut()
|
|
1025
|
+
? "Opting session ".concat(sessionId, " out of recording due to optOut config.")
|
|
1026
|
+
: "Session Replay capture stopping for ".concat(sessionId, "."));
|
|
1027
|
+
_this.stopRecordingEvents();
|
|
1028
|
+
_this.sendEvents();
|
|
1029
|
+
return;
|
|
1030
|
+
}
|
|
1031
|
+
if (event.type === rrweb_types_1.EventType.Meta) {
|
|
1032
|
+
event.data.href = (0, helpers_1.getPageUrl)(event.data.href, ugcFilterRules);
|
|
1033
|
+
}
|
|
1034
|
+
if (_this.eventCompressor) {
|
|
1035
|
+
// Schedule processing during idle time if the browser supports requestIdleCallback
|
|
1036
|
+
_this.eventCompressor.enqueueEvent(event, sessionId);
|
|
1037
|
+
}
|
|
1038
|
+
else {
|
|
1039
|
+
// eventCompressor is not yet ready (concurrent call racing _init()).
|
|
1040
|
+
// Buffer the event so it can be flushed once the compressor is initialized.
|
|
1041
|
+
_this.pendingEmitEvents.push({ event: event, sessionId: sessionId });
|
|
1042
|
+
}
|
|
1043
|
+
}, 'Error while capturing replay: ')), { plugins: plugins, recordCrossOriginIframes: crossOriginIframesEnabled }));
|
|
996
1044
|
if (crossOriginIframesEnabled && !childMode && coordinateChildren) {
|
|
997
1045
|
if (!this.crossOriginIframeCoordinator) {
|
|
998
1046
|
this.crossOriginIframeCoordinator = new cross_origin_iframes_1.CrossOriginIframeCoordinator();
|
|
@@ -1005,7 +1053,7 @@ var SessionReplay = /** @class */ (function () {
|
|
|
1005
1053
|
}
|
|
1006
1054
|
return [3 /*break*/, 6];
|
|
1007
1055
|
case 5:
|
|
1008
|
-
error_5 =
|
|
1056
|
+
error_5 = _j.sent();
|
|
1009
1057
|
this.loggerProvider.warn('Failed to initialize session replay:', error_5);
|
|
1010
1058
|
return [3 /*break*/, 6];
|
|
1011
1059
|
case 6: return [2 /*return*/];
|
|
@@ -1075,6 +1123,31 @@ var SessionReplay = /** @class */ (function () {
|
|
|
1075
1123
|
var _a;
|
|
1076
1124
|
return (_a = this.identifiers) === null || _a === void 0 ? void 0 : _a.sessionId;
|
|
1077
1125
|
};
|
|
1126
|
+
SessionReplay.prototype.start = function () {
|
|
1127
|
+
return (0, analytics_core_1.returnWrapper)(this._start());
|
|
1128
|
+
};
|
|
1129
|
+
SessionReplay.prototype._start = function () {
|
|
1130
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1131
|
+
return tslib_1.__generator(this, function (_a) {
|
|
1132
|
+
switch (_a.label) {
|
|
1133
|
+
case 0:
|
|
1134
|
+
this.recordingEnabled = true;
|
|
1135
|
+
this.startChildRecordingOnSetup = true;
|
|
1136
|
+
return [4 /*yield*/, this.recordEvents()];
|
|
1137
|
+
case 1:
|
|
1138
|
+
_a.sent();
|
|
1139
|
+
return [2 /*return*/];
|
|
1140
|
+
}
|
|
1141
|
+
});
|
|
1142
|
+
});
|
|
1143
|
+
};
|
|
1144
|
+
SessionReplay.prototype.stop = function () {
|
|
1145
|
+
this.recordingEnabled = false;
|
|
1146
|
+
this.startChildRecordingOnSetup = false;
|
|
1147
|
+
this.recordingGeneration++;
|
|
1148
|
+
this.stopRecordingEvents();
|
|
1149
|
+
this.sendEvents();
|
|
1150
|
+
};
|
|
1078
1151
|
SessionReplay.prototype.flush = function (useRetry) {
|
|
1079
1152
|
var _a;
|
|
1080
1153
|
if (useRetry === void 0) { useRetry = false; }
|
|
@@ -1091,6 +1164,9 @@ var SessionReplay = /** @class */ (function () {
|
|
|
1091
1164
|
};
|
|
1092
1165
|
SessionReplay.prototype.shutdown = function () {
|
|
1093
1166
|
var _a, _b;
|
|
1167
|
+
this.recordingEnabled = false;
|
|
1168
|
+
this.startChildRecordingOnSetup = false;
|
|
1169
|
+
this.recordingGeneration++;
|
|
1094
1170
|
(_a = this.urlChangeCleanup) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
1095
1171
|
(_b = this.crossOriginParentSignalCleanup) === null || _b === void 0 ? void 0 : _b.call(this);
|
|
1096
1172
|
this.crossOriginParentSignalCleanup = null;
|