@amplitude/session-replay-browser 1.29.8 → 1.30.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 +1 -1
- package/lib/cjs/config/local-config.d.ts +1 -3
- package/lib/cjs/config/local-config.d.ts.map +1 -1
- package/lib/cjs/config/local-config.js +10 -3
- package/lib/cjs/config/local-config.js.map +1 -1
- package/lib/cjs/config/types.d.ts +32 -7
- package/lib/cjs/config/types.d.ts.map +1 -1
- package/lib/cjs/config/types.js.map +1 -1
- package/lib/cjs/events/event-compressor.js +1 -1
- package/lib/cjs/events/event-compressor.js.map +1 -1
- package/lib/cjs/helpers.d.ts +1 -3
- package/lib/cjs/helpers.d.ts.map +1 -1
- package/lib/cjs/hooks/click.d.ts +2 -1
- package/lib/cjs/hooks/click.d.ts.map +1 -1
- package/lib/cjs/hooks/click.js +2 -2
- package/lib/cjs/hooks/click.js.map +1 -1
- package/lib/cjs/session-replay.d.ts.map +1 -1
- package/lib/cjs/session-replay.js +38 -37
- package/lib/cjs/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/config/local-config.d.ts +1 -3
- package/lib/esm/config/local-config.d.ts.map +1 -1
- package/lib/esm/config/local-config.js +10 -3
- package/lib/esm/config/local-config.js.map +1 -1
- package/lib/esm/config/types.d.ts +32 -7
- package/lib/esm/config/types.d.ts.map +1 -1
- package/lib/esm/config/types.js.map +1 -1
- package/lib/esm/events/event-compressor.js +1 -1
- package/lib/esm/events/event-compressor.js.map +1 -1
- package/lib/esm/helpers.d.ts +1 -3
- package/lib/esm/helpers.d.ts.map +1 -1
- package/lib/esm/hooks/click.d.ts +2 -1
- package/lib/esm/hooks/click.d.ts.map +1 -1
- package/lib/esm/hooks/click.js +2 -2
- package/lib/esm/hooks/click.js.map +1 -1
- package/lib/esm/session-replay.d.ts.map +1 -1
- package/lib/esm/session-replay.js +38 -37
- package/lib/esm/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-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 +2 -2
package/README.md
CHANGED
|
@@ -103,7 +103,7 @@ sessionReplay.shutdown()
|
|
|
103
103
|
|`storeType`|`string`|No|`idb`|Specifies how replay events should be stored. `idb` uses IndexedDB to persist replay events when all events cannot be sent during capture. `memory` stores replay events only in memory, meaning events are lost when the page is closed. If IndexedDB is unavailable, the system falls back to `memory`.|
|
|
104
104
|
|`performanceConfig.enabled`|`boolean`|No|`true`|If enabled, event compression will be deferred to occur during the browser's idle periods.|
|
|
105
105
|
|`performanceConfig.timeout`|`number`|No|`undefined`|Optional timeout in milliseconds for the `requestIdleCallback` API. If specified, this value will be used to set a maximum time for the browser to wait before executing the deferred compression task, even if the browser is not idle.|
|
|
106
|
-
|`
|
|
106
|
+
|`useWebWorker`|`boolean`|No|`false`|If true, the SDK will compress replay events using a web worker. This offloads compression to a separate thread, improving performance on the main thread.|
|
|
107
107
|
|
|
108
108
|
## Bundle Size Optimization
|
|
109
109
|
The Session Replay SDK uses dynamic imports to optimize bundle size and improve initial page load performance. Key modules are loaded on-demand rather than being included in the initial bundle:
|
|
@@ -19,9 +19,7 @@ export declare class SessionReplayLocalConfig extends Config implements ISession
|
|
|
19
19
|
version?: SessionReplayVersion;
|
|
20
20
|
storeType: StoreType;
|
|
21
21
|
performanceConfig?: SessionReplayPerformanceConfig;
|
|
22
|
-
|
|
23
|
-
useWebWorker: boolean;
|
|
24
|
-
};
|
|
22
|
+
useWebWorker?: boolean;
|
|
25
23
|
applyBackgroundColorToBlockedElements?: boolean;
|
|
26
24
|
omitElementTags?: {
|
|
27
25
|
script?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-config.d.ts","sourceRoot":"","sources":["../../../src/config/local-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAOrF,OAAO,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC5E,OAAO,EACL,wBAAwB,IAAI,yBAAyB,EACrD,iBAAiB,EACjB,aAAa,EACb,8BAA8B,EAC9B,oBAAoB,EACrB,MAAM,SAAS,CAAC;AAIjB,eAAO,MAAM,gBAAgB;;;;;CAK3B,CAAC;AAEH,qBAAa,wBAAyB,SAAQ,MAAO,YAAW,yBAAyB;IACvF,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,OAAO,CAAC,EAAE,oBAAoB,CAAC;IAC/B,SAAS,EAAE,SAAS,CAAC;IACrB,iBAAiB,CAAC,EAAE,8BAA8B,CAAC;IACnD,YAAY,CAAC,EAAE
|
|
1
|
+
{"version":3,"file":"local-config.d.ts","sourceRoot":"","sources":["../../../src/config/local-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAOrF,OAAO,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC5E,OAAO,EACL,wBAAwB,IAAI,yBAAyB,EACrD,iBAAiB,EACjB,aAAa,EACb,8BAA8B,EAC9B,oBAAoB,EACrB,MAAM,SAAS,CAAC;AAIjB,eAAO,MAAM,gBAAgB;;;;;CAK3B,CAAC;AAEH,qBAAa,wBAAyB,SAAQ,MAAO,YAAW,yBAAyB;IACvF,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,OAAO,CAAC,EAAE,oBAAoB,CAAC;IAC/B,SAAS,EAAE,SAAS,CAAC;IACrB,iBAAiB,CAAC,EAAE,8BAA8B,CAAC;IACnD,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,qCAAqC,CAAC,EAAE,OAAO,CAAC;IAChD,eAAe,CAAC,EAAE;QAChB,MAAM,CAAC,EAAE,OAAO,CAAC;QACjB,OAAO,CAAC,EAAE,OAAO,CAAC;KACnB,CAAC;IACF,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,oBAAoB,CAAC,EAAE,OAAO,CAAC;gBAEnB,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,oBAAoB;CAsD1D"}
|
|
@@ -17,7 +17,7 @@ var SessionReplayLocalConfig = /** @class */ (function (_super) {
|
|
|
17
17
|
tslib_1.__extends(SessionReplayLocalConfig, _super);
|
|
18
18
|
function SessionReplayLocalConfig(apiKey, options) {
|
|
19
19
|
var _this = this;
|
|
20
|
-
var _a, _b, _c, _d, _e;
|
|
20
|
+
var _a, _b, _c, _d, _e, _f;
|
|
21
21
|
var defaultConfig = (0, exports.getDefaultConfig)();
|
|
22
22
|
_this = _super.call(this, tslib_1.__assign(tslib_1.__assign({ transportProvider: defaultConfig.transportProvider, loggerProvider: new logger_1.SafeLoggerProvider(options.loggerProvider || defaultConfig.loggerProvider) }, options), { apiKey: apiKey })) || this;
|
|
23
23
|
_this.flushMaxRetries =
|
|
@@ -50,8 +50,15 @@ var SessionReplayLocalConfig = /** @class */ (function (_super) {
|
|
|
50
50
|
if (options.debugMode) {
|
|
51
51
|
_this.debugMode = options.debugMode;
|
|
52
52
|
}
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
// Support both new useWebWorker and legacy experimental.useWebWorker for backwards compatibility
|
|
54
|
+
if (options.useWebWorker !== undefined) {
|
|
55
|
+
_this.useWebWorker = options.useWebWorker;
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
var legacyOptions = options;
|
|
59
|
+
if (((_f = legacyOptions.experimental) === null || _f === void 0 ? void 0 : _f.useWebWorker) !== undefined) {
|
|
60
|
+
_this.useWebWorker = legacyOptions.experimental.useWebWorker;
|
|
61
|
+
}
|
|
55
62
|
}
|
|
56
63
|
if (options.omitElementTags) {
|
|
57
64
|
_this.omitElementTags = options.omitElementTags;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-config.js","sourceRoot":"","sources":["../../../src/config/local-config.ts"],"names":[],"mappings":";;;;AAAA,4DAAqF;AACrF,0CAKsB;AAStB,oCAA+C;AAC/C,sCAAoD;AAE7C,IAAM,gBAAgB,GAAG,cAAM,OAAA,CAAC;IACrC,eAAe,EAAE,CAAC;IAClB,QAAQ,EAAE,yBAAQ,CAAC,IAAI;IACvB,cAAc,EAAE,IAAI,uBAAM,EAAE;IAC5B,iBAAiB,EAAE,IAAI,+BAAc,EAAE;CACxC,CAAC,EALoC,CAKpC,CAAC;AALU,QAAA,gBAAgB,oBAK1B;AAEH;IAA8C,oDAAM;IAsBlD,kCAAY,MAAc,EAAE,OAA6B;QAAzD,
|
|
1
|
+
{"version":3,"file":"local-config.js","sourceRoot":"","sources":["../../../src/config/local-config.ts"],"names":[],"mappings":";;;;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AAI,CAAC,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;SAChD;;IACH,CAAC;IACH,+BAAC;AAAD,CAAC,AA5ED,CAA8C,uBAAM,GA4EnD;AA5EY,4DAAwB","sourcesContent":["import { Config, Logger, FetchTransport, LogLevel } from '@amplitude/analytics-core';\nimport {\n DEFAULT_PERFORMANCE_CONFIG,\n DEFAULT_SAMPLE_RATE,\n DEFAULT_SERVER_ZONE,\n DEFAULT_URL_CHANGE_POLLING_INTERVAL,\n} from '../constants';\nimport { SessionReplayOptions, StoreType } from '../typings/session-replay';\nimport {\n SessionReplayLocalConfig as ISessionReplayLocalConfig,\n InteractionConfig,\n PrivacyConfig,\n SessionReplayPerformanceConfig,\n SessionReplayVersion,\n} from './types';\nimport { SafeLoggerProvider } from '../logger';\nimport { validateUGCFilterRules } from '../helpers';\n\nexport const getDefaultConfig = () => ({\n flushMaxRetries: 2,\n logLevel: LogLevel.Warn,\n loggerProvider: new Logger(),\n transportProvider: new FetchTransport(),\n});\n\nexport class SessionReplayLocalConfig extends Config implements ISessionReplayLocalConfig {\n apiKey: string;\n sampleRate: number;\n privacyConfig?: PrivacyConfig;\n interactionConfig?: InteractionConfig;\n debugMode?: boolean;\n configServerUrl?: string;\n trackServerUrl?: string;\n shouldInlineStylesheet?: boolean;\n version?: SessionReplayVersion;\n storeType: StoreType;\n performanceConfig?: SessionReplayPerformanceConfig;\n useWebWorker?: boolean;\n applyBackgroundColorToBlockedElements?: boolean;\n omitElementTags?: {\n script?: boolean;\n comment?: boolean;\n };\n enableUrlChangePolling?: boolean;\n urlChangePollingInterval?: number;\n captureDocumentTitle?: boolean;\n\n constructor(apiKey: string, options: SessionReplayOptions) {\n const defaultConfig = getDefaultConfig();\n super({\n transportProvider: defaultConfig.transportProvider,\n loggerProvider: new SafeLoggerProvider(options.loggerProvider || defaultConfig.loggerProvider),\n ...options,\n apiKey,\n });\n this.flushMaxRetries =\n options.flushMaxRetries !== undefined && options.flushMaxRetries <= defaultConfig.flushMaxRetries\n ? options.flushMaxRetries\n : defaultConfig.flushMaxRetries;\n\n this.apiKey = apiKey;\n this.sampleRate = options.sampleRate || DEFAULT_SAMPLE_RATE;\n this.serverZone = options.serverZone || DEFAULT_SERVER_ZONE;\n this.configServerUrl = options.configServerUrl;\n this.trackServerUrl = options.trackServerUrl;\n this.shouldInlineStylesheet = options.shouldInlineStylesheet;\n this.version = options.version;\n this.performanceConfig = options.performanceConfig || DEFAULT_PERFORMANCE_CONFIG;\n this.storeType = options.storeType ?? 'idb';\n this.applyBackgroundColorToBlockedElements = options.applyBackgroundColorToBlockedElements ?? false;\n this.enableUrlChangePolling = options.enableUrlChangePolling ?? false;\n this.urlChangePollingInterval = options.urlChangePollingInterval ?? DEFAULT_URL_CHANGE_POLLING_INTERVAL;\n this.captureDocumentTitle = options.captureDocumentTitle ?? false;\n\n if (options.privacyConfig) {\n this.privacyConfig = options.privacyConfig;\n }\n if (options.interactionConfig) {\n this.interactionConfig = options.interactionConfig;\n\n // validate ugcFilterRules, throw error if invalid - throw error at the beginning of the config\n if (this.interactionConfig.ugcFilterRules) {\n validateUGCFilterRules(this.interactionConfig.ugcFilterRules);\n }\n }\n if (options.debugMode) {\n this.debugMode = options.debugMode;\n }\n // Support both new useWebWorker and legacy experimental.useWebWorker for backwards compatibility\n if (options.useWebWorker !== undefined) {\n this.useWebWorker = options.useWebWorker;\n } else {\n const legacyOptions = options as { experimental?: { useWebWorker?: boolean } };\n if (legacyOptions.experimental?.useWebWorker !== undefined) {\n this.useWebWorker = legacyOptions.experimental.useWebWorker;\n }\n }\n if (options.omitElementTags) {\n this.omitElementTags = options.omitElementTags;\n }\n }\n}\n"]}
|
|
@@ -121,14 +121,12 @@ export interface SessionReplayLocalConfig extends IConfig {
|
|
|
121
121
|
*/
|
|
122
122
|
storeType: StoreType;
|
|
123
123
|
/**
|
|
124
|
-
*
|
|
124
|
+
* If true, the SDK will compress replay events using a web worker.
|
|
125
|
+
* This offloads compression to a separate thread, improving performance on the main thread.
|
|
126
|
+
*
|
|
127
|
+
* @defaultValue false
|
|
125
128
|
*/
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* If the SDK should compress the replay events using a webworker.
|
|
129
|
-
*/
|
|
130
|
-
useWebWorker: boolean;
|
|
131
|
-
};
|
|
129
|
+
useWebWorker?: boolean;
|
|
132
130
|
userProperties?: {
|
|
133
131
|
[key: string]: any;
|
|
134
132
|
};
|
|
@@ -223,6 +221,33 @@ export interface SessionReplayPerformanceConfig {
|
|
|
223
221
|
* before executing the deferred compression task, even if the browser is not idle.
|
|
224
222
|
*/
|
|
225
223
|
timeout?: number;
|
|
224
|
+
/**
|
|
225
|
+
* Performance configuration for interaction tracking (clicks, scrolls).
|
|
226
|
+
*/
|
|
227
|
+
interaction?: InteractionPerformanceConfig;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Performance configuration for interaction tracking, specifically for CSS selector generation.
|
|
231
|
+
*/
|
|
232
|
+
export interface InteractionPerformanceConfig {
|
|
233
|
+
/**
|
|
234
|
+
* Maximum time in milliseconds allowed for CSS selector generation.
|
|
235
|
+
* If selector generation takes longer than this, it will throw a timeout error.
|
|
236
|
+
* Default: undefined (no timeout limit)
|
|
237
|
+
*/
|
|
238
|
+
timeoutMs?: number;
|
|
239
|
+
/**
|
|
240
|
+
* Maximum number of attempts to optimize/simplify the CSS selector path.
|
|
241
|
+
* Higher values may produce shorter selectors but take longer to compute.
|
|
242
|
+
* Default: 10000
|
|
243
|
+
*/
|
|
244
|
+
maxNumberOfTries?: number;
|
|
245
|
+
/**
|
|
246
|
+
* Maximum number of CSS selector combinations to test for uniqueness.
|
|
247
|
+
* If more combinations would be generated, falls back to a simpler strategy.
|
|
248
|
+
* Default: 1000
|
|
249
|
+
*/
|
|
250
|
+
threshold?: number;
|
|
226
251
|
}
|
|
227
252
|
export type SessionReplayType = 'standalone' | 'plugin' | 'segment';
|
|
228
253
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
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,CAAC;CAC5C;AAED;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC3C;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,iBAAiB,GAAG,YAAY,GAAG,QAAQ,GAAG,SAAS,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/config/types.ts"],"names":[],"mappings":";;;AAkDa,QAAA,kBAAkB,GAAG,QAAQ,CAAC","sourcesContent":["import { IConfig, LogLevel, ILogger } from '@amplitude/analytics-core';\nimport { StoreType, ConsoleLogLevel } from '../typings/session-replay';\nimport { TargetingFlag } from '@amplitude/targeting';\n\nexport interface SamplingConfig {\n sample_rate: number;\n capture_enabled: boolean;\n}\n\nexport interface InteractionConfig {\n trackEveryNms?: number;\n enabled: boolean; // defaults to false\n batch: boolean; // defaults to false\n /**\n * UGC filter rules.\n */\n ugcFilterRules?: UGCFilterRule[];\n}\n\nexport interface LoggingConfig {\n console: {\n enabled: boolean;\n levels: ConsoleLogLevel[];\n };\n network?: {\n enabled: boolean;\n };\n}\n\nexport type TargetingConfig = TargetingFlag;\n\nexport type SessionReplayRemoteConfig = {\n sr_sampling_config?: SamplingConfig;\n sr_privacy_config?: PrivacyConfig;\n sr_interaction_config?: InteractionConfig;\n sr_logging_config?: LoggingConfig;\n sr_targeting_config?: TargetingConfig;\n};\n\nexport interface SessionReplayRemoteConfigAPIResponse {\n configs: {\n sessionReplay: SessionReplayRemoteConfig;\n };\n}\n\nexport type MaskLevel =\n | 'light' // only mask a subset of inputs that's deemed sensitive - password, credit card, telephone #, email. These are information we never want to capture.\n | 'medium' // mask all inputs\n | 'conservative'; // mask all inputs and all texts\n\nexport const DEFAULT_MASK_LEVEL = 'medium';\n\n// err on the side of excluding more\nexport type PrivacyConfig = {\n blockSelector?: string | string[]; // exclude in the UI\n defaultMaskLevel?: MaskLevel;\n maskSelector?: string[];\n unmaskSelector?: string[];\n};\n\n/**\n * UGC filter rule.\n */\nexport type UGCFilterRule = {\n /**\n * The selector of the UGC element.\n */\n selector: string;\n /**\n * The replacement text for the UGC element.\n */\n replacement: string;\n};\n\nexport interface SessionReplayLocalConfig extends IConfig {\n apiKey: string;\n loggerProvider: ILogger;\n /**\n * LogLevel.None or LogLevel.Error or LogLevel.Warn or LogLevel.Verbose or LogLevel.Debug.\n * Sets the log level.\n *\n * @defaultValue LogLevel.Warn\n */\n logLevel: LogLevel;\n /**\n * The maximum number of retries allowed for sending replay events.\n * Once this limit is reached, failed events will no longer be sent.\n *\n * @defaultValue 2\n */\n flushMaxRetries: number;\n /**\n * Use this option to control how many sessions to select for replay collection.\n * The number should be a decimal between 0 and 1, for example 0.4, representing\n * the fraction of sessions to have randomly selected for replay collection.\n * Over a large number of sessions, 0.4 would select 40% of those sessions.\n * Sample rates as small as six decimal places (0.000001) are supported.\n *\n * @defaultValue 0\n */\n sampleRate: number;\n privacyConfig?: PrivacyConfig;\n /**\n * Adds additional debug event property to help debug instrumentation issues\n * (such as mismatching apps). Only recommended for debugging initial setup,\n * and not recommended for production.\n */\n debugMode?: boolean;\n /**\n * Specifies the endpoint URL to fetch remote configuration.\n * If provided, it overrides the default server zone configuration.\n */\n configServerUrl?: string;\n /**\n * Specifies the endpoint URL for sending session replay data.\n * If provided, it overrides the default server zone configuration.\n */\n trackServerUrl?: string;\n /**\n * If stylesheets are inlined, the contents of the stylesheet will be stored.\n * During replay, the stored stylesheet will be used instead of attempting to fetch it remotely.\n * This prevents replays from appearing broken due to missing stylesheets.\n * Note: Inlining stylesheets may not work in all cases.\n */\n shouldInlineStylesheet?: boolean;\n version?: SessionReplayVersion;\n /**\n * Performance configuration config. If enabled, we will defer compression\n * to be done during the browser's idle periods.\n */\n performanceConfig?: SessionReplayPerformanceConfig;\n /**\n * Specifies how replay events should be stored. `idb` uses IndexedDB to persist replay events\n * when all events cannot be sent during capture. `memory` stores replay events only in memory,\n * meaning events are lost when the page is closed. If IndexedDB is unavailable, the system falls back to `memory`.\n */\n storeType: StoreType;\n\n /**\n *
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/config/types.ts"],"names":[],"mappings":";;;AAkDa,QAAA,kBAAkB,GAAG,QAAQ,CAAC","sourcesContent":["import { IConfig, LogLevel, ILogger } from '@amplitude/analytics-core';\nimport { StoreType, ConsoleLogLevel } from '../typings/session-replay';\nimport { TargetingFlag } from '@amplitude/targeting';\n\nexport interface SamplingConfig {\n sample_rate: number;\n capture_enabled: boolean;\n}\n\nexport interface InteractionConfig {\n trackEveryNms?: number;\n enabled: boolean; // defaults to false\n batch: boolean; // defaults to false\n /**\n * UGC filter rules.\n */\n ugcFilterRules?: UGCFilterRule[];\n}\n\nexport interface LoggingConfig {\n console: {\n enabled: boolean;\n levels: ConsoleLogLevel[];\n };\n network?: {\n enabled: boolean;\n };\n}\n\nexport type TargetingConfig = TargetingFlag;\n\nexport type SessionReplayRemoteConfig = {\n sr_sampling_config?: SamplingConfig;\n sr_privacy_config?: PrivacyConfig;\n sr_interaction_config?: InteractionConfig;\n sr_logging_config?: LoggingConfig;\n sr_targeting_config?: TargetingConfig;\n};\n\nexport interface SessionReplayRemoteConfigAPIResponse {\n configs: {\n sessionReplay: SessionReplayRemoteConfig;\n };\n}\n\nexport type MaskLevel =\n | 'light' // only mask a subset of inputs that's deemed sensitive - password, credit card, telephone #, email. These are information we never want to capture.\n | 'medium' // mask all inputs\n | 'conservative'; // mask all inputs and all texts\n\nexport const DEFAULT_MASK_LEVEL = 'medium';\n\n// err on the side of excluding more\nexport type PrivacyConfig = {\n blockSelector?: string | string[]; // exclude in the UI\n defaultMaskLevel?: MaskLevel;\n maskSelector?: string[];\n unmaskSelector?: string[];\n};\n\n/**\n * UGC filter rule.\n */\nexport type UGCFilterRule = {\n /**\n * The selector of the UGC element.\n */\n selector: string;\n /**\n * The replacement text for the UGC element.\n */\n replacement: string;\n};\n\nexport interface SessionReplayLocalConfig extends IConfig {\n apiKey: string;\n loggerProvider: ILogger;\n /**\n * LogLevel.None or LogLevel.Error or LogLevel.Warn or LogLevel.Verbose or LogLevel.Debug.\n * Sets the log level.\n *\n * @defaultValue LogLevel.Warn\n */\n logLevel: LogLevel;\n /**\n * The maximum number of retries allowed for sending replay events.\n * Once this limit is reached, failed events will no longer be sent.\n *\n * @defaultValue 2\n */\n flushMaxRetries: number;\n /**\n * Use this option to control how many sessions to select for replay collection.\n * The number should be a decimal between 0 and 1, for example 0.4, representing\n * the fraction of sessions to have randomly selected for replay collection.\n * Over a large number of sessions, 0.4 would select 40% of those sessions.\n * Sample rates as small as six decimal places (0.000001) are supported.\n *\n * @defaultValue 0\n */\n sampleRate: number;\n privacyConfig?: PrivacyConfig;\n /**\n * Adds additional debug event property to help debug instrumentation issues\n * (such as mismatching apps). Only recommended for debugging initial setup,\n * and not recommended for production.\n */\n debugMode?: boolean;\n /**\n * Specifies the endpoint URL to fetch remote configuration.\n * If provided, it overrides the default server zone configuration.\n */\n configServerUrl?: string;\n /**\n * Specifies the endpoint URL for sending session replay data.\n * If provided, it overrides the default server zone configuration.\n */\n trackServerUrl?: string;\n /**\n * If stylesheets are inlined, the contents of the stylesheet will be stored.\n * During replay, the stored stylesheet will be used instead of attempting to fetch it remotely.\n * This prevents replays from appearing broken due to missing stylesheets.\n * Note: Inlining stylesheets may not work in all cases.\n */\n shouldInlineStylesheet?: boolean;\n version?: SessionReplayVersion;\n /**\n * Performance configuration config. If enabled, we will defer compression\n * to be done during the browser's idle periods.\n */\n performanceConfig?: SessionReplayPerformanceConfig;\n /**\n * Specifies how replay events should be stored. `idb` uses IndexedDB to persist replay events\n * when all events cannot be sent during capture. `memory` stores replay events only in memory,\n * meaning events are lost when the page is closed. If IndexedDB is unavailable, the system falls back to `memory`.\n */\n storeType: StoreType;\n\n /**\n * If true, the SDK will compress replay events using a web worker.\n * This offloads compression to a separate thread, improving performance on the main thread.\n *\n * @defaultValue false\n */\n useWebWorker?: boolean;\n\n userProperties?: { [key: string]: any };\n\n /**\n * Remove certain parts of the DOM from being captured. These are typically ignored when blocking by selectors.\n */\n omitElementTags?: {\n /**\n * If true, removes script tags from the DOM, but not noscript tags.\n */\n script?: boolean;\n /**\n * If true, removes comment tags from the DOM.\n */\n comment?: boolean;\n };\n\n /**\n * If true, applies a background color to blocked elements in the replay.\n * This helps visualize which elements are blocked from being captured.\n */\n applyBackgroundColorToBlockedElements?: boolean;\n /**\n * Enables URL change polling as a fallback for SPA route tracking.\n * When enabled, the SDK will periodically check for URL changes every second\n * in addition to patching the History API. This is useful for edge cases where\n * route changes might bypass the standard History API methods.\n *\n * @defaultValue false\n */\n enableUrlChangePolling?: boolean;\n /**\n * Specifies the interval in milliseconds for URL change polling when enableUrlChangePolling is true.\n * The SDK will check for URL changes at this interval as a fallback for SPA route tracking.\n *\n * @defaultValue 1000\n */\n urlChangePollingInterval?: number;\n /**\n * Whether to capture document title in URL change events.\n * When disabled, the title field will be empty in URL change events.\n *\n * @defaultValue false\n */\n captureDocumentTitle?: boolean;\n interactionConfig?: InteractionConfig;\n}\n\nexport interface SessionReplayJoinedConfig extends SessionReplayLocalConfig {\n captureEnabled?: boolean;\n interactionConfig?: InteractionConfig;\n loggingConfig?: LoggingConfig;\n targetingConfig?: TargetingConfig;\n}\n\nexport interface SessionReplayConfigs {\n localConfig: SessionReplayLocalConfig;\n joinedConfig: SessionReplayJoinedConfig;\n remoteConfig: SessionReplayRemoteConfig | undefined;\n}\nexport interface SessionReplayJoinedConfigGenerator {\n generateJoinedConfig: () => Promise<SessionReplayConfigs>;\n}\n\nexport interface SessionReplayMetadata {\n remoteConfig: SessionReplayRemoteConfig | undefined;\n localConfig: SessionReplayLocalConfig;\n joinedConfig: SessionReplayJoinedConfig;\n framework?: {\n name: string;\n version: string;\n };\n sessionId: string | number | undefined;\n hashValue?: number;\n sampleRate: number;\n replaySDKType: string | null;\n replaySDKVersion: string | undefined;\n standaloneSDKType: string;\n standaloneSDKVersion: string | undefined;\n}\n\nexport interface SessionReplayVersion {\n version: string;\n type: SessionReplayType;\n}\n\n/**\n * Configuration options for session replay performance.\n */\nexport interface SessionReplayPerformanceConfig {\n /**\n * If enabled, event compression will be deferred to occur during the browser's idle periods.\n */\n enabled: boolean;\n /**\n * Optional timeout in milliseconds for the `requestIdleCallback` API.\n * If specified, this value will be used to set a maximum time for the browser to wait\n * before executing the deferred compression task, even if the browser is not idle.\n */\n timeout?: number;\n /**\n * Performance configuration for interaction tracking (clicks, scrolls).\n */\n interaction?: InteractionPerformanceConfig;\n}\n\n/**\n * Performance configuration for interaction tracking, specifically for CSS selector generation.\n */\nexport interface InteractionPerformanceConfig {\n /**\n * Maximum time in milliseconds allowed for CSS selector generation.\n * If selector generation takes longer than this, it will throw a timeout error.\n * Default: undefined (no timeout limit)\n */\n timeoutMs?: number;\n /**\n * Maximum number of attempts to optimize/simplify the CSS selector path.\n * Higher values may produce shorter selectors but take longer to compute.\n * Default: 10000\n */\n maxNumberOfTries?: number;\n /**\n * Maximum number of CSS selector combinations to test for uniqueness.\n * If more combinations would be generated, falls back to a simpler strategy.\n * Default: 1000\n */\n threshold?: number;\n}\n\nexport type SessionReplayType = 'standalone' | 'plugin' | 'segment';\n"]}
|
|
@@ -56,7 +56,7 @@ var EventCompressor = /** @class */ (function () {
|
|
|
56
56
|
this.deviceId = deviceId;
|
|
57
57
|
this.timeout = ((_a = config.performanceConfig) === null || _a === void 0 ? void 0 : _a.timeout) || DEFAULT_TIMEOUT;
|
|
58
58
|
if (workerScript) {
|
|
59
|
-
config.loggerProvider.log('
|
|
59
|
+
config.loggerProvider.log('Enabling web worker for compression');
|
|
60
60
|
var worker = new Worker(URL.createObjectURL(new Blob([workerScript], { type: 'application/javascript' })));
|
|
61
61
|
worker.onerror = function (e) {
|
|
62
62
|
config.loggerProvider.error(e);
|
|
@@ -1 +1 @@
|
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C,OAAO,EAAE,CAC1B,CAAC;SACH;aAAM;YACL,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;SAC3B;IACH,CAAC;IAwCH,sBAAC;AAAD,CAAC,AA9HD,IA8HC;AA9HY,0CAAe","sourcesContent":["import { getGlobalScope } from '@amplitude/analytics-core';\nimport { pack } from '@amplitude/rrweb-packer';\nimport type { eventWithTime } from '@amplitude/rrweb-types';\nimport { SessionReplayJoinedConfig } from '../config/types';\nimport { SessionReplayEventsManager } from '../typings/session-replay';\n\ninterface TaskQueue {\n event: eventWithTime;\n sessionId: string | number;\n}\n\nconst DEFAULT_TIMEOUT = 2000;\nexport class EventCompressor {\n taskQueue: TaskQueue[] = [];\n isProcessing = false;\n eventsManager?: SessionReplayEventsManager<'replay' | 'interaction', string>;\n config: SessionReplayJoinedConfig;\n deviceId: string | undefined;\n canUseIdleCallback: boolean | undefined;\n timeout: number;\n worker?: Worker;\n\n constructor(\n eventsManager: SessionReplayEventsManager<'replay' | 'interaction', string>,\n config: SessionReplayJoinedConfig,\n deviceId: string | undefined,\n workerScript?: string,\n ) {\n const globalScope = getGlobalScope();\n this.canUseIdleCallback = globalScope && 'requestIdleCallback' in globalScope;\n this.eventsManager = eventsManager;\n this.config = config;\n this.deviceId = deviceId;\n this.timeout = config.performanceConfig?.timeout || DEFAULT_TIMEOUT;\n\n if (workerScript) {\n config.loggerProvider.log('Enabling web worker for compression');\n\n const worker = new Worker(URL.createObjectURL(new Blob([workerScript], { type: 'application/javascript' })));\n worker.onerror = (e) => {\n config.loggerProvider.error(e);\n };\n worker.onmessage = (e) => {\n const { compressedEvent, sessionId } = e.data as Record<string, string>;\n this.addCompressedEventToManager(compressedEvent, sessionId);\n };\n\n this.worker = worker;\n }\n }\n\n // Schedule processing during idle time\n public scheduleIdleProcessing(): void {\n if (!this.isProcessing) {\n this.isProcessing = true;\n requestIdleCallback(\n (idleDeadline) => {\n this.processQueue(idleDeadline);\n },\n { timeout: this.timeout },\n );\n }\n }\n\n // Add an event to the task queue if idle callback is supported or compress the event directly\n public enqueueEvent(event: eventWithTime, sessionId: string | number): void {\n if (this.canUseIdleCallback && this.config.performanceConfig?.enabled) {\n this.config.loggerProvider.debug('Enqueuing event for processing during idle time.');\n this.taskQueue.push({ event, sessionId });\n this.scheduleIdleProcessing();\n } else {\n this.config.loggerProvider.debug('Processing event without idle callback.');\n this.addCompressedEvent(event, sessionId);\n }\n }\n\n // Process the task queue during idle time\n public processQueue(idleDeadline: IdleDeadline): void {\n // Process tasks while there's idle time or until the max number of tasks is reached\n while (this.taskQueue.length > 0 && (idleDeadline.timeRemaining() > 0 || idleDeadline.didTimeout)) {\n const task = this.taskQueue.shift();\n if (task) {\n const { event, sessionId } = task;\n this.addCompressedEvent(event, sessionId);\n }\n }\n\n // If there are still tasks in the queue, schedule the next idle callback\n if (this.taskQueue.length > 0) {\n requestIdleCallback(\n (idleDeadline) => {\n this.processQueue(idleDeadline);\n },\n { timeout: this.timeout },\n );\n } else {\n this.isProcessing = false;\n }\n }\n\n compressEvent = (event: eventWithTime) => {\n const packedEvent = pack(event);\n return JSON.stringify(packedEvent);\n };\n\n private addCompressedEventToManager = (compressedEvent: string, sessionId: string | number) => {\n if (this.eventsManager && this.deviceId) {\n this.eventsManager.addEvent({\n event: { type: 'replay', data: compressedEvent },\n sessionId,\n deviceId: this.deviceId,\n });\n }\n };\n\n public addCompressedEvent = (event: eventWithTime, sessionId: string | number) => {\n if (this.worker) {\n // This indirectly compresses the event.\n try {\n this.worker.postMessage({ event, sessionId });\n } catch (err: any) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n if (err.name === 'DataCloneError') {\n // fallback: serialize\n this.worker.postMessage(JSON.stringify({ event, sessionId }));\n } else {\n this.config.loggerProvider.warn('Unexpected error while posting message to worker:', err);\n }\n }\n } else {\n const compressedEvent = this.compressEvent(event);\n this.addCompressedEventToManager(compressedEvent, sessionId);\n }\n };\n\n public terminate = () => {\n this.worker?.terminate();\n };\n}\n"]}
|
package/lib/cjs/helpers.d.ts
CHANGED
|
@@ -26,9 +26,7 @@ export declare const getDebugConfig: (config: SessionReplayJoinedConfig) => {
|
|
|
26
26
|
version?: import("./config/types").SessionReplayVersion | undefined;
|
|
27
27
|
performanceConfig?: import("./config/types").SessionReplayPerformanceConfig | undefined;
|
|
28
28
|
storeType: import("./typings/session-replay").StoreType;
|
|
29
|
-
|
|
30
|
-
useWebWorker: boolean;
|
|
31
|
-
} | undefined;
|
|
29
|
+
useWebWorker?: boolean | undefined;
|
|
32
30
|
userProperties?: {
|
|
33
31
|
[key: string]: any;
|
|
34
32
|
} | undefined;
|
package/lib/cjs/helpers.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvE,OAAO,EAAiC,aAAa,EAAE,yBAAyB,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AASxH,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAqFvD,eAAO,MAAM,MAAM,gBACH,MAAM,GAAG,OAAO,WAAW,aAAa,YAC/C,MAAM,WAAW,WAAW,GAAG,IAAI,KAAG,MAE5C,CAAC;AAEJ,eAAO,MAAM,aAAa,cAGzB,CAAC;AAEF,eAAO,MAAM,uBAAuB,cAAe,MAAM,GAAG,MAAM,YAAY,MAAM,KAAG,MAEtF,CAAC;AAEF,eAAO,MAAM,YAAY,gBAAiB,MAAM,iBAAiB,mBAAmB,MAAM,KAAG,MAc5F,CAAC;AAmBF,eAAO,MAAM,sBAAsB,mBAAoB,aAAa,EAAE,SAUrE,CAAC;AAEF,eAAO,MAAM,UAAU,YAAa,MAAM,kBAAkB,aAAa,EAAE,WAW1E,CAAC;AAEF,eAAO,MAAM,cAAc,QAAa,QAAQ,WAAW,CAa1D,CAAC;AAEF,eAAO,MAAM,cAAc,WAAY,yBAAyB
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvE,OAAO,EAAiC,aAAa,EAAE,yBAAyB,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AASxH,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAqFvD,eAAO,MAAM,MAAM,gBACH,MAAM,GAAG,OAAO,WAAW,aAAa,YAC/C,MAAM,WAAW,WAAW,GAAG,IAAI,KAAG,MAE5C,CAAC;AAEJ,eAAO,MAAM,aAAa,cAGzB,CAAC;AAEF,eAAO,MAAM,uBAAuB,cAAe,MAAM,GAAG,MAAM,YAAY,MAAM,KAAG,MAEtF,CAAC;AAEF,eAAO,MAAM,YAAY,gBAAiB,MAAM,iBAAiB,mBAAmB,MAAM,KAAG,MAc5F,CAAC;AAmBF,eAAO,MAAM,sBAAsB,mBAAoB,aAAa,EAAE,SAUrE,CAAC;AAEF,eAAO,MAAM,UAAU,YAAa,MAAM,kBAAkB,aAAa,EAAE,WAW1E,CAAC;AAEF,eAAO,MAAM,cAAc,QAAa,QAAQ,WAAW,CAa1D,CAAC;AAEF,eAAO,MAAM,cAAc,WAAY,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAO/D,CAAC"}
|
package/lib/cjs/hooks/click.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { Mirror } from '../utils/rrweb';
|
|
|
3
3
|
import { SessionReplayEventsManager as AmplitudeSessionReplayEventsManager } from '../typings/session-replay';
|
|
4
4
|
import { PayloadBatcher } from '../track-destination';
|
|
5
5
|
import { ILogger } from '@amplitude/analytics-core';
|
|
6
|
-
import { UGCFilterRule } from '../config/types';
|
|
6
|
+
import { UGCFilterRule, InteractionPerformanceConfig } from '../config/types';
|
|
7
7
|
import { ScrollWatcher } from './scroll';
|
|
8
8
|
export type ClickEvent = {
|
|
9
9
|
timestamp: number;
|
|
@@ -24,6 +24,7 @@ type Context = {
|
|
|
24
24
|
eventsManager: AmplitudeSessionReplayEventsManager<'interaction', string>;
|
|
25
25
|
mirror: Mirror;
|
|
26
26
|
ugcFilterRules: UGCFilterRule[];
|
|
27
|
+
performanceOptions?: InteractionPerformanceConfig;
|
|
27
28
|
};
|
|
28
29
|
export declare const clickNonBatcher: PayloadBatcher;
|
|
29
30
|
export declare const clickBatcher: PayloadBatcher;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"click.d.ts","sourceRoot":"","sources":["../../../src/hooks/click.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAEvE,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,0BAA0B,IAAI,mCAAmC,EAAE,MAAM,2BAA2B,CAAC;AAC9G,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,EAAkB,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"click.d.ts","sourceRoot":"","sources":["../../../src/hooks/click.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAEvE,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,0BAA0B,IAAI,mCAAmC,EAAE,MAAM,2BAA2B,CAAC;AAC9G,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,EAAkB,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AAE9E,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAGzC,MAAM,MAAM,UAAU,GAAG;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AAGF,MAAM,MAAM,mBAAmB,GAAG,UAAU,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEjE,KAAK,OAAO,GAAG;IACb,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC;IAC3B,UAAU,EAAE,MAAM,MAAM,GAAG,SAAS,CAAC;IACrC,aAAa,EAAE,mCAAmC,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;IAC1E,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,aAAa,EAAE,CAAC;IAChC,kBAAkB,CAAC,EAAE,4BAA4B,CAAC;CACnD,CAAC;AAIF,eAAO,MAAM,eAAe,EAAE,cAU7B,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,cAyB1B,CAAC;AAEF,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAU;IACjC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAgB;gBAElC,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,aAAa;IAKzD,UAAU,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,wBAAwB,CA4DxD;CACH"}
|
package/lib/cjs/hooks/click.js
CHANGED
|
@@ -49,7 +49,7 @@ var ClickHandler = /** @class */ (function () {
|
|
|
49
49
|
function ClickHandler(logger, scrollWatcher) {
|
|
50
50
|
var _this = this;
|
|
51
51
|
this.createHook = function (_a) {
|
|
52
|
-
var eventsManager = _a.eventsManager, sessionId = _a.sessionId, deviceIdFn = _a.deviceIdFn, mirror = _a.mirror, ugcFilterRules = _a.ugcFilterRules;
|
|
52
|
+
var eventsManager = _a.eventsManager, sessionId = _a.sessionId, deviceIdFn = _a.deviceIdFn, mirror = _a.mirror, ugcFilterRules = _a.ugcFilterRules, performanceOptions = _a.performanceOptions;
|
|
53
53
|
return function (e) {
|
|
54
54
|
if (e.type !== rrweb_types_1.MouseInteractions.Click) {
|
|
55
55
|
return;
|
|
@@ -71,7 +71,7 @@ var ClickHandler = /** @class */ (function () {
|
|
|
71
71
|
var selector;
|
|
72
72
|
if (node) {
|
|
73
73
|
try {
|
|
74
|
-
selector = (0, finder_1.finder)(node);
|
|
74
|
+
selector = (0, finder_1.finder)(node, performanceOptions);
|
|
75
75
|
}
|
|
76
76
|
catch (err) {
|
|
77
77
|
_this.logger.debug('error resolving selector from finder');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"click.js","sourceRoot":"","sources":["../../../src/hooks/click.ts"],"names":[],"mappings":";;;;AACA,sDAA2D;AAI3D,
|
|
1
|
+
{"version":3,"file":"click.js","sourceRoot":"","sources":["../../../src/hooks/click.ts"],"names":[],"mappings":";;;;AACA,sDAA2D;AAI3D,yCAAkE;AAClE,4DAAoE;AAEpE,sCAAwC;AA2BxC,IAAM,oBAAoB,GAAG,OAAS,CAAC;AAEhC,IAAM,eAAe,GAAmB,UAAC,EAAmB;QAAjB,OAAO,aAAA,EAAE,MAAM,YAAA;IAC/D,IAAM,WAAW,GAAiB,EAAE,CAAC;IACrC,MAAM,CAAC,OAAO,CAAC,UAAC,GAAW;QACzB,IAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAA4B,CAAC;QAC1D,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC;QACjB,IAAI,MAAM,CAAC,IAAI,KAAK,OAAO,EAAE;YAC3B,WAAW,CAAC,IAAI,CAAC,MAAoB,CAAC,CAAC;SACxC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,EAAE,OAAO,SAAA,EAAE,MAAM,EAAE,WAAW,EA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,KAAI,CAAC,aAAa,CAAC,cAAc;oBACxC,CAAC,EAAE,CAAC,GAAG,KAAI,CAAC,aAAa,CAAC,cAAc;oBACxC,QAAQ,UAAA;oBAER,cAAc,EAAE,WAAW;oBAC3B,aAAa,EAAE,UAAU;oBACzB,OAAO,SAAA;oBACP,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;oBACrB,IAAI,EAAE,OAAO;iBACd,CAAC;gBACF,IAAM,QAAQ,GAAG,UAAU,EAAE,CAAC;gBAC9B,IAAI,QAAQ,EAAE;oBACZ,aAAa,CAAC,QAAQ,CAAC,EAAE,SAAS,WAAA,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,EAAE,QAAQ,UAAA,EAAE,CAAC,CAAC;iBAC9G;YACH,CAAC,CAAC;QACJ,CAAC,CAAC;QAhEA,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACrC,CAAC;IA+DH,mBAAC;AAAD,CAAC,AAtED,IAsEC;AAtEY,oCAAY","sourcesContent":["import type { mouseInteractionCallBack } from '@amplitude/rrweb-types';\nimport { MouseInteractions } from '@amplitude/rrweb-types';\nimport { Mirror } from '../utils/rrweb';\nimport { SessionReplayEventsManager as AmplitudeSessionReplayEventsManager } from '../typings/session-replay';\nimport { PayloadBatcher } from '../track-destination';\nimport { finder, Options as FinderOptions } from '../libs/finder';\nimport { getGlobalScope, ILogger } from '@amplitude/analytics-core';\nimport { UGCFilterRule, InteractionPerformanceConfig } from '../config/types';\nimport { getPageUrl } from '../helpers';\nimport { ScrollWatcher } from './scroll';\n\n// exported for testing\nexport type ClickEvent = {\n timestamp: number;\n x: number;\n y: number;\n viewportWidth: number;\n viewportHeight: number;\n pageUrl: string;\n selector?: string;\n type: 'click';\n};\n\n// exported for testing\nexport type ClickEventWithCount = ClickEvent & { count: number };\n\ntype Context = {\n sessionId: string | number;\n deviceIdFn: () => string | undefined;\n eventsManager: AmplitudeSessionReplayEventsManager<'interaction', string>;\n mirror: Mirror;\n ugcFilterRules: UGCFilterRule[];\n performanceOptions?: InteractionPerformanceConfig;\n};\n\nconst HOUR_IN_MILLISECONDS = 3_600_000;\n\nexport const clickNonBatcher: PayloadBatcher = ({ version, events }) => {\n const clickEvents: ClickEvent[] = [];\n events.forEach((evt: string) => {\n const record = JSON.parse(evt) as Record<string, unknown>;\n record.count = 1;\n if (record.type === 'click') {\n clickEvents.push(record as ClickEvent);\n }\n });\n return { version, events: clickEvents };\n};\n\nexport const clickBatcher: PayloadBatcher = ({ version, events }) => {\n const clickEvents: ClickEvent[] = [];\n events.forEach((evt: string) => {\n const record = JSON.parse(evt) as Record<string, unknown>;\n if (record.type === 'click') {\n clickEvents.push(record as ClickEvent);\n }\n });\n\n const reduced = clickEvents.reduce<Record<string, ClickEventWithCount>>((prev, curr) => {\n const { x, y, selector, timestamp } = curr;\n\n // round down to nearest hour.\n const hour = timestamp - (timestamp % HOUR_IN_MILLISECONDS);\n\n const k = `${x}:${y}:${selector ?? ''}:${hour}`;\n if (!prev[k]) {\n prev[k] = { ...curr, timestamp: hour, count: 1 };\n } else {\n prev[k].count += 1;\n }\n return prev;\n }, {});\n\n return { version, events: Object.values(reduced) };\n};\n\nexport class ClickHandler {\n private readonly logger: ILogger;\n private readonly scrollWatcher: ScrollWatcher;\n\n constructor(logger: ILogger, scrollWatcher: ScrollWatcher) {\n this.logger = logger;\n this.scrollWatcher = scrollWatcher;\n }\n\n createHook: (context: Context) => mouseInteractionCallBack = ({\n eventsManager,\n sessionId,\n deviceIdFn,\n mirror,\n ugcFilterRules,\n performanceOptions,\n }) => {\n return (e) => {\n if (e.type !== MouseInteractions.Click) {\n return;\n }\n\n const globalScope = getGlobalScope();\n if (!globalScope) {\n return;\n }\n\n const { location, innerHeight, innerWidth } = globalScope;\n // it only makes sense to send events if a pageUrl exists\n if (!location) {\n return;\n }\n\n const { x, y } = e;\n if (x === undefined || y === undefined) {\n return;\n }\n\n const node = mirror.getNode(e.id);\n let selector;\n if (node) {\n try {\n selector = finder(\n node as Element,\n performanceOptions as Pick<FinderOptions, 'timeoutMs' | 'maxNumberOfTries' | 'threshold'>,\n );\n } catch (err) {\n this.logger.debug('error resolving selector from finder');\n }\n }\n\n const pageUrl = getPageUrl(location.href, ugcFilterRules);\n\n const event: ClickEvent = {\n x: x + this.scrollWatcher.currentScrollX,\n y: y + this.scrollWatcher.currentScrollY,\n selector,\n\n viewportHeight: innerHeight,\n viewportWidth: innerWidth,\n pageUrl,\n timestamp: Date.now(),\n type: 'click',\n };\n const deviceId = deviceIdFn();\n if (deviceId) {\n eventsManager.addEvent({ sessionId, event: { type: 'interaction', data: JSON.stringify(event) }, deviceId });\n }\n };\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-replay.d.ts","sourceRoot":"","sources":["../../src/session-replay.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,OAAO,EAOR,MAAM,2BAA2B,CAAC;AAInC,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAE3D,OAAO,EACL,aAAa,EACb,yBAAyB,EACzB,kCAAkC,EAInC,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAEL,gBAAgB,EAMjB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAS5D,OAAO,EACL,sBAAsB,EACtB,0BAA0B,IAAI,mCAAmC,EAIjE,kBAAkB,IAAI,mBAAmB,EACzC,oBAAoB,EACrB,MAAM,0BAA0B,CAAC;AAMlC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD,KAAK,WAAW,GAAG,CAAC,CAAC,EAAE,mBAAmB,GAAG,KAAK,KAAK,IAAI,CAAC;AAE5D,qBAAa,aAAc,YAAW,sBAAsB;IAC1D,IAAI,SAAuC;IAC3C,MAA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C,sBAAsB,UAAQ;IAgB/C,YAAY;IAUZ,eAAe;IA+Df,iBAAiB,IAAI,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS;IAWlD,oBAAoB,IAAI,MAAM,GAAG,SAAS;IAapC,mBAAmB,CAAC,aAAa,EAAE,aAAa,GAAG,SAAS;YAyCpD,iBAAiB;IAezB,YAAY,CAAC,iBAAiB,UAAO;IA6G3C,mBAAmB,cACN,gBAAgB;;kDAmC3B;IAEF,mBAAmB,aAUjB;IAEF,WAAW;IAIX,YAAY;IAIN,KAAK,CAAC,QAAQ,UAAQ;IAI5B,QAAQ;IAMR,OAAO,CAAC,UAAU;IAYlB,OAAO,CAAC,WAAW;YAyBL,0BAA0B;CAUzC"}
|
|
@@ -203,23 +203,23 @@ var SessionReplay = /** @class */ (function () {
|
|
|
203
203
|
return (0, analytics_core_1.returnWrapper)(this._init(apiKey, options));
|
|
204
204
|
};
|
|
205
205
|
SessionReplay.prototype._init = function (apiKey, options) {
|
|
206
|
-
var _a, _b, _c, _d, _e, _f
|
|
206
|
+
var _a, _b, _c, _d, _e, _f;
|
|
207
207
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
208
|
-
var
|
|
209
|
-
return tslib_1.__generator(this, function (
|
|
210
|
-
switch (
|
|
208
|
+
var _g, _h, joinedConfig, localConfig, remoteConfig, scrollWatcher, managers, storeType, rrwebEventManager, error_1, typedError, payloadBatcher, interactionEventManager, error_2, typedError, workerScript, globalScope, compressionScript;
|
|
209
|
+
return tslib_1.__generator(this, function (_j) {
|
|
210
|
+
switch (_j.label) {
|
|
211
211
|
case 0:
|
|
212
212
|
this.loggerProvider = new logger_1.SafeLoggerProvider(options.loggerProvider || new analytics_core_1.Logger());
|
|
213
213
|
Object.prototype.hasOwnProperty.call(options, 'logLevel') &&
|
|
214
214
|
this.loggerProvider.enable(options.logLevel);
|
|
215
215
|
this.identifiers = new identifiers_1.SessionIdentifiers({ sessionId: options.sessionId, deviceId: options.deviceId });
|
|
216
|
-
|
|
216
|
+
_g = this;
|
|
217
217
|
return [4 /*yield*/, (0, joined_config_1.createSessionReplayJoinedConfigGenerator)(apiKey, options)];
|
|
218
218
|
case 1:
|
|
219
|
-
|
|
219
|
+
_g.joinedConfigGenerator = _j.sent();
|
|
220
220
|
return [4 /*yield*/, this.joinedConfigGenerator.generateJoinedConfig()];
|
|
221
221
|
case 2:
|
|
222
|
-
|
|
222
|
+
_h = _j.sent(), joinedConfig = _h.joinedConfig, localConfig = _h.localConfig, remoteConfig = _h.remoteConfig;
|
|
223
223
|
this.config = joinedConfig;
|
|
224
224
|
this.setMetadata(options.sessionId, joinedConfig, localConfig, remoteConfig, (_a = options.version) === null || _a === void 0 ? void 0 : _a.version, version_1.VERSION, (_b = options.version) === null || _b === void 0 ? void 0 : _b.type);
|
|
225
225
|
if (options.sessionId && ((_c = this.config.interactionConfig) === null || _c === void 0 ? void 0 : _c.enabled)) {
|
|
@@ -238,9 +238,9 @@ var SessionReplay = /** @class */ (function () {
|
|
|
238
238
|
this.loggerProvider.warn('Could not use preferred indexedDB storage, reverting to in memory option.');
|
|
239
239
|
}
|
|
240
240
|
this.loggerProvider.log("Using ".concat(storeType, " for event storage."));
|
|
241
|
-
|
|
241
|
+
_j.label = 3;
|
|
242
242
|
case 3:
|
|
243
|
-
|
|
243
|
+
_j.trys.push([3, 5, , 6]);
|
|
244
244
|
return [4 /*yield*/, (0, events_manager_1.createEventsManager)({
|
|
245
245
|
config: this.config,
|
|
246
246
|
sessionId: this.identifiers.sessionId,
|
|
@@ -248,20 +248,20 @@ var SessionReplay = /** @class */ (function () {
|
|
|
248
248
|
storeType: storeType,
|
|
249
249
|
})];
|
|
250
250
|
case 4:
|
|
251
|
-
rrwebEventManager =
|
|
251
|
+
rrwebEventManager = _j.sent();
|
|
252
252
|
managers.push({ name: 'replay', manager: rrwebEventManager });
|
|
253
253
|
return [3 /*break*/, 6];
|
|
254
254
|
case 5:
|
|
255
|
-
error_1 =
|
|
255
|
+
error_1 = _j.sent();
|
|
256
256
|
typedError = error_1;
|
|
257
257
|
this.loggerProvider.warn("Error occurred while creating replay events manager: ".concat(typedError.toString()));
|
|
258
258
|
return [3 /*break*/, 6];
|
|
259
259
|
case 6:
|
|
260
260
|
if (!((_e = this.config.interactionConfig) === null || _e === void 0 ? void 0 : _e.enabled)) return [3 /*break*/, 10];
|
|
261
261
|
payloadBatcher = this.config.interactionConfig.batch ? click_1.clickBatcher : click_1.clickNonBatcher;
|
|
262
|
-
|
|
262
|
+
_j.label = 7;
|
|
263
263
|
case 7:
|
|
264
|
-
|
|
264
|
+
_j.trys.push([7, 9, , 10]);
|
|
265
265
|
return [4 /*yield*/, (0, events_manager_1.createEventsManager)({
|
|
266
266
|
config: this.config,
|
|
267
267
|
sessionId: this.identifiers.sessionId,
|
|
@@ -272,11 +272,11 @@ var SessionReplay = /** @class */ (function () {
|
|
|
272
272
|
storeType: storeType,
|
|
273
273
|
})];
|
|
274
274
|
case 8:
|
|
275
|
-
interactionEventManager =
|
|
275
|
+
interactionEventManager = _j.sent();
|
|
276
276
|
managers.push({ name: 'interaction', manager: interactionEventManager });
|
|
277
277
|
return [3 /*break*/, 10];
|
|
278
278
|
case 9:
|
|
279
|
-
error_2 =
|
|
279
|
+
error_2 = _j.sent();
|
|
280
280
|
typedError = error_2;
|
|
281
281
|
this.loggerProvider.warn("Error occurred while creating interaction events manager: ".concat(typedError.toString()));
|
|
282
282
|
return [3 /*break*/, 10];
|
|
@@ -288,22 +288,22 @@ var SessionReplay = /** @class */ (function () {
|
|
|
288
288
|
}
|
|
289
289
|
workerScript = undefined;
|
|
290
290
|
globalScope = (0, analytics_core_1.getGlobalScope)();
|
|
291
|
-
if (!(
|
|
291
|
+
if (!(this.config.useWebWorker && globalScope && globalScope.Worker)) return [3 /*break*/, 12];
|
|
292
292
|
return [4 /*yield*/, Promise.resolve().then(function () { return tslib_1.__importStar(require('./worker')); })];
|
|
293
293
|
case 11:
|
|
294
|
-
compressionScript = (
|
|
294
|
+
compressionScript = (_j.sent()).compressionScript;
|
|
295
295
|
workerScript = compressionScript;
|
|
296
|
-
|
|
296
|
+
_j.label = 12;
|
|
297
297
|
case 12:
|
|
298
298
|
this.eventCompressor = new event_compressor_1.EventCompressor(this.eventsManager, this.config, this.getDeviceId(), workerScript);
|
|
299
299
|
return [4 /*yield*/, this.initializeNetworkObservers()];
|
|
300
300
|
case 13:
|
|
301
|
-
|
|
301
|
+
_j.sent();
|
|
302
302
|
this.loggerProvider.log('Installing @amplitude/session-replay-browser.');
|
|
303
303
|
this.teardownEventListeners(false);
|
|
304
304
|
return [4 /*yield*/, this.evaluateTargetingAndCapture({ userProperties: options.userProperties }, true)];
|
|
305
305
|
case 14:
|
|
306
|
-
|
|
306
|
+
_j.sent();
|
|
307
307
|
return [2 /*return*/];
|
|
308
308
|
}
|
|
309
309
|
});
|
|
@@ -564,14 +564,14 @@ var SessionReplay = /** @class */ (function () {
|
|
|
564
564
|
});
|
|
565
565
|
};
|
|
566
566
|
SessionReplay.prototype.recordEvents = function (shouldLogMetadata) {
|
|
567
|
-
var _a, _b, _c, _d, _e, _f;
|
|
567
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
568
568
|
if (shouldLogMetadata === void 0) { shouldLogMetadata = true; }
|
|
569
569
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
570
|
-
var config, shouldRecord, sessionId, recordFunction, privacyConfig, interactionConfig, loggingConfig, hooks, ugcFilterRules,
|
|
571
|
-
var
|
|
570
|
+
var config, shouldRecord, sessionId, recordFunction, privacyConfig, interactionConfig, loggingConfig, hooks, ugcFilterRules, _h, _j, error_5;
|
|
571
|
+
var _k;
|
|
572
572
|
var _this = this;
|
|
573
|
-
return tslib_1.__generator(this, function (
|
|
574
|
-
switch (
|
|
573
|
+
return tslib_1.__generator(this, function (_l) {
|
|
574
|
+
switch (_l.label) {
|
|
575
575
|
case 0:
|
|
576
576
|
config = this.config;
|
|
577
577
|
shouldRecord = this.getShouldRecord();
|
|
@@ -582,14 +582,14 @@ var SessionReplay = /** @class */ (function () {
|
|
|
582
582
|
this.stopRecordingEvents();
|
|
583
583
|
return [4 /*yield*/, this.getRecordFunction()];
|
|
584
584
|
case 1:
|
|
585
|
-
recordFunction =
|
|
585
|
+
recordFunction = _l.sent();
|
|
586
586
|
// May be undefined if cannot import rrweb-record
|
|
587
587
|
if (!recordFunction) {
|
|
588
588
|
return [2 /*return*/];
|
|
589
589
|
}
|
|
590
590
|
return [4 /*yield*/, this.initializeNetworkObservers()];
|
|
591
591
|
case 2:
|
|
592
|
-
|
|
592
|
+
_l.sent();
|
|
593
593
|
(_b = this.networkObservers) === null || _b === void 0 ? void 0 : _b.start(function (event) {
|
|
594
594
|
void _this.addCustomRRWebEvent(constants_1.CustomRRwebEvent.FETCH_REQUEST, event);
|
|
595
595
|
});
|
|
@@ -603,18 +603,19 @@ var SessionReplay = /** @class */ (function () {
|
|
|
603
603
|
deviceIdFn: this.getDeviceId.bind(this),
|
|
604
604
|
mirror: recordFunction.mirror,
|
|
605
605
|
ugcFilterRules: (_d = interactionConfig.ugcFilterRules) !== null && _d !== void 0 ? _d : [],
|
|
606
|
+
performanceOptions: (_e = config.performanceConfig) === null || _e === void 0 ? void 0 : _e.interaction,
|
|
606
607
|
})),
|
|
607
608
|
scroll: this.scrollHook,
|
|
608
609
|
}
|
|
609
610
|
: {};
|
|
610
611
|
ugcFilterRules = (interactionConfig === null || interactionConfig === void 0 ? void 0 : interactionConfig.enabled) && interactionConfig.ugcFilterRules ? interactionConfig.ugcFilterRules : [];
|
|
611
612
|
this.loggerProvider.log("Session Replay capture beginning for ".concat(sessionId, "."));
|
|
612
|
-
|
|
613
|
+
_l.label = 3;
|
|
613
614
|
case 3:
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
615
|
+
_l.trys.push([3, 5, , 6]);
|
|
616
|
+
_h = this;
|
|
617
|
+
_j = recordFunction;
|
|
618
|
+
_k = {
|
|
618
619
|
emit: function (event) {
|
|
619
620
|
if (_this.shouldOptOut()) {
|
|
620
621
|
_this.loggerProvider.log("Opting session ".concat(sessionId, " out of recording due to optOut config."));
|
|
@@ -642,8 +643,8 @@ var SessionReplay = /** @class */ (function () {
|
|
|
642
643
|
maskTextSelector: this.getMaskTextSelectors(),
|
|
643
644
|
recordCanvas: false,
|
|
644
645
|
slimDOMOptions: {
|
|
645
|
-
script: (
|
|
646
|
-
comment: (
|
|
646
|
+
script: (_f = config.omitElementTags) === null || _f === void 0 ? void 0 : _f.script,
|
|
647
|
+
comment: (_g = config.omitElementTags) === null || _g === void 0 ? void 0 : _g.comment,
|
|
647
648
|
},
|
|
648
649
|
errorHandler: function (error) {
|
|
649
650
|
var typedError = error;
|
|
@@ -664,15 +665,15 @@ var SessionReplay = /** @class */ (function () {
|
|
|
664
665
|
};
|
|
665
666
|
return [4 /*yield*/, this.getRecordingPlugins(loggingConfig)];
|
|
666
667
|
case 4:
|
|
667
|
-
|
|
668
|
-
|
|
668
|
+
_h.recordCancelCallback = _j.apply(void 0, [(_k.plugins = _l.sent(),
|
|
669
|
+
_k)]);
|
|
669
670
|
void this.addCustomRRWebEvent(constants_1.CustomRRwebEvent.DEBUG_INFO);
|
|
670
671
|
if (shouldLogMetadata) {
|
|
671
672
|
void this.addCustomRRWebEvent(constants_1.CustomRRwebEvent.METADATA, this.metadata);
|
|
672
673
|
}
|
|
673
674
|
return [3 /*break*/, 6];
|
|
674
675
|
case 5:
|
|
675
|
-
error_5 =
|
|
676
|
+
error_5 = _l.sent();
|
|
676
677
|
this.loggerProvider.warn('Failed to initialize session replay:', error_5);
|
|
677
678
|
return [3 /*break*/, 6];
|
|
678
679
|
case 6: return [2 /*return*/];
|