@amplitude/session-replay-browser 1.22.6 → 1.22.7-prereleasenetworkcapture.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/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 +2 -10
- package/lib/cjs/config/joined-config.js.map +1 -1
- package/lib/cjs/config/types.d.ts +1 -22
- 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 +1 -2
- package/lib/cjs/constants.d.ts.map +1 -1
- package/lib/cjs/constants.js +0 -1
- package/lib/cjs/constants.js.map +1 -1
- package/lib/cjs/session-replay.d.ts +1 -3
- package/lib/cjs/session-replay.d.ts.map +1 -1
- package/lib/cjs/session-replay.js +30 -50
- 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/scripts/amplitude-min.js +2 -0
- package/lib/scripts/amplitude-min.js.gz +0 -0
- package/lib/scripts/amplitude-min.js.map +1 -0
- package/lib/scripts/amplitude-min.umd.js +1 -0
- package/lib/scripts/amplitude-min.umd.js.gz +0 -0
- package/lib/scripts/beacon-transport.d.ts +28 -0
- package/lib/scripts/beacon-transport.d.ts.map +1 -0
- package/lib/scripts/config/joined-config.d.ts +13 -0
- package/lib/scripts/config/joined-config.d.ts.map +1 -0
- package/lib/scripts/config/local-config.d.ts +27 -0
- package/lib/scripts/config/local-config.d.ts.map +1 -0
- package/lib/scripts/config/types.d.ts +147 -0
- package/lib/scripts/config/types.d.ts.map +1 -0
- package/lib/scripts/console-plugin-min.js.gz +0 -0
- package/lib/scripts/constants.d.ts +29 -0
- package/lib/scripts/constants.d.ts.map +1 -0
- package/lib/scripts/events/base-events-store.d.ts +31 -0
- package/lib/scripts/events/base-events-store.d.ts.map +1 -0
- package/lib/scripts/events/event-compressor.d.ts +27 -0
- package/lib/scripts/events/event-compressor.d.ts.map +1 -0
- package/lib/scripts/events/events-idb-store.d.ts +52 -0
- package/lib/scripts/events/events-idb-store.d.ts.map +1 -0
- package/lib/scripts/events/events-manager.d.ts +13 -0
- package/lib/scripts/events/events-manager.d.ts.map +1 -0
- package/lib/scripts/events/events-memory-store.d.ts +15 -0
- package/lib/scripts/events/events-memory-store.d.ts.map +1 -0
- package/lib/scripts/events/legacy-idb-types.d.ts +26 -0
- package/lib/scripts/events/legacy-idb-types.d.ts.map +1 -0
- package/lib/scripts/events/multi-manager.d.ts +26 -0
- package/lib/scripts/events/multi-manager.d.ts.map +1 -0
- package/lib/scripts/helpers.d.ts +46 -0
- package/lib/scripts/helpers.d.ts.map +1 -0
- package/lib/scripts/hooks/click.d.ts +27 -0
- package/lib/scripts/hooks/click.d.ts.map +1 -0
- package/lib/scripts/hooks/scroll.d.ts +44 -0
- package/lib/scripts/hooks/scroll.d.ts.map +1 -0
- package/lib/scripts/identifiers.d.ts +11 -0
- package/lib/scripts/identifiers.d.ts.map +1 -0
- package/lib/scripts/index.d.ts +7 -0
- package/lib/scripts/index.d.ts.map +1 -0
- package/lib/scripts/libs/finder.d.ts +14 -0
- package/lib/scripts/libs/finder.d.ts.map +1 -0
- package/lib/scripts/logger.d.ts +13 -0
- package/lib/scripts/logger.d.ts.map +1 -0
- package/lib/scripts/messages.d.ts +7 -0
- package/lib/scripts/messages.d.ts.map +1 -0
- package/lib/scripts/observers.d.ts +24 -0
- package/lib/scripts/observers.d.ts.map +1 -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/lib/scripts/session-replay-factory.d.ts +7 -0
- package/lib/scripts/session-replay-factory.d.ts.map +1 -0
- package/lib/scripts/session-replay.d.ts +56 -0
- package/lib/scripts/session-replay.d.ts.map +1 -0
- package/lib/scripts/track-destination.d.ts +37 -0
- package/lib/scripts/track-destination.d.ts.map +1 -0
- package/lib/scripts/typings/session-replay.d.ts +129 -0
- package/lib/scripts/typings/session-replay.d.ts.map +1 -0
- package/lib/scripts/version.d.ts +2 -0
- package/lib/scripts/version.d.ts.map +1 -0
- package/lib/scripts/worker/compression.d.ts +2 -0
- package/lib/scripts/worker/compression.d.ts.map +1 -0
- package/package.json +3 -3
|
@@ -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, SessionReplayJoinedConfig, 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<SessionReplayJoinedConfig>;
|
|
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,yBAAyB,EACzB,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,yBAAyB,CAAC;CAgJ5F;AAED,eAAO,MAAM,wCAAwC,WAAkB,MAAM,WAAW,oBAAoB,gDAQ3G,CAAC"}
|
|
@@ -92,11 +92,7 @@ var SessionReplayJoinedConfigGenerator = /** @class */ (function () {
|
|
|
92
92
|
return [3 /*break*/, 7];
|
|
93
93
|
case 7:
|
|
94
94
|
if (!remoteConfig) {
|
|
95
|
-
return [2 /*return*/,
|
|
96
|
-
localConfig: this.localConfig,
|
|
97
|
-
joinedConfig: config,
|
|
98
|
-
remoteConfig: remoteConfig,
|
|
99
|
-
}];
|
|
95
|
+
return [2 /*return*/, config];
|
|
100
96
|
}
|
|
101
97
|
samplingConfig = remoteConfig.sr_sampling_config, remotePrivacyConfig = remoteConfig.sr_privacy_config;
|
|
102
98
|
if (samplingConfig && Object.keys(samplingConfig).length > 0) {
|
|
@@ -211,11 +207,7 @@ var SessionReplayJoinedConfigGenerator = /** @class */ (function () {
|
|
|
211
207
|
config.privacyConfig = (0, exports.removeInvalidSelectorsFromPrivacyConfig)(joinedPrivacyConfig, this.localConfig.loggerProvider);
|
|
212
208
|
}
|
|
213
209
|
this.localConfig.loggerProvider.debug(JSON.stringify({ name: 'session replay joined config', config: (0, helpers_1.getDebugConfig)(config) }, null, 2));
|
|
214
|
-
return [2 /*return*/,
|
|
215
|
-
localConfig: this.localConfig,
|
|
216
|
-
joinedConfig: config,
|
|
217
|
-
remoteConfig: remoteConfig,
|
|
218
|
-
}];
|
|
210
|
+
return [2 /*return*/, config];
|
|
219
211
|
}
|
|
220
212
|
});
|
|
221
213
|
});
|
|
@@ -1 +1 @@
|
|
|
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,aA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IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,KAAK,CACnC,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,8BAA8B,EAAE,MAAM,EAAE,IAAA,wBAAc,EAAC,MAAM,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAClG,CAAC;wBAEF,sBAAO;gCACL,WAAW,EAAE,IAAI,CAAC,WAAW;gCAC7B,YAAY,EAAE,MAAM;gCACpB,YAAY,cAAA;6BACb,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"]}
|
|
1
|
+
{"version":3,"file":"joined-config.js","sourceRoot":"","sources":["../../../src/config/joined-config.ts"],"names":[],"mappings":";;;;AAAA,8EAAgG;AAEhG,sCAA4C;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,mBAAmB,CAAC,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;qCAClD;yCAAM,IAAI,YAAY,KAAK,QAAQ,EAAE;wCACpC,mBAAmB,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;qCACnD;iCACF;;;;;;;;;4BAED,MAAM,CAAC,aAAa,GAAG,IAAA,+CAAuC,EAC5D,mBAAmB,EACnB,IAAI,CAAC,WAAW,CAAC,cAAc,CAChC,CAAC;yBACH;wBAED,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,KAAK,CACnC,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,8BAA8B,EAAE,MAAM,EAAE,IAAA,wBAAc,EAAC,MAAM,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAClG,CAAC;wBAEF,sBAAO,MAAM,EAAC;;;;KACf;IACH,yCAAC;AAAD,CAAC,AAzJD,IAyJC;AAzJY,gFAAkC;AA2JxC,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 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"]}
|
|
@@ -121,29 +121,8 @@ 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
|
-
}
|
|
129
124
|
export interface SessionReplayJoinedConfigGenerator {
|
|
130
|
-
generateJoinedConfig: (sessionId?: string | number) => Promise<
|
|
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;
|
|
144
|
-
replaySDKVersion: string | undefined;
|
|
145
|
-
standaloneSDKType: string;
|
|
146
|
-
standaloneSDKVersion: string | undefined;
|
|
125
|
+
generateJoinedConfig: (sessionId?: string | number) => Promise<SessionReplayJoinedConfig>;
|
|
147
126
|
}
|
|
148
127
|
export interface SessionReplayVersion {
|
|
149
128
|
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,CA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,OAAO,CAAC,yBAAyB,CAAC,CAAC;CAC3F;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 SessionReplayJoinedConfigGenerator {\n generateJoinedConfig: (sessionId?: string | number) => Promise<SessionReplayJoinedConfig>;\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,7 +24,6 @@ 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"
|
|
28
|
-
METADATA = "metadata"
|
|
27
|
+
FETCH_REQUEST = "fetch-request"
|
|
29
28
|
}
|
|
30
29
|
//# 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,QAA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AM,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;CAChC"}
|
package/lib/cjs/constants.js
CHANGED
|
@@ -29,6 +29,5 @@ 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";
|
|
33
32
|
})(CustomRRwebEvent = exports.CustomRRwebEvent || (exports.CustomRRwebEvent = {}));
|
|
34
33
|
//# 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,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,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,QAAA,OAAO,GAAG,IAAI,CAAC;AACf,QAAA,cAAc,GAAG,IAAI,CAAC;AAEnC,IAAY,gBAIX;AAJD,WAAY,gBAAgB;IAC1B,iDAA6B,CAAA;IAC7B,6CAAyB,CAAA;IACzB,mDAA+B,CAAA;AACjC,CAAC,EAJW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAI3B","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}\n"]}
|
|
@@ -18,7 +18,6 @@ export declare class SessionReplay implements AmplitudeSessionReplay {
|
|
|
18
18
|
pageLeaveFns: PageLeaveFn[];
|
|
19
19
|
private scrollHook?;
|
|
20
20
|
private networkObservers?;
|
|
21
|
-
private metadata;
|
|
22
21
|
constructor();
|
|
23
22
|
init(apiKey: string, options: SessionReplayOptions): import("@amplitude/analytics-core").AmplitudeReturn<void>;
|
|
24
23
|
private teardownEventListeners;
|
|
@@ -43,7 +42,7 @@ export declare class SessionReplay implements AmplitudeSessionReplay {
|
|
|
43
42
|
getBlockSelectors(): string | string[] | undefined;
|
|
44
43
|
getMaskTextSelectors(): string | undefined;
|
|
45
44
|
getRecordingPlugins(loggingConfig: LoggingConfig | undefined): Promise<import("@amplitude/rrweb-types").RecordPlugin<unknown>[] | undefined>;
|
|
46
|
-
recordEvents(
|
|
45
|
+
recordEvents(): Promise<void>;
|
|
47
46
|
addCustomRRWebEvent: (eventName: CustomRRwebEvent, eventData?: {
|
|
48
47
|
[key: string]: any;
|
|
49
48
|
}, addStorageInfo?: boolean) => Promise<void>;
|
|
@@ -52,7 +51,6 @@ export declare class SessionReplay implements AmplitudeSessionReplay {
|
|
|
52
51
|
getSessionId(): string | number | undefined;
|
|
53
52
|
flush(useRetry?: boolean): Promise<void | undefined>;
|
|
54
53
|
shutdown(): void;
|
|
55
|
-
private setMetadata;
|
|
56
54
|
}
|
|
57
55
|
export {};
|
|
58
56
|
//# 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,EAAE,aAAa,EAAE,yBAAyB,EAAE,kCAAkC,EAAE,MAAM,gBAAgB,CAAC;AAC9G,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,CAAC;IAC9C,qBAAqB,EAAE,kCAAkC,GAAG,SAAS,CAAC;IACtE,WA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QAAQ;CAKT"}
|
|
@@ -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();
|
|
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 (!
|
|
77
|
+
if (!config) return [3 /*break*/, 2];
|
|
78
78
|
debugInfo = {
|
|
79
79
|
config: (0, helpers_1.getDebugConfig)(config),
|
|
80
80
|
version: version_1.VERSION,
|
|
@@ -122,26 +122,25 @@ 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;
|
|
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 _g, _h, scrollWatcher, managers, storeType, rrwebEventManager, error_1, typedError, payloadBatcher, interactionEventManager, error_2, typedError;
|
|
128
|
+
return tslib_1.__generator(this, function (_j) {
|
|
129
|
+
switch (_j.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
|
+
_g = this;
|
|
136
136
|
return [4 /*yield*/, (0, joined_config_1.createSessionReplayJoinedConfigGenerator)(apiKey, options)];
|
|
137
137
|
case 1:
|
|
138
|
-
|
|
138
|
+
_g.joinedConfigGenerator = _j.sent();
|
|
139
|
+
_h = this;
|
|
139
140
|
return [4 /*yield*/, this.joinedConfigGenerator.generateJoinedConfig(this.identifiers.sessionId)];
|
|
140
141
|
case 2:
|
|
141
|
-
|
|
142
|
-
this.config
|
|
143
|
-
this.setMetadata(options.sessionId, joinedConfig, localConfig, remoteConfig, (_a = options.version) === null || _a === void 0 ? void 0 : _a.version, version_1.VERSION);
|
|
144
|
-
if (options.sessionId && ((_b = this.config.interactionConfig) === null || _b === void 0 ? void 0 : _b.enabled)) {
|
|
142
|
+
_h.config = _j.sent();
|
|
143
|
+
if (options.sessionId && ((_a = this.config.interactionConfig) === null || _a === void 0 ? void 0 : _a.enabled)) {
|
|
145
144
|
scrollWatcher = scroll_1.ScrollWatcher.default({
|
|
146
145
|
sessionId: options.sessionId,
|
|
147
146
|
type: 'interaction',
|
|
@@ -151,14 +150,14 @@ var SessionReplay = /** @class */ (function () {
|
|
|
151
150
|
}
|
|
152
151
|
managers = [];
|
|
153
152
|
storeType = this.config.storeType;
|
|
154
|
-
if (storeType === 'idb' && !((
|
|
153
|
+
if (storeType === 'idb' && !((_b = (0, analytics_core_1.getGlobalScope)()) === null || _b === void 0 ? void 0 : _b.indexedDB)) {
|
|
155
154
|
storeType = 'memory';
|
|
156
155
|
this.loggerProvider.warn('Could not use preferred indexedDB storage, reverting to in memory option.');
|
|
157
156
|
}
|
|
158
157
|
this.loggerProvider.log("Using ".concat(storeType, " for event storage."));
|
|
159
|
-
|
|
158
|
+
_j.label = 3;
|
|
160
159
|
case 3:
|
|
161
|
-
|
|
160
|
+
_j.trys.push([3, 5, , 6]);
|
|
162
161
|
return [4 /*yield*/, (0, events_manager_1.createEventsManager)({
|
|
163
162
|
config: this.config,
|
|
164
163
|
sessionId: this.identifiers.sessionId,
|
|
@@ -166,35 +165,35 @@ var SessionReplay = /** @class */ (function () {
|
|
|
166
165
|
storeType: storeType,
|
|
167
166
|
})];
|
|
168
167
|
case 4:
|
|
169
|
-
rrwebEventManager =
|
|
168
|
+
rrwebEventManager = _j.sent();
|
|
170
169
|
managers.push({ name: 'replay', manager: rrwebEventManager });
|
|
171
170
|
return [3 /*break*/, 6];
|
|
172
171
|
case 5:
|
|
173
|
-
error_1 =
|
|
172
|
+
error_1 = _j.sent();
|
|
174
173
|
typedError = error_1;
|
|
175
174
|
this.loggerProvider.warn("Error occurred while creating replay events manager: ".concat(typedError.toString()));
|
|
176
175
|
return [3 /*break*/, 6];
|
|
177
176
|
case 6:
|
|
178
|
-
if (!((
|
|
177
|
+
if (!((_c = this.config.interactionConfig) === null || _c === void 0 ? void 0 : _c.enabled)) return [3 /*break*/, 10];
|
|
179
178
|
payloadBatcher = this.config.interactionConfig.batch ? click_1.clickBatcher : click_1.clickNonBatcher;
|
|
180
|
-
|
|
179
|
+
_j.label = 7;
|
|
181
180
|
case 7:
|
|
182
|
-
|
|
181
|
+
_j.trys.push([7, 9, , 10]);
|
|
183
182
|
return [4 /*yield*/, (0, events_manager_1.createEventsManager)({
|
|
184
183
|
config: this.config,
|
|
185
184
|
sessionId: this.identifiers.sessionId,
|
|
186
185
|
type: 'interaction',
|
|
187
|
-
minInterval: (
|
|
186
|
+
minInterval: (_d = this.config.interactionConfig.trackEveryNms) !== null && _d !== void 0 ? _d : constants_1.INTERACTION_MIN_INTERVAL,
|
|
188
187
|
maxInterval: constants_1.INTERACTION_MAX_INTERVAL,
|
|
189
188
|
payloadBatcher: payloadBatcher,
|
|
190
189
|
storeType: storeType,
|
|
191
190
|
})];
|
|
192
191
|
case 8:
|
|
193
|
-
interactionEventManager =
|
|
192
|
+
interactionEventManager = _j.sent();
|
|
194
193
|
managers.push({ name: 'interaction', manager: interactionEventManager });
|
|
195
194
|
return [3 /*break*/, 10];
|
|
196
195
|
case 9:
|
|
197
|
-
error_2 =
|
|
196
|
+
error_2 = _j.sent();
|
|
198
197
|
typedError = error_2;
|
|
199
198
|
this.loggerProvider.warn("Error occurred while creating interaction events manager: ".concat(typedError.toString()));
|
|
200
199
|
return [3 /*break*/, 10];
|
|
@@ -206,7 +205,7 @@ var SessionReplay = /** @class */ (function () {
|
|
|
206
205
|
}
|
|
207
206
|
this.eventCompressor = new event_compressor_1.EventCompressor(this.eventsManager, this.config, this.getDeviceId());
|
|
208
207
|
// Initialize network observers if logging is enabled
|
|
209
|
-
if ((
|
|
208
|
+
if ((_f = (_e = this.config.loggingConfig) === null || _e === void 0 ? void 0 : _e.network) === null || _f === void 0 ? void 0 : _f.enabled) {
|
|
210
209
|
this.networkObservers = new observers_1.NetworkObservers();
|
|
211
210
|
}
|
|
212
211
|
this.loggerProvider.log('Installing @amplitude/session-replay-browser.');
|
|
@@ -222,9 +221,9 @@ var SessionReplay = /** @class */ (function () {
|
|
|
222
221
|
};
|
|
223
222
|
SessionReplay.prototype.asyncSetSessionId = function (sessionId, deviceId) {
|
|
224
223
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
225
|
-
var previousSessionId, deviceIdForReplayId,
|
|
226
|
-
return tslib_1.__generator(this, function (
|
|
227
|
-
switch (
|
|
224
|
+
var previousSessionId, deviceIdForReplayId, _a;
|
|
225
|
+
return tslib_1.__generator(this, function (_b) {
|
|
226
|
+
switch (_b.label) {
|
|
228
227
|
case 0:
|
|
229
228
|
previousSessionId = this.identifiers && this.identifiers.sessionId;
|
|
230
229
|
if (previousSessionId) {
|
|
@@ -236,11 +235,11 @@ var SessionReplay = /** @class */ (function () {
|
|
|
236
235
|
deviceId: deviceIdForReplayId,
|
|
237
236
|
});
|
|
238
237
|
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
|
-
|
|
243
|
-
_a.label = 2;
|
|
241
|
+
_a.config = _b.sent();
|
|
242
|
+
_b.label = 2;
|
|
244
243
|
case 2:
|
|
245
244
|
void this.recordEvents();
|
|
246
245
|
return [2 /*return*/];
|
|
@@ -383,9 +382,8 @@ var SessionReplay = /** @class */ (function () {
|
|
|
383
382
|
});
|
|
384
383
|
});
|
|
385
384
|
};
|
|
386
|
-
SessionReplay.prototype.recordEvents = function (
|
|
385
|
+
SessionReplay.prototype.recordEvents = function () {
|
|
387
386
|
var _a, _b;
|
|
388
|
-
if (shouldLogMetadata === void 0) { shouldLogMetadata = true; }
|
|
389
387
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
390
388
|
var config, shouldRecord, sessionId, privacyConfig, interactionConfig, loggingConfig, hooks, _c, _d, error_4;
|
|
391
389
|
var _e;
|
|
@@ -468,9 +466,6 @@ var SessionReplay = /** @class */ (function () {
|
|
|
468
466
|
_c.recordCancelCallback = _d.apply(void 0, [(_e.plugins = _f.sent(),
|
|
469
467
|
_e)]);
|
|
470
468
|
void this.addCustomRRWebEvent(constants_1.CustomRRwebEvent.DEBUG_INFO);
|
|
471
|
-
if (shouldLogMetadata) {
|
|
472
|
-
void this.addCustomRRWebEvent(constants_1.CustomRRwebEvent.METADATA, this.metadata);
|
|
473
|
-
}
|
|
474
469
|
return [3 /*break*/, 4];
|
|
475
470
|
case 3:
|
|
476
471
|
error_4 = _f.sent();
|
|
@@ -503,21 +498,6 @@ var SessionReplay = /** @class */ (function () {
|
|
|
503
498
|
this.stopRecordingEvents();
|
|
504
499
|
this.sendEvents();
|
|
505
500
|
};
|
|
506
|
-
SessionReplay.prototype.setMetadata = function (sessionId, joinedConfig, localConfig, remoteConfig, replaySDKVersion, standaloneSDKVersion) {
|
|
507
|
-
var hashValue = (sessionId === null || sessionId === void 0 ? void 0 : sessionId.toString()) ? (0, helpers_1.generateHashCode)(sessionId.toString()) : undefined;
|
|
508
|
-
this.metadata = {
|
|
509
|
-
joinedConfig: joinedConfig,
|
|
510
|
-
localConfig: localConfig,
|
|
511
|
-
remoteConfig: remoteConfig,
|
|
512
|
-
sessionId: sessionId,
|
|
513
|
-
hashValue: hashValue,
|
|
514
|
-
sampleRate: joinedConfig.sampleRate,
|
|
515
|
-
replaySDKType: '@amplitude/plugin-session-replay-browser',
|
|
516
|
-
replaySDKVersion: replaySDKVersion,
|
|
517
|
-
standaloneSDKType: '@amplitude/session-replay-browser',
|
|
518
|
-
standaloneSDKVersion: standaloneSDKVersion,
|
|
519
|
-
};
|
|
520
|
-
};
|
|
521
501
|
return SessionReplay;
|
|
522
502
|
}());
|
|
523
503
|
exports.SessionReplay = SessionReplay;
|