@amplitude/session-replay-browser 1.22.7-prereleasenetworkcapture.0 → 1.22.11
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/lib/cjs/config/joined-config.d.ts +2 -2
- package/lib/cjs/config/joined-config.d.ts.map +1 -1
- package/lib/cjs/config/joined-config.js +10 -2
- package/lib/cjs/config/joined-config.js.map +1 -1
- package/lib/cjs/config/types.d.ts +22 -1
- package/lib/cjs/config/types.d.ts.map +1 -1
- package/lib/cjs/config/types.js.map +1 -1
- package/lib/cjs/constants.d.ts +2 -1
- package/lib/cjs/constants.d.ts.map +1 -1
- package/lib/cjs/constants.js +1 -0
- package/lib/cjs/constants.js.map +1 -1
- package/lib/cjs/helpers.d.ts +7 -1
- package/lib/cjs/helpers.d.ts.map +1 -1
- package/lib/cjs/helpers.js +2 -2
- package/lib/cjs/helpers.js.map +1 -1
- package/lib/cjs/session-replay.d.ts +4 -1
- package/lib/cjs/session-replay.d.ts.map +1 -1
- package/lib/cjs/session-replay.js +59 -30
- package/lib/cjs/session-replay.js.map +1 -1
- package/lib/cjs/utils/get-input-type.d.ts +9 -0
- package/lib/cjs/utils/get-input-type.d.ts.map +1 -0
- package/lib/cjs/utils/get-input-type.js +25 -0
- package/lib/cjs/utils/get-input-type.js.map +1 -0
- package/lib/cjs/version.d.ts +1 -1
- package/lib/cjs/version.d.ts.map +1 -1
- package/lib/cjs/version.js +1 -1
- package/lib/cjs/version.js.map +1 -1
- package/lib/esm/config/types.d.ts +1 -1
- package/lib/esm/config/types.d.ts.map +1 -1
- package/lib/esm/config/types.js.map +1 -1
- package/lib/esm/helpers.d.ts +7 -1
- package/lib/esm/helpers.d.ts.map +1 -1
- package/lib/esm/helpers.js +1 -1
- package/lib/esm/helpers.js.map +1 -1
- package/lib/esm/session-replay.d.ts +1 -0
- package/lib/esm/session-replay.d.ts.map +1 -1
- package/lib/esm/session-replay.js +32 -23
- package/lib/esm/session-replay.js.map +1 -1
- package/lib/esm/utils/get-input-type.d.ts +9 -0
- package/lib/esm/utils/get-input-type.d.ts.map +1 -0
- package/lib/esm/utils/get-input-type.js +20 -0
- package/lib/esm/utils/get-input-type.js.map +1 -0
- package/lib/esm/version.d.ts +1 -1
- package/lib/esm/version.d.ts.map +1 -1
- package/lib/esm/version.js +1 -1
- package/lib/esm/version.js.map +1 -1
- package/lib/scripts/console-plugin-min.js.gz +0 -0
- 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-esm.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 +3 -4
- package/lib/scripts/amplitude-min.js +0 -2
- package/lib/scripts/amplitude-min.js.gz +0 -0
- package/lib/scripts/amplitude-min.js.map +0 -1
- package/lib/scripts/amplitude-min.umd.js +0 -1
- package/lib/scripts/amplitude-min.umd.js.gz +0 -0
- package/lib/scripts/beacon-transport.d.ts +0 -28
- package/lib/scripts/beacon-transport.d.ts.map +0 -1
- package/lib/scripts/config/joined-config.d.ts +0 -13
- package/lib/scripts/config/joined-config.d.ts.map +0 -1
- package/lib/scripts/config/local-config.d.ts +0 -27
- package/lib/scripts/config/local-config.d.ts.map +0 -1
- package/lib/scripts/config/types.d.ts +0 -147
- package/lib/scripts/config/types.d.ts.map +0 -1
- package/lib/scripts/constants.d.ts +0 -29
- package/lib/scripts/constants.d.ts.map +0 -1
- package/lib/scripts/events/base-events-store.d.ts +0 -31
- package/lib/scripts/events/base-events-store.d.ts.map +0 -1
- package/lib/scripts/events/event-compressor.d.ts +0 -27
- package/lib/scripts/events/event-compressor.d.ts.map +0 -1
- package/lib/scripts/events/events-idb-store.d.ts +0 -52
- package/lib/scripts/events/events-idb-store.d.ts.map +0 -1
- package/lib/scripts/events/events-manager.d.ts +0 -13
- package/lib/scripts/events/events-manager.d.ts.map +0 -1
- package/lib/scripts/events/events-memory-store.d.ts +0 -15
- package/lib/scripts/events/events-memory-store.d.ts.map +0 -1
- package/lib/scripts/events/legacy-idb-types.d.ts +0 -26
- package/lib/scripts/events/legacy-idb-types.d.ts.map +0 -1
- package/lib/scripts/events/multi-manager.d.ts +0 -26
- package/lib/scripts/events/multi-manager.d.ts.map +0 -1
- package/lib/scripts/helpers.d.ts +0 -46
- package/lib/scripts/helpers.d.ts.map +0 -1
- package/lib/scripts/hooks/click.d.ts +0 -27
- package/lib/scripts/hooks/click.d.ts.map +0 -1
- package/lib/scripts/hooks/scroll.d.ts +0 -44
- package/lib/scripts/hooks/scroll.d.ts.map +0 -1
- package/lib/scripts/identifiers.d.ts +0 -11
- package/lib/scripts/identifiers.d.ts.map +0 -1
- package/lib/scripts/index.d.ts +0 -7
- package/lib/scripts/index.d.ts.map +0 -1
- package/lib/scripts/libs/finder.d.ts +0 -14
- package/lib/scripts/libs/finder.d.ts.map +0 -1
- package/lib/scripts/logger.d.ts +0 -13
- package/lib/scripts/logger.d.ts.map +0 -1
- package/lib/scripts/messages.d.ts +0 -7
- package/lib/scripts/messages.d.ts.map +0 -1
- package/lib/scripts/observers.d.ts +0 -24
- package/lib/scripts/observers.d.ts.map +0 -1
- package/lib/scripts/session-replay-factory.d.ts +0 -7
- package/lib/scripts/session-replay-factory.d.ts.map +0 -1
- package/lib/scripts/session-replay.d.ts +0 -56
- package/lib/scripts/session-replay.d.ts.map +0 -1
- package/lib/scripts/track-destination.d.ts +0 -37
- package/lib/scripts/track-destination.d.ts.map +0 -1
- package/lib/scripts/typings/session-replay.d.ts +0 -129
- package/lib/scripts/typings/session-replay.d.ts.map +0 -1
- package/lib/scripts/version.d.ts +0 -2
- package/lib/scripts/version.d.ts.map +0 -1
- package/lib/scripts/worker/compression.d.ts +0 -2
- package/lib/scripts/worker/compression.d.ts.map +0 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { RemoteConfigFetch } from '@amplitude/analytics-remote-config';
|
|
2
2
|
import { ILogger } from '@amplitude/analytics-core';
|
|
3
3
|
import { SessionReplayOptions } from '../typings/session-replay';
|
|
4
|
-
import { SessionReplayLocalConfig as ISessionReplayLocalConfig, PrivacyConfig,
|
|
4
|
+
import { SessionReplayLocalConfig as ISessionReplayLocalConfig, PrivacyConfig, SessionReplayConfigs, SessionReplayRemoteConfig } from './types';
|
|
5
5
|
export declare const removeInvalidSelectorsFromPrivacyConfig: (privacyConfig: PrivacyConfig, loggerProvider: ILogger) => PrivacyConfig;
|
|
6
6
|
export declare class SessionReplayJoinedConfigGenerator {
|
|
7
7
|
private readonly localConfig;
|
|
8
8
|
private readonly remoteConfigFetch;
|
|
9
9
|
constructor(remoteConfigFetch: RemoteConfigFetch<SessionReplayRemoteConfig>, localConfig: ISessionReplayLocalConfig);
|
|
10
|
-
generateJoinedConfig(sessionId?: string | number): Promise<
|
|
10
|
+
generateJoinedConfig(sessionId?: string | number): Promise<SessionReplayConfigs>;
|
|
11
11
|
}
|
|
12
12
|
export declare const createSessionReplayJoinedConfigGenerator: (apiKey: string, options: SessionReplayOptions) => Promise<SessionReplayJoinedConfigGenerator>;
|
|
13
13
|
//# sourceMappingURL=joined-config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"joined-config.d.ts","sourceRoot":"","sources":["../../../src/config/joined-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAA2B,MAAM,oCAAoC,CAAC;AAChG,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAEpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE,OAAO,EACL,wBAAwB,IAAI,yBAAyB,EACrD,aAAa,EACb,
|
|
1
|
+
{"version":3,"file":"joined-config.d.ts","sourceRoot":"","sources":["../../../src/config/joined-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAA2B,MAAM,oCAAoC,CAAC;AAChG,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAEpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE,OAAO,EACL,wBAAwB,IAAI,yBAAyB,EACrD,aAAa,EACb,oBAAoB,EAEpB,yBAAyB,EAC1B,MAAM,SAAS,CAAC;AAEjB,eAAO,MAAM,uCAAuC,kBAAmB,aAAa,kBAAkB,OAAO,kBA0B5G,CAAC;AACF,qBAAa,kCAAkC;IAC7C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA4B;IACxD,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAA+C;gBAErE,iBAAiB,EAAE,iBAAiB,CAAC,yBAAyB,CAAC,EAAE,WAAW,EAAE,yBAAyB;IAK7G,oBAAoB,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;CAwJvF;AAED,eAAO,MAAM,wCAAwC,WAAkB,MAAM,WAAW,oBAAoB,gDAQ3G,CAAC"}
|
|
@@ -92,7 +92,11 @@ var SessionReplayJoinedConfigGenerator = /** @class */ (function () {
|
|
|
92
92
|
return [3 /*break*/, 7];
|
|
93
93
|
case 7:
|
|
94
94
|
if (!remoteConfig) {
|
|
95
|
-
return [2 /*return*/,
|
|
95
|
+
return [2 /*return*/, {
|
|
96
|
+
localConfig: this.localConfig,
|
|
97
|
+
joinedConfig: config,
|
|
98
|
+
remoteConfig: remoteConfig,
|
|
99
|
+
}];
|
|
96
100
|
}
|
|
97
101
|
samplingConfig = remoteConfig.sr_sampling_config, remotePrivacyConfig = remoteConfig.sr_privacy_config;
|
|
98
102
|
if (samplingConfig && Object.keys(samplingConfig).length > 0) {
|
|
@@ -207,7 +211,11 @@ var SessionReplayJoinedConfigGenerator = /** @class */ (function () {
|
|
|
207
211
|
config.privacyConfig = (0, exports.removeInvalidSelectorsFromPrivacyConfig)(joinedPrivacyConfig, this.localConfig.loggerProvider);
|
|
208
212
|
}
|
|
209
213
|
this.localConfig.loggerProvider.debug(JSON.stringify({ name: 'session replay joined config', config: (0, helpers_1.getDebugConfig)(config) }, null, 2));
|
|
210
|
-
return [2 /*return*/,
|
|
214
|
+
return [2 /*return*/, {
|
|
215
|
+
localConfig: this.localConfig,
|
|
216
|
+
joinedConfig: config,
|
|
217
|
+
remoteConfig: remoteConfig,
|
|
218
|
+
}];
|
|
211
219
|
}
|
|
212
220
|
});
|
|
213
221
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"joined-config.js","sourceRoot":"","sources":["../../../src/config/joined-config.ts"],"names":[],"mappings":";;;;AAAA,8EAAgG;AAEhG,sCAA4C;AAE5C,+CAA0D;AAQnD,IAAM,uCAAuC,GAAG,UAAC,aAA4B,EAAE,cAAuB;IAC3G,wCAAwC;IACxC,IAAM,QAAQ,GAAG,QAAQ,CAAC,sBAAsB,EAAE,CAAC;IAEnD,IAAM,oBAAoB,GAAG,UAAC,SAAiC;QAAjC,0BAAA,EAAA,cAAiC;QAC7D,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE;YACjC,SAAS,GAAG,CAAC,SAAS,CAAC,CAAC;SACzB;QACD,SAAS,GAAG,SAAS,CAAC,MAAM,CAAC,UAAC,QAAgB;YAC5C,IAAI;gBACF,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;aAClC;YAAC,WAAM;gBACN,cAAc,CAAC,IAAI,CAAC,uDAA+C,QAAQ,6BAAyB,CAAC,CAAC;gBACtG,OAAO,KAAK,CAAC;aACd;YACD,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;QACH,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE;YAC1B,OAAO,SAAS,CAAC;SAClB;QACD,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC;IACF,aAAa,CAAC,aAAa,GAAG,oBAAoB,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;IAChF,aAAa,CAAC,YAAY,GAAG,oBAAoB,CAAC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BAC9B,CAAC,EAAA;;gBAHI,iBAAiB,GAAG,SAGxB;gBAEF,sBAAO,IAAI,kCAAkC,CAAC,iBAAiB,EAAE,WAAW,CAAC,EAAC;;;KAC/E,CAAC;AARW,QAAA,wCAAwC,4CAQnD","sourcesContent":["import { RemoteConfigFetch, createRemoteConfigFetch } from '@amplitude/analytics-remote-config';\nimport { ILogger } from '@amplitude/analytics-core';\nimport { getDebugConfig } from '../helpers';\nimport { SessionReplayOptions } from '../typings/session-replay';\nimport { SessionReplayLocalConfig } from './local-config';\nimport {\n SessionReplayLocalConfig as ISessionReplayLocalConfig,\n PrivacyConfig,\n SessionReplayJoinedConfig,\n SessionReplayRemoteConfig,\n} from './types';\n\nexport const removeInvalidSelectorsFromPrivacyConfig = (privacyConfig: PrivacyConfig, loggerProvider: ILogger) => {\n // This allows us to not search the DOM.\n const fragment = document.createDocumentFragment();\n\n const dropInvalidSelectors = (selectors: string[] | string = []): string[] | undefined => {\n if (typeof selectors === 'string') {\n selectors = [selectors];\n }\n selectors = selectors.filter((selector: string) => {\n try {\n fragment.querySelector(selector);\n } catch {\n loggerProvider.warn(`[session-replay-browser] omitting selector \"${selector}\" because it is invalid`);\n return false;\n }\n return true;\n });\n if (selectors.length === 0) {\n return undefined;\n }\n return selectors;\n };\n privacyConfig.blockSelector = dropInvalidSelectors(privacyConfig.blockSelector);\n privacyConfig.maskSelector = dropInvalidSelectors(privacyConfig.maskSelector);\n privacyConfig.unmaskSelector = dropInvalidSelectors(privacyConfig.unmaskSelector);\n return privacyConfig;\n};\nexport class SessionReplayJoinedConfigGenerator {\n private readonly localConfig: ISessionReplayLocalConfig;\n private readonly remoteConfigFetch: RemoteConfigFetch<SessionReplayRemoteConfig>;\n\n constructor(remoteConfigFetch: RemoteConfigFetch<SessionReplayRemoteConfig>, localConfig: ISessionReplayLocalConfig) {\n this.localConfig = localConfig;\n this.remoteConfigFetch = remoteConfigFetch;\n }\n\n async generateJoinedConfig(sessionId?: string | number): Promise<SessionReplayJoinedConfig> {\n const config: SessionReplayJoinedConfig = { ...this.localConfig };\n // Special case here as optOut is implemented via getter/setter\n config.optOut = this.localConfig.optOut;\n // We always want captureEnabled to be true, unless there's an override\n // in the remote config.\n config.captureEnabled = true;\n let remoteConfig: SessionReplayRemoteConfig | undefined;\n try {\n const samplingConfig = await this.remoteConfigFetch.getRemoteConfig(\n 'sessionReplay',\n 'sr_sampling_config',\n sessionId,\n );\n\n const privacyConfig = await this.remoteConfigFetch.getRemoteConfig(\n 'sessionReplay',\n 'sr_privacy_config',\n sessionId,\n );\n\n // This is intentionally forced to only be set through the remote config.\n config.interactionConfig = await this.remoteConfigFetch.getRemoteConfig(\n 'sessionReplay',\n 'sr_interaction_config',\n sessionId,\n );\n\n // This is intentionally forced to only be set through the remote config.\n config.loggingConfig = await this.remoteConfigFetch.getRemoteConfig(\n 'sessionReplay',\n 'sr_logging_config',\n sessionId,\n );\n\n if (samplingConfig || privacyConfig) {\n remoteConfig = {};\n if (samplingConfig) {\n remoteConfig.sr_sampling_config = samplingConfig;\n }\n if (privacyConfig) {\n remoteConfig.sr_privacy_config = privacyConfig;\n }\n }\n } catch (err: unknown) {\n const knownError = err as Error;\n this.localConfig.loggerProvider.warn(knownError.message);\n config.captureEnabled = false;\n }\n\n if (!remoteConfig) {\n return config;\n }\n\n const { sr_sampling_config: samplingConfig, sr_privacy_config: remotePrivacyConfig } = remoteConfig;\n if (samplingConfig && Object.keys(samplingConfig).length > 0) {\n if (Object.prototype.hasOwnProperty.call(samplingConfig, 'capture_enabled')) {\n config.captureEnabled = samplingConfig.capture_enabled;\n } else {\n config.captureEnabled = false;\n }\n\n if (Object.prototype.hasOwnProperty.call(samplingConfig, 'sample_rate')) {\n config.sampleRate = samplingConfig.sample_rate;\n }\n } else {\n // If config API response was valid (ie 200), but no config returned, assume that\n // customer has not yet set up config, and use sample rate from SDK options,\n // allowing for immediate replay capture\n config.captureEnabled = true;\n this.localConfig.loggerProvider.debug(\n 'Remote config successfully fetched, but no values set for project, Session Replay capture enabled.',\n );\n }\n\n // Remote config join acts somewhat like a left join between the remote and the local\n // config. That is, remote config has precedence over local values as with sampling.\n // However, non conflicting values will be added to the lists.\n // Here's an example to illustrate:\n //\n // Remote config: {'.selector1': 'MASK', '.selector2': 'UNMASK'}\n // Local config: {'.selector1': 'UNMASK', '.selector3': 'MASK'}\n //\n // Resolved config: {'.selector1': 'MASK', '.selector2': 'UNMASK', '.selector3': 'MASK'}\n // config.privacyConfig = {\n // ...(config.privacyConfig ?? {}),\n // ...remotePrivacyConfig,\n // };\n\n if (remotePrivacyConfig) {\n const localPrivacyConfig: PrivacyConfig = config.privacyConfig ?? {};\n\n const joinedPrivacyConfig: Required<PrivacyConfig> & { blockSelector: string[] } = {\n defaultMaskLevel: remotePrivacyConfig.defaultMaskLevel ?? localPrivacyConfig.defaultMaskLevel ?? 'medium',\n blockSelector: [],\n maskSelector: [],\n unmaskSelector: [],\n };\n\n const privacyConfigSelectorMap = (privacyConfig: PrivacyConfig): Record<string, 'mask' | 'unmask' | 'block'> => {\n const selectorMap: Record<string, 'mask' | 'unmask' | 'block'> = {};\n if (typeof privacyConfig.blockSelector === 'string') {\n privacyConfig.blockSelector = [privacyConfig.blockSelector];\n }\n\n for (const selector of privacyConfig.blockSelector ?? []) {\n selectorMap[selector] = 'block';\n }\n for (const selector of privacyConfig.maskSelector ?? []) {\n selectorMap[selector] = 'mask';\n }\n for (const selector of privacyConfig.unmaskSelector ?? []) {\n selectorMap[selector] = 'unmask';\n }\n return selectorMap;\n };\n\n const selectorMap: Record<string, 'mask' | 'unmask' | 'block'> = {\n ...privacyConfigSelectorMap(localPrivacyConfig),\n ...privacyConfigSelectorMap(remotePrivacyConfig),\n };\n\n for (const [selector, selectorType] of Object.entries(selectorMap)) {\n if (selectorType === 'mask') {\n joinedPrivacyConfig.maskSelector.push(selector);\n } else if (selectorType === 'block') {\n joinedPrivacyConfig.blockSelector.push(selector);\n } else if (selectorType === 'unmask') {\n joinedPrivacyConfig.unmaskSelector.push(selector);\n }\n }\n\n config.privacyConfig = removeInvalidSelectorsFromPrivacyConfig(\n joinedPrivacyConfig,\n this.localConfig.loggerProvider,\n );\n }\n\n this.localConfig.loggerProvider.debug(\n JSON.stringify({ name: 'session replay joined config', config: getDebugConfig(config) }, null, 2),\n );\n\n return config;\n }\n}\n\nexport const createSessionReplayJoinedConfigGenerator = async (apiKey: string, options: SessionReplayOptions) => {\n const localConfig = new SessionReplayLocalConfig(apiKey, options);\n const remoteConfigFetch = await createRemoteConfigFetch<SessionReplayRemoteConfig>({\n localConfig,\n configKeys: ['sessionReplay'],\n });\n\n return new SessionReplayJoinedConfigGenerator(remoteConfigFetch, localConfig);\n};\n"]}
|
|
1
|
+
{"version":3,"file":"joined-config.js","sourceRoot":"","sources":["../../../src/config/joined-config.ts"],"names":[],"mappings":";;;;AAAA,8EAAgG;AAEhG,sCAA4C;AAE5C,+CAA0D;AASnD,IAAM,uCAAuC,GAAG,UAAC,aAA4B,EAAE,cAAuB;IAC3G,wCAAwC;IACxC,IAAM,QAAQ,GAAG,QAAQ,CAAC,sBAAsB,EAAE,CAAC;IAEnD,IAAM,oBAAoB,GAAG,UAAC,SAAiC;QAAjC,0BAAA,EAAA,cAAiC;QAC7D,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE;YACjC,SAAS,GAAG,CAAC,SAAS,CAAC,CAAC;SACzB;QACD,SAAS,GAAG,SAAS,CAAC,MAAM,CAAC,UAAC,QAAgB;YAC5C,IAAI;gBACF,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;aAClC;YAAC,WAAM;gBACN,cAAc,CAAC,IAAI,CAAC,uDAA+C,QAAQ,6BAAyB,CAAC,CAAC;gBACtG,OAAO,KAAK,CAAC;aACd;YACD,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;QACH,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE;YAC1B,OAAO,SAAS,CAAC;SAClB;QACD,OAAO,SAAS,CAAC;IACn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BACb,EAAC;;;;KACH;IACH,yCAAC;AAAD,CAAC,AAjKD,IAiKC;AAjKY,gFAAkC;AAmKxC,IAAM,wCAAwC,GAAG,UAAO,MAAc,EAAE,OAA6B;;;;;gBACpG,WAAW,GAAG,IAAI,uCAAwB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBACxC,qBAAM,IAAA,iDAAuB,EAA4B;wBACjF,WAAW,aAAA;wBACX,UAAU,EAAE,CAAC,eAAe,CAAC;qBAC9B,CAAC,EAAA;;gBAHI,iBAAiB,GAAG,SAGxB;gBAEF,sBAAO,IAAI,kCAAkC,CAAC,iBAAiB,EAAE,WAAW,CAAC,EAAC;;;KAC/E,CAAC;AARW,QAAA,wCAAwC,4CAQnD","sourcesContent":["import { RemoteConfigFetch, createRemoteConfigFetch } from '@amplitude/analytics-remote-config';\nimport { ILogger } from '@amplitude/analytics-core';\nimport { getDebugConfig } from '../helpers';\nimport { SessionReplayOptions } from '../typings/session-replay';\nimport { SessionReplayLocalConfig } from './local-config';\nimport {\n SessionReplayLocalConfig as ISessionReplayLocalConfig,\n PrivacyConfig,\n SessionReplayConfigs,\n SessionReplayJoinedConfig,\n SessionReplayRemoteConfig,\n} from './types';\n\nexport const removeInvalidSelectorsFromPrivacyConfig = (privacyConfig: PrivacyConfig, loggerProvider: ILogger) => {\n // This allows us to not search the DOM.\n const fragment = document.createDocumentFragment();\n\n const dropInvalidSelectors = (selectors: string[] | string = []): string[] | undefined => {\n if (typeof selectors === 'string') {\n selectors = [selectors];\n }\n selectors = selectors.filter((selector: string) => {\n try {\n fragment.querySelector(selector);\n } catch {\n loggerProvider.warn(`[session-replay-browser] omitting selector \"${selector}\" because it is invalid`);\n return false;\n }\n return true;\n });\n if (selectors.length === 0) {\n return undefined;\n }\n return selectors;\n };\n privacyConfig.blockSelector = dropInvalidSelectors(privacyConfig.blockSelector);\n privacyConfig.maskSelector = dropInvalidSelectors(privacyConfig.maskSelector);\n privacyConfig.unmaskSelector = dropInvalidSelectors(privacyConfig.unmaskSelector);\n return privacyConfig;\n};\nexport class SessionReplayJoinedConfigGenerator {\n private readonly localConfig: ISessionReplayLocalConfig;\n private readonly remoteConfigFetch: RemoteConfigFetch<SessionReplayRemoteConfig>;\n\n constructor(remoteConfigFetch: RemoteConfigFetch<SessionReplayRemoteConfig>, localConfig: ISessionReplayLocalConfig) {\n this.localConfig = localConfig;\n this.remoteConfigFetch = remoteConfigFetch;\n }\n\n async generateJoinedConfig(sessionId?: string | number): Promise<SessionReplayConfigs> {\n const config: SessionReplayJoinedConfig = { ...this.localConfig };\n // Special case here as optOut is implemented via getter/setter\n config.optOut = this.localConfig.optOut;\n // We always want captureEnabled to be true, unless there's an override\n // in the remote config.\n config.captureEnabled = true;\n let remoteConfig: SessionReplayRemoteConfig | undefined;\n try {\n const samplingConfig = await this.remoteConfigFetch.getRemoteConfig(\n 'sessionReplay',\n 'sr_sampling_config',\n sessionId,\n );\n\n const privacyConfig = await this.remoteConfigFetch.getRemoteConfig(\n 'sessionReplay',\n 'sr_privacy_config',\n sessionId,\n );\n\n // This is intentionally forced to only be set through the remote config.\n config.interactionConfig = await this.remoteConfigFetch.getRemoteConfig(\n 'sessionReplay',\n 'sr_interaction_config',\n sessionId,\n );\n\n // This is intentionally forced to only be set through the remote config.\n config.loggingConfig = await this.remoteConfigFetch.getRemoteConfig(\n 'sessionReplay',\n 'sr_logging_config',\n sessionId,\n );\n\n if (samplingConfig || privacyConfig) {\n remoteConfig = {};\n if (samplingConfig) {\n remoteConfig.sr_sampling_config = samplingConfig;\n }\n if (privacyConfig) {\n remoteConfig.sr_privacy_config = privacyConfig;\n }\n }\n } catch (err: unknown) {\n const knownError = err as Error;\n this.localConfig.loggerProvider.warn(knownError.message);\n config.captureEnabled = false;\n }\n\n if (!remoteConfig) {\n return {\n localConfig: this.localConfig,\n joinedConfig: config,\n remoteConfig,\n };\n }\n\n const { sr_sampling_config: samplingConfig, sr_privacy_config: remotePrivacyConfig } = remoteConfig;\n if (samplingConfig && Object.keys(samplingConfig).length > 0) {\n if (Object.prototype.hasOwnProperty.call(samplingConfig, 'capture_enabled')) {\n config.captureEnabled = samplingConfig.capture_enabled;\n } else {\n config.captureEnabled = false;\n }\n\n if (Object.prototype.hasOwnProperty.call(samplingConfig, 'sample_rate')) {\n config.sampleRate = samplingConfig.sample_rate;\n }\n } else {\n // If config API response was valid (ie 200), but no config returned, assume that\n // customer has not yet set up config, and use sample rate from SDK options,\n // allowing for immediate replay capture\n config.captureEnabled = true;\n this.localConfig.loggerProvider.debug(\n 'Remote config successfully fetched, but no values set for project, Session Replay capture enabled.',\n );\n }\n\n // Remote config join acts somewhat like a left join between the remote and the local\n // config. That is, remote config has precedence over local values as with sampling.\n // However, non conflicting values will be added to the lists.\n // Here's an example to illustrate:\n //\n // Remote config: {'.selector1': 'MASK', '.selector2': 'UNMASK'}\n // Local config: {'.selector1': 'UNMASK', '.selector3': 'MASK'}\n //\n // Resolved config: {'.selector1': 'MASK', '.selector2': 'UNMASK', '.selector3': 'MASK'}\n // config.privacyConfig = {\n // ...(config.privacyConfig ?? {}),\n // ...remotePrivacyConfig,\n // };\n\n if (remotePrivacyConfig) {\n const localPrivacyConfig: PrivacyConfig = config.privacyConfig ?? {};\n\n const joinedPrivacyConfig: Required<PrivacyConfig> & { blockSelector: string[] } = {\n defaultMaskLevel: remotePrivacyConfig.defaultMaskLevel ?? localPrivacyConfig.defaultMaskLevel ?? 'medium',\n blockSelector: [],\n maskSelector: [],\n unmaskSelector: [],\n };\n\n const privacyConfigSelectorMap = (privacyConfig: PrivacyConfig): Record<string, 'mask' | 'unmask' | 'block'> => {\n const selectorMap: Record<string, 'mask' | 'unmask' | 'block'> = {};\n if (typeof privacyConfig.blockSelector === 'string') {\n privacyConfig.blockSelector = [privacyConfig.blockSelector];\n }\n\n for (const selector of privacyConfig.blockSelector ?? []) {\n selectorMap[selector] = 'block';\n }\n for (const selector of privacyConfig.maskSelector ?? []) {\n selectorMap[selector] = 'mask';\n }\n for (const selector of privacyConfig.unmaskSelector ?? []) {\n selectorMap[selector] = 'unmask';\n }\n return selectorMap;\n };\n\n const selectorMap: Record<string, 'mask' | 'unmask' | 'block'> = {\n ...privacyConfigSelectorMap(localPrivacyConfig),\n ...privacyConfigSelectorMap(remotePrivacyConfig),\n };\n\n for (const [selector, selectorType] of Object.entries(selectorMap)) {\n if (selectorType === 'mask') {\n joinedPrivacyConfig.maskSelector.push(selector);\n } else if (selectorType === 'block') {\n joinedPrivacyConfig.blockSelector.push(selector);\n } else if (selectorType === 'unmask') {\n joinedPrivacyConfig.unmaskSelector.push(selector);\n }\n }\n\n config.privacyConfig = removeInvalidSelectorsFromPrivacyConfig(\n joinedPrivacyConfig,\n this.localConfig.loggerProvider,\n );\n }\n\n this.localConfig.loggerProvider.debug(\n JSON.stringify({ name: 'session replay joined config', config: getDebugConfig(config) }, null, 2),\n );\n\n return {\n localConfig: this.localConfig,\n joinedConfig: config,\n remoteConfig,\n };\n }\n}\n\nexport const createSessionReplayJoinedConfigGenerator = async (apiKey: string, options: SessionReplayOptions) => {\n const localConfig = new SessionReplayLocalConfig(apiKey, options);\n const remoteConfigFetch = await createRemoteConfigFetch<SessionReplayRemoteConfig>({\n localConfig,\n configKeys: ['sessionReplay'],\n });\n\n return new SessionReplayJoinedConfigGenerator(remoteConfigFetch, localConfig);\n};\n"]}
|
|
@@ -121,8 +121,29 @@ export interface SessionReplayRemoteConfigFetch {
|
|
|
121
121
|
fetchRemoteConfig: (sessionId?: number) => Promise<SessionReplayRemoteConfig | void>;
|
|
122
122
|
getRemoteConfig: (sessionId?: number) => Promise<SessionReplayRemoteConfig | void>;
|
|
123
123
|
}
|
|
124
|
+
export interface SessionReplayConfigs {
|
|
125
|
+
localConfig: SessionReplayLocalConfig;
|
|
126
|
+
joinedConfig: SessionReplayJoinedConfig;
|
|
127
|
+
remoteConfig: SessionReplayRemoteConfig | undefined;
|
|
128
|
+
}
|
|
124
129
|
export interface SessionReplayJoinedConfigGenerator {
|
|
125
|
-
generateJoinedConfig: (sessionId?: string | number) => Promise<
|
|
130
|
+
generateJoinedConfig: (sessionId?: string | number) => Promise<SessionReplayConfigs>;
|
|
131
|
+
}
|
|
132
|
+
export interface SessionReplayMetadata {
|
|
133
|
+
remoteConfig: SessionReplayRemoteConfig | undefined;
|
|
134
|
+
localConfig: SessionReplayLocalConfig;
|
|
135
|
+
joinedConfig: SessionReplayJoinedConfig;
|
|
136
|
+
framework?: {
|
|
137
|
+
name: string;
|
|
138
|
+
version: string;
|
|
139
|
+
};
|
|
140
|
+
sessionId: string | number | undefined;
|
|
141
|
+
hashValue?: number;
|
|
142
|
+
sampleRate: number;
|
|
143
|
+
replaySDKType: string | null;
|
|
144
|
+
replaySDKVersion: string | undefined;
|
|
145
|
+
standaloneSDKType: string;
|
|
146
|
+
standaloneSDKVersion: string | undefined;
|
|
126
147
|
}
|
|
127
148
|
export interface SessionReplayVersion {
|
|
128
149
|
version: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/config/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAEvE,MAAM,WAAW,cAAc;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,iBAAiB;IAChC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE;QACP,OAAO,EAAE,OAAO,CAAC;QACjB,MAAM,EAAE,eAAe,EAAE,CAAC;KAC3B,CAAC;IACF,OAAO,CAAC,EAAE;QACR,OAAO,EAAE,OAAO,CAAC;KAClB,CAAC;CACH;AAED,MAAM,MA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xC,SAAS,CAAC,EAAE;QACV,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IACvC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,gBAAgB,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,oBAAoB,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1C;AAED,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,iBAAiB,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,8BAA8B;IAC7C;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;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":";;;AA0Ca,QAAA,kBAAkB,GAAG,QAAQ,CAAC","sourcesContent":["import { IConfig, LogLevel, ILogger } from '@amplitude/analytics-core';\nimport { StoreType, ConsoleLogLevel } from '../typings/session-replay';\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\nexport interface LoggingConfig {\n console: {\n enabled: boolean;\n levels: ConsoleLogLevel[];\n };\n network?: {\n enabled: boolean;\n };\n}\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};\n\nexport interface SessionReplayRemoteConfigAPIResponse {\n configs: {\n sessionReplay: SessionReplayRemoteConfig;\n };\n}\n\nexport type MaskLevel =\n | 'light' // only mask a subset of inputs that
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/config/types.ts"],"names":[],"mappings":";;;AA0Ca,QAAA,kBAAkB,GAAG,QAAQ,CAAC","sourcesContent":["import { IConfig, LogLevel, ILogger } from '@amplitude/analytics-core';\nimport { StoreType, ConsoleLogLevel } from '../typings/session-replay';\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\nexport interface LoggingConfig {\n console: {\n enabled: boolean;\n levels: ConsoleLogLevel[];\n };\n network?: {\n enabled: boolean;\n };\n}\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};\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\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 * Experimental features.\n */\n experimental?: {\n /**\n * If the SDK should compress the replay events using a webworker.\n */\n useWebWorker: boolean;\n };\n}\n\nexport interface SessionReplayJoinedConfig extends SessionReplayLocalConfig {\n captureEnabled?: boolean;\n interactionConfig?: InteractionConfig;\n loggingConfig?: LoggingConfig;\n}\n\nexport interface SessionReplayRemoteConfigFetch {\n getServerUrl: () => void;\n getSamplingConfig: (sessionId?: number) => Promise<SessionReplayRemoteConfig['sr_sampling_config'] | void>;\n fetchRemoteConfig: (sessionId?: number) => Promise<SessionReplayRemoteConfig | void>;\n getRemoteConfig: (sessionId?: number) => Promise<SessionReplayRemoteConfig | void>;\n}\n\nexport interface SessionReplayConfigs {\n localConfig: SessionReplayLocalConfig;\n joinedConfig: SessionReplayJoinedConfig;\n remoteConfig: SessionReplayRemoteConfig | undefined;\n}\nexport interface SessionReplayJoinedConfigGenerator {\n generateJoinedConfig: (sessionId?: string | number) => 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\nexport type SessionReplayType = 'standalone' | 'plugin' | 'segment';\n"]}
|
package/lib/cjs/constants.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ export declare const MAX_URL_LENGTH = 1000;
|
|
|
24
24
|
export declare enum CustomRRwebEvent {
|
|
25
25
|
GET_SR_PROPS = "get-sr-props",
|
|
26
26
|
DEBUG_INFO = "debug-info",
|
|
27
|
-
FETCH_REQUEST = "fetch-request"
|
|
27
|
+
FETCH_REQUEST = "fetch-request",
|
|
28
|
+
METADATA = "metadata"
|
|
28
29
|
}
|
|
29
30
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAEzE,eAAO,MAAM,6BAA6B,gBAAgB,CAAC;AAE3D,eAAO,MAAM,+BAA+B,QAAuD,CAAC;AACpG,eAAO,MAAM,2BAA2B,kBAAkB,CAAC;AAC3D,eAAO,MAAM,yBAAyB,gBAAgB,CAAC;AACvD,eAAO,MAAM,mBAAmB,IAAI,CAAC;AACrC,eAAO,MAAM,mBAAmB,gBAAgB,CAAC;AAEjD,eAAO,MAAM,6BAA6B,QAA0D,CAAC;AAErG,eAAO,MAAM,WAAW,cAAc,CAAC;AACvC,eAAO,MAAM,eAAe,aAAa,CAAC;AAC1C,eAAO,MAAM,iBAAiB,eAAe,CAAC;AAC9C,eAAO,MAAM,yBAAyB,mDAAmD,CAAC;AAC1F,eAAO,MAAM,qBAAqB,sDAAsD,CAAC;AACzF,eAAO,MAAM,0BAA0B,yDAAyD,CAAC;AACjG,eAAO,MAAM,cAAc,QAAsC,CAAC;AAClE,eAAO,MAAM,4BAA4B,QAAc,CAAC;AACxD,eAAO,MAAM,wBAAwB,QAAS,CAAC;AAC/C,eAAO,MAAM,wBAAwB,QAAS,CAAC;AAC/C,eAAO,MAAM,YAAY,MAAM,CAAC;AAChC,eAAO,MAAM,YAAY,QAAY,CAAC;AACtC,eAAO,MAAM,sBAAsB,QAA0B,CAAC;AAC9D,eAAO,MAAM,OAAO,OAAO,CAAC;AAC5B,eAAO,MAAM,cAAc,OAAO,CAAC;AAEnC,oBAAY,gBAAgB;IAC1B,YAAY,iBAAiB;IAC7B,UAAU,eAAe;IACzB,aAAa,kBAAkB;
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAEzE,eAAO,MAAM,6BAA6B,gBAAgB,CAAC;AAE3D,eAAO,MAAM,+BAA+B,QAAuD,CAAC;AACpG,eAAO,MAAM,2BAA2B,kBAAkB,CAAC;AAC3D,eAAO,MAAM,yBAAyB,gBAAgB,CAAC;AACvD,eAAO,MAAM,mBAAmB,IAAI,CAAC;AACrC,eAAO,MAAM,mBAAmB,gBAAgB,CAAC;AAEjD,eAAO,MAAM,6BAA6B,QAA0D,CAAC;AAErG,eAAO,MAAM,WAAW,cAAc,CAAC;AACvC,eAAO,MAAM,eAAe,aAAa,CAAC;AAC1C,eAAO,MAAM,iBAAiB,eAAe,CAAC;AAC9C,eAAO,MAAM,yBAAyB,mDAAmD,CAAC;AAC1F,eAAO,MAAM,qBAAqB,sDAAsD,CAAC;AACzF,eAAO,MAAM,0BAA0B,yDAAyD,CAAC;AACjG,eAAO,MAAM,cAAc,QAAsC,CAAC;AAClE,eAAO,MAAM,4BAA4B,QAAc,CAAC;AACxD,eAAO,MAAM,wBAAwB,QAAS,CAAC;AAC/C,eAAO,MAAM,wBAAwB,QAAS,CAAC;AAC/C,eAAO,MAAM,YAAY,MAAM,CAAC;AAChC,eAAO,MAAM,YAAY,QAAY,CAAC;AACtC,eAAO,MAAM,sBAAsB,QAA0B,CAAC;AAC9D,eAAO,MAAM,OAAO,OAAO,CAAC;AAC5B,eAAO,MAAM,cAAc,OAAO,CAAC;AAEnC,oBAAY,gBAAgB;IAC1B,YAAY,iBAAiB;IAC7B,UAAU,eAAe;IACzB,aAAa,kBAAkB;IAC/B,QAAQ,aAAa;CACtB"}
|
package/lib/cjs/constants.js
CHANGED
|
@@ -29,5 +29,6 @@ var CustomRRwebEvent;
|
|
|
29
29
|
CustomRRwebEvent["GET_SR_PROPS"] = "get-sr-props";
|
|
30
30
|
CustomRRwebEvent["DEBUG_INFO"] = "debug-info";
|
|
31
31
|
CustomRRwebEvent["FETCH_REQUEST"] = "fetch-request";
|
|
32
|
+
CustomRRwebEvent["METADATA"] = "metadata";
|
|
32
33
|
})(CustomRRwebEvent = exports.CustomRRwebEvent || (exports.CustomRRwebEvent = {}));
|
|
33
34
|
//# sourceMappingURL=constants.js.map
|
package/lib/cjs/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":";;;AAAA,4DAAyE;AAE5D,QAAA,6BAA6B,GAAG,aAAa,CAAC;AAE9C,QAAA,+BAA+B,GAAG,UAAG,qCAA6B,uBAAoB,CAAC;AACvF,QAAA,2BAA2B,GAAG,eAAe,CAAC;AAC9C,QAAA,yBAAyB,GAAG,aAAa,CAAC;AAC1C,QAAA,mBAAmB,GAAG,CAAC,CAAC;AACxB,QAAA,mBAAmB,GAAG,2BAAU,CAAC,EAAE,CAAC;AAEpC,QAAA,6BAA6B,GAAG,UAAG,qCAA6B,0BAAuB,CAAC;AAExF,QAAA,WAAW,GAAG,WAAW,CAAC;AAC1B,QAAA,eAAe,GAAG,UAAU,CAAC;AAC7B,QAAA,iBAAiB,GAAG,YAAY,CAAC;AACjC,QAAA,yBAAyB,GAAG,gDAAgD,CAAC;AAC7E,QAAA,qBAAqB,GAAG,mDAAmD,CAAC;AAC5E,QAAA,0BAA0B,GAAG,sDAAsD,CAAC;AACpF,QAAA,cAAc,GAAG,UAAG,iCAAgB,mBAAgB,CAAC;AACrD,QAAA,4BAA4B,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,OAAO;AACnD,QAAA,wBAAwB,GAAG,KAAM,CAAC,CAAC,aAAa;AAChD,QAAA,wBAAwB,GAAG,KAAM,CAAC,CAAC,WAAW;AAC9C,QAAA,YAAY,GAAG,GAAG,CAAC,CAAC,SAAS;AAC7B,QAAA,YAAY,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,aAAa;AACvC,QAAA,sBAAsB,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,SAAS;AAC3D,Q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,IAAY,gBAKX;AALD,WAAY,gBAAgB;IAC1B,iDAA6B,CAAA;IAC7B,6CAAyB,CAAA;IACzB,mDAA+B,CAAA;IAC/B,yCAAqB,CAAA;AACvB,CAAC,EALW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAK3B","sourcesContent":["import { AMPLITUDE_PREFIX, ServerZone } from '@amplitude/analytics-core';\n\nexport const DEFAULT_EVENT_PROPERTY_PREFIX = '[Amplitude]';\n\nexport const DEFAULT_SESSION_REPLAY_PROPERTY = `${DEFAULT_EVENT_PROPERTY_PREFIX} Session Replay ID`;\nexport const DEFAULT_SESSION_START_EVENT = 'session_start';\nexport const DEFAULT_SESSION_END_EVENT = 'session_end';\nexport const DEFAULT_SAMPLE_RATE = 0;\nexport const DEFAULT_SERVER_ZONE = ServerZone.US;\n\nexport const SESSION_REPLAY_DEBUG_PROPERTY = `${DEFAULT_EVENT_PROPERTY_PREFIX} Session Replay Debug`;\n\nexport const BLOCK_CLASS = 'amp-block';\nexport const MASK_TEXT_CLASS = 'amp-mask';\nexport const UNMASK_TEXT_CLASS = 'amp-unmask';\nexport const SESSION_REPLAY_SERVER_URL = 'https://api-sr.amplitude.com/sessions/v2/track';\nexport const SESSION_REPLAY_EU_URL = 'https://api-sr.eu.amplitude.com/sessions/v2/track';\nexport const SESSION_REPLAY_STAGING_URL = 'https://api-sr.stag2.amplitude.com/sessions/v2/track';\nexport const STORAGE_PREFIX = `${AMPLITUDE_PREFIX}_replay_unsent`;\nexport const MAX_EVENT_LIST_SIZE_IN_BYTES = 1 * 1000000; // 1 MB\nexport const INTERACTION_MIN_INTERVAL = 30_000; // 30 seconds\nexport const INTERACTION_MAX_INTERVAL = 60_000; // 1 minute\nexport const MIN_INTERVAL = 500; // 500 ms\nexport const MAX_INTERVAL = 10 * 1000; // 10 seconds\nexport const MAX_IDB_STORAGE_LENGTH = 1000 * 60 * 60 * 24 * 3; // 3 days\nexport const KB_SIZE = 1024;\nexport const MAX_URL_LENGTH = 1000;\n\nexport enum CustomRRwebEvent {\n GET_SR_PROPS = 'get-sr-props',\n DEBUG_INFO = 'debug-info',\n FETCH_REQUEST = 'fetch-request',\n METADATA = 'metadata',\n}\n"]}
|
package/lib/cjs/helpers.d.ts
CHANGED
|
@@ -13,7 +13,13 @@ export declare const getDebugConfig: (config: SessionReplayJoinedConfig) => {
|
|
|
13
13
|
interactionConfig?: import("./config/types").InteractionConfig | undefined;
|
|
14
14
|
loggingConfig?: import("./config/types").LoggingConfig | undefined;
|
|
15
15
|
apiKey: string;
|
|
16
|
-
loggerProvider: import("@amplitude/analytics-core").ILogger;
|
|
16
|
+
loggerProvider: import("@amplitude/analytics-core").ILogger; /**
|
|
17
|
+
* Checks if the given element set to be masked by rrweb
|
|
18
|
+
*
|
|
19
|
+
* Priority is:
|
|
20
|
+
* 1. [In code] Element/class based masking/unmasking <> [Config based] Selector based masking/unmasking
|
|
21
|
+
* 2. Use app defaults
|
|
22
|
+
*/
|
|
17
23
|
logLevel: import("@amplitude/analytics-core").LogLevel;
|
|
18
24
|
flushMaxRetries: number;
|
|
19
25
|
sampleRate: number;
|
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;
|
|
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,MAAM,gBAAgB,CAAC;AASzG,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,gBAAgB,QAAkB,MAAM,WASpD,CAAC;AAEF,eAAO,MAAM,iBAAiB,cAAwB,MAAM,GAAG,MAAM,cAAc,MAAM,YAMxF,CAAC;AAEF,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;AAEF,eAAO,MAAM,cAAc,QAAa,QAAQ,WAAW,CAa1D,CAAC;AAEF,eAAO,MAAM,cAAc,WAAY,yBAAyB;;;;;iEAzGhE;;;;;;OAMG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0GF,CAAC"}
|
package/lib/cjs/helpers.js
CHANGED
|
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getDebugConfig = exports.getStorageSize = exports.getServerUrl = exports.generateSessionReplayId = exports.getCurrentUrl = exports.isSessionInSample = exports.generateHashCode = exports.maskFn = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var analytics_core_1 = require("@amplitude/analytics-core");
|
|
6
|
-
var rrweb_snapshot_1 = require("@amplitude/rrweb-snapshot");
|
|
7
6
|
var types_1 = require("./config/types");
|
|
8
7
|
var constants_1 = require("./constants");
|
|
8
|
+
var get_input_type_1 = require("./utils/get-input-type");
|
|
9
9
|
/**
|
|
10
10
|
* Light: Subset of inputs
|
|
11
11
|
* Medium: All inputs
|
|
@@ -17,7 +17,7 @@ var isMaskedForLevel = function (elementType, level, element) {
|
|
|
17
17
|
if (elementType !== 'input') {
|
|
18
18
|
return true;
|
|
19
19
|
}
|
|
20
|
-
var inputType = element ? (0,
|
|
20
|
+
var inputType = element ? (0, get_input_type_1.getInputType)(element) : '';
|
|
21
21
|
/* istanbul ignore if */ // TODO(lew): For some reason it's impossible to test this.
|
|
22
22
|
if (!inputType) {
|
|
23
23
|
return false;
|
package/lib/cjs/helpers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/helpers.ts"],"names":[],"mappings":";;;;AAAA,4DAAuE;AACvE,
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/helpers.ts"],"names":[],"mappings":";;;;AAAA,4DAAuE;AACvE,wCAAyG;AACzG,yCAOqB;AAErB,yDAAsD;AAQtD;;;;GAIG;AACH,IAAM,gBAAgB,GAAG,UAAC,WAA6B,EAAE,KAAgB,EAAE,OAA2B;IACpG,QAAQ,KAAK,EAAE;QACb,KAAK,OAAO,CAAC,CAAC;YACZ,IAAI,WAAW,KAAK,OAAO,EAAE;gBAC3B,OAAO,IAAI,CAAC;aACb;YAED,IAAM,SAAS,GAAG,OAAO,CAAC,CAAC,CAAC,IAAA,6BAAY,EAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YACvD,wBAAwB,CAAC,2DAA2D;YACpF,IAAI,CAAC,SAAS,EAAE;gBACd,OAAO,KAAK,CAAC;aACd;YAED,IAAI,CAAC,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;gBAC9D,OAAO,IAAI,CAAC;aACb;YAED,IAAK,OAA4B,CAAC,YAAY,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE;gBAChE,OAAO,IAAI,CAAC;aACb;YAED,OAAO,KAAK,CAAC;SACd;QACD,KAAK,QAAQ,CAAC;QACd,KAAK,cAAc;YACjB,OAAO,IAAI,CAAC;QACd;YACE,OAAO,gBAAgB,CAAC,WAAW,EAAE,0BAAkB,EAAE,OAAO,CAAC,CAAC;KACrE;AACH,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,IAAM,QAAQ,GAAG,UACf,WAA6B,EAC7B,MAAgE,EAChE,OAA2B;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AAc,kBAazB;AAEK,IAAM,cAAc,GAAG,UAAC,MAAiC;IAC9D,IAAM,WAAW,wBACZ,MAAM,CACV,CAAC;IACM,IAAA,MAAM,GAAK,WAAW,OAAhB,CAAiB;IAC/B,WAAW,CAAC,MAAM,GAAG,cAAO,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAE,CAAC;IAClE,OAAO,WAAW,CAAC;AACrB,CAAC,CAAC;AAPW,QAAA,cAAc,kBAOzB","sourcesContent":["import { getGlobalScope, ServerZone } from '@amplitude/analytics-core';\nimport { DEFAULT_MASK_LEVEL, MaskLevel, PrivacyConfig, SessionReplayJoinedConfig } from './config/types';\nimport {\n KB_SIZE,\n MASK_TEXT_CLASS,\n SESSION_REPLAY_EU_URL,\n SESSION_REPLAY_SERVER_URL,\n SESSION_REPLAY_STAGING_URL,\n UNMASK_TEXT_CLASS,\n} from './constants';\nimport { StorageData } from './typings/session-replay';\nimport { getInputType } from './utils/get-input-type';\n\ntype ChromeStorageEstimate = {\n quota?: number;\n usage?: number;\n usageDetails?: { [key: string]: number };\n};\n\n/**\n * Light: Subset of inputs\n * Medium: All inputs\n * Conservative: All inputs and all texts\n */\nconst isMaskedForLevel = (elementType: 'input' | 'text', level: MaskLevel, element: HTMLElement | null): boolean => {\n switch (level) {\n case 'light': {\n if (elementType !== 'input') {\n return true;\n }\n\n const inputType = element ? getInputType(element) : '';\n /* istanbul ignore if */ // TODO(lew): For some reason it's impossible to test this.\n if (!inputType) {\n return false;\n }\n\n if (['password', 'hidden', 'email', 'tel'].includes(inputType)) {\n return true;\n }\n\n if ((element as HTMLInputElement).autocomplete.startsWith('cc-')) {\n return true;\n }\n\n return false;\n }\n case 'medium':\n case 'conservative':\n return true;\n default:\n return isMaskedForLevel(elementType, DEFAULT_MASK_LEVEL, element);\n }\n};\n\n/**\n * Checks if the given element set to be masked by rrweb\n *\n * Priority is:\n * 1. [In code] Element/class based masking/unmasking <> [Config based] Selector based masking/unmasking\n * 2. Use app defaults\n */\nconst isMasked = (\n elementType: 'input' | 'text',\n config: PrivacyConfig = { defaultMaskLevel: DEFAULT_MASK_LEVEL },\n element: HTMLElement | null,\n): boolean => {\n if (element) {\n // Element or parent is explicitly instrumented in code to mask\n if (element.closest('.' + MASK_TEXT_CLASS)) {\n return true;\n }\n\n // Config has override for mask\n const shouldMask = (config.maskSelector ?? []).some((selector) => element.closest(selector));\n if (shouldMask) {\n return true;\n }\n\n // Code or config has override to unmask\n if (element.closest('.' + UNMASK_TEXT_CLASS)) {\n return false;\n }\n\n // Here we are probably sent an element, but we want to match if they have a\n // parent with an unmask selector.\n const shouldUnmask = (config.unmaskSelector ?? []).some((selector) => element.closest(selector));\n if (shouldUnmask) {\n return false;\n }\n }\n\n return isMaskedForLevel(elementType, config.defaultMaskLevel ?? DEFAULT_MASK_LEVEL, element);\n};\n\nexport const maskFn =\n (elementType: 'text' | 'input', config?: PrivacyConfig) =>\n (text: string, element: HTMLElement | null): string => {\n return isMasked(elementType, config, element) ? text.replace(/[^\\s]/g, '*') : text;\n };\n\nexport const generateHashCode = function (str: string) {\n let hash = 0;\n if (str.length === 0) return hash;\n for (let i = 0; i < str.length; i++) {\n const chr = str.charCodeAt(i);\n hash = (hash << 5) - hash + chr;\n hash |= 0;\n }\n return hash;\n};\n\nexport const isSessionInSample = function (sessionId: string | number, sampleRate: number) {\n const hashNumber = generateHashCode(sessionId.toString());\n const absHash = Math.abs(hashNumber);\n const absHashMultiply = absHash * 31;\n const mod = absHashMultiply % 1000000;\n return mod / 1000000 < sampleRate;\n};\n\nexport const getCurrentUrl = () => {\n const globalScope = getGlobalScope();\n return globalScope?.location ? globalScope.location.href : '';\n};\n\nexport const generateSessionReplayId = (sessionId: string | number, deviceId: string): string => {\n return `${deviceId}/${sessionId}`;\n};\n\nexport const getServerUrl = (serverZone?: keyof typeof ServerZone, trackServerUrl?: string): string => {\n if (trackServerUrl) {\n return trackServerUrl;\n }\n\n if (serverZone === ServerZone.STAGING) {\n return SESSION_REPLAY_STAGING_URL;\n }\n\n if (serverZone === ServerZone.EU) {\n return SESSION_REPLAY_EU_URL;\n }\n\n return SESSION_REPLAY_SERVER_URL;\n};\n\nexport const getStorageSize = async (): Promise<StorageData> => {\n try {\n const globalScope = getGlobalScope();\n if (globalScope) {\n const { usage, quota, usageDetails }: ChromeStorageEstimate = await globalScope.navigator.storage.estimate();\n const totalStorageSize = usage ? Math.round(usage / KB_SIZE) : 0;\n const percentOfQuota = usage && quota ? Math.round((usage / quota + Number.EPSILON) * 1000) / 1000 : 0;\n return { totalStorageSize, percentOfQuota, usageDetails: JSON.stringify(usageDetails) };\n }\n } catch (e) {\n // swallow\n }\n return { totalStorageSize: 0, percentOfQuota: 0, usageDetails: '' };\n};\n\nexport const getDebugConfig = (config: SessionReplayJoinedConfig) => {\n const debugConfig = {\n ...config,\n };\n const { apiKey } = debugConfig;\n debugConfig.apiKey = `****${apiKey.substring(apiKey.length - 4)}`;\n return debugConfig;\n};\n"]}
|
|
@@ -18,6 +18,7 @@ export declare class SessionReplay implements AmplitudeSessionReplay {
|
|
|
18
18
|
pageLeaveFns: PageLeaveFn[];
|
|
19
19
|
private scrollHook?;
|
|
20
20
|
private networkObservers?;
|
|
21
|
+
private metadata;
|
|
21
22
|
constructor();
|
|
22
23
|
init(apiKey: string, options: SessionReplayOptions): import("@amplitude/analytics-core").AmplitudeReturn<void>;
|
|
23
24
|
private teardownEventListeners;
|
|
@@ -42,7 +43,7 @@ export declare class SessionReplay implements AmplitudeSessionReplay {
|
|
|
42
43
|
getBlockSelectors(): string | string[] | undefined;
|
|
43
44
|
getMaskTextSelectors(): string | undefined;
|
|
44
45
|
getRecordingPlugins(loggingConfig: LoggingConfig | undefined): Promise<import("@amplitude/rrweb-types").RecordPlugin<unknown>[] | undefined>;
|
|
45
|
-
recordEvents(): Promise<void>;
|
|
46
|
+
recordEvents(shouldLogMetadata?: boolean): Promise<void>;
|
|
46
47
|
addCustomRRWebEvent: (eventName: CustomRRwebEvent, eventData?: {
|
|
47
48
|
[key: string]: any;
|
|
48
49
|
}, addStorageInfo?: boolean) => Promise<void>;
|
|
@@ -51,6 +52,8 @@ export declare class SessionReplay implements AmplitudeSessionReplay {
|
|
|
51
52
|
getSessionId(): string | number | undefined;
|
|
52
53
|
flush(useRetry?: boolean): Promise<void | undefined>;
|
|
53
54
|
shutdown(): void;
|
|
55
|
+
private mapSDKType;
|
|
56
|
+
private setMetadata;
|
|
54
57
|
}
|
|
55
58
|
export {};
|
|
56
59
|
//# sourceMappingURL=session-replay.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-replay.d.ts","sourceRoot":"","sources":["../../src/session-replay.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,OAAO,EAER,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAG1C,OAAO,
|
|
1
|
+
{"version":3,"file":"session-replay.d.ts","sourceRoot":"","sources":["../../src/session-replay.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,OAAO,EAER,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAG1C,OAAO,EACL,aAAa,EACb,yBAAyB,EACzB,kCAAkC,EAInC,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAEL,gBAAgB,EAMjB,MAAM,aAAa,CAAC;AAOrB,OAAO,EACL,sBAAsB,EACtB,0BAA0B,IAAI,mCAAmC,EAIjE,kBAAkB,IAAI,mBAAmB,EACzC,oBAAoB,EACrB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAI5D,KAAK,WAAW,GAAG,CAAC,CAAC,EAAE,mBAAmB,GAAG,KAAK,KAAK,IAAI,CAAC;AAE5D,qBAAa,aAAc,YAAW,sBAAsB;IAC1D,IAAI,SAAuC;IAC3C,MAAM,EAAE,yBAAyB,GAAG,SAAS,CA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AmB,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;CAwBpB"}
|
|
@@ -51,7 +51,7 @@ var SessionReplay = /** @class */ (function () {
|
|
|
51
51
|
this.focusListener = function () {
|
|
52
52
|
// Restart recording on focus to ensure that when user
|
|
53
53
|
// switches tabs, we take a full snapshot
|
|
54
|
-
void _this.recordEvents();
|
|
54
|
+
void _this.recordEvents(false);
|
|
55
55
|
};
|
|
56
56
|
/**
|
|
57
57
|
* This is an instance member so that if init is called multiple times
|
|
@@ -74,7 +74,7 @@ var SessionReplay = /** @class */ (function () {
|
|
|
74
74
|
_a.trys.push([0, 3, , 4]);
|
|
75
75
|
debugInfo = undefined;
|
|
76
76
|
config = this.config;
|
|
77
|
-
if (!config) return [3 /*break*/, 2];
|
|
77
|
+
if (!(config && eventName !== constants_1.CustomRRwebEvent.METADATA)) return [3 /*break*/, 2];
|
|
78
78
|
debugInfo = {
|
|
79
79
|
config: (0, helpers_1.getDebugConfig)(config),
|
|
80
80
|
version: version_1.VERSION,
|
|
@@ -122,25 +122,26 @@ var SessionReplay = /** @class */ (function () {
|
|
|
122
122
|
return (0, analytics_core_1.returnWrapper)(this._init(apiKey, options));
|
|
123
123
|
};
|
|
124
124
|
SessionReplay.prototype._init = function (apiKey, options) {
|
|
125
|
-
var _a, _b, _c, _d, _e, _f;
|
|
125
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
126
126
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
127
|
-
var
|
|
128
|
-
return tslib_1.__generator(this, function (
|
|
129
|
-
switch (
|
|
127
|
+
var _j, _k, joinedConfig, localConfig, remoteConfig, scrollWatcher, managers, storeType, rrwebEventManager, error_1, typedError, payloadBatcher, interactionEventManager, error_2, typedError;
|
|
128
|
+
return tslib_1.__generator(this, function (_l) {
|
|
129
|
+
switch (_l.label) {
|
|
130
130
|
case 0:
|
|
131
131
|
this.loggerProvider = new logger_1.SafeLoggerProvider(options.loggerProvider || new analytics_core_1.Logger());
|
|
132
132
|
Object.prototype.hasOwnProperty.call(options, 'logLevel') &&
|
|
133
133
|
this.loggerProvider.enable(options.logLevel);
|
|
134
134
|
this.identifiers = new identifiers_1.SessionIdentifiers({ sessionId: options.sessionId, deviceId: options.deviceId });
|
|
135
|
-
|
|
135
|
+
_j = this;
|
|
136
136
|
return [4 /*yield*/, (0, joined_config_1.createSessionReplayJoinedConfigGenerator)(apiKey, options)];
|
|
137
137
|
case 1:
|
|
138
|
-
|
|
139
|
-
_h = this;
|
|
138
|
+
_j.joinedConfigGenerator = _l.sent();
|
|
140
139
|
return [4 /*yield*/, this.joinedConfigGenerator.generateJoinedConfig(this.identifiers.sessionId)];
|
|
141
140
|
case 2:
|
|
142
|
-
|
|
143
|
-
|
|
141
|
+
_k = _l.sent(), joinedConfig = _k.joinedConfig, localConfig = _k.localConfig, remoteConfig = _k.remoteConfig;
|
|
142
|
+
this.config = joinedConfig;
|
|
143
|
+
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);
|
|
144
|
+
if (options.sessionId && ((_c = this.config.interactionConfig) === null || _c === void 0 ? void 0 : _c.enabled)) {
|
|
144
145
|
scrollWatcher = scroll_1.ScrollWatcher.default({
|
|
145
146
|
sessionId: options.sessionId,
|
|
146
147
|
type: 'interaction',
|
|
@@ -150,14 +151,14 @@ var SessionReplay = /** @class */ (function () {
|
|
|
150
151
|
}
|
|
151
152
|
managers = [];
|
|
152
153
|
storeType = this.config.storeType;
|
|
153
|
-
if (storeType === 'idb' && !((
|
|
154
|
+
if (storeType === 'idb' && !((_d = (0, analytics_core_1.getGlobalScope)()) === null || _d === void 0 ? void 0 : _d.indexedDB)) {
|
|
154
155
|
storeType = 'memory';
|
|
155
156
|
this.loggerProvider.warn('Could not use preferred indexedDB storage, reverting to in memory option.');
|
|
156
157
|
}
|
|
157
158
|
this.loggerProvider.log("Using ".concat(storeType, " for event storage."));
|
|
158
|
-
|
|
159
|
+
_l.label = 3;
|
|
159
160
|
case 3:
|
|
160
|
-
|
|
161
|
+
_l.trys.push([3, 5, , 6]);
|
|
161
162
|
return [4 /*yield*/, (0, events_manager_1.createEventsManager)({
|
|
162
163
|
config: this.config,
|
|
163
164
|
sessionId: this.identifiers.sessionId,
|
|
@@ -165,35 +166,35 @@ var SessionReplay = /** @class */ (function () {
|
|
|
165
166
|
storeType: storeType,
|
|
166
167
|
})];
|
|
167
168
|
case 4:
|
|
168
|
-
rrwebEventManager =
|
|
169
|
+
rrwebEventManager = _l.sent();
|
|
169
170
|
managers.push({ name: 'replay', manager: rrwebEventManager });
|
|
170
171
|
return [3 /*break*/, 6];
|
|
171
172
|
case 5:
|
|
172
|
-
error_1 =
|
|
173
|
+
error_1 = _l.sent();
|
|
173
174
|
typedError = error_1;
|
|
174
175
|
this.loggerProvider.warn("Error occurred while creating replay events manager: ".concat(typedError.toString()));
|
|
175
176
|
return [3 /*break*/, 6];
|
|
176
177
|
case 6:
|
|
177
|
-
if (!((
|
|
178
|
+
if (!((_e = this.config.interactionConfig) === null || _e === void 0 ? void 0 : _e.enabled)) return [3 /*break*/, 10];
|
|
178
179
|
payloadBatcher = this.config.interactionConfig.batch ? click_1.clickBatcher : click_1.clickNonBatcher;
|
|
179
|
-
|
|
180
|
+
_l.label = 7;
|
|
180
181
|
case 7:
|
|
181
|
-
|
|
182
|
+
_l.trys.push([7, 9, , 10]);
|
|
182
183
|
return [4 /*yield*/, (0, events_manager_1.createEventsManager)({
|
|
183
184
|
config: this.config,
|
|
184
185
|
sessionId: this.identifiers.sessionId,
|
|
185
186
|
type: 'interaction',
|
|
186
|
-
minInterval: (
|
|
187
|
+
minInterval: (_f = this.config.interactionConfig.trackEveryNms) !== null && _f !== void 0 ? _f : constants_1.INTERACTION_MIN_INTERVAL,
|
|
187
188
|
maxInterval: constants_1.INTERACTION_MAX_INTERVAL,
|
|
188
189
|
payloadBatcher: payloadBatcher,
|
|
189
190
|
storeType: storeType,
|
|
190
191
|
})];
|
|
191
192
|
case 8:
|
|
192
|
-
interactionEventManager =
|
|
193
|
+
interactionEventManager = _l.sent();
|
|
193
194
|
managers.push({ name: 'interaction', manager: interactionEventManager });
|
|
194
195
|
return [3 /*break*/, 10];
|
|
195
196
|
case 9:
|
|
196
|
-
error_2 =
|
|
197
|
+
error_2 = _l.sent();
|
|
197
198
|
typedError = error_2;
|
|
198
199
|
this.loggerProvider.warn("Error occurred while creating interaction events manager: ".concat(typedError.toString()));
|
|
199
200
|
return [3 /*break*/, 10];
|
|
@@ -205,7 +206,7 @@ var SessionReplay = /** @class */ (function () {
|
|
|
205
206
|
}
|
|
206
207
|
this.eventCompressor = new event_compressor_1.EventCompressor(this.eventsManager, this.config, this.getDeviceId());
|
|
207
208
|
// Initialize network observers if logging is enabled
|
|
208
|
-
if ((
|
|
209
|
+
if ((_h = (_g = this.config.loggingConfig) === null || _g === void 0 ? void 0 : _g.network) === null || _h === void 0 ? void 0 : _h.enabled) {
|
|
209
210
|
this.networkObservers = new observers_1.NetworkObservers();
|
|
210
211
|
}
|
|
211
212
|
this.loggerProvider.log('Installing @amplitude/session-replay-browser.');
|
|
@@ -221,9 +222,9 @@ var SessionReplay = /** @class */ (function () {
|
|
|
221
222
|
};
|
|
222
223
|
SessionReplay.prototype.asyncSetSessionId = function (sessionId, deviceId) {
|
|
223
224
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
224
|
-
var previousSessionId, deviceIdForReplayId,
|
|
225
|
-
return tslib_1.__generator(this, function (
|
|
226
|
-
switch (
|
|
225
|
+
var previousSessionId, deviceIdForReplayId, joinedConfig;
|
|
226
|
+
return tslib_1.__generator(this, function (_a) {
|
|
227
|
+
switch (_a.label) {
|
|
227
228
|
case 0:
|
|
228
229
|
previousSessionId = this.identifiers && this.identifiers.sessionId;
|
|
229
230
|
if (previousSessionId) {
|
|
@@ -235,11 +236,11 @@ var SessionReplay = /** @class */ (function () {
|
|
|
235
236
|
deviceId: deviceIdForReplayId,
|
|
236
237
|
});
|
|
237
238
|
if (!(this.joinedConfigGenerator && previousSessionId)) return [3 /*break*/, 2];
|
|
238
|
-
_a = this;
|
|
239
239
|
return [4 /*yield*/, this.joinedConfigGenerator.generateJoinedConfig(this.identifiers.sessionId)];
|
|
240
240
|
case 1:
|
|
241
|
-
|
|
242
|
-
|
|
241
|
+
joinedConfig = (_a.sent()).joinedConfig;
|
|
242
|
+
this.config = joinedConfig;
|
|
243
|
+
_a.label = 2;
|
|
243
244
|
case 2:
|
|
244
245
|
void this.recordEvents();
|
|
245
246
|
return [2 /*return*/];
|
|
@@ -382,8 +383,9 @@ var SessionReplay = /** @class */ (function () {
|
|
|
382
383
|
});
|
|
383
384
|
});
|
|
384
385
|
};
|
|
385
|
-
SessionReplay.prototype.recordEvents = function () {
|
|
386
|
+
SessionReplay.prototype.recordEvents = function (shouldLogMetadata) {
|
|
386
387
|
var _a, _b;
|
|
388
|
+
if (shouldLogMetadata === void 0) { shouldLogMetadata = true; }
|
|
387
389
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
388
390
|
var config, shouldRecord, sessionId, privacyConfig, interactionConfig, loggingConfig, hooks, _c, _d, error_4;
|
|
389
391
|
var _e;
|
|
@@ -466,6 +468,9 @@ var SessionReplay = /** @class */ (function () {
|
|
|
466
468
|
_c.recordCancelCallback = _d.apply(void 0, [(_e.plugins = _f.sent(),
|
|
467
469
|
_e)]);
|
|
468
470
|
void this.addCustomRRWebEvent(constants_1.CustomRRwebEvent.DEBUG_INFO);
|
|
471
|
+
if (shouldLogMetadata) {
|
|
472
|
+
void this.addCustomRRWebEvent(constants_1.CustomRRwebEvent.METADATA, this.metadata);
|
|
473
|
+
}
|
|
469
474
|
return [3 /*break*/, 4];
|
|
470
475
|
case 3:
|
|
471
476
|
error_4 = _f.sent();
|
|
@@ -498,6 +503,30 @@ var SessionReplay = /** @class */ (function () {
|
|
|
498
503
|
this.stopRecordingEvents();
|
|
499
504
|
this.sendEvents();
|
|
500
505
|
};
|
|
506
|
+
SessionReplay.prototype.mapSDKType = function (sdkType) {
|
|
507
|
+
if (sdkType === 'plugin') {
|
|
508
|
+
return '@amplitude/plugin-session-replay-browser';
|
|
509
|
+
}
|
|
510
|
+
if (sdkType === 'segment') {
|
|
511
|
+
return '@amplitude/segment-session-replay-plugin';
|
|
512
|
+
}
|
|
513
|
+
return null;
|
|
514
|
+
};
|
|
515
|
+
SessionReplay.prototype.setMetadata = function (sessionId, joinedConfig, localConfig, remoteConfig, replaySDKVersion, standaloneSDKVersion, sdkType) {
|
|
516
|
+
var hashValue = (sessionId === null || sessionId === void 0 ? void 0 : sessionId.toString()) ? (0, helpers_1.generateHashCode)(sessionId.toString()) : undefined;
|
|
517
|
+
this.metadata = {
|
|
518
|
+
joinedConfig: joinedConfig,
|
|
519
|
+
localConfig: localConfig,
|
|
520
|
+
remoteConfig: remoteConfig,
|
|
521
|
+
sessionId: sessionId,
|
|
522
|
+
hashValue: hashValue,
|
|
523
|
+
sampleRate: joinedConfig.sampleRate,
|
|
524
|
+
replaySDKType: this.mapSDKType(sdkType),
|
|
525
|
+
replaySDKVersion: replaySDKVersion,
|
|
526
|
+
standaloneSDKType: '@amplitude/session-replay-browser',
|
|
527
|
+
standaloneSDKVersion: standaloneSDKVersion,
|
|
528
|
+
};
|
|
529
|
+
};
|
|
501
530
|
return SessionReplay;
|
|
502
531
|
}());
|
|
503
532
|
exports.SessionReplay = SessionReplay;
|