@amplitude/plugin-session-replay-browser 0.9.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -23,7 +23,7 @@ yarn add @amplitude/plugin-session-replay-browser
23
23
 
24
24
  ## Usage
25
25
 
26
- This plugin works on top of Amplitude Browser SDK and adds session replay features to built-in features. To use this plugin, you need to install `@amplitude/analytics-browser` version `v1.0.0` or later.
26
+ This plugin works on top of Amplitude Browser SDK and adds session replay features to built-in features. To use this plugin, you need to install `@amplitude/analytics-browser` version `v1.9.1` or later.
27
27
 
28
28
  This plugin requires that default tracking for sessions is enabled. If default tracking for sessions is not enabled in the config, the plugin will automatically enable it.
29
29
 
@@ -1,17 +1,18 @@
1
- import { BrowserConfig, EnrichmentPlugin, Event } from '@amplitude/analytics-types';
1
+ import { BrowserClient, BrowserConfig, DestinationPlugin, Event, Result } from '@amplitude/analytics-types';
2
2
  import { SessionReplayOptions } from './typings/session-replay';
3
- export declare class SessionReplayPlugin implements EnrichmentPlugin {
3
+ export declare class SessionReplayPlugin implements DestinationPlugin {
4
4
  name: string;
5
- type: "enrichment";
5
+ type: "destination";
6
6
  config: BrowserConfig;
7
7
  options: SessionReplayOptions;
8
8
  constructor(options?: SessionReplayOptions);
9
- setup(config: BrowserConfig): Promise<void>;
10
- execute(event: Event): Promise<Event>;
9
+ setup(config: BrowserConfig, client?: BrowserClient): Promise<void>;
10
+ execute(event: Event): Promise<Result>;
11
+ flush(): Promise<void>;
11
12
  teardown(): Promise<void>;
12
13
  getSessionReplayProperties(): {
13
14
  [key: string]: string | boolean | null;
14
15
  };
15
16
  }
16
- export declare const sessionReplayPlugin: (options?: SessionReplayOptions) => EnrichmentPlugin;
17
+ export declare const sessionReplayPlugin: (options?: SessionReplayOptions) => DestinationPlugin;
17
18
  //# 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,EAAE,aAAa,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAGpF,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,qBAAa,mBAAoB,YAAW,gBAAgB;IAC1D,IAAI,SAA8C;IAClD,IAAI,eAAyB;IAI7B,MAAM,EAAE,aAAa,CAAC;IACtB,OAAO,EAAE,oBAAoB,CAAC;gBAElB,OAAO,CAAC,EAAE,oBAAoB;IAIpC,KAAK,CAAC,MAAM,EAAE,aAAa;IAqC3B,OAAO,CAAC,KAAK,EAAE,KAAK;IAcpB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAI/B,0BAA0B;;;CAG3B;AAED,eAAO,MAAM,mBAAmB,EAAE,CAAC,OAAO,CAAC,EAAE,oBAAoB,KAAK,gBAIrE,CAAC"}
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;AAGpC,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAyBhE,qBAAa,mBAAoB,YAAW,iBAAiB;IAC3D,IAAI,SAA8C;IAClD,IAAI,gBAA0B;IAI9B,MAAM,EAAE,aAAa,CAAC;IACtB,OAAO,EAAE,oBAAoB,CAAC;gBAElB,OAAO,CAAC,EAAE,oBAAoB;IAIpC,KAAK,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,CAAC,EAAE,aAAa;IA6CnD,OAAO,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC;IAQtC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAItB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAI/B,0BAA0B;;;CAG3B;AAED,eAAO,MAAM,mBAAmB,EAAE,CAAC,OAAO,CAAC,EAAE,oBAAoB,KAAK,iBAIrE,CAAC"}
@@ -3,18 +3,49 @@ exports.sessionReplayPlugin = exports.SessionReplayPlugin = void 0;
3
3
  var tslib_1 = require("tslib");
4
4
  var sessionReplay = tslib_1.__importStar(require("@amplitude/session-replay-browser"));
5
5
  var constants_1 = require("./constants");
6
+ var SessionReplayEnrichmentPlugin = /** @class */ (function () {
7
+ function SessionReplayEnrichmentPlugin() {
8
+ this.name = '@amplitude/plugin-session-replay-enrichment-browser';
9
+ this.type = 'enrichment';
10
+ }
11
+ SessionReplayEnrichmentPlugin.prototype.setup = function (_config, _client) {
12
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
13
+ return tslib_1.__generator(this, function (_a) {
14
+ return [2 /*return*/];
15
+ });
16
+ });
17
+ };
18
+ SessionReplayEnrichmentPlugin.prototype.execute = function (event) {
19
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
20
+ var sessionRecordingProperties;
21
+ return tslib_1.__generator(this, function (_a) {
22
+ if (event.event_type === constants_1.DEFAULT_SESSION_START_EVENT && event.session_id) {
23
+ sessionReplay.setSessionId(event.session_id);
24
+ }
25
+ sessionRecordingProperties = sessionReplay.getSessionReplayProperties();
26
+ event.event_properties = tslib_1.__assign(tslib_1.__assign({}, event.event_properties), sessionRecordingProperties);
27
+ return [2 /*return*/, Promise.resolve(event)];
28
+ });
29
+ });
30
+ };
31
+ return SessionReplayEnrichmentPlugin;
32
+ }());
6
33
  var SessionReplayPlugin = /** @class */ (function () {
7
34
  function SessionReplayPlugin(options) {
8
35
  this.name = '@amplitude/plugin-session-replay-browser';
9
- this.type = 'enrichment';
36
+ this.type = 'destination';
10
37
  this.options = tslib_1.__assign({}, options);
11
38
  }
12
- SessionReplayPlugin.prototype.setup = function (config) {
39
+ SessionReplayPlugin.prototype.setup = function (config, client) {
13
40
  var _a;
14
41
  return tslib_1.__awaiter(this, void 0, void 0, function () {
15
42
  return tslib_1.__generator(this, function (_b) {
16
43
  switch (_b.label) {
17
44
  case 0:
45
+ if (!client) {
46
+ config.loggerProvider.error('SessionReplayPlugin requires v1.9.1+ of the Amplitude SDK.');
47
+ return [2 /*return*/];
48
+ }
18
49
  config.loggerProvider.log('Installing @amplitude/plugin-session-replay.');
19
50
  this.config = config;
20
51
  if (typeof config.defaultTracking === 'boolean') {
@@ -46,6 +77,8 @@ var SessionReplayPlugin = /** @class */ (function () {
46
77
  }).promise];
47
78
  case 1:
48
79
  _b.sent();
80
+ // add enrichment plugin to add session replay properties to events
81
+ client.add(new SessionReplayEnrichmentPlugin());
49
82
  return [2 /*return*/];
50
83
  }
51
84
  });
@@ -53,14 +86,24 @@ var SessionReplayPlugin = /** @class */ (function () {
53
86
  };
54
87
  SessionReplayPlugin.prototype.execute = function (event) {
55
88
  return tslib_1.__awaiter(this, void 0, void 0, function () {
56
- var sessionRecordingProperties;
57
89
  return tslib_1.__generator(this, function (_a) {
58
- if (event.event_type === constants_1.DEFAULT_SESSION_START_EVENT && event.session_id) {
59
- sessionReplay.setSessionId(event.session_id);
90
+ return [2 /*return*/, Promise.resolve({
91
+ event: event,
92
+ code: 200,
93
+ message: 'success',
94
+ })];
95
+ });
96
+ });
97
+ };
98
+ SessionReplayPlugin.prototype.flush = function () {
99
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
100
+ return tslib_1.__generator(this, function (_a) {
101
+ switch (_a.label) {
102
+ case 0: return [4 /*yield*/, sessionReplay.flush(false)];
103
+ case 1:
104
+ _a.sent();
105
+ return [2 /*return*/];
60
106
  }
61
- sessionRecordingProperties = sessionReplay.getSessionReplayProperties();
62
- event.event_properties = tslib_1.__assign(tslib_1.__assign({}, event.event_properties), sessionRecordingProperties);
63
- return [2 /*return*/, Promise.resolve(event)];
64
107
  });
65
108
  });
66
109
  };
@@ -1 +1 @@
1
- {"version":3,"file":"session-replay.js","sourceRoot":"","sources":["../../src/session-replay.ts"],"names":[],"mappings":";;;AACA,uFAAmE;AACnE,yCAA0D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AI,CAAC,OAAO,CAAC,aAAa,0CAAE,aAAa;iCACzD;6BACF,CAAC,CAAC,OAAO,EAAA;;wBAbV,SAaU,CAAC;;;;;KACZ;IAEK,qCAAO,GAAb,UAAc,KAAY;;;;gBACxB,IAAI,KAAK,CAAC,UAAU,KAAK,uCAA2B,IAAI,KAAK,CAAC,UAAU,EAAE;oBACxE,aAAa,CAAC,YAAY,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;iBAC9C;gBAEK,0BAA0B,GAAG,aAAa,CAAC,0BAA0B,EAAE,CAAC;gBAC9E,KAAK,CAAC,gBAAgB,yCACjB,KAAK,CAAC,gBAAgB,GACtB,0BAA0B,CAC9B,CAAC;gBAEF,sBAAO,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAAC;;;KAC/B;IAEK,sCAAQ,GAAd;;;gBACE,aAAa,CAAC,QAAQ,EAAE,CAAC;;;;KAC1B;IAED,wDAA0B,GAA1B;QACE,OAAO,aAAa,CAAC,0BAA0B,EAAE,CAAC;IACpD,CAAC;IACH,0BAAC;AAAD,CAAC,AAvED,IAuEC;AAvEY,kDAAmB;AAyEzB,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 { DEFAULT_SESSION_START_EVENT } from './constants';\nimport { SessionReplayOptions } from './typings/session-replay';\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 = { ...options };\n }\n\n async setup(config: BrowserConfig) {\n config.loggerProvider.log('Installing @amplitude/plugin-session-replay.');\n\n this.config = config;\n\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 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 },\n }).promise;\n }\n\n async execute(event: Event) {\n if (event.event_type === DEFAULT_SESSION_START_EVENT && event.session_id) {\n sessionReplay.setSessionId(event.session_id);\n }\n\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 async teardown(): Promise<void> {\n sessionReplay.shutdown();\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":";;;AAQA,uFAAmE;AACnE,yCAA0D;AAG1D;IAAA;QACE,SAAI,GAAG,qDAAqD,CAAC;QAC7D,SAAI,GAAG,YAAqB,CAAC;IAmB/B,CAAC;IAjBO,6CAAK,GAAX,UAAY,OAAsB,EAAE,OAAsB;;;;;;KAEzD;IAEK,+CAAO,GAAb,UAAc,KAAY;;;;gBACxB,IAAI,KAAK,CAAC,UAAU,KAAK,uCAA2B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C1C,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 { DEFAULT_SESSION_START_EVENT } from './constants';\nimport { SessionReplayOptions } from './typings/session-replay';\n\nclass SessionReplayEnrichmentPlugin implements EnrichmentPlugin {\n name = '@amplitude/plugin-session-replay-enrichment-browser';\n type = 'enrichment' as const;\n\n async setup(_config: BrowserConfig, _client: BrowserClient) {\n // do nothing\n }\n\n async execute(event: Event) {\n if (event.event_type === DEFAULT_SESSION_START_EVENT && event.session_id) {\n sessionReplay.setSessionId(event.session_id);\n }\n\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.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 }\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.config = config;\n\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 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 },\n }).promise;\n\n // add enrichment plugin to add session replay properties to events\n client.add(new SessionReplayEnrichmentPlugin());\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 sessionReplay.shutdown();\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,17 +1,18 @@
1
- import { BrowserConfig, EnrichmentPlugin, Event } from '@amplitude/analytics-types';
1
+ import { BrowserClient, BrowserConfig, DestinationPlugin, Event, Result } from '@amplitude/analytics-types';
2
2
  import { SessionReplayOptions } from './typings/session-replay';
3
- export declare class SessionReplayPlugin implements EnrichmentPlugin {
3
+ export declare class SessionReplayPlugin implements DestinationPlugin {
4
4
  name: string;
5
- type: "enrichment";
5
+ type: "destination";
6
6
  config: BrowserConfig;
7
7
  options: SessionReplayOptions;
8
8
  constructor(options?: SessionReplayOptions);
9
- setup(config: BrowserConfig): Promise<void>;
10
- execute(event: Event): Promise<Event>;
9
+ setup(config: BrowserConfig, client?: BrowserClient): Promise<void>;
10
+ execute(event: Event): Promise<Result>;
11
+ flush(): Promise<void>;
11
12
  teardown(): Promise<void>;
12
13
  getSessionReplayProperties(): {
13
14
  [key: string]: string | boolean | null;
14
15
  };
15
16
  }
16
- export declare const sessionReplayPlugin: (options?: SessionReplayOptions) => EnrichmentPlugin;
17
+ export declare const sessionReplayPlugin: (options?: SessionReplayOptions) => DestinationPlugin;
17
18
  //# 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,EAAE,aAAa,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAGpF,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,qBAAa,mBAAoB,YAAW,gBAAgB;IAC1D,IAAI,SAA8C;IAClD,IAAI,eAAyB;IAI7B,MAAM,EAAE,aAAa,CAAC;IACtB,OAAO,EAAE,oBAAoB,CAAC;gBAElB,OAAO,CAAC,EAAE,oBAAoB;IAIpC,KAAK,CAAC,MAAM,EAAE,aAAa;IAqC3B,OAAO,CAAC,KAAK,EAAE,KAAK;IAcpB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAI/B,0BAA0B;;;CAG3B;AAED,eAAO,MAAM,mBAAmB,EAAE,CAAC,OAAO,CAAC,EAAE,oBAAoB,KAAK,gBAIrE,CAAC"}
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;AAGpC,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAyBhE,qBAAa,mBAAoB,YAAW,iBAAiB;IAC3D,IAAI,SAA8C;IAClD,IAAI,gBAA0B;IAI9B,MAAM,EAAE,aAAa,CAAC;IACtB,OAAO,EAAE,oBAAoB,CAAC;gBAElB,OAAO,CAAC,EAAE,oBAAoB;IAIpC,KAAK,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,CAAC,EAAE,aAAa;IA6CnD,OAAO,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC;IAQtC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAItB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAI/B,0BAA0B;;;CAG3B;AAED,eAAO,MAAM,mBAAmB,EAAE,CAAC,OAAO,CAAC,EAAE,oBAAoB,KAAK,iBAIrE,CAAC"}
@@ -1,18 +1,49 @@
1
1
  import { __assign, __awaiter, __generator } from "tslib";
2
2
  import * as sessionReplay from '@amplitude/session-replay-browser';
3
3
  import { DEFAULT_SESSION_START_EVENT } from './constants';
4
+ var SessionReplayEnrichmentPlugin = /** @class */ (function () {
5
+ function SessionReplayEnrichmentPlugin() {
6
+ this.name = '@amplitude/plugin-session-replay-enrichment-browser';
7
+ this.type = 'enrichment';
8
+ }
9
+ SessionReplayEnrichmentPlugin.prototype.setup = function (_config, _client) {
10
+ return __awaiter(this, void 0, void 0, function () {
11
+ return __generator(this, function (_a) {
12
+ return [2 /*return*/];
13
+ });
14
+ });
15
+ };
16
+ SessionReplayEnrichmentPlugin.prototype.execute = function (event) {
17
+ return __awaiter(this, void 0, void 0, function () {
18
+ var sessionRecordingProperties;
19
+ return __generator(this, function (_a) {
20
+ if (event.event_type === DEFAULT_SESSION_START_EVENT && event.session_id) {
21
+ sessionReplay.setSessionId(event.session_id);
22
+ }
23
+ sessionRecordingProperties = sessionReplay.getSessionReplayProperties();
24
+ event.event_properties = __assign(__assign({}, event.event_properties), sessionRecordingProperties);
25
+ return [2 /*return*/, Promise.resolve(event)];
26
+ });
27
+ });
28
+ };
29
+ return SessionReplayEnrichmentPlugin;
30
+ }());
4
31
  var SessionReplayPlugin = /** @class */ (function () {
5
32
  function SessionReplayPlugin(options) {
6
33
  this.name = '@amplitude/plugin-session-replay-browser';
7
- this.type = 'enrichment';
34
+ this.type = 'destination';
8
35
  this.options = __assign({}, options);
9
36
  }
10
- SessionReplayPlugin.prototype.setup = function (config) {
37
+ SessionReplayPlugin.prototype.setup = function (config, client) {
11
38
  var _a;
12
39
  return __awaiter(this, void 0, void 0, function () {
13
40
  return __generator(this, function (_b) {
14
41
  switch (_b.label) {
15
42
  case 0:
43
+ if (!client) {
44
+ config.loggerProvider.error('SessionReplayPlugin requires v1.9.1+ of the Amplitude SDK.');
45
+ return [2 /*return*/];
46
+ }
16
47
  config.loggerProvider.log('Installing @amplitude/plugin-session-replay.');
17
48
  this.config = config;
18
49
  if (typeof config.defaultTracking === 'boolean') {
@@ -44,6 +75,8 @@ var SessionReplayPlugin = /** @class */ (function () {
44
75
  }).promise];
45
76
  case 1:
46
77
  _b.sent();
78
+ // add enrichment plugin to add session replay properties to events
79
+ client.add(new SessionReplayEnrichmentPlugin());
47
80
  return [2 /*return*/];
48
81
  }
49
82
  });
@@ -51,14 +84,24 @@ var SessionReplayPlugin = /** @class */ (function () {
51
84
  };
52
85
  SessionReplayPlugin.prototype.execute = function (event) {
53
86
  return __awaiter(this, void 0, void 0, function () {
54
- var sessionRecordingProperties;
55
87
  return __generator(this, function (_a) {
56
- if (event.event_type === DEFAULT_SESSION_START_EVENT && event.session_id) {
57
- sessionReplay.setSessionId(event.session_id);
88
+ return [2 /*return*/, Promise.resolve({
89
+ event: event,
90
+ code: 200,
91
+ message: 'success',
92
+ })];
93
+ });
94
+ });
95
+ };
96
+ SessionReplayPlugin.prototype.flush = function () {
97
+ return __awaiter(this, void 0, void 0, function () {
98
+ return __generator(this, function (_a) {
99
+ switch (_a.label) {
100
+ case 0: return [4 /*yield*/, sessionReplay.flush(false)];
101
+ case 1:
102
+ _a.sent();
103
+ return [2 /*return*/];
58
104
  }
59
- sessionRecordingProperties = sessionReplay.getSessionReplayProperties();
60
- event.event_properties = __assign(__assign({}, event.event_properties), sessionRecordingProperties);
61
- return [2 /*return*/, Promise.resolve(event)];
62
105
  });
63
106
  });
64
107
  };
@@ -1 +1 @@
1
- {"version":3,"file":"session-replay.js","sourceRoot":"","sources":["../../src/session-replay.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,aAAa,MAAM,mCAAmC,CAAC;AACnE,OAAO,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC;AAE1D;IAS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AAO,CAAC,aAAa,0CAAE,aAAa;iCACzD;6BACF,CAAC,CAAC,OAAO,EAAA;;wBAbV,SAaU,CAAC;;;;;KACZ;IAEK,qCAAO,GAAb,UAAc,KAAY;;;;gBACxB,IAAI,KAAK,CAAC,UAAU,KAAK,2BAA2B,IAAI,KAAK,CAAC,UAAU,EAAE;oBACxE,aAAa,CAAC,YAAY,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;iBAC9C;gBAEK,0BAA0B,GAAG,aAAa,CAAC,0BAA0B,EAAE,CAAC;gBAC9E,KAAK,CAAC,gBAAgB,yBACjB,KAAK,CAAC,gBAAgB,GACtB,0BAA0B,CAC9B,CAAC;gBAEF,sBAAO,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAAC;;;KAC/B;IAEK,sCAAQ,GAAd;;;gBACE,aAAa,CAAC,QAAQ,EAAE,CAAC;;;;KAC1B;IAED,wDAA0B,GAA1B;QACE,OAAO,aAAa,CAAC,0BAA0B,EAAE,CAAC;IACpD,CAAC;IACH,0BAAC;AAAD,CAAC,AAvED,IAuEC;;AAED,MAAM,CAAC,IAAM,mBAAmB,GAAyD,UACvF,OAA8B;IAE9B,OAAO,IAAI,mBAAmB,CAAC,OAAO,CAAC,CAAC;AAC1C,CAAC,CAAC","sourcesContent":["import { BrowserConfig, EnrichmentPlugin, Event } from '@amplitude/analytics-types';\nimport * as sessionReplay from '@amplitude/session-replay-browser';\nimport { DEFAULT_SESSION_START_EVENT } from './constants';\nimport { SessionReplayOptions } from './typings/session-replay';\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 = { ...options };\n }\n\n async setup(config: BrowserConfig) {\n config.loggerProvider.log('Installing @amplitude/plugin-session-replay.');\n\n this.config = config;\n\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 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 },\n }).promise;\n }\n\n async execute(event: Event) {\n if (event.event_type === DEFAULT_SESSION_START_EVENT && event.session_id) {\n sessionReplay.setSessionId(event.session_id);\n }\n\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 async teardown(): Promise<void> {\n sessionReplay.shutdown();\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":";AAQA,OAAO,KAAK,aAAa,MAAM,mCAAmC,CAAC;AACnE,OAAO,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC;AAG1D;IAAA;QACE,SAAI,GAAG,qDAAqD,CAAC;QAC7D,SAAI,GAAG,YAAqB,CAAC;IAmB/B,CAAC;IAjBO,6CAAK,GAAX,UAAY,OAAsB,EAAE,OAAsB;;;;;;KAEzD;IAEK,+CAAO,GAAb,UAAc,KAAY;;;;gBACxB,IAAI,KAAK,CAAC,U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AC,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 { DEFAULT_SESSION_START_EVENT } from './constants';\nimport { SessionReplayOptions } from './typings/session-replay';\n\nclass SessionReplayEnrichmentPlugin implements EnrichmentPlugin {\n name = '@amplitude/plugin-session-replay-enrichment-browser';\n type = 'enrichment' as const;\n\n async setup(_config: BrowserConfig, _client: BrowserClient) {\n // do nothing\n }\n\n async execute(event: Event) {\n if (event.event_type === DEFAULT_SESSION_START_EVENT && event.session_id) {\n sessionReplay.setSessionId(event.session_id);\n }\n\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.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 }\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.config = config;\n\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 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 },\n }).promise;\n\n // add enrichment plugin to add session replay properties to events\n client.add(new SessionReplayEnrichmentPlugin());\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 sessionReplay.shutdown();\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"]}