@amplitude/unified 1.0.4 → 1.0.5

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.
@@ -20,6 +20,7 @@ export interface UnifiedClient extends BrowserClient {
20
20
  }
21
21
  export declare class AmplitudeUnified extends AmplitudeBrowser implements UnifiedClient {
22
22
  private _sessionReplay;
23
+ private _initAllPromise?;
23
24
  sessionReplay(): AmplitudeSessionReplay;
24
25
  experiment(): IExperimentClient | undefined;
25
26
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"unified.d.ts","sourceRoot":"","sources":["../../src/unified.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EACL,sBAAsB,EACtB,oBAAoB,EAGrB,MAAM,0CAA0C,CAAC;AAClD,OAAO,EACL,iBAAiB,EACjB,sBAAsB,EAGvB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,WAAW,EAA8B,MAAM,+BAA+B,CAAC;AACxF,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAG1E,MAAM,WAAW,oBAAoB;IACnC,UAAU,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,MAAM,cAAc,GAAG,oBAAoB,GAAG;IAClD,SAAS,CAAC,EAAE,cAAc,CAAC;IAC3B,aAAa,CAAC,EAAE,IAAI,CAAC,oBAAoB,EAAE,MAAM,oBAAoB,CAAC,CAAC;IACvE,UAAU,CAAC,EAAE,IAAI,CAAC,sBAAsB,EAAE,MAAM,oBAAoB,CAAC,CAAC;IACtE,UAAU,CAAC,EAAE,IAAI,CAAC,WAAW,EAAE,MAAM,oBAAoB,CAAC,CAAC;CAC5D,CAAC;AAEF,MAAM,WAAW,aAAc,SAAQ,aAAa;IAClD,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,cAAc,CAA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CAAC,EAAE,IAAI,CAAC,WAAW,EAAE,MAAM,oBAAoB,CAAC,CAAC;CAC5D,CAAC;AAEF,MAAM,WAAW,aAAc,SAAQ,aAAa;IAClD,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxE,aAAa,IAAI,sBAAsB,CAAC;IACxC,UAAU,IAAI,iBAAiB,GAAG,SAAS,CAAC;CAC7C;AAED,qBAAa,gBAAiB,SAAQ,gBAAiB,YAAW,aAAa;IAG7E,OAAO,CAAC,cAAc,CAAyB;IAC/C,OAAO,CAAC,eAAe,CAAC,CAAgB;IAExC,aAAa,IAAI,sBAAsB;IAIvC,UAAU,IAAI,iBAAiB,GAAG,SAAS;IAkB3C;;;;;;OAMG;IACG,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,cAAc;IAuC7D;;OAEG;IAEH,IAAI,CAAC,MAAM,SAAK,EAAE,eAAe,CAAC,EAAE,MAAM,GAAG,cAAc,EAAE,YAAY,CAAC,EAAE,cAAc;CAI3F"}
@@ -42,36 +42,47 @@ var AmplitudeUnified = /** @class */ (function (_super) {
42
42
  */
43
43
  AmplitudeUnified.prototype.initAll = function (apiKey, unifiedOptions) {
44
44
  return tslib_1.__awaiter(this, void 0, void 0, function () {
45
- var sharedOptions, srPlugin;
45
+ var _this = this;
46
46
  return tslib_1.__generator(this, function (_a) {
47
- switch (_a.label) {
48
- case 0:
49
- sharedOptions = {
50
- serverZone: unifiedOptions === null || unifiedOptions === void 0 ? void 0 : unifiedOptions.serverZone,
51
- instanceName: unifiedOptions === null || unifiedOptions === void 0 ? void 0 : unifiedOptions.instanceName,
52
- };
53
- _super.prototype.add.call(this, (0, library_1.libraryPlugin)());
54
- return [4 /*yield*/, _super.prototype.init.call(this, apiKey, tslib_1.__assign(tslib_1.__assign({}, unifiedOptions === null || unifiedOptions === void 0 ? void 0 : unifiedOptions.analytics), sharedOptions)).promise];
55
- case 1:
56
- _a.sent();
57
- return [4 /*yield*/, _super.prototype.add.call(this, (0, plugin_session_replay_browser_1.sessionReplayPlugin)(tslib_1.__assign(tslib_1.__assign({}, unifiedOptions === null || unifiedOptions === void 0 ? void 0 : unifiedOptions.sessionReplay), sharedOptions))).promise];
58
- case 2:
59
- _a.sent();
60
- return [4 /*yield*/, _super.prototype.add.call(this, (0, plugin_experiment_browser_1.experimentPlugin)(tslib_1.__assign(tslib_1.__assign({}, unifiedOptions === null || unifiedOptions === void 0 ? void 0 : unifiedOptions.experiment), sharedOptions))).promise];
61
- case 3:
62
- _a.sent();
63
- srPlugin = this.plugin(plugin_session_replay_browser_1.SessionReplayPlugin.pluginName);
64
- if (srPlugin === undefined) {
65
- this.config.loggerProvider.debug("".concat(plugin_session_replay_browser_1.SessionReplayPlugin.pluginName, " plugin is not found."));
66
- }
67
- else {
68
- this._sessionReplay = srPlugin.sessionReplay;
69
- }
70
- return [4 /*yield*/, _super.prototype.add.call(this, (0, engagement_browser_1.plugin)(tslib_1.__assign(tslib_1.__assign({}, unifiedOptions === null || unifiedOptions === void 0 ? void 0 : unifiedOptions.engagement), sharedOptions))).promise];
71
- case 4:
72
- _a.sent();
73
- return [2 /*return*/];
47
+ if (this._initAllPromise) {
48
+ return [2 /*return*/, this._initAllPromise];
74
49
  }
50
+ this._initAllPromise = (function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
51
+ var sharedOptions, srPlugin;
52
+ return tslib_1.__generator(this, function (_a) {
53
+ switch (_a.label) {
54
+ case 0:
55
+ sharedOptions = {
56
+ serverZone: unifiedOptions === null || unifiedOptions === void 0 ? void 0 : unifiedOptions.serverZone,
57
+ instanceName: unifiedOptions === null || unifiedOptions === void 0 ? void 0 : unifiedOptions.instanceName,
58
+ };
59
+ _super.prototype.add.call(this, (0, library_1.libraryPlugin)());
60
+ return [4 /*yield*/, _super.prototype.init.call(this, apiKey, tslib_1.__assign(tslib_1.__assign({}, unifiedOptions === null || unifiedOptions === void 0 ? void 0 : unifiedOptions.analytics), sharedOptions)).promise];
61
+ case 1:
62
+ _a.sent();
63
+ return [4 /*yield*/, _super.prototype.add.call(this, (0, plugin_session_replay_browser_1.sessionReplayPlugin)(tslib_1.__assign(tslib_1.__assign({}, unifiedOptions === null || unifiedOptions === void 0 ? void 0 : unifiedOptions.sessionReplay), sharedOptions))).promise];
64
+ case 2:
65
+ _a.sent();
66
+ return [4 /*yield*/, _super.prototype.add.call(this, (0, plugin_experiment_browser_1.experimentPlugin)(tslib_1.__assign(tslib_1.__assign({}, unifiedOptions === null || unifiedOptions === void 0 ? void 0 : unifiedOptions.experiment), sharedOptions))).promise];
67
+ case 3:
68
+ _a.sent();
69
+ srPlugin = this.plugin(plugin_session_replay_browser_1.SessionReplayPlugin.pluginName);
70
+ if (srPlugin === undefined) {
71
+ this.config.loggerProvider.debug("".concat(plugin_session_replay_browser_1.SessionReplayPlugin.pluginName, " plugin is not found."));
72
+ }
73
+ else {
74
+ this._sessionReplay = srPlugin.sessionReplay;
75
+ }
76
+ return [4 /*yield*/, _super.prototype.add.call(this, (0, engagement_browser_1.plugin)(tslib_1.__assign(tslib_1.__assign({}, unifiedOptions === null || unifiedOptions === void 0 ? void 0 : unifiedOptions.engagement), sharedOptions))).promise];
77
+ case 4:
78
+ _a.sent();
79
+ return [2 /*return*/];
80
+ }
81
+ });
82
+ }); })().finally(function () {
83
+ _this._initAllPromise = undefined;
84
+ });
85
+ return [2 /*return*/, this._initAllPromise];
75
86
  });
76
87
  });
77
88
  };
@@ -1 +1 @@
1
- {"version":3,"file":"unified.js","sourceRoot":"","sources":["../../src/unified.ts"],"names":[],"mappings":";;;;AAAA,kEAAgE;AAChE,0FAKkD;AAClD,kFAK8C;AAC9C,oEAAwF;AAExF,qCAA0C;AAoB1C;IAAsC,4CAAgB;IAAtD;;IAsEA,CAAC;IAjEC,wCAAa,GAAb;QACE,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAED,qCAAU,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AAA,4CAAgB,wCAAM,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,UAAU,GAAK,aAAa,EAAG,CAAC,CAAC,OAAO,EAAA;;wBAA9F,SAA8F,CAAC;wBAEzF,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,mDAAmB,CAAC,UAAU,CAAC,CAAC;wBAC7D,IAAI,QAAQ,KAAK,SAAS,EAAE;4BAC1B,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,UAAG,mDAAmB,CAAC,UAAU,0BAAuB,CAAC,CAAC;yBAC5F;6BAAM;4BACL,IAAI,CAAC,cAAc,GAAI,QAAgC,CAAC,aAAa,CAAC;yBACvE;wBAED,qBAAM,iBAAM,GAAG,YACb,IAAA,2BAAgB,wCACX,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,UAAU,GAC1B,aAAa,EAChB,CACH,CAAC,OAAO,EAAA;;wBALT,SAKS,CAAC;;;;;KACX;IAED;;OAEG;IACH,0BAA0B;IAC1B,+BAAI,GAAJ,UAAK,MAAW,EAAE,eAAyC,EAAE,YAA6B;QAArF,uBAAA,EAAA,WAAW;QACd,IAAM,GAAG,GAAG,iBAAM,IAAI,YAAC,MAAM,EAAE,eAAe,EAAE,YAAY,CAAC,CAAC;QAC9D,OAAO,GAAG,CAAC;IACb,CAAC;IACH,uBAAC;AAAD,CAAC,AAtED,CAAsC,oCAAgB,GAsErD;AAtEY,4CAAgB","sourcesContent":["import { AmplitudeBrowser } from '@amplitude/analytics-browser';\nimport {\n AmplitudeSessionReplay,\n SessionReplayOptions,\n sessionReplayPlugin,\n SessionReplayPlugin,\n} from '@amplitude/plugin-session-replay-browser';\nimport {\n IExperimentClient,\n ExperimentPluginConfig,\n ExperimentPlugin,\n experimentPlugin,\n} from '@amplitude/plugin-experiment-browser';\nimport { InitOptions, plugin as EngagementPlugin } from '@amplitude/engagement-browser';\nimport { BrowserClient, BrowserOptions } from '@amplitude/analytics-core';\nimport { libraryPlugin } from './library';\n\nexport interface UnifiedSharedOptions {\n serverZone?: 'US' | 'EU';\n instanceName?: string;\n}\n\nexport type UnifiedOptions = UnifiedSharedOptions & {\n analytics?: BrowserOptions;\n sessionReplay?: Omit<SessionReplayOptions, keyof UnifiedSharedOptions>;\n experiment?: Omit<ExperimentPluginConfig, keyof UnifiedSharedOptions>;\n engagement?: Omit<InitOptions, keyof UnifiedSharedOptions>;\n};\n\nexport interface UnifiedClient extends BrowserClient {\n initAll(apiKey: string, unifiedOptions?: UnifiedOptions): Promise<void>;\n sessionReplay(): AmplitudeSessionReplay;\n experiment(): IExperimentClient | undefined;\n}\n\nexport class AmplitudeUnified extends AmplitudeBrowser implements UnifiedClient {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n private _sessionReplay: AmplitudeSessionReplay;\n\n sessionReplay(): AmplitudeSessionReplay {\n return this._sessionReplay;\n }\n\n experiment(): IExperimentClient | undefined {\n // Return when init() or initAll() is not called\n if (this.config === undefined) {\n return undefined;\n }\n\n const expPlugins = this.plugins(ExperimentPlugin);\n if (expPlugins.length === 0) {\n this.config.loggerProvider.debug(`${ExperimentPlugin.pluginName} plugin is not found.`);\n return undefined;\n } else if (expPlugins.length === 1) {\n return expPlugins[0].experiment;\n } else {\n this.config.loggerProvider.debug(`Multiple instances of ${ExperimentPlugin.pluginName} are found.`);\n return undefined;\n }\n }\n\n /**\n * Initialize SDKs with configuration options.\n *\n * @param apiKey Amplitude API key.\n * @param analyticsOptions Analytics configuration options. Refer to {@link https://amplitude.com/docs/sdks/analytics/browser/browser-sdk-2#configure-the-sdk here} for more info.\n * @param unifiedOptions Shared configuration for all SDKs and for blade SDKs.\n */\n async initAll(apiKey: string, unifiedOptions?: UnifiedOptions) {\n const sharedOptions = {\n serverZone: unifiedOptions?.serverZone,\n instanceName: unifiedOptions?.instanceName,\n };\n\n super.add(libraryPlugin());\n await super.init(apiKey, { ...unifiedOptions?.analytics, ...sharedOptions }).promise;\n\n await super.add(sessionReplayPlugin({ ...unifiedOptions?.sessionReplay, ...sharedOptions })).promise;\n\n await super.add(experimentPlugin({ ...unifiedOptions?.experiment, ...sharedOptions })).promise;\n\n const srPlugin = this.plugin(SessionReplayPlugin.pluginName);\n if (srPlugin === undefined) {\n this.config.loggerProvider.debug(`${SessionReplayPlugin.pluginName} plugin is not found.`);\n } else {\n this._sessionReplay = (srPlugin as SessionReplayPlugin).sessionReplay;\n }\n\n await super.add(\n EngagementPlugin({\n ...unifiedOptions?.engagement,\n ...sharedOptions,\n }),\n ).promise;\n }\n\n /**\n * Only analytics SDK is initialized. Use initAll() instead to initialize all blade SDKs.\n */\n /* istanbul ignore next */\n init(apiKey = '', userIdOrOptions?: string | BrowserOptions, maybeOptions?: BrowserOptions) {\n const res = super.init(apiKey, userIdOrOptions, maybeOptions);\n return res;\n }\n}\n"]}
1
+ {"version":3,"file":"unified.js","sourceRoot":"","sources":["../../src/unified.ts"],"names":[],"mappings":";;;;AAAA,kEAAgE;AAChE,0FAKkD;AAClD,kFAK8C;AAC9C,oEAAwF;AAExF,qCAA0C;AAoB1C;IAAsC,4CAAgB;IAAtD;;IAkFA,CAAC;IA5EC,wCAAa,GAAb;QACE,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAED,qCAAU,GAAV;QACE,gDAAgD;QAChD,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE;YAC7B,OAAO,SAAS,CAAC;SAClB;QAED,IAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,4CAAgB,CAAC,CAAC;QAClD,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE;YAC3B,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,UAAG,4CAAgB,CAAC,UAAU,0BAAuB,CAAC,CAAC;YACxF,OAAO,SAAS,CAAC;SAClB;aAAM,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE;YAClC,OAAO,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAA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,UAAU,0BAAuB,CAAC,CAAC;iCAC5F;qCAAM;oCACL,IAAI,CAAC,cAAc,GAAI,QAAgC,CAAC,aAAa,CAAC;iCACvE;gCAED,qBAAM,iBAAM,GAAG,YACb,IAAA,2BAAgB,wCACX,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,UAAU,GAC1B,aAAa,EAChB,CACH,CAAC,OAAO,EAAA;;gCALT,SAKS,CAAC;;;;qBACX,CAAC,EAAE,CAAC,OAAO,CAAC;oBACX,KAAI,CAAC,eAAe,GAAG,SAAS,CAAC;gBACnC,CAAC,CAAC,CAAC;gBAEH,sBAAO,IAAI,CAAC,eAAe,EAAC;;;KAC7B;IAED;;OAEG;IACH,0BAA0B;IAC1B,+BAAI,GAAJ,UAAK,MAAW,EAAE,eAAyC,EAAE,YAA6B;QAArF,uBAAA,EAAA,WAAW;QACd,IAAM,GAAG,GAAG,iBAAM,IAAI,YAAC,MAAM,EAAE,eAAe,EAAE,YAAY,CAAC,CAAC;QAC9D,OAAO,GAAG,CAAC;IACb,CAAC;IACH,uBAAC;AAAD,CAAC,AAlFD,CAAsC,oCAAgB,GAkFrD;AAlFY,4CAAgB","sourcesContent":["import { AmplitudeBrowser } from '@amplitude/analytics-browser';\nimport {\n AmplitudeSessionReplay,\n SessionReplayOptions,\n sessionReplayPlugin,\n SessionReplayPlugin,\n} from '@amplitude/plugin-session-replay-browser';\nimport {\n IExperimentClient,\n ExperimentPluginConfig,\n ExperimentPlugin,\n experimentPlugin,\n} from '@amplitude/plugin-experiment-browser';\nimport { InitOptions, plugin as EngagementPlugin } from '@amplitude/engagement-browser';\nimport { BrowserClient, BrowserOptions } from '@amplitude/analytics-core';\nimport { libraryPlugin } from './library';\n\nexport interface UnifiedSharedOptions {\n serverZone?: 'US' | 'EU';\n instanceName?: string;\n}\n\nexport type UnifiedOptions = UnifiedSharedOptions & {\n analytics?: BrowserOptions;\n sessionReplay?: Omit<SessionReplayOptions, keyof UnifiedSharedOptions>;\n experiment?: Omit<ExperimentPluginConfig, keyof UnifiedSharedOptions>;\n engagement?: Omit<InitOptions, keyof UnifiedSharedOptions>;\n};\n\nexport interface UnifiedClient extends BrowserClient {\n initAll(apiKey: string, unifiedOptions?: UnifiedOptions): Promise<void>;\n sessionReplay(): AmplitudeSessionReplay;\n experiment(): IExperimentClient | undefined;\n}\n\nexport class AmplitudeUnified extends AmplitudeBrowser implements UnifiedClient {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n private _sessionReplay: AmplitudeSessionReplay;\n private _initAllPromise?: Promise<void>;\n\n sessionReplay(): AmplitudeSessionReplay {\n return this._sessionReplay;\n }\n\n experiment(): IExperimentClient | undefined {\n // Return when init() or initAll() is not called\n if (this.config === undefined) {\n return undefined;\n }\n\n const expPlugins = this.plugins(ExperimentPlugin);\n if (expPlugins.length === 0) {\n this.config.loggerProvider.debug(`${ExperimentPlugin.pluginName} plugin is not found.`);\n return undefined;\n } else if (expPlugins.length === 1) {\n return expPlugins[0].experiment;\n } else {\n this.config.loggerProvider.debug(`Multiple instances of ${ExperimentPlugin.pluginName} are found.`);\n return undefined;\n }\n }\n\n /**\n * Initialize SDKs with configuration options.\n *\n * @param apiKey Amplitude API key.\n * @param analyticsOptions Analytics configuration options. Refer to {@link https://amplitude.com/docs/sdks/analytics/browser/browser-sdk-2#configure-the-sdk here} for more info.\n * @param unifiedOptions Shared configuration for all SDKs and for blade SDKs.\n */\n async initAll(apiKey: string, unifiedOptions?: UnifiedOptions) {\n if (this._initAllPromise) {\n return this._initAllPromise;\n }\n\n this._initAllPromise = (async () => {\n const sharedOptions = {\n serverZone: unifiedOptions?.serverZone,\n instanceName: unifiedOptions?.instanceName,\n };\n\n super.add(libraryPlugin());\n\n await super.init(apiKey, { ...unifiedOptions?.analytics, ...sharedOptions }).promise;\n\n await super.add(sessionReplayPlugin({ ...unifiedOptions?.sessionReplay, ...sharedOptions })).promise;\n\n await super.add(experimentPlugin({ ...unifiedOptions?.experiment, ...sharedOptions })).promise;\n\n const srPlugin = this.plugin(SessionReplayPlugin.pluginName);\n if (srPlugin === undefined) {\n this.config.loggerProvider.debug(`${SessionReplayPlugin.pluginName} plugin is not found.`);\n } else {\n this._sessionReplay = (srPlugin as SessionReplayPlugin).sessionReplay;\n }\n\n await super.add(\n EngagementPlugin({\n ...unifiedOptions?.engagement,\n ...sharedOptions,\n }),\n ).promise;\n })().finally(() => {\n this._initAllPromise = undefined;\n });\n\n return this._initAllPromise;\n }\n\n /**\n * Only analytics SDK is initialized. Use initAll() instead to initialize all blade SDKs.\n */\n /* istanbul ignore next */\n init(apiKey = '', userIdOrOptions?: string | BrowserOptions, maybeOptions?: BrowserOptions) {\n const res = super.init(apiKey, userIdOrOptions, maybeOptions);\n return res;\n }\n}\n"]}
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "1.0.4";
1
+ export declare const VERSION = "1.0.5";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -2,5 +2,5 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
4
  // Autogenerated by `pnpm version-file`. DO NOT EDIT
5
- exports.VERSION = '1.0.4';
5
+ exports.VERSION = '1.0.5';
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,OAAO,CAAC","sourcesContent":["// Autogenerated by `pnpm version-file`. DO NOT EDIT\nexport const VERSION = '1.0.4';\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";;;AAAA,oDAAoD;AACvC,QAAA,OAAO,GAAG,OAAO,CAAC","sourcesContent":["// Autogenerated by `pnpm version-file`. DO NOT EDIT\nexport const VERSION = '1.0.5';\n"]}
@@ -20,6 +20,7 @@ export interface UnifiedClient extends BrowserClient {
20
20
  }
21
21
  export declare class AmplitudeUnified extends AmplitudeBrowser implements UnifiedClient {
22
22
  private _sessionReplay;
23
+ private _initAllPromise?;
23
24
  sessionReplay(): AmplitudeSessionReplay;
24
25
  experiment(): IExperimentClient | undefined;
25
26
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"unified.d.ts","sourceRoot":"","sources":["../../src/unified.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EACL,sBAAsB,EACtB,oBAAoB,EAGrB,MAAM,0CAA0C,CAAC;AAClD,OAAO,EACL,iBAAiB,EACjB,sBAAsB,EAGvB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,WAAW,EAA8B,MAAM,+BAA+B,CAAC;AACxF,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAG1E,MAAM,WAAW,oBAAoB;IACnC,UAAU,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,MAAM,cAAc,GAAG,oBAAoB,GAAG;IAClD,SAAS,CAAC,EAAE,cAAc,CAAC;IAC3B,aAAa,CAAC,EAAE,IAAI,CAAC,oBAAoB,EAAE,MAAM,oBAAoB,CAAC,CAAC;IACvE,UAAU,CAAC,EAAE,IAAI,CAAC,sBAAsB,EAAE,MAAM,oBAAoB,CAAC,CAAC;IACtE,UAAU,CAAC,EAAE,IAAI,CAAC,WAAW,EAAE,MAAM,oBAAoB,CAAC,CAAC;CAC5D,CAAC;AAEF,MAAM,WAAW,aAAc,SAAQ,aAAa;IAClD,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxE,aAAa,IAAI,sBAAsB,CAAC;IACxC,UAAU,IAAI,iBAAiB,GAAG,SAAS,CAAC;CAC7C;AAED,qBAAa,gBAAiB,SAAQ,gBAAiB,YAAW,aAAa;IAG7E,OAAO,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,IAAI,CAAC,CAAC;IACxE,aAAa,IAAI,sBAAsB,CAAC;IACxC,UAAU,IAAI,iBAAiB,GAAG,SAAS,CAAC;CAC7C;AAED,qBAAa,gBAAiB,SAAQ,gBAAiB,YAAW,aAAa;IAG7E,OAAO,CAAC,cAAc,CAAyB;IAC/C,OAAO,CAAC,eAAe,CAAC,CAAgB;IAExC,aAAa,IAAI,sBAAsB;IAIvC,UAAU,IAAI,iBAAiB,GAAG,SAAS;IAkB3C;;;;;;OAMG;IACG,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,cAAc;IAuC7D;;OAEG;IAEH,IAAI,CAAC,MAAM,SAAK,EAAE,eAAe,CAAC,EAAE,MAAM,GAAG,cAAc,EAAE,YAAY,CAAC,EAAE,cAAc;CAI3F"}
@@ -39,36 +39,47 @@ var AmplitudeUnified = /** @class */ (function (_super) {
39
39
  */
40
40
  AmplitudeUnified.prototype.initAll = function (apiKey, unifiedOptions) {
41
41
  return __awaiter(this, void 0, void 0, function () {
42
- var sharedOptions, srPlugin;
42
+ var _this = this;
43
43
  return __generator(this, function (_a) {
44
- switch (_a.label) {
45
- case 0:
46
- sharedOptions = {
47
- serverZone: unifiedOptions === null || unifiedOptions === void 0 ? void 0 : unifiedOptions.serverZone,
48
- instanceName: unifiedOptions === null || unifiedOptions === void 0 ? void 0 : unifiedOptions.instanceName,
49
- };
50
- _super.prototype.add.call(this, libraryPlugin());
51
- return [4 /*yield*/, _super.prototype.init.call(this, apiKey, __assign(__assign({}, unifiedOptions === null || unifiedOptions === void 0 ? void 0 : unifiedOptions.analytics), sharedOptions)).promise];
52
- case 1:
53
- _a.sent();
54
- return [4 /*yield*/, _super.prototype.add.call(this, sessionReplayPlugin(__assign(__assign({}, unifiedOptions === null || unifiedOptions === void 0 ? void 0 : unifiedOptions.sessionReplay), sharedOptions))).promise];
55
- case 2:
56
- _a.sent();
57
- return [4 /*yield*/, _super.prototype.add.call(this, experimentPlugin(__assign(__assign({}, unifiedOptions === null || unifiedOptions === void 0 ? void 0 : unifiedOptions.experiment), sharedOptions))).promise];
58
- case 3:
59
- _a.sent();
60
- srPlugin = this.plugin(SessionReplayPlugin.pluginName);
61
- if (srPlugin === undefined) {
62
- this.config.loggerProvider.debug("".concat(SessionReplayPlugin.pluginName, " plugin is not found."));
63
- }
64
- else {
65
- this._sessionReplay = srPlugin.sessionReplay;
66
- }
67
- return [4 /*yield*/, _super.prototype.add.call(this, EngagementPlugin(__assign(__assign({}, unifiedOptions === null || unifiedOptions === void 0 ? void 0 : unifiedOptions.engagement), sharedOptions))).promise];
68
- case 4:
69
- _a.sent();
70
- return [2 /*return*/];
44
+ if (this._initAllPromise) {
45
+ return [2 /*return*/, this._initAllPromise];
71
46
  }
47
+ this._initAllPromise = (function () { return __awaiter(_this, void 0, void 0, function () {
48
+ var sharedOptions, srPlugin;
49
+ return __generator(this, function (_a) {
50
+ switch (_a.label) {
51
+ case 0:
52
+ sharedOptions = {
53
+ serverZone: unifiedOptions === null || unifiedOptions === void 0 ? void 0 : unifiedOptions.serverZone,
54
+ instanceName: unifiedOptions === null || unifiedOptions === void 0 ? void 0 : unifiedOptions.instanceName,
55
+ };
56
+ _super.prototype.add.call(this, libraryPlugin());
57
+ return [4 /*yield*/, _super.prototype.init.call(this, apiKey, __assign(__assign({}, unifiedOptions === null || unifiedOptions === void 0 ? void 0 : unifiedOptions.analytics), sharedOptions)).promise];
58
+ case 1:
59
+ _a.sent();
60
+ return [4 /*yield*/, _super.prototype.add.call(this, sessionReplayPlugin(__assign(__assign({}, unifiedOptions === null || unifiedOptions === void 0 ? void 0 : unifiedOptions.sessionReplay), sharedOptions))).promise];
61
+ case 2:
62
+ _a.sent();
63
+ return [4 /*yield*/, _super.prototype.add.call(this, experimentPlugin(__assign(__assign({}, unifiedOptions === null || unifiedOptions === void 0 ? void 0 : unifiedOptions.experiment), sharedOptions))).promise];
64
+ case 3:
65
+ _a.sent();
66
+ srPlugin = this.plugin(SessionReplayPlugin.pluginName);
67
+ if (srPlugin === undefined) {
68
+ this.config.loggerProvider.debug("".concat(SessionReplayPlugin.pluginName, " plugin is not found."));
69
+ }
70
+ else {
71
+ this._sessionReplay = srPlugin.sessionReplay;
72
+ }
73
+ return [4 /*yield*/, _super.prototype.add.call(this, EngagementPlugin(__assign(__assign({}, unifiedOptions === null || unifiedOptions === void 0 ? void 0 : unifiedOptions.engagement), sharedOptions))).promise];
74
+ case 4:
75
+ _a.sent();
76
+ return [2 /*return*/];
77
+ }
78
+ });
79
+ }); })().finally(function () {
80
+ _this._initAllPromise = undefined;
81
+ });
82
+ return [2 /*return*/, this._initAllPromise];
72
83
  });
73
84
  });
74
85
  };
@@ -1 +1 @@
1
- {"version":3,"file":"unified.js","sourceRoot":"","sources":["../../src/unified.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAGL,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAGL,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAe,MAAM,IAAI,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAExF,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAoB1C;IAAsC,oCAAgB;IAAtD;;IAsEA,CAAC;IAjEC,wCAAa,GAAb;QACE,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAED,qCAAU,GAAV;QACE,gDAAgD;QAChD,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE;YAC7B,OAAO,SAAS,CAAC;SAClB;QAED,IAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;QAClD,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE;YAC3B,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,UAAG,gBAAgB,CAAC,UAAU,0BAAuB,C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AAU,0BAAuB,CAAC,CAAC;yBAC5F;6BAAM;4BACL,IAAI,CAAC,cAAc,GAAI,QAAgC,CAAC,aAAa,CAAC;yBACvE;wBAED,qBAAM,iBAAM,GAAG,YACb,gBAAgB,uBACX,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,UAAU,GAC1B,aAAa,EAChB,CACH,CAAC,OAAO,EAAA;;wBALT,SAKS,CAAC;;;;;KACX;IAED;;OAEG;IACH,0BAA0B;IAC1B,+BAAI,GAAJ,UAAK,MAAW,EAAE,eAAyC,EAAE,YAA6B;QAArF,uBAAA,EAAA,WAAW;QACd,IAAM,GAAG,GAAG,iBAAM,IAAI,YAAC,MAAM,EAAE,eAAe,EAAE,YAAY,CAAC,CAAC;QAC9D,OAAO,GAAG,CAAC;IACb,CAAC;IACH,uBAAC;AAAD,CAAC,AAtED,CAAsC,gBAAgB,GAsErD","sourcesContent":["import { AmplitudeBrowser } from '@amplitude/analytics-browser';\nimport {\n AmplitudeSessionReplay,\n SessionReplayOptions,\n sessionReplayPlugin,\n SessionReplayPlugin,\n} from '@amplitude/plugin-session-replay-browser';\nimport {\n IExperimentClient,\n ExperimentPluginConfig,\n ExperimentPlugin,\n experimentPlugin,\n} from '@amplitude/plugin-experiment-browser';\nimport { InitOptions, plugin as EngagementPlugin } from '@amplitude/engagement-browser';\nimport { BrowserClient, BrowserOptions } from '@amplitude/analytics-core';\nimport { libraryPlugin } from './library';\n\nexport interface UnifiedSharedOptions {\n serverZone?: 'US' | 'EU';\n instanceName?: string;\n}\n\nexport type UnifiedOptions = UnifiedSharedOptions & {\n analytics?: BrowserOptions;\n sessionReplay?: Omit<SessionReplayOptions, keyof UnifiedSharedOptions>;\n experiment?: Omit<ExperimentPluginConfig, keyof UnifiedSharedOptions>;\n engagement?: Omit<InitOptions, keyof UnifiedSharedOptions>;\n};\n\nexport interface UnifiedClient extends BrowserClient {\n initAll(apiKey: string, unifiedOptions?: UnifiedOptions): Promise<void>;\n sessionReplay(): AmplitudeSessionReplay;\n experiment(): IExperimentClient | undefined;\n}\n\nexport class AmplitudeUnified extends AmplitudeBrowser implements UnifiedClient {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n private _sessionReplay: AmplitudeSessionReplay;\n\n sessionReplay(): AmplitudeSessionReplay {\n return this._sessionReplay;\n }\n\n experiment(): IExperimentClient | undefined {\n // Return when init() or initAll() is not called\n if (this.config === undefined) {\n return undefined;\n }\n\n const expPlugins = this.plugins(ExperimentPlugin);\n if (expPlugins.length === 0) {\n this.config.loggerProvider.debug(`${ExperimentPlugin.pluginName} plugin is not found.`);\n return undefined;\n } else if (expPlugins.length === 1) {\n return expPlugins[0].experiment;\n } else {\n this.config.loggerProvider.debug(`Multiple instances of ${ExperimentPlugin.pluginName} are found.`);\n return undefined;\n }\n }\n\n /**\n * Initialize SDKs with configuration options.\n *\n * @param apiKey Amplitude API key.\n * @param analyticsOptions Analytics configuration options. Refer to {@link https://amplitude.com/docs/sdks/analytics/browser/browser-sdk-2#configure-the-sdk here} for more info.\n * @param unifiedOptions Shared configuration for all SDKs and for blade SDKs.\n */\n async initAll(apiKey: string, unifiedOptions?: UnifiedOptions) {\n const sharedOptions = {\n serverZone: unifiedOptions?.serverZone,\n instanceName: unifiedOptions?.instanceName,\n };\n\n super.add(libraryPlugin());\n await super.init(apiKey, { ...unifiedOptions?.analytics, ...sharedOptions }).promise;\n\n await super.add(sessionReplayPlugin({ ...unifiedOptions?.sessionReplay, ...sharedOptions })).promise;\n\n await super.add(experimentPlugin({ ...unifiedOptions?.experiment, ...sharedOptions })).promise;\n\n const srPlugin = this.plugin(SessionReplayPlugin.pluginName);\n if (srPlugin === undefined) {\n this.config.loggerProvider.debug(`${SessionReplayPlugin.pluginName} plugin is not found.`);\n } else {\n this._sessionReplay = (srPlugin as SessionReplayPlugin).sessionReplay;\n }\n\n await super.add(\n EngagementPlugin({\n ...unifiedOptions?.engagement,\n ...sharedOptions,\n }),\n ).promise;\n }\n\n /**\n * Only analytics SDK is initialized. Use initAll() instead to initialize all blade SDKs.\n */\n /* istanbul ignore next */\n init(apiKey = '', userIdOrOptions?: string | BrowserOptions, maybeOptions?: BrowserOptions) {\n const res = super.init(apiKey, userIdOrOptions, maybeOptions);\n return res;\n }\n}\n"]}
1
+ {"version":3,"file":"unified.js","sourceRoot":"","sources":["../../src/unified.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAGL,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAGL,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAe,MAAM,IAAI,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAExF,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAoB1C;IAAsC,oCAAgB;IAAtD;;IAkFA,CAAC;IA5EC,wCAAa,GAAb;QACE,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAED,qCAAU,GAAV;QACE,gDAAgD;QAChD,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE;YAC7B,OAAO,SAAS,CAAC;SAClB;QAED,IAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;QAClD,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE;YAC3B,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,UAAG,gBAAgB,CAAC,UAAU,0BAAuB,CAAC,CAAC;YACxF,OAAO,SAAS,CAAC;SAClB;aAAM,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE;YAClC,OAAO,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC;SACjC;aAAM;YACL,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,gCAAyB,gBAAgB,CAAC,UAAU,gBAAa,CAAC,CAAC;YACpG,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AgB,uBACX,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,UAAU,GAC1B,aAAa,EAChB,CACH,CAAC,OAAO,EAAA;;gCALT,SAKS,CAAC;;;;qBACX,CAAC,EAAE,CAAC,OAAO,CAAC;oBACX,KAAI,CAAC,eAAe,GAAG,SAAS,CAAC;gBACnC,CAAC,CAAC,CAAC;gBAEH,sBAAO,IAAI,CAAC,eAAe,EAAC;;;KAC7B;IAED;;OAEG;IACH,0BAA0B;IAC1B,+BAAI,GAAJ,UAAK,MAAW,EAAE,eAAyC,EAAE,YAA6B;QAArF,uBAAA,EAAA,WAAW;QACd,IAAM,GAAG,GAAG,iBAAM,IAAI,YAAC,MAAM,EAAE,eAAe,EAAE,YAAY,CAAC,CAAC;QAC9D,OAAO,GAAG,CAAC;IACb,CAAC;IACH,uBAAC;AAAD,CAAC,AAlFD,CAAsC,gBAAgB,GAkFrD","sourcesContent":["import { AmplitudeBrowser } from '@amplitude/analytics-browser';\nimport {\n AmplitudeSessionReplay,\n SessionReplayOptions,\n sessionReplayPlugin,\n SessionReplayPlugin,\n} from '@amplitude/plugin-session-replay-browser';\nimport {\n IExperimentClient,\n ExperimentPluginConfig,\n ExperimentPlugin,\n experimentPlugin,\n} from '@amplitude/plugin-experiment-browser';\nimport { InitOptions, plugin as EngagementPlugin } from '@amplitude/engagement-browser';\nimport { BrowserClient, BrowserOptions } from '@amplitude/analytics-core';\nimport { libraryPlugin } from './library';\n\nexport interface UnifiedSharedOptions {\n serverZone?: 'US' | 'EU';\n instanceName?: string;\n}\n\nexport type UnifiedOptions = UnifiedSharedOptions & {\n analytics?: BrowserOptions;\n sessionReplay?: Omit<SessionReplayOptions, keyof UnifiedSharedOptions>;\n experiment?: Omit<ExperimentPluginConfig, keyof UnifiedSharedOptions>;\n engagement?: Omit<InitOptions, keyof UnifiedSharedOptions>;\n};\n\nexport interface UnifiedClient extends BrowserClient {\n initAll(apiKey: string, unifiedOptions?: UnifiedOptions): Promise<void>;\n sessionReplay(): AmplitudeSessionReplay;\n experiment(): IExperimentClient | undefined;\n}\n\nexport class AmplitudeUnified extends AmplitudeBrowser implements UnifiedClient {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n private _sessionReplay: AmplitudeSessionReplay;\n private _initAllPromise?: Promise<void>;\n\n sessionReplay(): AmplitudeSessionReplay {\n return this._sessionReplay;\n }\n\n experiment(): IExperimentClient | undefined {\n // Return when init() or initAll() is not called\n if (this.config === undefined) {\n return undefined;\n }\n\n const expPlugins = this.plugins(ExperimentPlugin);\n if (expPlugins.length === 0) {\n this.config.loggerProvider.debug(`${ExperimentPlugin.pluginName} plugin is not found.`);\n return undefined;\n } else if (expPlugins.length === 1) {\n return expPlugins[0].experiment;\n } else {\n this.config.loggerProvider.debug(`Multiple instances of ${ExperimentPlugin.pluginName} are found.`);\n return undefined;\n }\n }\n\n /**\n * Initialize SDKs with configuration options.\n *\n * @param apiKey Amplitude API key.\n * @param analyticsOptions Analytics configuration options. Refer to {@link https://amplitude.com/docs/sdks/analytics/browser/browser-sdk-2#configure-the-sdk here} for more info.\n * @param unifiedOptions Shared configuration for all SDKs and for blade SDKs.\n */\n async initAll(apiKey: string, unifiedOptions?: UnifiedOptions) {\n if (this._initAllPromise) {\n return this._initAllPromise;\n }\n\n this._initAllPromise = (async () => {\n const sharedOptions = {\n serverZone: unifiedOptions?.serverZone,\n instanceName: unifiedOptions?.instanceName,\n };\n\n super.add(libraryPlugin());\n\n await super.init(apiKey, { ...unifiedOptions?.analytics, ...sharedOptions }).promise;\n\n await super.add(sessionReplayPlugin({ ...unifiedOptions?.sessionReplay, ...sharedOptions })).promise;\n\n await super.add(experimentPlugin({ ...unifiedOptions?.experiment, ...sharedOptions })).promise;\n\n const srPlugin = this.plugin(SessionReplayPlugin.pluginName);\n if (srPlugin === undefined) {\n this.config.loggerProvider.debug(`${SessionReplayPlugin.pluginName} plugin is not found.`);\n } else {\n this._sessionReplay = (srPlugin as SessionReplayPlugin).sessionReplay;\n }\n\n await super.add(\n EngagementPlugin({\n ...unifiedOptions?.engagement,\n ...sharedOptions,\n }),\n ).promise;\n })().finally(() => {\n this._initAllPromise = undefined;\n });\n\n return this._initAllPromise;\n }\n\n /**\n * Only analytics SDK is initialized. Use initAll() instead to initialize all blade SDKs.\n */\n /* istanbul ignore next */\n init(apiKey = '', userIdOrOptions?: string | BrowserOptions, maybeOptions?: BrowserOptions) {\n const res = super.init(apiKey, userIdOrOptions, maybeOptions);\n return res;\n }\n}\n"]}
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "1.0.4";
1
+ export declare const VERSION = "1.0.5";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -1,3 +1,3 @@
1
1
  // Autogenerated by `pnpm version-file`. DO NOT EDIT
2
- export var VERSION = '1.0.4';
2
+ export var VERSION = '1.0.5';
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,OAAO,CAAC","sourcesContent":["// Autogenerated by `pnpm version-file`. DO NOT EDIT\nexport const VERSION = '1.0.4';\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,MAAM,CAAC,IAAM,OAAO,GAAG,OAAO,CAAC","sourcesContent":["// Autogenerated by `pnpm version-file`. DO NOT EDIT\nexport const VERSION = '1.0.5';\n"]}