@amplitude/plugin-session-replay-browser 1.13.13 → 1.15.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/session-replay.d.ts +7 -3
- package/lib/cjs/session-replay.d.ts.map +1 -1
- package/lib/cjs/session-replay.js +60 -26
- package/lib/cjs/session-replay.js.map +1 -1
- package/lib/cjs/typings/session-replay.d.ts +1 -1
- package/lib/cjs/typings/session-replay.d.ts.map +1 -1
- package/lib/cjs/typings/session-replay.js.map +1 -1
- package/lib/cjs/version.d.ts +1 -1
- package/lib/cjs/version.d.ts.map +1 -1
- package/lib/cjs/version.js +1 -1
- package/lib/cjs/version.js.map +1 -1
- package/lib/esm/session-replay.d.ts +7 -3
- package/lib/esm/session-replay.d.ts.map +1 -1
- package/lib/esm/session-replay.js +60 -26
- package/lib/esm/session-replay.js.map +1 -1
- package/lib/esm/typings/session-replay.d.ts +1 -1
- package/lib/esm/typings/session-replay.d.ts.map +1 -1
- package/lib/esm/typings/session-replay.js.map +1 -1
- package/lib/esm/version.d.ts +1 -1
- package/lib/esm/version.d.ts.map +1 -1
- package/lib/esm/version.js +1 -1
- package/lib/esm/version.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.js.map +1 -1
- 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 +7 -3
- package/lib/scripts/session-replay.d.ts.map +1 -1
- package/lib/scripts/typings/session-replay.d.ts +1 -1
- package/lib/scripts/typings/session-replay.d.ts.map +1 -1
- package/lib/scripts/version.d.ts +1 -1
- package/lib/scripts/version.d.ts.map +1 -1
- package/package.json +5 -7
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
import { BrowserConfig, EnrichmentPlugin, Event } from '@amplitude/analytics-
|
|
1
|
+
import { BrowserClient, BrowserConfig, EnrichmentPlugin, Event } from '@amplitude/analytics-core';
|
|
2
|
+
import * as sessionReplay from '@amplitude/session-replay-browser';
|
|
2
3
|
import { SessionReplayOptions } from './typings/session-replay';
|
|
3
|
-
export declare class SessionReplayPlugin implements EnrichmentPlugin {
|
|
4
|
+
export declare class SessionReplayPlugin implements EnrichmentPlugin<BrowserClient, BrowserConfig> {
|
|
4
5
|
name: string;
|
|
5
6
|
type: "enrichment";
|
|
6
7
|
config: BrowserConfig;
|
|
7
8
|
options: SessionReplayOptions;
|
|
9
|
+
srInitOptions: sessionReplay.SessionReplayOptions;
|
|
8
10
|
constructor(options?: SessionReplayOptions);
|
|
9
|
-
setup(config: BrowserConfig): Promise<void>;
|
|
11
|
+
setup(config: BrowserConfig, _client: BrowserClient): Promise<void>;
|
|
12
|
+
onSessionIdChanged(sessionId: number): Promise<void>;
|
|
13
|
+
onOptOutChanged(optOut: boolean): Promise<void>;
|
|
10
14
|
execute(event: Event): Promise<Event>;
|
|
11
15
|
teardown(): Promise<void>;
|
|
12
16
|
getSessionReplayProperties(): {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-replay.d.ts","sourceRoot":"","sources":["../../src/session-replay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"session-replay.d.ts","sourceRoot":"","sources":["../../src/session-replay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAClG,OAAO,KAAK,aAAa,MAAM,mCAAmC,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAGhE,qBAAa,mBAAoB,YAAW,gBAAgB,CAAC,aAAa,EAAE,aAAa,CAAC;IACxF,IAAI,SAA8C;IAClD,IAAI,eAAyB;IAI7B,MAAM,EAAE,aAAa,CAAC;IACtB,OAAO,EAAE,oBAAoB,CAAC;IAC9B,aAAa,EAAE,aAAa,CAAC,oBAAoB,CAAC;gBAEtC,OAAO,CAAC,EAAE,oBAAoB;IAKpC,KAAK,CAAC,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,aAAa;IA0DnD,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAOpD,eAAe,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAa/C,OAAO,CAAC,KAAK,EAAE,KAAK;IA6CpB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAc/B,0BAA0B;;;CAG3B;AAED,eAAO,MAAM,mBAAmB,EAAE,CAAC,OAAO,CAAC,EAAE,oBAAoB,KAAK,gBAIrE,CAAC"}
|
|
@@ -9,8 +9,9 @@ var SessionReplayPlugin = /** @class */ (function () {
|
|
|
9
9
|
this.name = '@amplitude/plugin-session-replay-browser';
|
|
10
10
|
this.type = 'enrichment';
|
|
11
11
|
this.options = tslib_1.__assign({ forceSessionTracking: false }, options);
|
|
12
|
+
this.srInitOptions = this.options;
|
|
12
13
|
}
|
|
13
|
-
SessionReplayPlugin.prototype.setup = function (config) {
|
|
14
|
+
SessionReplayPlugin.prototype.setup = function (config, _client) {
|
|
14
15
|
var _a, _b, _c, _d, _e;
|
|
15
16
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
16
17
|
var error_1;
|
|
@@ -36,31 +37,32 @@ var SessionReplayPlugin = /** @class */ (function () {
|
|
|
36
37
|
config.defaultTracking = tslib_1.__assign(tslib_1.__assign({}, config.defaultTracking), { sessions: true });
|
|
37
38
|
}
|
|
38
39
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
40
|
+
this.srInitOptions = {
|
|
41
|
+
instanceName: this.config.instanceName,
|
|
42
|
+
deviceId: (_a = this.options.deviceId) !== null && _a !== void 0 ? _a : this.config.deviceId,
|
|
43
|
+
optOut: this.config.optOut,
|
|
44
|
+
sessionId: this.options.customSessionId ? undefined : this.config.sessionId,
|
|
45
|
+
loggerProvider: this.config.loggerProvider,
|
|
46
|
+
logLevel: this.config.logLevel,
|
|
47
|
+
flushMaxRetries: this.config.flushMaxRetries,
|
|
48
|
+
serverZone: this.config.serverZone,
|
|
49
|
+
configServerUrl: this.options.configServerUrl,
|
|
50
|
+
trackServerUrl: this.options.trackServerUrl,
|
|
51
|
+
sampleRate: this.options.sampleRate,
|
|
52
|
+
privacyConfig: {
|
|
53
|
+
blockSelector: (_b = this.options.privacyConfig) === null || _b === void 0 ? void 0 : _b.blockSelector,
|
|
54
|
+
maskSelector: (_c = this.options.privacyConfig) === null || _c === void 0 ? void 0 : _c.maskSelector,
|
|
55
|
+
unmaskSelector: (_d = this.options.privacyConfig) === null || _d === void 0 ? void 0 : _d.unmaskSelector,
|
|
56
|
+
defaultMaskLevel: (_e = this.options.privacyConfig) === null || _e === void 0 ? void 0 : _e.defaultMaskLevel,
|
|
57
|
+
},
|
|
58
|
+
debugMode: this.options.debugMode,
|
|
59
|
+
shouldInlineStylesheet: this.options.shouldInlineStylesheet,
|
|
60
|
+
version: { type: 'plugin', version: version_1.VERSION },
|
|
61
|
+
performanceConfig: this.options.performanceConfig,
|
|
62
|
+
storeType: this.options.storeType,
|
|
63
|
+
experimental: this.options.experimental,
|
|
64
|
+
};
|
|
65
|
+
return [4 /*yield*/, sessionReplay.init(config.apiKey, this.srInitOptions).promise];
|
|
64
66
|
case 1:
|
|
65
67
|
_f.sent();
|
|
66
68
|
return [3 /*break*/, 3];
|
|
@@ -74,6 +76,38 @@ var SessionReplayPlugin = /** @class */ (function () {
|
|
|
74
76
|
});
|
|
75
77
|
});
|
|
76
78
|
};
|
|
79
|
+
SessionReplayPlugin.prototype.onSessionIdChanged = function (sessionId) {
|
|
80
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
81
|
+
return tslib_1.__generator(this, function (_a) {
|
|
82
|
+
switch (_a.label) {
|
|
83
|
+
case 0:
|
|
84
|
+
this.config.loggerProvider.debug("Analytics session id is changed to ".concat(sessionId, ", SR session id is ").concat(String(sessionReplay.getSessionId()), "."));
|
|
85
|
+
return [4 /*yield*/, sessionReplay.setSessionId(sessionId).promise];
|
|
86
|
+
case 1:
|
|
87
|
+
_a.sent();
|
|
88
|
+
return [2 /*return*/];
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
SessionReplayPlugin.prototype.onOptOutChanged = function (optOut) {
|
|
94
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
95
|
+
return tslib_1.__generator(this, function (_a) {
|
|
96
|
+
switch (_a.label) {
|
|
97
|
+
case 0:
|
|
98
|
+
this.config.loggerProvider.debug("optOut is changed to ".concat(String(optOut), ", calling ").concat(optOut ? 'sessionReplay.shutdown()' : 'sessionReplay.init()', "."));
|
|
99
|
+
if (!optOut) return [3 /*break*/, 1];
|
|
100
|
+
sessionReplay.shutdown();
|
|
101
|
+
return [3 /*break*/, 3];
|
|
102
|
+
case 1: return [4 /*yield*/, sessionReplay.init(this.config.apiKey, this.srInitOptions).promise];
|
|
103
|
+
case 2:
|
|
104
|
+
_a.sent();
|
|
105
|
+
_a.label = 3;
|
|
106
|
+
case 3: return [2 /*return*/];
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
};
|
|
77
111
|
SessionReplayPlugin.prototype.execute = function (event) {
|
|
78
112
|
var _a;
|
|
79
113
|
return tslib_1.__awaiter(this, void 0, void 0, function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AAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAAC;;;;;KAEjC;IAEK,sCAAQ,GAAd;;;;gBACE,IAAI;oBACF,aAAa,CAAC,QAAQ,EAAE,CAAC;oBACzB,6EAA6E;oBAC7E,qDAAqD;oBACrD,6DAA6D;oBAC7D,aAAa;oBACb,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;iBACpB;gBAAC,OAAO,KAAK,EAAE;oBACd,0BAA0B;oBAC1B,MAAA,IAAI,CAAC,MAAM,0CAAE,cAAc,CAAC,KAAK,CAAC,iDAA2C,KAAe,CAAC,OAAO,CAAE,CAAC,CAAC;iBACzG;;;;KACF;IAED,wDAA0B,GAA1B;QACE,OAAO,aAAa,CAAC,0BAA0B,EAAE,CAAC;IACpD,CAAC;IACH,0BAAC;AAAD,CAAC,AAnID,IAmIC;AAnIY,kDAAmB;AAqIzB,IAAM,mBAAmB,GAAyD,UACvF,OAA8B;IAE9B,OAAO,IAAI,mBAAmB,CAAC,OAAO,CAAC,CAAC;AAC1C,CAAC,CAAC;AAJW,QAAA,mBAAmB,uBAI9B","sourcesContent":["import { BrowserConfig, EnrichmentPlugin, Event } from '@amplitude/analytics-types';\nimport * as sessionReplay from '@amplitude/session-replay-browser';\nimport { SessionReplayOptions } from './typings/session-replay';\nimport { VERSION } from './version';\n\nexport class SessionReplayPlugin implements EnrichmentPlugin {\n name = '@amplitude/plugin-session-replay-browser';\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 options: SessionReplayOptions;\n\n constructor(options?: SessionReplayOptions) {\n this.options = { forceSessionTracking: false, ...options };\n }\n\n async setup(config: BrowserConfig) {\n try {\n /* istanbul ignore next */\n config?.loggerProvider.log(`Installing @amplitude/plugin-session-replay, version ${VERSION}.`);\n\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.options.deviceId ?? this.config.deviceId,\n optOut: this.config.optOut,\n sessionId: this.options.customSessionId ? undefined : this.config.sessionId,\n loggerProvider: this.config.loggerProvider,\n logLevel: this.config.logLevel,\n flushMaxRetries: this.config.flushMaxRetries,\n serverZone: this.config.serverZone,\n configServerUrl: this.options.configServerUrl,\n trackServerUrl: this.options.trackServerUrl,\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 shouldInlineStylesheet: this.options.shouldInlineStylesheet,\n version: { type: 'plugin', version: VERSION },\n performanceConfig: this.options.performanceConfig,\n storeType: this.options.storeType,\n experimental: this.options.experimental,\n }).promise;\n } catch (error) {\n /* istanbul ignore next */\n config?.loggerProvider.error(`Session Replay: Failed to initialize due to ${(error as Error).message}`);\n }\n }\n\n async execute(event: Event) {\n try {\n if (this.options.customSessionId) {\n const sessionId = this.options.customSessionId(event);\n if (sessionId) {\n // On event, synchronize the session id to the custom session id from the event. This may\n // suffer from offline/delayed events messing up the state stored\n if (sessionId !== sessionReplay.getSessionId()) {\n await sessionReplay.setSessionId(sessionId).promise;\n }\n\n const sessionRecordingProperties = sessionReplay.getSessionReplayProperties();\n event.event_properties = {\n ...event.event_properties,\n ...sessionRecordingProperties,\n };\n }\n } else {\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 const sessionId: string | number | undefined = this.config.sessionId;\n if (sessionId && sessionId !== sessionReplay.getSessionId()) {\n await sessionReplay.setSessionId(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 (sessionId && sessionId === event.session_id) {\n const sessionRecordingProperties = sessionReplay.getSessionReplayProperties();\n event.event_properties = {\n ...event.event_properties,\n ...sessionRecordingProperties,\n };\n }\n }\n\n return Promise.resolve(event);\n } catch (error) {\n /* istanbul ignore next */\n this.config?.loggerProvider.error(`Session Replay: Failed to enrich event due to ${(error as Error).message}`);\n return Promise.resolve(event);\n }\n }\n\n async teardown(): Promise<void> {\n try {\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 } catch (error) {\n /* istanbul ignore next */\n this.config?.loggerProvider.error(`Session Replay: teardown failed due to ${(error as Error).message}`);\n }\n }\n\n getSessionReplayProperties() {\n return sessionReplay.getSessionReplayProperties();\n }\n}\n\nexport const sessionReplayPlugin: (options?: SessionReplayOptions) => EnrichmentPlugin = (\n options?: SessionReplayOptions,\n) => {\n return new SessionReplayPlugin(options);\n};\n"]}
|
|
1
|
+
{"version":3,"file":"session-replay.js","sourceRoot":"","sources":["../../src/session-replay.ts"],"names":[],"mappings":";;;;AACA,uFAAmE;AAEnE,qCAAoC;AAEpC;IAUE,6BAAY,OAA8B;QAT1C,SAAI,GAAG,0CAA0C,CAAC;QAClD,SAAI,GAAG,YAAqB,CAAC;QAS3B,IAAI,CAAC,OAAO,sBAAK,oBAAoB,EAAE,KAAK,IAAK,OAAO,CAAE,CAAC;QAC3D,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC;IACpC,CAAC;IAEK,mCAAK,GAAX,UAAY,MAAqB,EAAE,OAAsB;;;;;;;;wBAErD,0BAA0B;wBAC1B,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,cAAc,CAAC,GAAG,CAAC,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AAa,CAAC,0BAA0B,EAAE,CAAC;4BAC9E,KAAK,CAAC,gBAAgB,yCACjB,KAAK,CAAC,gBAAgB,GACtB,0BAA0B,CAC9B,CAAC;yBACH;;4BAGH,sBAAO,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAAC;;;wBAE9B,0BAA0B;wBAC1B,MAAA,IAAI,CAAC,MAAM,0CAAE,cAAc,CAAC,KAAK,CAAC,wDAAkD,OAAe,CAAC,OAAO,CAAE,CAAC,CAAC;wBAC/G,sBAAO,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAAC;;;;;KAEjC;IAEK,sCAAQ,GAAd;;;;gBACE,IAAI;oBACF,aAAa,CAAC,QAAQ,EAAE,CAAC;oBACzB,6EAA6E;oBAC7E,qDAAqD;oBACrD,6DAA6D;oBAC7D,aAAa;oBACb,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;iBACpB;gBAAC,OAAO,KAAK,EAAE;oBACd,0BAA0B;oBAC1B,MAAA,IAAI,CAAC,MAAM,0CAAE,cAAc,CAAC,KAAK,CAAC,iDAA2C,KAAe,CAAC,OAAO,CAAE,CAAC,CAAC;iBACzG;;;;KACF;IAED,wDAA0B,GAA1B;QACE,OAAO,aAAa,CAAC,0BAA0B,EAAE,CAAC;IACpD,CAAC;IACH,0BAAC;AAAD,CAAC,AA3JD,IA2JC;AA3JY,kDAAmB;AA6JzB,IAAM,mBAAmB,GAAyD,UACvF,OAA8B;IAE9B,OAAO,IAAI,mBAAmB,CAAC,OAAO,CAAC,CAAC;AAC1C,CAAC,CAAC;AAJW,QAAA,mBAAmB,uBAI9B","sourcesContent":["import { BrowserClient, BrowserConfig, EnrichmentPlugin, Event } from '@amplitude/analytics-core';\nimport * as sessionReplay from '@amplitude/session-replay-browser';\nimport { SessionReplayOptions } from './typings/session-replay';\nimport { VERSION } from './version';\n\nexport class SessionReplayPlugin implements EnrichmentPlugin<BrowserClient, BrowserConfig> {\n name = '@amplitude/plugin-session-replay-browser';\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 options: SessionReplayOptions;\n srInitOptions: sessionReplay.SessionReplayOptions;\n\n constructor(options?: SessionReplayOptions) {\n this.options = { forceSessionTracking: false, ...options };\n this.srInitOptions = this.options;\n }\n\n async setup(config: BrowserConfig, _client: BrowserClient) {\n try {\n /* istanbul ignore next */\n config?.loggerProvider.log(`Installing @amplitude/plugin-session-replay, version ${VERSION}.`);\n\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 this.srInitOptions = {\n instanceName: this.config.instanceName,\n deviceId: this.options.deviceId ?? this.config.deviceId,\n optOut: this.config.optOut,\n sessionId: this.options.customSessionId ? undefined : this.config.sessionId,\n loggerProvider: this.config.loggerProvider,\n logLevel: this.config.logLevel,\n flushMaxRetries: this.config.flushMaxRetries,\n serverZone: this.config.serverZone,\n configServerUrl: this.options.configServerUrl,\n trackServerUrl: this.options.trackServerUrl,\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 shouldInlineStylesheet: this.options.shouldInlineStylesheet,\n version: { type: 'plugin', version: VERSION },\n performanceConfig: this.options.performanceConfig,\n storeType: this.options.storeType,\n experimental: this.options.experimental,\n };\n\n await sessionReplay.init(config.apiKey, this.srInitOptions).promise;\n } catch (error) {\n /* istanbul ignore next */\n config?.loggerProvider.error(`Session Replay: Failed to initialize due to ${(error as Error).message}`);\n }\n }\n\n async onSessionIdChanged(sessionId: number): Promise<void> {\n this.config.loggerProvider.debug(\n `Analytics session id is changed to ${sessionId}, SR session id is ${String(sessionReplay.getSessionId())}.`,\n );\n await sessionReplay.setSessionId(sessionId).promise;\n }\n\n async onOptOutChanged(optOut: boolean): Promise<void> {\n this.config.loggerProvider.debug(\n `optOut is changed to ${String(optOut)}, calling ${\n optOut ? 'sessionReplay.shutdown()' : 'sessionReplay.init()'\n }.`,\n );\n if (optOut) {\n sessionReplay.shutdown();\n } else {\n await sessionReplay.init(this.config.apiKey, this.srInitOptions).promise;\n }\n }\n\n async execute(event: Event) {\n try {\n if (this.options.customSessionId) {\n const sessionId = this.options.customSessionId(event);\n if (sessionId) {\n // On event, synchronize the session id to the custom session id from the event. This may\n // suffer from offline/delayed events messing up the state stored\n if (sessionId !== sessionReplay.getSessionId()) {\n await sessionReplay.setSessionId(sessionId).promise;\n }\n\n const sessionRecordingProperties = sessionReplay.getSessionReplayProperties();\n event.event_properties = {\n ...event.event_properties,\n ...sessionRecordingProperties,\n };\n }\n } else {\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 const sessionId: string | number | undefined = this.config.sessionId;\n if (sessionId && sessionId !== sessionReplay.getSessionId()) {\n await sessionReplay.setSessionId(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 (sessionId && sessionId === event.session_id) {\n const sessionRecordingProperties = sessionReplay.getSessionReplayProperties();\n event.event_properties = {\n ...event.event_properties,\n ...sessionRecordingProperties,\n };\n }\n }\n\n return Promise.resolve(event);\n } catch (error) {\n /* istanbul ignore next */\n this.config?.loggerProvider.error(`Session Replay: Failed to enrich event due to ${(error as Error).message}`);\n return Promise.resolve(event);\n }\n }\n\n async teardown(): Promise<void> {\n try {\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 } catch (error) {\n /* istanbul ignore next */\n this.config?.loggerProvider.error(`Session Replay: teardown failed due to ${(error as Error).message}`);\n }\n }\n\n getSessionReplayProperties() {\n return sessionReplay.getSessionReplayProperties();\n }\n}\n\nexport const sessionReplayPlugin: (options?: SessionReplayOptions) => EnrichmentPlugin = (\n options?: SessionReplayOptions,\n) => {\n return new SessionReplayPlugin(options);\n};\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Event } from '@amplitude/analytics-
|
|
1
|
+
import { Event } from '@amplitude/analytics-core';
|
|
2
2
|
import { StoreType } from '@amplitude/session-replay-browser';
|
|
3
3
|
export type MaskLevel = 'light' | 'medium' | 'conservative';
|
|
4
4
|
export interface SessionReplayPrivacyConfig {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-replay.d.ts","sourceRoot":"","sources":["../../../src/typings/session-replay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"session-replay.d.ts","sourceRoot":"","sources":["../../../src/typings/session-replay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAClD,OAAO,EACL,SAAS,EAGV,MAAM,mCAAmC,CAAC;AAE3C,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;AAED,MAAM,WAAW,8BAA8B;IAC7C,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,aAAa,CAAC,EAAE,0BAA0B,CAAC;IAC3C;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;OAEG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;OAEG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC;;OAEG;IACH,iBAAiB,CAAC,EAAE,8BAA8B,CAAC;IACnD;;OAEG;IACH,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,MAAM,GAAG,SAAS,CAAC;IACvD;;OAEG;IACH,YAAY,CAAC,EAAE;QACb,YAAY,EAAE,OAAO,CAAC;KACvB,CAAC;CACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-replay.js","sourceRoot":"","sources":["../../../src/typings/session-replay.ts"],"names":[],"mappings":"","sourcesContent":["import { Event } from '@amplitude/analytics-
|
|
1
|
+
{"version":3,"file":"session-replay.js","sourceRoot":"","sources":["../../../src/typings/session-replay.ts"],"names":[],"mappings":"","sourcesContent":["import { Event } from '@amplitude/analytics-core';\nimport {\n StoreType,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n type SessionReplayOptions as StandaloneSessionReplayOptions, // used for documentation\n} from '@amplitude/session-replay-browser';\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 interface SessionReplayPrivacyConfig {\n blockSelector?: string | string[];\n defaultMaskLevel?: MaskLevel;\n maskSelector?: string[];\n unmaskSelector?: string[];\n}\n\nexport interface SessionReplayPerformanceConfig {\n enabled: boolean;\n timeout?: number;\n}\n\nexport interface SessionReplayOptions {\n /**\n * @see {@link StandaloneSessionReplayOptions.sampleRate}\n */\n sampleRate?: number;\n /**\n * @see {@link StandaloneSessionReplayOptions.privacyConfig}\n */\n privacyConfig?: SessionReplayPrivacyConfig;\n /**\n * @see {@link StandaloneSessionReplayOptions.debugMode}\n */\n debugMode?: boolean;\n /**\n * If this is enabled we will force the browser SDK to also send start and end session events.\n */\n forceSessionTracking?: boolean;\n /**\n * @see {@link StandaloneSessionReplayOptions.configServerUrl}\n */\n configServerUrl?: string;\n /**\n * @see {@link StandaloneSessionReplayOptions.trackServerUrl}\n */\n trackServerUrl?: string;\n /**\n * @see {@link StandaloneSessionReplayOptions.shouldInlineStylesheet}\n */\n shouldInlineStylesheet?: boolean;\n /**\n * @see {@link StandaloneSessionReplayOptions.performanceConfig}\n */\n performanceConfig?: SessionReplayPerformanceConfig;\n /**\n * @see {@link StandaloneSessionReplayOptions.storeType}\n */\n storeType?: StoreType;\n /**\n * Override the device ID for session replay.\n */\n deviceId?: string;\n /**\n * Dynamically overrides the session ID for replay. Ensure stability to avoid frequent restarts.\n * @param event Browser SDK event\n * @returns The session ID for the session replay.\n */\n customSessionId?: (event: Event) => string | undefined;\n /**\n * @see {@link StandaloneSessionReplayOptions.experimental}\n */\n experimental?: {\n useWebWorker: boolean;\n };\n}\n"]}
|
package/lib/cjs/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "1.
|
|
1
|
+
export declare const VERSION = "1.15.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/lib/cjs/version.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,OAAO,WAAW,CAAC"}
|
package/lib/cjs/version.js
CHANGED
package/lib/cjs/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";;;AAAA,oDAAoD;AACvC,QAAA,OAAO,GAAG,
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";;;AAAA,oDAAoD;AACvC,QAAA,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["// Autogenerated by `yarn version-file`. DO NOT EDIT\nexport const VERSION = '1.15.0';\n"]}
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
import { BrowserConfig, EnrichmentPlugin, Event } from '@amplitude/analytics-
|
|
1
|
+
import { BrowserClient, BrowserConfig, EnrichmentPlugin, Event } from '@amplitude/analytics-core';
|
|
2
|
+
import * as sessionReplay from '@amplitude/session-replay-browser';
|
|
2
3
|
import { SessionReplayOptions } from './typings/session-replay';
|
|
3
|
-
export declare class SessionReplayPlugin implements EnrichmentPlugin {
|
|
4
|
+
export declare class SessionReplayPlugin implements EnrichmentPlugin<BrowserClient, BrowserConfig> {
|
|
4
5
|
name: string;
|
|
5
6
|
type: "enrichment";
|
|
6
7
|
config: BrowserConfig;
|
|
7
8
|
options: SessionReplayOptions;
|
|
9
|
+
srInitOptions: sessionReplay.SessionReplayOptions;
|
|
8
10
|
constructor(options?: SessionReplayOptions);
|
|
9
|
-
setup(config: BrowserConfig): Promise<void>;
|
|
11
|
+
setup(config: BrowserConfig, _client: BrowserClient): Promise<void>;
|
|
12
|
+
onSessionIdChanged(sessionId: number): Promise<void>;
|
|
13
|
+
onOptOutChanged(optOut: boolean): Promise<void>;
|
|
10
14
|
execute(event: Event): Promise<Event>;
|
|
11
15
|
teardown(): Promise<void>;
|
|
12
16
|
getSessionReplayProperties(): {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-replay.d.ts","sourceRoot":"","sources":["../../src/session-replay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"session-replay.d.ts","sourceRoot":"","sources":["../../src/session-replay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAClG,OAAO,KAAK,aAAa,MAAM,mCAAmC,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAGhE,qBAAa,mBAAoB,YAAW,gBAAgB,CAAC,aAAa,EAAE,aAAa,CAAC;IACxF,IAAI,SAA8C;IAClD,IAAI,eAAyB;IAI7B,MAAM,EAAE,aAAa,CAAC;IACtB,OAAO,EAAE,oBAAoB,CAAC;IAC9B,aAAa,EAAE,aAAa,CAAC,oBAAoB,CAAC;gBAEtC,OAAO,CAAC,EAAE,oBAAoB;IAKpC,KAAK,CAAC,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,aAAa;IA0DnD,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAOpD,eAAe,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAa/C,OAAO,CAAC,KAAK,EAAE,KAAK;IA6CpB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAc/B,0BAA0B;;;CAG3B;AAED,eAAO,MAAM,mBAAmB,EAAE,CAAC,OAAO,CAAC,EAAE,oBAAoB,KAAK,gBAIrE,CAAC"}
|
|
@@ -6,8 +6,9 @@ var SessionReplayPlugin = /** @class */ (function () {
|
|
|
6
6
|
this.name = '@amplitude/plugin-session-replay-browser';
|
|
7
7
|
this.type = 'enrichment';
|
|
8
8
|
this.options = __assign({ forceSessionTracking: false }, options);
|
|
9
|
+
this.srInitOptions = this.options;
|
|
9
10
|
}
|
|
10
|
-
SessionReplayPlugin.prototype.setup = function (config) {
|
|
11
|
+
SessionReplayPlugin.prototype.setup = function (config, _client) {
|
|
11
12
|
var _a, _b, _c, _d, _e;
|
|
12
13
|
return __awaiter(this, void 0, void 0, function () {
|
|
13
14
|
var error_1;
|
|
@@ -33,31 +34,32 @@ var SessionReplayPlugin = /** @class */ (function () {
|
|
|
33
34
|
config.defaultTracking = __assign(__assign({}, config.defaultTracking), { sessions: true });
|
|
34
35
|
}
|
|
35
36
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
37
|
+
this.srInitOptions = {
|
|
38
|
+
instanceName: this.config.instanceName,
|
|
39
|
+
deviceId: (_a = this.options.deviceId) !== null && _a !== void 0 ? _a : this.config.deviceId,
|
|
40
|
+
optOut: this.config.optOut,
|
|
41
|
+
sessionId: this.options.customSessionId ? undefined : this.config.sessionId,
|
|
42
|
+
loggerProvider: this.config.loggerProvider,
|
|
43
|
+
logLevel: this.config.logLevel,
|
|
44
|
+
flushMaxRetries: this.config.flushMaxRetries,
|
|
45
|
+
serverZone: this.config.serverZone,
|
|
46
|
+
configServerUrl: this.options.configServerUrl,
|
|
47
|
+
trackServerUrl: this.options.trackServerUrl,
|
|
48
|
+
sampleRate: this.options.sampleRate,
|
|
49
|
+
privacyConfig: {
|
|
50
|
+
blockSelector: (_b = this.options.privacyConfig) === null || _b === void 0 ? void 0 : _b.blockSelector,
|
|
51
|
+
maskSelector: (_c = this.options.privacyConfig) === null || _c === void 0 ? void 0 : _c.maskSelector,
|
|
52
|
+
unmaskSelector: (_d = this.options.privacyConfig) === null || _d === void 0 ? void 0 : _d.unmaskSelector,
|
|
53
|
+
defaultMaskLevel: (_e = this.options.privacyConfig) === null || _e === void 0 ? void 0 : _e.defaultMaskLevel,
|
|
54
|
+
},
|
|
55
|
+
debugMode: this.options.debugMode,
|
|
56
|
+
shouldInlineStylesheet: this.options.shouldInlineStylesheet,
|
|
57
|
+
version: { type: 'plugin', version: VERSION },
|
|
58
|
+
performanceConfig: this.options.performanceConfig,
|
|
59
|
+
storeType: this.options.storeType,
|
|
60
|
+
experimental: this.options.experimental,
|
|
61
|
+
};
|
|
62
|
+
return [4 /*yield*/, sessionReplay.init(config.apiKey, this.srInitOptions).promise];
|
|
61
63
|
case 1:
|
|
62
64
|
_f.sent();
|
|
63
65
|
return [3 /*break*/, 3];
|
|
@@ -71,6 +73,38 @@ var SessionReplayPlugin = /** @class */ (function () {
|
|
|
71
73
|
});
|
|
72
74
|
});
|
|
73
75
|
};
|
|
76
|
+
SessionReplayPlugin.prototype.onSessionIdChanged = function (sessionId) {
|
|
77
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
78
|
+
return __generator(this, function (_a) {
|
|
79
|
+
switch (_a.label) {
|
|
80
|
+
case 0:
|
|
81
|
+
this.config.loggerProvider.debug("Analytics session id is changed to ".concat(sessionId, ", SR session id is ").concat(String(sessionReplay.getSessionId()), "."));
|
|
82
|
+
return [4 /*yield*/, sessionReplay.setSessionId(sessionId).promise];
|
|
83
|
+
case 1:
|
|
84
|
+
_a.sent();
|
|
85
|
+
return [2 /*return*/];
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
SessionReplayPlugin.prototype.onOptOutChanged = function (optOut) {
|
|
91
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
92
|
+
return __generator(this, function (_a) {
|
|
93
|
+
switch (_a.label) {
|
|
94
|
+
case 0:
|
|
95
|
+
this.config.loggerProvider.debug("optOut is changed to ".concat(String(optOut), ", calling ").concat(optOut ? 'sessionReplay.shutdown()' : 'sessionReplay.init()', "."));
|
|
96
|
+
if (!optOut) return [3 /*break*/, 1];
|
|
97
|
+
sessionReplay.shutdown();
|
|
98
|
+
return [3 /*break*/, 3];
|
|
99
|
+
case 1: return [4 /*yield*/, sessionReplay.init(this.config.apiKey, this.srInitOptions).promise];
|
|
100
|
+
case 2:
|
|
101
|
+
_a.sent();
|
|
102
|
+
_a.label = 3;
|
|
103
|
+
case 3: return [2 /*return*/];
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
};
|
|
74
108
|
SessionReplayPlugin.prototype.execute = function (event) {
|
|
75
109
|
var _a;
|
|
76
110
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-replay.js","sourceRoot":"","sources":["../../src/session-replay.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,aAAa,MAAM,mCAAmC,CAAC;AAEnE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC;IASE,6BAAY,OAA8B;QAR1C,SAAI,GAAG,0CAA0C,CAAC;QAClD,SAAI,GAAG,YAAqB,CAAC;QAQ3B,IAAI,CAAC,OAAO,cAAK,oBAAoB,EAAE,KAAK,IAAK,OAAO,CAAE,CAAC;IAC7D,CAAC;IAEK,mCAAK,GAAX,UAAY,MAAqB;;;;;;;;wBAE7B,0BAA0B;wBAC1B,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,cAAc,CAAC,GAAG,CAAC,+DAAwD,OAAO,MAAG,CAAC,CAAC;wBAE/F,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;wBAErB,IAAI,IAAI,CAAC,OAAO,CAAC,oBAAoB,EAAE;4BACrC,IAAI,OAAO,MAAM,CAAC,eAAe,KAAK,SAAS,EAAE;gCA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AC","sourcesContent":["import { BrowserConfig, EnrichmentPlugin, Event } from '@amplitude/analytics-types';\nimport * as sessionReplay from '@amplitude/session-replay-browser';\nimport { SessionReplayOptions } from './typings/session-replay';\nimport { VERSION } from './version';\n\nexport class SessionReplayPlugin implements EnrichmentPlugin {\n name = '@amplitude/plugin-session-replay-browser';\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 options: SessionReplayOptions;\n\n constructor(options?: SessionReplayOptions) {\n this.options = { forceSessionTracking: false, ...options };\n }\n\n async setup(config: BrowserConfig) {\n try {\n /* istanbul ignore next */\n config?.loggerProvider.log(`Installing @amplitude/plugin-session-replay, version ${VERSION}.`);\n\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.options.deviceId ?? this.config.deviceId,\n optOut: this.config.optOut,\n sessionId: this.options.customSessionId ? undefined : this.config.sessionId,\n loggerProvider: this.config.loggerProvider,\n logLevel: this.config.logLevel,\n flushMaxRetries: this.config.flushMaxRetries,\n serverZone: this.config.serverZone,\n configServerUrl: this.options.configServerUrl,\n trackServerUrl: this.options.trackServerUrl,\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 shouldInlineStylesheet: this.options.shouldInlineStylesheet,\n version: { type: 'plugin', version: VERSION },\n performanceConfig: this.options.performanceConfig,\n storeType: this.options.storeType,\n experimental: this.options.experimental,\n }).promise;\n } catch (error) {\n /* istanbul ignore next */\n config?.loggerProvider.error(`Session Replay: Failed to initialize due to ${(error as Error).message}`);\n }\n }\n\n async execute(event: Event) {\n try {\n if (this.options.customSessionId) {\n const sessionId = this.options.customSessionId(event);\n if (sessionId) {\n // On event, synchronize the session id to the custom session id from the event. This may\n // suffer from offline/delayed events messing up the state stored\n if (sessionId !== sessionReplay.getSessionId()) {\n await sessionReplay.setSessionId(sessionId).promise;\n }\n\n const sessionRecordingProperties = sessionReplay.getSessionReplayProperties();\n event.event_properties = {\n ...event.event_properties,\n ...sessionRecordingProperties,\n };\n }\n } else {\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 const sessionId: string | number | undefined = this.config.sessionId;\n if (sessionId && sessionId !== sessionReplay.getSessionId()) {\n await sessionReplay.setSessionId(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 (sessionId && sessionId === event.session_id) {\n const sessionRecordingProperties = sessionReplay.getSessionReplayProperties();\n event.event_properties = {\n ...event.event_properties,\n ...sessionRecordingProperties,\n };\n }\n }\n\n return Promise.resolve(event);\n } catch (error) {\n /* istanbul ignore next */\n this.config?.loggerProvider.error(`Session Replay: Failed to enrich event due to ${(error as Error).message}`);\n return Promise.resolve(event);\n }\n }\n\n async teardown(): Promise<void> {\n try {\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 } catch (error) {\n /* istanbul ignore next */\n this.config?.loggerProvider.error(`Session Replay: teardown failed due to ${(error as Error).message}`);\n }\n }\n\n getSessionReplayProperties() {\n return sessionReplay.getSessionReplayProperties();\n }\n}\n\nexport const sessionReplayPlugin: (options?: SessionReplayOptions) => EnrichmentPlugin = (\n options?: SessionReplayOptions,\n) => {\n return new SessionReplayPlugin(options);\n};\n"]}
|
|
1
|
+
{"version":3,"file":"session-replay.js","sourceRoot":"","sources":["../../src/session-replay.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,aAAa,MAAM,mCAAmC,CAAC;AAEnE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC;IAUE,6BAAY,OAA8B;QAT1C,SAAI,GAAG,0CAA0C,CAAC;QAClD,SAAI,GAAG,YAAqB,CAAC;QAS3B,IAAI,CAAC,OAAO,cAAK,oBAAoB,EAAE,KAAK,IAAK,OAAO,CAAE,CAAC;QAC3D,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC;IACpC,CAAC;IAEK,mCAAK,GAAX,UAAY,MAAqB,EAAE,OAAsB;;;;;;;;wBAErD,0BAA0B;wBAC1B,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,cAAc,CAAC,GAAG,CAAC,+DAAwD,OAAO,MAAG,CAAC,CAAC;wBAE/F,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;wBAErB,IAAI,IAAI,CAAC,OAAO,CAAC,oBAAoB,EAAE;4BACrC,IAAI,OAAO,MAAM,CAAC,eAAe,KAAK,SAAS,EAAE;gCAC/C,IAAI,MAAM,CAAC,eAAe,KAAK,KAAK,EAAE;oCACpC,MAAM,CAAC,eAAe,GAAG;wCACvB,SAAS,EAAE,KAAK;wCAChB,gBAAgB,EAAE,KAAK;wCACvB,aAAa,EAAE,KAAK;wCACpB,QAAQ,EAAE,IAAI;qCACf,CAAC;iCACH;6BACF;iCAAM;gCACL,MAAM,CAAC,eAAe,yBACjB,MAAM,CAAC,eAAe,KACzB,QAAQ,EAAE,IAAI,GACf,CAAC;6BACH;yBACF;wBAED,IAAI,CAAC,aAAa,GAAG;4BACnB,YAAY,EAAE,IAAI,CAAC,MAAM,CAAC,YAAY;4BACtC,QAAQ,EAAE,MAAA,IAAI,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A,IAAI,CAAC,MAAM,0CAAE,cAAc,CAAC,KAAK,CAAC,iDAA2C,KAAe,CAAC,OAAO,CAAE,CAAC,CAAC;iBACzG;;;;KACF;IAED,wDAA0B,GAA1B;QACE,OAAO,aAAa,CAAC,0BAA0B,EAAE,CAAC;IACpD,CAAC;IACH,0BAAC;AAAD,CAAC,AA3JD,IA2JC;;AAED,MAAM,CAAC,IAAM,mBAAmB,GAAyD,UACvF,OAA8B;IAE9B,OAAO,IAAI,mBAAmB,CAAC,OAAO,CAAC,CAAC;AAC1C,CAAC,CAAC","sourcesContent":["import { BrowserClient, BrowserConfig, EnrichmentPlugin, Event } from '@amplitude/analytics-core';\nimport * as sessionReplay from '@amplitude/session-replay-browser';\nimport { SessionReplayOptions } from './typings/session-replay';\nimport { VERSION } from './version';\n\nexport class SessionReplayPlugin implements EnrichmentPlugin<BrowserClient, BrowserConfig> {\n name = '@amplitude/plugin-session-replay-browser';\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 options: SessionReplayOptions;\n srInitOptions: sessionReplay.SessionReplayOptions;\n\n constructor(options?: SessionReplayOptions) {\n this.options = { forceSessionTracking: false, ...options };\n this.srInitOptions = this.options;\n }\n\n async setup(config: BrowserConfig, _client: BrowserClient) {\n try {\n /* istanbul ignore next */\n config?.loggerProvider.log(`Installing @amplitude/plugin-session-replay, version ${VERSION}.`);\n\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 this.srInitOptions = {\n instanceName: this.config.instanceName,\n deviceId: this.options.deviceId ?? this.config.deviceId,\n optOut: this.config.optOut,\n sessionId: this.options.customSessionId ? undefined : this.config.sessionId,\n loggerProvider: this.config.loggerProvider,\n logLevel: this.config.logLevel,\n flushMaxRetries: this.config.flushMaxRetries,\n serverZone: this.config.serverZone,\n configServerUrl: this.options.configServerUrl,\n trackServerUrl: this.options.trackServerUrl,\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 shouldInlineStylesheet: this.options.shouldInlineStylesheet,\n version: { type: 'plugin', version: VERSION },\n performanceConfig: this.options.performanceConfig,\n storeType: this.options.storeType,\n experimental: this.options.experimental,\n };\n\n await sessionReplay.init(config.apiKey, this.srInitOptions).promise;\n } catch (error) {\n /* istanbul ignore next */\n config?.loggerProvider.error(`Session Replay: Failed to initialize due to ${(error as Error).message}`);\n }\n }\n\n async onSessionIdChanged(sessionId: number): Promise<void> {\n this.config.loggerProvider.debug(\n `Analytics session id is changed to ${sessionId}, SR session id is ${String(sessionReplay.getSessionId())}.`,\n );\n await sessionReplay.setSessionId(sessionId).promise;\n }\n\n async onOptOutChanged(optOut: boolean): Promise<void> {\n this.config.loggerProvider.debug(\n `optOut is changed to ${String(optOut)}, calling ${\n optOut ? 'sessionReplay.shutdown()' : 'sessionReplay.init()'\n }.`,\n );\n if (optOut) {\n sessionReplay.shutdown();\n } else {\n await sessionReplay.init(this.config.apiKey, this.srInitOptions).promise;\n }\n }\n\n async execute(event: Event) {\n try {\n if (this.options.customSessionId) {\n const sessionId = this.options.customSessionId(event);\n if (sessionId) {\n // On event, synchronize the session id to the custom session id from the event. This may\n // suffer from offline/delayed events messing up the state stored\n if (sessionId !== sessionReplay.getSessionId()) {\n await sessionReplay.setSessionId(sessionId).promise;\n }\n\n const sessionRecordingProperties = sessionReplay.getSessionReplayProperties();\n event.event_properties = {\n ...event.event_properties,\n ...sessionRecordingProperties,\n };\n }\n } else {\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 const sessionId: string | number | undefined = this.config.sessionId;\n if (sessionId && sessionId !== sessionReplay.getSessionId()) {\n await sessionReplay.setSessionId(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 (sessionId && sessionId === event.session_id) {\n const sessionRecordingProperties = sessionReplay.getSessionReplayProperties();\n event.event_properties = {\n ...event.event_properties,\n ...sessionRecordingProperties,\n };\n }\n }\n\n return Promise.resolve(event);\n } catch (error) {\n /* istanbul ignore next */\n this.config?.loggerProvider.error(`Session Replay: Failed to enrich event due to ${(error as Error).message}`);\n return Promise.resolve(event);\n }\n }\n\n async teardown(): Promise<void> {\n try {\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 } catch (error) {\n /* istanbul ignore next */\n this.config?.loggerProvider.error(`Session Replay: teardown failed due to ${(error as Error).message}`);\n }\n }\n\n getSessionReplayProperties() {\n return sessionReplay.getSessionReplayProperties();\n }\n}\n\nexport const sessionReplayPlugin: (options?: SessionReplayOptions) => EnrichmentPlugin = (\n options?: SessionReplayOptions,\n) => {\n return new SessionReplayPlugin(options);\n};\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Event } from '@amplitude/analytics-
|
|
1
|
+
import { Event } from '@amplitude/analytics-core';
|
|
2
2
|
import { StoreType } from '@amplitude/session-replay-browser';
|
|
3
3
|
export type MaskLevel = 'light' | 'medium' | 'conservative';
|
|
4
4
|
export interface SessionReplayPrivacyConfig {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-replay.d.ts","sourceRoot":"","sources":["../../../src/typings/session-replay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"session-replay.d.ts","sourceRoot":"","sources":["../../../src/typings/session-replay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAClD,OAAO,EACL,SAAS,EAGV,MAAM,mCAAmC,CAAC;AAE3C,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;AAED,MAAM,WAAW,8BAA8B;IAC7C,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,aAAa,CAAC,EAAE,0BAA0B,CAAC;IAC3C;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;OAEG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;OAEG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC;;OAEG;IACH,iBAAiB,CAAC,EAAE,8BAA8B,CAAC;IACnD;;OAEG;IACH,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,MAAM,GAAG,SAAS,CAAC;IACvD;;OAEG;IACH,YAAY,CAAC,EAAE;QACb,YAAY,EAAE,OAAO,CAAC;KACvB,CAAC;CACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-replay.js","sourceRoot":"","sources":["../../../src/typings/session-replay.ts"],"names":[],"mappings":"","sourcesContent":["import { Event } from '@amplitude/analytics-
|
|
1
|
+
{"version":3,"file":"session-replay.js","sourceRoot":"","sources":["../../../src/typings/session-replay.ts"],"names":[],"mappings":"","sourcesContent":["import { Event } from '@amplitude/analytics-core';\nimport {\n StoreType,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n type SessionReplayOptions as StandaloneSessionReplayOptions, // used for documentation\n} from '@amplitude/session-replay-browser';\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 interface SessionReplayPrivacyConfig {\n blockSelector?: string | string[];\n defaultMaskLevel?: MaskLevel;\n maskSelector?: string[];\n unmaskSelector?: string[];\n}\n\nexport interface SessionReplayPerformanceConfig {\n enabled: boolean;\n timeout?: number;\n}\n\nexport interface SessionReplayOptions {\n /**\n * @see {@link StandaloneSessionReplayOptions.sampleRate}\n */\n sampleRate?: number;\n /**\n * @see {@link StandaloneSessionReplayOptions.privacyConfig}\n */\n privacyConfig?: SessionReplayPrivacyConfig;\n /**\n * @see {@link StandaloneSessionReplayOptions.debugMode}\n */\n debugMode?: boolean;\n /**\n * If this is enabled we will force the browser SDK to also send start and end session events.\n */\n forceSessionTracking?: boolean;\n /**\n * @see {@link StandaloneSessionReplayOptions.configServerUrl}\n */\n configServerUrl?: string;\n /**\n * @see {@link StandaloneSessionReplayOptions.trackServerUrl}\n */\n trackServerUrl?: string;\n /**\n * @see {@link StandaloneSessionReplayOptions.shouldInlineStylesheet}\n */\n shouldInlineStylesheet?: boolean;\n /**\n * @see {@link StandaloneSessionReplayOptions.performanceConfig}\n */\n performanceConfig?: SessionReplayPerformanceConfig;\n /**\n * @see {@link StandaloneSessionReplayOptions.storeType}\n */\n storeType?: StoreType;\n /**\n * Override the device ID for session replay.\n */\n deviceId?: string;\n /**\n * Dynamically overrides the session ID for replay. Ensure stability to avoid frequent restarts.\n * @param event Browser SDK event\n * @returns The session ID for the session replay.\n */\n customSessionId?: (event: Event) => string | undefined;\n /**\n * @see {@link StandaloneSessionReplayOptions.experimental}\n */\n experimental?: {\n useWebWorker: boolean;\n };\n}\n"]}
|
package/lib/esm/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "1.
|
|
1
|
+
export declare const VERSION = "1.15.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/lib/esm/version.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,OAAO,WAAW,CAAC"}
|
package/lib/esm/version.js
CHANGED
package/lib/esm/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,MAAM,CAAC,IAAM,OAAO,GAAG,
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,MAAM,CAAC,IAAM,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["// Autogenerated by `yarn version-file`. DO NOT EDIT\nexport const VERSION = '1.15.0';\n"]}
|