@amplitude/plugin-session-replay-browser 1.22.26-perfrecord-init-prelease.0 → 1.22.27

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.
@@ -24,13 +24,13 @@ var SessionReplayPlugin = /** @class */ (function () {
24
24
  this.srInitOptions = this.options;
25
25
  }
26
26
  SessionReplayPlugin.prototype.setup = function (config, _client) {
27
- var _a, _b, _c, _d, _e;
27
+ var _a, _b, _c, _d, _e, _f;
28
28
  return tslib_1.__awaiter(this, void 0, void 0, function () {
29
29
  var identityStore, userProperties, error_1;
30
- return tslib_1.__generator(this, function (_f) {
31
- switch (_f.label) {
30
+ return tslib_1.__generator(this, function (_g) {
31
+ switch (_g.label) {
32
32
  case 0:
33
- _f.trys.push([0, 2, , 3]);
33
+ _g.trys.push([0, 2, , 3]);
34
34
  /* istanbul ignore next */
35
35
  config === null || config === void 0 ? void 0 : config.loggerProvider.log("Installing @amplitude/plugin-session-replay, version ".concat(version_1.VERSION, "."));
36
36
  this.config = config;
@@ -60,14 +60,14 @@ var SessionReplayPlugin = /** @class */ (function () {
60
60
  logLevel: this.config.logLevel,
61
61
  flushMaxRetries: this.config.flushMaxRetries,
62
62
  serverZone: this.config.serverZone,
63
- configServerUrl: this.options.configServerUrl,
63
+ configServerUrl: this.options.configServerUrl || ((_b = this.config.remoteConfig) === null || _b === void 0 ? void 0 : _b.serverUrl),
64
64
  trackServerUrl: this.options.trackServerUrl,
65
65
  sampleRate: this.options.sampleRate,
66
66
  privacyConfig: {
67
- blockSelector: (_b = this.options.privacyConfig) === null || _b === void 0 ? void 0 : _b.blockSelector,
68
- maskSelector: (_c = this.options.privacyConfig) === null || _c === void 0 ? void 0 : _c.maskSelector,
69
- unmaskSelector: (_d = this.options.privacyConfig) === null || _d === void 0 ? void 0 : _d.unmaskSelector,
70
- defaultMaskLevel: (_e = this.options.privacyConfig) === null || _e === void 0 ? void 0 : _e.defaultMaskLevel,
67
+ blockSelector: (_c = this.options.privacyConfig) === null || _c === void 0 ? void 0 : _c.blockSelector,
68
+ maskSelector: (_d = this.options.privacyConfig) === null || _d === void 0 ? void 0 : _d.maskSelector,
69
+ unmaskSelector: (_e = this.options.privacyConfig) === null || _e === void 0 ? void 0 : _e.unmaskSelector,
70
+ defaultMaskLevel: (_f = this.options.privacyConfig) === null || _f === void 0 ? void 0 : _f.defaultMaskLevel,
71
71
  },
72
72
  debugMode: this.options.debugMode,
73
73
  shouldInlineStylesheet: this.options.shouldInlineStylesheet,
@@ -85,10 +85,10 @@ var SessionReplayPlugin = /** @class */ (function () {
85
85
  };
86
86
  return [4 /*yield*/, this.sessionReplay.init(config.apiKey, this.srInitOptions).promise];
87
87
  case 1:
88
- _f.sent();
88
+ _g.sent();
89
89
  return [3 /*break*/, 3];
90
90
  case 2:
91
- error_1 = _f.sent();
91
+ error_1 = _g.sent();
92
92
  /* istanbul ignore next */
93
93
  config === null || config === void 0 ? void 0 : config.loggerProvider.error("Session Replay: Failed to initialize due to ".concat(error_1.message));
94
94
  return [3 /*break*/, 3];
@@ -1 +1 @@
1
- {"version":3,"file":"session-replay.js","sourceRoot":"","sources":["../../src/session-replay.ts"],"names":[],"mappings":";;;;AAAA,4DAAoH;AACpH,4EAU2C;AAC3C,8EAA2E;AAC3E,qCAAgD;AAEhD,qCAAoC;AAEpC;IAoBE,6BAAY,OAA8B;QAlB1C,SAAI,GAAG,mBAAmB,CAAC,UAAU,CAAC;QACtC,SAAI,GAAG,YAAqB,CAAC;QAO7B,kBAAa,GAA2B;YACtC,KAAK,EAAE,8BAAK;YACZ,YAAY,EAAE,qCAAY;YAC1B,0BAA0B,EAAE,mDAA0B;YACtD,IAAI,EAAE,6BAAI;YACV,YAAY,EAAE,qCAAY;YAC1B,QAAQ,EAAE,iCAAQ;YAClB,2BAA2B,EAAE,oDAA2B;SACzD,CAAC;QAGA,IAAI,CAAC,OAAO,sBAAK,oBAAoB,EAAE,KAAK,IAAK,OAAO,CAAE,CAAC;QAC3D,I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AAO,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,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,CAAC;oBAC9B,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,IAAI,CAAC,aAAa,CAAC,0BAA0B,EAAE,CAAC;IACzD,CAAC;IAnLM,8BAAU,GAAG,0CAA0C,CAAC;IAoLjE,0BAAC;CAAA,AArLD,IAqLC;AArLY,kDAAmB;AAuLzB,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, SpecialEventType } from '@amplitude/analytics-core';\nimport {\n init,\n setSessionId,\n getSessionId,\n getSessionReplayProperties,\n flush,\n shutdown,\n evaluateTargetingAndCapture,\n AmplitudeSessionReplay,\n SessionReplayOptions as SessionReplayBrowserOptions,\n} from '@amplitude/session-replay-browser';\nimport { getAnalyticsConnector } from '@amplitude/analytics-client-common';\nimport { parseUserProperties } from './helpers';\nimport { SessionReplayOptions } from './typings/session-replay';\nimport { VERSION } from './version';\n\nexport class SessionReplayPlugin implements EnrichmentPlugin<BrowserClient, BrowserConfig> {\n static pluginName = '@amplitude/plugin-session-replay-browser';\n name = SessionReplayPlugin.pluginName;\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: SessionReplayBrowserOptions;\n sessionReplay: AmplitudeSessionReplay = {\n flush: flush,\n getSessionId: getSessionId,\n getSessionReplayProperties: getSessionReplayProperties,\n init: init,\n setSessionId: setSessionId,\n shutdown: shutdown,\n evaluateTargetingAndCapture: evaluateTargetingAndCapture,\n };\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 const identityStore = getAnalyticsConnector(this.config.instanceName).identityStore;\n const userProperties = identityStore.getIdentity().userProperties;\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 userProperties: userProperties,\n omitElementTags: this.options.omitElementTags,\n applyBackgroundColorToBlockedElements: this.options.applyBackgroundColorToBlockedElements,\n interactionConfig: this.options.interactionConfig,\n captureDocumentTitle: this.options.captureDocumentTitle,\n enableUrlChangePolling: this.options.enableUrlChangePolling,\n urlChangePollingInterval: this.options.urlChangePollingInterval,\n };\n\n await this.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(this.sessionReplay.getSessionId())}.`,\n );\n await this.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 // TODO: compare optOut with this.sessionReplay.getOptOut().\n // Need to add getOptOut() to the interface AmplitudeSessionReplay first.\n if (optOut) {\n this.sessionReplay.shutdown();\n } else {\n await this.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 !== this.sessionReplay.getSessionId()) {\n await this.sessionReplay.setSessionId(sessionId).promise;\n }\n\n const sessionRecordingProperties = this.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 !== this.sessionReplay.getSessionId()) {\n await this.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 let userProperties;\n if (event.event_type === SpecialEventType.IDENTIFY) {\n userProperties = parseUserProperties(event);\n }\n await this.sessionReplay.evaluateTargetingAndCapture({ event, userProperties });\n const sessionRecordingProperties = this.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 this.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 this.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":";;;;AAAA,4DAAoH;AACpH,4EAU2C;AAC3C,8EAA2E;AAC3E,qCAA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AAC;CAAA,AArLD,IAqLC;AArLY,kDAAmB;AAuLzB,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, SpecialEventType } from '@amplitude/analytics-core';\nimport {\n init,\n setSessionId,\n getSessionId,\n getSessionReplayProperties,\n flush,\n shutdown,\n evaluateTargetingAndCapture,\n AmplitudeSessionReplay,\n SessionReplayOptions as SessionReplayBrowserOptions,\n} from '@amplitude/session-replay-browser';\nimport { getAnalyticsConnector } from '@amplitude/analytics-client-common';\nimport { parseUserProperties } from './helpers';\nimport { SessionReplayOptions } from './typings/session-replay';\nimport { VERSION } from './version';\n\nexport class SessionReplayPlugin implements EnrichmentPlugin<BrowserClient, BrowserConfig> {\n static pluginName = '@amplitude/plugin-session-replay-browser';\n name = SessionReplayPlugin.pluginName;\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: SessionReplayBrowserOptions;\n sessionReplay: AmplitudeSessionReplay = {\n flush: flush,\n getSessionId: getSessionId,\n getSessionReplayProperties: getSessionReplayProperties,\n init: init,\n setSessionId: setSessionId,\n shutdown: shutdown,\n evaluateTargetingAndCapture: evaluateTargetingAndCapture,\n };\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 const identityStore = getAnalyticsConnector(this.config.instanceName).identityStore;\n const userProperties = identityStore.getIdentity().userProperties;\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 || this.config.remoteConfig?.serverUrl,\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 userProperties: userProperties,\n omitElementTags: this.options.omitElementTags,\n applyBackgroundColorToBlockedElements: this.options.applyBackgroundColorToBlockedElements,\n interactionConfig: this.options.interactionConfig,\n captureDocumentTitle: this.options.captureDocumentTitle,\n enableUrlChangePolling: this.options.enableUrlChangePolling,\n urlChangePollingInterval: this.options.urlChangePollingInterval,\n };\n\n await this.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(this.sessionReplay.getSessionId())}.`,\n );\n await this.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 // TODO: compare optOut with this.sessionReplay.getOptOut().\n // Need to add getOptOut() to the interface AmplitudeSessionReplay first.\n if (optOut) {\n this.sessionReplay.shutdown();\n } else {\n await this.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 !== this.sessionReplay.getSessionId()) {\n await this.sessionReplay.setSessionId(sessionId).promise;\n }\n\n const sessionRecordingProperties = this.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 !== this.sessionReplay.getSessionId()) {\n await this.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 let userProperties;\n if (event.event_type === SpecialEventType.IDENTIFY) {\n userProperties = parseUserProperties(event);\n }\n await this.sessionReplay.evaluateTargetingAndCapture({ event, userProperties });\n const sessionRecordingProperties = this.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 this.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 this.sessionReplay.getSessionReplayProperties();\n }\n}\n\nexport const sessionReplayPlugin: (options?: SessionReplayOptions) => EnrichmentPlugin = (\n options?: SessionReplayOptions,\n) => {\n return new SessionReplayPlugin(options);\n};\n"]}
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "1.22.26-perfrecord-init-prelease.0";
1
+ export declare const VERSION = "1.22.27";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,OAAO,uCAAuC,CAAC"}
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,OAAO,YAAY,CAAC"}
@@ -2,5 +2,5 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
4
  // Autogenerated by `yarn version-file`. DO NOT EDIT
5
- exports.VERSION = '1.22.26-perfrecord-init-prelease.0';
5
+ exports.VERSION = '1.22.27';
6
6
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";;;AAAA,oDAAoD;AACvC,QAAA,OAAO,GAAG,oCAAoC,CAAC","sourcesContent":["// Autogenerated by `yarn version-file`. DO NOT EDIT\nexport const VERSION = '1.22.26-perfrecord-init-prelease.0';\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";;;AAAA,oDAAoD;AACvC,QAAA,OAAO,GAAG,SAAS,CAAC","sourcesContent":["// Autogenerated by `yarn version-file`. DO NOT EDIT\nexport const VERSION = '1.22.27';\n"]}
@@ -21,13 +21,13 @@ var SessionReplayPlugin = /** @class */ (function () {
21
21
  this.srInitOptions = this.options;
22
22
  }
23
23
  SessionReplayPlugin.prototype.setup = function (config, _client) {
24
- var _a, _b, _c, _d, _e;
24
+ var _a, _b, _c, _d, _e, _f;
25
25
  return __awaiter(this, void 0, void 0, function () {
26
26
  var identityStore, userProperties, error_1;
27
- return __generator(this, function (_f) {
28
- switch (_f.label) {
27
+ return __generator(this, function (_g) {
28
+ switch (_g.label) {
29
29
  case 0:
30
- _f.trys.push([0, 2, , 3]);
30
+ _g.trys.push([0, 2, , 3]);
31
31
  /* istanbul ignore next */
32
32
  config === null || config === void 0 ? void 0 : config.loggerProvider.log("Installing @amplitude/plugin-session-replay, version ".concat(VERSION, "."));
33
33
  this.config = config;
@@ -57,14 +57,14 @@ var SessionReplayPlugin = /** @class */ (function () {
57
57
  logLevel: this.config.logLevel,
58
58
  flushMaxRetries: this.config.flushMaxRetries,
59
59
  serverZone: this.config.serverZone,
60
- configServerUrl: this.options.configServerUrl,
60
+ configServerUrl: this.options.configServerUrl || ((_b = this.config.remoteConfig) === null || _b === void 0 ? void 0 : _b.serverUrl),
61
61
  trackServerUrl: this.options.trackServerUrl,
62
62
  sampleRate: this.options.sampleRate,
63
63
  privacyConfig: {
64
- blockSelector: (_b = this.options.privacyConfig) === null || _b === void 0 ? void 0 : _b.blockSelector,
65
- maskSelector: (_c = this.options.privacyConfig) === null || _c === void 0 ? void 0 : _c.maskSelector,
66
- unmaskSelector: (_d = this.options.privacyConfig) === null || _d === void 0 ? void 0 : _d.unmaskSelector,
67
- defaultMaskLevel: (_e = this.options.privacyConfig) === null || _e === void 0 ? void 0 : _e.defaultMaskLevel,
64
+ blockSelector: (_c = this.options.privacyConfig) === null || _c === void 0 ? void 0 : _c.blockSelector,
65
+ maskSelector: (_d = this.options.privacyConfig) === null || _d === void 0 ? void 0 : _d.maskSelector,
66
+ unmaskSelector: (_e = this.options.privacyConfig) === null || _e === void 0 ? void 0 : _e.unmaskSelector,
67
+ defaultMaskLevel: (_f = this.options.privacyConfig) === null || _f === void 0 ? void 0 : _f.defaultMaskLevel,
68
68
  },
69
69
  debugMode: this.options.debugMode,
70
70
  shouldInlineStylesheet: this.options.shouldInlineStylesheet,
@@ -82,10 +82,10 @@ var SessionReplayPlugin = /** @class */ (function () {
82
82
  };
83
83
  return [4 /*yield*/, this.sessionReplay.init(config.apiKey, this.srInitOptions).promise];
84
84
  case 1:
85
- _f.sent();
85
+ _g.sent();
86
86
  return [3 /*break*/, 3];
87
87
  case 2:
88
- error_1 = _f.sent();
88
+ error_1 = _g.sent();
89
89
  /* istanbul ignore next */
90
90
  config === null || config === void 0 ? void 0 : config.loggerProvider.error("Session Replay: Failed to initialize due to ".concat(error_1.message));
91
91
  return [3 /*break*/, 3];
@@ -1 +1 @@
1
- {"version":3,"file":"session-replay.js","sourceRoot":"","sources":["../../src/session-replay.ts"],"names":[],"mappings":";AAAA,OAAO,EAAyD,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AACpH,OAAO,EACL,IAAI,EACJ,YAAY,EACZ,YAAY,EACZ,0BAA0B,EAC1B,KAAK,EACL,QAAQ,EACR,2BAA2B,GAG5B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAEhD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC;IAoBE,6BAAY,OAA8B;QAlB1C,SAAI,GAAG,mBAAmB,CAAC,UAAU,CAAC;QACtC,SAAI,GAAG,YAAqB,CAAC;QAO7B,kBAAa,GAA2B;YACtC,KAAK,EAAE,KAAK;YACZ,YAAY,EAAE,YAAY;YAC1B,0BAA0B,EAAE,0BAA0B;YACtD,IAAI,EAAE,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AAC;wBAC1E,0BAA0B,GAAG,IAAI,CAAC,aAAa,CAAC,0BAA0B,EAAE,CAAC;wBACnF,KAAK,CAAC,gBAAgB,yBACjB,KAAK,CAAC,gBAAgB,GACtB,0BAA0B,CAC9B,CAAC;;4BAIN,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,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,CAAC;oBAC9B,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,IAAI,CAAC,aAAa,CAAC,0BAA0B,EAAE,CAAC;IACzD,CAAC;IAnLM,8BAAU,GAAG,0CAA0C,CAAC;IAoLjE,0BAAC;CAAA,AArLD,IAqLC;SArLY,mBAAmB;AAuLhC,MAAM,CAAC,IAAM,mBAAmB,GAAyD,UACvF,OAA8B;IAE9B,OAAO,IAAI,mBAAmB,CAAC,OAAO,CAAC,CAAC;AAC1C,CAAC,CAAC","sourcesContent":["import { BrowserClient, BrowserConfig, EnrichmentPlugin, Event, SpecialEventType } from '@amplitude/analytics-core';\nimport {\n init,\n setSessionId,\n getSessionId,\n getSessionReplayProperties,\n flush,\n shutdown,\n evaluateTargetingAndCapture,\n AmplitudeSessionReplay,\n SessionReplayOptions as SessionReplayBrowserOptions,\n} from '@amplitude/session-replay-browser';\nimport { getAnalyticsConnector } from '@amplitude/analytics-client-common';\nimport { parseUserProperties } from './helpers';\nimport { SessionReplayOptions } from './typings/session-replay';\nimport { VERSION } from './version';\n\nexport class SessionReplayPlugin implements EnrichmentPlugin<BrowserClient, BrowserConfig> {\n static pluginName = '@amplitude/plugin-session-replay-browser';\n name = SessionReplayPlugin.pluginName;\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: SessionReplayBrowserOptions;\n sessionReplay: AmplitudeSessionReplay = {\n flush: flush,\n getSessionId: getSessionId,\n getSessionReplayProperties: getSessionReplayProperties,\n init: init,\n setSessionId: setSessionId,\n shutdown: shutdown,\n evaluateTargetingAndCapture: evaluateTargetingAndCapture,\n };\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 const identityStore = getAnalyticsConnector(this.config.instanceName).identityStore;\n const userProperties = identityStore.getIdentity().userProperties;\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 userProperties: userProperties,\n omitElementTags: this.options.omitElementTags,\n applyBackgroundColorToBlockedElements: this.options.applyBackgroundColorToBlockedElements,\n interactionConfig: this.options.interactionConfig,\n captureDocumentTitle: this.options.captureDocumentTitle,\n enableUrlChangePolling: this.options.enableUrlChangePolling,\n urlChangePollingInterval: this.options.urlChangePollingInterval,\n };\n\n await this.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(this.sessionReplay.getSessionId())}.`,\n );\n await this.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 // TODO: compare optOut with this.sessionReplay.getOptOut().\n // Need to add getOptOut() to the interface AmplitudeSessionReplay first.\n if (optOut) {\n this.sessionReplay.shutdown();\n } else {\n await this.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 !== this.sessionReplay.getSessionId()) {\n await this.sessionReplay.setSessionId(sessionId).promise;\n }\n\n const sessionRecordingProperties = this.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 !== this.sessionReplay.getSessionId()) {\n await this.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 let userProperties;\n if (event.event_type === SpecialEventType.IDENTIFY) {\n userProperties = parseUserProperties(event);\n }\n await this.sessionReplay.evaluateTargetingAndCapture({ event, userProperties });\n const sessionRecordingProperties = this.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 this.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 this.sessionReplay.getSessionReplayProperties();\n }\n}\n\nexport const sessionReplayPlugin: (options?: SessionReplayOptions) => EnrichmentPlugin = (\n options?: SessionReplayOptions,\n) => {\n return new SessionReplay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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,IAAI,CAAC,aAAa,CAAC,0BAA0B,EAAE,CAAC;IACzD,CAAC;IAnLM,8BAAU,GAAG,0CAA0C,CAAC;IAoLjE,0BAAC;CAAA,AArLD,IAqLC;SArLY,mBAAmB;AAuLhC,MAAM,CAAC,IAAM,mBAAmB,GAAyD,UACvF,OAA8B;IAE9B,OAAO,IAAI,mBAAmB,CAAC,OAAO,CAAC,CAAC;AAC1C,CAAC,CAAC","sourcesContent":["import { BrowserClient, BrowserConfig, EnrichmentPlugin, Event, SpecialEventType } from '@amplitude/analytics-core';\nimport {\n init,\n setSessionId,\n getSessionId,\n getSessionReplayProperties,\n flush,\n shutdown,\n evaluateTargetingAndCapture,\n AmplitudeSessionReplay,\n SessionReplayOptions as SessionReplayBrowserOptions,\n} from '@amplitude/session-replay-browser';\nimport { getAnalyticsConnector } from '@amplitude/analytics-client-common';\nimport { parseUserProperties } from './helpers';\nimport { SessionReplayOptions } from './typings/session-replay';\nimport { VERSION } from './version';\n\nexport class SessionReplayPlugin implements EnrichmentPlugin<BrowserClient, BrowserConfig> {\n static pluginName = '@amplitude/plugin-session-replay-browser';\n name = SessionReplayPlugin.pluginName;\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: SessionReplayBrowserOptions;\n sessionReplay: AmplitudeSessionReplay = {\n flush: flush,\n getSessionId: getSessionId,\n getSessionReplayProperties: getSessionReplayProperties,\n init: init,\n setSessionId: setSessionId,\n shutdown: shutdown,\n evaluateTargetingAndCapture: evaluateTargetingAndCapture,\n };\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 const identityStore = getAnalyticsConnector(this.config.instanceName).identityStore;\n const userProperties = identityStore.getIdentity().userProperties;\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 || this.config.remoteConfig?.serverUrl,\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 userProperties: userProperties,\n omitElementTags: this.options.omitElementTags,\n applyBackgroundColorToBlockedElements: this.options.applyBackgroundColorToBlockedElements,\n interactionConfig: this.options.interactionConfig,\n captureDocumentTitle: this.options.captureDocumentTitle,\n enableUrlChangePolling: this.options.enableUrlChangePolling,\n urlChangePollingInterval: this.options.urlChangePollingInterval,\n };\n\n await this.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(this.sessionReplay.getSessionId())}.`,\n );\n await this.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 // TODO: compare optOut with this.sessionReplay.getOptOut().\n // Need to add getOptOut() to the interface AmplitudeSessionReplay first.\n if (optOut) {\n this.sessionReplay.shutdown();\n } else {\n await this.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 !== this.sessionReplay.getSessionId()) {\n await this.sessionReplay.setSessionId(sessionId).promise;\n }\n\n const sessionRecordingProperties = this.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 !== this.sessionReplay.getSessionId()) {\n await this.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 let userProperties;\n if (event.event_type === SpecialEventType.IDENTIFY) {\n userProperties = parseUserProperties(event);\n }\n await this.sessionReplay.evaluateTargetingAndCapture({ event, userProperties });\n const sessionRecordingProperties = this.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 this.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 this.sessionReplay.getSessionReplayProperties();\n }\n}\n\nexport const sessionReplayPlugin: (options?: SessionReplayOptions) => EnrichmentPlugin = (\n options?: SessionReplayOptions,\n) => {\n return new SessionReplayPlugin(options);\n};\n"]}
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "1.22.26-perfrecord-init-prelease.0";
1
+ export declare const VERSION = "1.22.27";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,OAAO,uCAAuC,CAAC"}
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,OAAO,YAAY,CAAC"}
@@ -1,3 +1,3 @@
1
1
  // Autogenerated by `yarn version-file`. DO NOT EDIT
2
- export var VERSION = '1.22.26-perfrecord-init-prelease.0';
2
+ export var VERSION = '1.22.27';
3
3
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,MAAM,CAAC,IAAM,OAAO,GAAG,oCAAoC,CAAC","sourcesContent":["// Autogenerated by `yarn version-file`. DO NOT EDIT\nexport const VERSION = '1.22.26-perfrecord-init-prelease.0';\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,MAAM,CAAC,IAAM,OAAO,GAAG,SAAS,CAAC","sourcesContent":["// Autogenerated by `yarn version-file`. DO NOT EDIT\nexport const VERSION = '1.22.27';\n"]}