@amplitude/plugin-session-replay-browser 1.3.2 → 1.4.1
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/session-replay.d.ts.map +1 -1
- package/lib/cjs/session-replay.js +8 -5
- package/lib/cjs/session-replay.js.map +1 -1
- package/lib/cjs/typings/session-replay.d.ts +4 -0
- package/lib/cjs/typings/session-replay.d.ts.map +1 -1
- package/lib/cjs/typings/session-replay.js.map +1 -1
- package/lib/esm/session-replay.d.ts.map +1 -1
- package/lib/esm/session-replay.js +8 -5
- package/lib/esm/session-replay.js.map +1 -1
- package/lib/esm/typings/session-replay.d.ts +4 -0
- package/lib/esm/typings/session-replay.d.ts.map +1 -1
- package/lib/esm/typings/session-replay.js.map +1 -1
- package/lib/scripts/amplitude-min.js +1 -1
- package/lib/scripts/amplitude-min.js.gz +0 -0
- package/lib/scripts/amplitude-min.umd.js +1 -1
- package/lib/scripts/amplitude-min.umd.js.gz +0 -0
- package/lib/scripts/session-replay.d.ts.map +1 -1
- package/lib/scripts/typings/session-replay.d.ts +4 -0
- package/lib/scripts/typings/session-replay.d.ts.map +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-replay.d.ts","sourceRoot":"","sources":["../../src/session-replay.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,aAAa,EACb,iBAAiB,EAEjB,KAAK,EACL,MAAM,EACP,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAoChE,qBAAa,mBAAoB,YAAW,iBAAiB;IAC3D,IAAI,SAA8C;IAClD,IAAI,gBAA0B;IAI9B,YAAY,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;IAItC,MAAM,EAAE,aAAa,CAAC;IACtB,OAAO,EAAE,oBAAoB,CAAC;gBAElB,OAAO,CAAC,EAAE,oBAAoB;IAQpC,KAAK,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,CAAC,EAAE,aAAa;
|
|
1
|
+
{"version":3,"file":"session-replay.d.ts","sourceRoot":"","sources":["../../src/session-replay.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,aAAa,EACb,iBAAiB,EAEjB,KAAK,EACL,MAAM,EACP,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAoChE,qBAAa,mBAAoB,YAAW,iBAAiB;IAC3D,IAAI,SAA8C;IAClD,IAAI,gBAA0B;IAI9B,YAAY,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;IAItC,MAAM,EAAE,aAAa,CAAC;IACtB,OAAO,EAAE,oBAAoB,CAAC;gBAElB,OAAO,CAAC,EAAE,oBAAoB;IAQpC,KAAK,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,CAAC,EAAE,aAAa;IAqDnD,OAAO,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC;IAQtC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAItB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAa/B,0BAA0B;;;CAG3B;AAED,eAAO,MAAM,mBAAmB,EAAE,CAAC,OAAO,CAAC,EAAE,oBAAoB,KAAK,iBAIrE,CAAC"}
|
|
@@ -52,10 +52,10 @@ var SessionReplayPlugin = /** @class */ (function () {
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
SessionReplayPlugin.prototype.setup = function (config, client) {
|
|
55
|
-
var _a;
|
|
55
|
+
var _a, _b, _c, _d;
|
|
56
56
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
57
|
-
return tslib_1.__generator(this, function (
|
|
58
|
-
switch (
|
|
57
|
+
return tslib_1.__generator(this, function (_e) {
|
|
58
|
+
switch (_e.label) {
|
|
59
59
|
case 0:
|
|
60
60
|
if (!client) {
|
|
61
61
|
config.loggerProvider.error('SessionReplayPlugin requires v1.9.1+ of the Amplitude SDK.');
|
|
@@ -91,17 +91,20 @@ var SessionReplayPlugin = /** @class */ (function () {
|
|
|
91
91
|
sampleRate: this.options.sampleRate,
|
|
92
92
|
privacyConfig: {
|
|
93
93
|
blockSelector: (_a = this.options.privacyConfig) === null || _a === void 0 ? void 0 : _a.blockSelector,
|
|
94
|
+
maskSelector: (_b = this.options.privacyConfig) === null || _b === void 0 ? void 0 : _b.maskSelector,
|
|
95
|
+
unmaskSelector: (_c = this.options.privacyConfig) === null || _c === void 0 ? void 0 : _c.unmaskSelector,
|
|
96
|
+
defaultMaskLevel: (_d = this.options.privacyConfig) === null || _d === void 0 ? void 0 : _d.defaultMaskLevel,
|
|
94
97
|
},
|
|
95
98
|
debugMode: this.options.debugMode,
|
|
96
99
|
configEndpointUrl: this.options.configEndpointUrl,
|
|
97
100
|
}).promise];
|
|
98
101
|
case 1:
|
|
99
|
-
|
|
102
|
+
_e.sent();
|
|
100
103
|
// add enrichment plugin to add session replay properties to events
|
|
101
104
|
return [4 /*yield*/, client.add(new SessionReplayEnrichmentPlugin()).promise];
|
|
102
105
|
case 2:
|
|
103
106
|
// add enrichment plugin to add session replay properties to events
|
|
104
|
-
|
|
107
|
+
_e.sent();
|
|
105
108
|
return [2 /*return*/];
|
|
106
109
|
}
|
|
107
110
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-replay.js","sourceRoot":"","sources":["../../src/session-replay.ts"],"names":[],"mappings":";;;AAQA,uFAAmE;AAEnE,IAAM,sBAAsB,GAAG,qDAAqD,CAAC;AAErF;IAAA;QACE,SAAI,GAAG,sBAAsB,CAAC;QAC9B,SAAI,GAAG,YAAqB,CAAC;IA6B/B,CAAC;IAvBO,6CAAK,GAAX,UAAY,OAAsB,EAAE,OAAsB;;;gBACxD,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC;;;;KACvB;IAEK,+CAAO,GAAb,UAAc,KAAY;;;;;;6BAIpB,CAAA,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AA0B,GAA1B;QACE,OAAO,aAAa,CAAC,0BAA0B,EAAE,CAAC;IACpD,CAAC;IACH,0BAAC;AAAD,CAAC,AAtGD,IAsGC;AAtGY,kDAAmB;AAwGzB,IAAM,mBAAmB,GAA0D,UACxF,OAA8B;IAE9B,OAAO,IAAI,mBAAmB,CAAC,OAAO,CAAC,CAAC;AAC1C,CAAC,CAAC;AAJW,QAAA,mBAAmB,uBAI9B","sourcesContent":["import {\n BrowserClient,\n BrowserConfig,\n DestinationPlugin,\n EnrichmentPlugin,\n Event,\n Result,\n} from '@amplitude/analytics-types';\nimport * as sessionReplay from '@amplitude/session-replay-browser';\nimport { SessionReplayOptions } from './typings/session-replay';\nconst ENRICHMENT_PLUGIN_NAME = '@amplitude/plugin-session-replay-enrichment-browser';\n\nclass SessionReplayEnrichmentPlugin implements EnrichmentPlugin {\n name = ENRICHMENT_PLUGIN_NAME;\n type = 'enrichment' as const;\n // this.config is defined in setup() which will always be called first\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n config: BrowserConfig;\n\n async setup(_config: BrowserConfig, _client: BrowserClient) {\n this.config = _config;\n }\n\n async execute(event: Event) {\n // On event, synchronize the session id to the what's on the browserConfig (source of truth)\n // Choosing not to read from event object here, concerned about offline/delayed events messing up the state stored\n // in SR.\n if (this.config.sessionId && this.config.sessionId !== sessionReplay.getSessionId()) {\n await sessionReplay.setSessionId(this.config.sessionId).promise;\n }\n\n // Treating config.sessionId as source of truth, if the event's session id doesn't match, the\n // event is not of the current session (offline/late events). In that case, don't tag the events\n if (this.config.sessionId && this.config.sessionId === event.session_id) {\n const sessionRecordingProperties = sessionReplay.getSessionReplayProperties();\n event.event_properties = {\n ...event.event_properties,\n ...sessionRecordingProperties,\n };\n }\n return Promise.resolve(event);\n }\n}\n\nexport class SessionReplayPlugin implements DestinationPlugin {\n name = '@amplitude/plugin-session-replay-browser';\n type = 'destination' as const;\n // this.client is defined in setup() which will always be called first\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n clientRemove: BrowserClient['remove'];\n // this.config is defined in setup() which will always be called first\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n config: BrowserConfig;\n options: SessionReplayOptions;\n\n constructor(options?: SessionReplayOptions) {\n this.options = { ...options };\n // The user did not explicitly configure forceSessionTracking to false, default to true.\n if (this.options.forceSessionTracking !== false) {\n this.options.forceSessionTracking = true;\n }\n }\n\n async setup(config: BrowserConfig, client?: BrowserClient) {\n if (!client) {\n config.loggerProvider.error('SessionReplayPlugin requires v1.9.1+ of the Amplitude SDK.');\n return;\n }\n\n config.loggerProvider.log('Installing @amplitude/plugin-session-replay.');\n\n this.clientRemove = client.remove.bind(client);\n this.config = config;\n\n if (this.options.forceSessionTracking) {\n if (typeof config.defaultTracking === 'boolean') {\n if (config.defaultTracking === false) {\n config.defaultTracking = {\n pageViews: false,\n formInteractions: false,\n fileDownloads: false,\n sessions: true,\n };\n }\n } else {\n config.defaultTracking = {\n ...config.defaultTracking,\n sessions: true,\n };\n }\n }\n\n await sessionReplay.init(config.apiKey, {\n instanceName: this.config.instanceName,\n deviceId: this.config.deviceId,\n optOut: this.config.optOut,\n sessionId: this.config.sessionId,\n loggerProvider: this.config.loggerProvider,\n logLevel: this.config.logLevel,\n flushMaxRetries: this.config.flushMaxRetries,\n serverZone: this.config.serverZone,\n sampleRate: this.options.sampleRate,\n privacyConfig: {\n blockSelector: this.options.privacyConfig?.blockSelector,\n maskSelector: this.options.privacyConfig?.maskSelector,\n unmaskSelector: this.options.privacyConfig?.unmaskSelector,\n defaultMaskLevel: this.options.privacyConfig?.defaultMaskLevel,\n },\n debugMode: this.options.debugMode,\n configEndpointUrl: this.options.configEndpointUrl,\n }).promise;\n\n // add enrichment plugin to add session replay properties to events\n await client.add(new SessionReplayEnrichmentPlugin()).promise;\n }\n\n async execute(event: Event): Promise<Result> {\n return Promise.resolve({\n event,\n code: 200,\n message: 'success',\n });\n }\n\n async flush(): Promise<void> {\n await sessionReplay.flush(false);\n }\n\n async teardown(): Promise<void> {\n await this.clientRemove(ENRICHMENT_PLUGIN_NAME).promise;\n sessionReplay.shutdown();\n // the following are initialized in setup() which will always be called first\n // here we reset them to null to prevent memory leaks\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n this.config = null;\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n this.clientRemove = null;\n }\n\n getSessionReplayProperties() {\n return sessionReplay.getSessionReplayProperties();\n }\n}\n\nexport const sessionReplayPlugin: (options?: SessionReplayOptions) => DestinationPlugin = (\n options?: SessionReplayOptions,\n) => {\n return new SessionReplayPlugin(options);\n};\n"]}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
export type MaskLevel = 'light' | 'medium' | 'conservative';
|
|
1
2
|
export interface SessionReplayPrivacyConfig {
|
|
2
3
|
blockSelector?: string | string[];
|
|
4
|
+
defaultMaskLevel?: MaskLevel;
|
|
5
|
+
maskSelector?: string[];
|
|
6
|
+
unmaskSelector?: string[];
|
|
3
7
|
}
|
|
4
8
|
export interface SessionReplayOptions {
|
|
5
9
|
sampleRate?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-replay.d.ts","sourceRoot":"","sources":["../../../src/typings/session-replay.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,0BAA0B;IACzC,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"session-replay.d.ts","sourceRoot":"","sources":["../../../src/typings/session-replay.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GACjB,OAAO,GACP,QAAQ,GACR,cAAc,CAAC;AAEnB,MAAM,WAAW,0BAA0B;IACzC,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAClC,gBAAgB,CAAC,EAAE,SAAS,CAAC;IAC7B,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B;AACD,MAAM,WAAW,oBAAoB;IACnC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,0BAA0B,CAAC;IAC3C,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-replay.js","sourceRoot":"","sources":["../../../src/typings/session-replay.ts"],"names":[],"mappings":"","sourcesContent":["export interface SessionReplayPrivacyConfig {\n blockSelector?: string | string[];\n}\nexport interface SessionReplayOptions {\n sampleRate?: number;\n privacyConfig?: SessionReplayPrivacyConfig;\n debugMode?: boolean;\n forceSessionTracking?: boolean;\n configEndpointUrl?: string;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"session-replay.js","sourceRoot":"","sources":["../../../src/typings/session-replay.ts"],"names":[],"mappings":"","sourcesContent":["export 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 interface SessionReplayPrivacyConfig {\n blockSelector?: string | string[];\n defaultMaskLevel?: MaskLevel;\n maskSelector?: string[];\n unmaskSelector?: string[];\n}\nexport interface SessionReplayOptions {\n sampleRate?: number;\n privacyConfig?: SessionReplayPrivacyConfig;\n debugMode?: boolean;\n forceSessionTracking?: boolean;\n configEndpointUrl?: string;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-replay.d.ts","sourceRoot":"","sources":["../../src/session-replay.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,aAAa,EACb,iBAAiB,EAEjB,KAAK,EACL,MAAM,EACP,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAoChE,qBAAa,mBAAoB,YAAW,iBAAiB;IAC3D,IAAI,SAA8C;IAClD,IAAI,gBAA0B;IAI9B,YAAY,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;IAItC,MAAM,EAAE,aAAa,CAAC;IACtB,OAAO,EAAE,oBAAoB,CAAC;gBAElB,OAAO,CAAC,EAAE,oBAAoB;IAQpC,KAAK,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,CAAC,EAAE,aAAa;
|
|
1
|
+
{"version":3,"file":"session-replay.d.ts","sourceRoot":"","sources":["../../src/session-replay.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,aAAa,EACb,iBAAiB,EAEjB,KAAK,EACL,MAAM,EACP,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAoChE,qBAAa,mBAAoB,YAAW,iBAAiB;IAC3D,IAAI,SAA8C;IAClD,IAAI,gBAA0B;IAI9B,YAAY,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;IAItC,MAAM,EAAE,aAAa,CAAC;IACtB,OAAO,EAAE,oBAAoB,CAAC;gBAElB,OAAO,CAAC,EAAE,oBAAoB;IAQpC,KAAK,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,CAAC,EAAE,aAAa;IAqDnD,OAAO,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC;IAQtC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAItB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAa/B,0BAA0B;;;CAG3B;AAED,eAAO,MAAM,mBAAmB,EAAE,CAAC,OAAO,CAAC,EAAE,oBAAoB,KAAK,iBAIrE,CAAC"}
|
|
@@ -50,10 +50,10 @@ var SessionReplayPlugin = /** @class */ (function () {
|
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
SessionReplayPlugin.prototype.setup = function (config, client) {
|
|
53
|
-
var _a;
|
|
53
|
+
var _a, _b, _c, _d;
|
|
54
54
|
return __awaiter(this, void 0, void 0, function () {
|
|
55
|
-
return __generator(this, function (
|
|
56
|
-
switch (
|
|
55
|
+
return __generator(this, function (_e) {
|
|
56
|
+
switch (_e.label) {
|
|
57
57
|
case 0:
|
|
58
58
|
if (!client) {
|
|
59
59
|
config.loggerProvider.error('SessionReplayPlugin requires v1.9.1+ of the Amplitude SDK.');
|
|
@@ -89,17 +89,20 @@ var SessionReplayPlugin = /** @class */ (function () {
|
|
|
89
89
|
sampleRate: this.options.sampleRate,
|
|
90
90
|
privacyConfig: {
|
|
91
91
|
blockSelector: (_a = this.options.privacyConfig) === null || _a === void 0 ? void 0 : _a.blockSelector,
|
|
92
|
+
maskSelector: (_b = this.options.privacyConfig) === null || _b === void 0 ? void 0 : _b.maskSelector,
|
|
93
|
+
unmaskSelector: (_c = this.options.privacyConfig) === null || _c === void 0 ? void 0 : _c.unmaskSelector,
|
|
94
|
+
defaultMaskLevel: (_d = this.options.privacyConfig) === null || _d === void 0 ? void 0 : _d.defaultMaskLevel,
|
|
92
95
|
},
|
|
93
96
|
debugMode: this.options.debugMode,
|
|
94
97
|
configEndpointUrl: this.options.configEndpointUrl,
|
|
95
98
|
}).promise];
|
|
96
99
|
case 1:
|
|
97
|
-
|
|
100
|
+
_e.sent();
|
|
98
101
|
// add enrichment plugin to add session replay properties to events
|
|
99
102
|
return [4 /*yield*/, client.add(new SessionReplayEnrichmentPlugin()).promise];
|
|
100
103
|
case 2:
|
|
101
104
|
// add enrichment plugin to add session replay properties to events
|
|
102
|
-
|
|
105
|
+
_e.sent();
|
|
103
106
|
return [2 /*return*/];
|
|
104
107
|
}
|
|
105
108
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-replay.js","sourceRoot":"","sources":["../../src/session-replay.ts"],"names":[],"mappings":";AAQA,OAAO,KAAK,aAAa,MAAM,mCAAmC,CAAC;AAEnE,IAAM,sBAAsB,GAAG,qDAAqD,C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,CAAC,OAAO,EAAA;;wBAAvD,SAAuD,CAAC;wBACxD,aAAa,CAAC,QAAQ,EAAE,CAAC;wBACzB,6EAA6E;wBAC7E,qDAAqD;wBACrD,6DAA6D;wBAC7D,aAAa;wBACb,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;wBACnB,6DAA6D;wBAC7D,aAAa;wBACb,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;;;;;KAC1B;IAED,wDAA0B,GAA1B;QACE,OAAO,aAAa,CAAC,0BAA0B,EAAE,CAAC;IACpD,CAAC;IACH,0BAAC;AAAD,CAAC,AAtGD,IAsGC;;AAED,MAAM,CAAC,IAAM,mBAAmB,GAA0D,UACxF,OAA8B;IAE9B,OAAO,IAAI,mBAAmB,CAAC,OAAO,CAAC,CAAC;AAC1C,CAAC,CAAC","sourcesContent":["import {\n BrowserClient,\n BrowserConfig,\n DestinationPlugin,\n EnrichmentPlugin,\n Event,\n Result,\n} from '@amplitude/analytics-types';\nimport * as sessionReplay from '@amplitude/session-replay-browser';\nimport { SessionReplayOptions } from './typings/session-replay';\nconst ENRICHMENT_PLUGIN_NAME = '@amplitude/plugin-session-replay-enrichment-browser';\n\nclass SessionReplayEnrichmentPlugin implements EnrichmentPlugin {\n name = ENRICHMENT_PLUGIN_NAME;\n type = 'enrichment' as const;\n // this.config is defined in setup() which will always be called first\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n config: BrowserConfig;\n\n async setup(_config: BrowserConfig, _client: BrowserClient) {\n this.config = _config;\n }\n\n async execute(event: Event) {\n // On event, synchronize the session id to the what's on the browserConfig (source of truth)\n // Choosing not to read from event object here, concerned about offline/delayed events messing up the state stored\n // in SR.\n if (this.config.sessionId && this.config.sessionId !== sessionReplay.getSessionId()) {\n await sessionReplay.setSessionId(this.config.sessionId).promise;\n }\n\n // Treating config.sessionId as source of truth, if the event's session id doesn't match, the\n // event is not of the current session (offline/late events). In that case, don't tag the events\n if (this.config.sessionId && this.config.sessionId === event.session_id) {\n const sessionRecordingProperties = sessionReplay.getSessionReplayProperties();\n event.event_properties = {\n ...event.event_properties,\n ...sessionRecordingProperties,\n };\n }\n return Promise.resolve(event);\n }\n}\n\nexport class SessionReplayPlugin implements DestinationPlugin {\n name = '@amplitude/plugin-session-replay-browser';\n type = 'destination' as const;\n // this.client is defined in setup() which will always be called first\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n clientRemove: BrowserClient['remove'];\n // this.config is defined in setup() which will always be called first\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n config: BrowserConfig;\n options: SessionReplayOptions;\n\n constructor(options?: SessionReplayOptions) {\n this.options = { ...options };\n // The user did not explicitly configure forceSessionTracking to false, default to true.\n if (this.options.forceSessionTracking !== false) {\n this.options.forceSessionTracking = true;\n }\n }\n\n async setup(config: BrowserConfig, client?: BrowserClient) {\n if (!client) {\n config.loggerProvider.error('SessionReplayPlugin requires v1.9.1+ of the Amplitude SDK.');\n return;\n }\n\n config.loggerProvider.log('Installing @amplitude/plugin-session-replay.');\n\n this.clientRemove = client.remove.bind(client);\n this.config = config;\n\n if (this.options.forceSessionTracking) {\n if (typeof config.defaultTracking === 'boolean') {\n if (config.defaultTracking === false) {\n config.defaultTracking = {\n pageViews: false,\n formInteractions: false,\n fileDownloads: false,\n sessions: true,\n };\n }\n } else {\n config.defaultTracking = {\n ...config.defaultTracking,\n sessions: true,\n };\n }\n }\n\n await sessionReplay.init(config.apiKey, {\n instanceName: this.config.instanceName,\n deviceId: this.config.deviceId,\n optOut: this.config.optOut,\n sessionId: this.config.sessionId,\n loggerProvider: this.config.loggerProvider,\n logLevel: this.config.logLevel,\n flushMaxRetries: this.config.flushMaxRetries,\n serverZone: this.config.serverZone,\n sampleRate: this.options.sampleRate,\n privacyConfig: {\n blockSelector: this.options.privacyConfig?.blockSelector,\n maskSelector: this.options.privacyConfig?.maskSelector,\n unmaskSelector: this.options.privacyConfig?.unmaskSelector,\n defaultMaskLevel: this.options.privacyConfig?.defaultMaskLevel,\n },\n debugMode: this.options.debugMode,\n configEndpointUrl: this.options.configEndpointUrl,\n }).promise;\n\n // add enrichment plugin to add session replay properties to events\n await client.add(new SessionReplayEnrichmentPlugin()).promise;\n }\n\n async execute(event: Event): Promise<Result> {\n return Promise.resolve({\n event,\n code: 200,\n message: 'success',\n });\n }\n\n async flush(): Promise<void> {\n await sessionReplay.flush(false);\n }\n\n async teardown(): Promise<void> {\n await this.clientRemove(ENRICHMENT_PLUGIN_NAME).promise;\n sessionReplay.shutdown();\n // the following are initialized in setup() which will always be called first\n // here we reset them to null to prevent memory leaks\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n this.config = null;\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n this.clientRemove = null;\n }\n\n getSessionReplayProperties() {\n return sessionReplay.getSessionReplayProperties();\n }\n}\n\nexport const sessionReplayPlugin: (options?: SessionReplayOptions) => DestinationPlugin = (\n options?: SessionReplayOptions,\n) => {\n return new SessionReplayPlugin(options);\n};\n"]}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
export type MaskLevel = 'light' | 'medium' | 'conservative';
|
|
1
2
|
export interface SessionReplayPrivacyConfig {
|
|
2
3
|
blockSelector?: string | string[];
|
|
4
|
+
defaultMaskLevel?: MaskLevel;
|
|
5
|
+
maskSelector?: string[];
|
|
6
|
+
unmaskSelector?: string[];
|
|
3
7
|
}
|
|
4
8
|
export interface SessionReplayOptions {
|
|
5
9
|
sampleRate?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-replay.d.ts","sourceRoot":"","sources":["../../../src/typings/session-replay.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,0BAA0B;IACzC,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"session-replay.d.ts","sourceRoot":"","sources":["../../../src/typings/session-replay.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GACjB,OAAO,GACP,QAAQ,GACR,cAAc,CAAC;AAEnB,MAAM,WAAW,0BAA0B;IACzC,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAClC,gBAAgB,CAAC,EAAE,SAAS,CAAC;IAC7B,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B;AACD,MAAM,WAAW,oBAAoB;IACnC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,0BAA0B,CAAC;IAC3C,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-replay.js","sourceRoot":"","sources":["../../../src/typings/session-replay.ts"],"names":[],"mappings":"","sourcesContent":["export interface SessionReplayPrivacyConfig {\n blockSelector?: string | string[];\n}\nexport interface SessionReplayOptions {\n sampleRate?: number;\n privacyConfig?: SessionReplayPrivacyConfig;\n debugMode?: boolean;\n forceSessionTracking?: boolean;\n configEndpointUrl?: string;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"session-replay.js","sourceRoot":"","sources":["../../../src/typings/session-replay.ts"],"names":[],"mappings":"","sourcesContent":["export 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 interface SessionReplayPrivacyConfig {\n blockSelector?: string | string[];\n defaultMaskLevel?: MaskLevel;\n maskSelector?: string[];\n unmaskSelector?: string[];\n}\nexport interface SessionReplayOptions {\n sampleRate?: number;\n privacyConfig?: SessionReplayPrivacyConfig;\n debugMode?: boolean;\n forceSessionTracking?: boolean;\n configEndpointUrl?: string;\n}\n"]}
|