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G,CAAA;KAAE;IAuD/F,OAAO,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC;IA+B5C,SAAS,CAAC,MAAM,EAAE,OAAO;IAQzB,UAAU,CAAC,MAAM,EAAE,OAAO;IAO1B,KAAK;IAIL,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAUxC,OAAO,CAAC,CAAC,SAAS,MAAM,EAAE,WAAW,EAAE;QAAE,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA;KAAE,GAAG,CAAC,EAAE;CAGzE"} |
@@ -31,5 +31,11 @@ "use strict"; | ||
| this.timeline.loggerProvider = this.config.loggerProvider; | ||
| return [4 /*yield*/, this.runQueuedFunctions('q')]; | ||
| case 1: | ||
| _a.label = 1; | ||
| case 1: return [4 /*yield*/, this.runQueuedFunctions('q')]; | ||
| case 2: | ||
| _a.sent(); | ||
| _a.label = 3; | ||
| case 3: | ||
| if (this.q.length > 0) return [3 /*break*/, 1]; | ||
| _a.label = 4; | ||
| case 4: | ||
| this.isReady = true; | ||
@@ -36,0 +42,0 @@ return [2 /*return*/]; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"core-client.js","sourceRoot":"","sources":["../../src/core-client.ts"],"names":[],"mappings":";;;;AAIA,6CAM6B;AAC7B,uCAAkE;AAElE,6CAA2E;AAC3E,uCAAsC;AACtC,uDAM+B;AAC/B,yDAAqD;AACrD,yDAAuD;AAEvD;IAmBE,uBAAY,IAAiB;QAAjB,qBAAA,EAAA,iBAAiB;QAlBnB,iBAAY,GAAG,KAAK,CAAC;QAQ/B,YAAO,GAAG,KAAK,CAAC;QACN,MAAC,GAAmD,EAAE,CAAC;QACvD,cAAS,GAA4B,EAAE,CAAC;QAgDlD,aAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAvC/B,IAAI,CAAC,QAAQ,GAAG,IAAI,mBAAQ,CAAC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C;IAC9C,CAAC;IAED,8BAAM,GAAN,UAAO,IAAY;QACjB,IAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,UAAC,MAAM,IAAK,OAAA,MAAM,CAAC,IAAI,KAAK,IAAI,EAApB,CAAoB,CAAC,CAAC;QAC5E,IAAI,MAAM,KAAK,SAAS,EAAE;YACxB,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,uCAAgC,IAAI,CAAE,CAAC,CAAC;YACzE,OAAO,SAAS,CAAC;SAClB;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,+BAAO,GAAP,UAA0B,WAAwC;QAChE,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,UAAC,MAAM,IAAK,OAAA,MAAM,YAAY,WAAW,EAA7B,CAA6B,CAAQ,CAAC;IACxF,CAAC;IACH,oBAAC;AAAD,CAAC,AA9QD,IA8QC;AA9QY,sCAAa","sourcesContent":["import { Plugin } from './types/plugin';\nimport { IConfig } from './types/config/core-config';\nimport { BaseEvent, EventOptions } from './types/event/base-event';\nimport { Result } from './types/result';\nimport {\n Event,\n IdentifyOperation,\n IdentifyUserProperties,\n SpecialEventType,\n UserProperties,\n} from './types/event/event';\nimport { IIdentify, OrderedIdentifyOperations } from './identify';\nimport { IRevenue } from './revenue';\nimport { CLIENT_NOT_INITIALIZED, OPT_OUT_MESSAGE } from './types/messages';\nimport { Timeline } from './timeline';\nimport {\n createGroupEvent,\n createGroupIdentifyEvent,\n createIdentifyEvent,\n createRevenueEvent,\n createTrackEvent,\n} from './utils/event-builder';\nimport { buildResult } from './utils/result-builder';\nimport { returnWrapper } from './utils/return-wrapper';\nimport { CoreClient, PluginHost } from './types/client/core-client';\nexport class AmplitudeCore implements CoreClient, PluginHost {\n protected initializing = false;\n protected name: string;\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n config: IConfig;\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n timeline: Timeline;\n isReady = false;\n protected q: Array<CallableFunction | typeof returnWrapper> = [];\n protected dispatchQ: Array<CallableFunction> = [];\n\n /**\n * Current user properties (operation-applied, flat key-value).\n * Only used by client-side SDKs; server SDKs may leave this undefined.\n */\n userProperties: { [key: string]: any } | undefined;\n\n constructor(name = '$default') {\n this.timeline = new Timeline(this);\n this.name = name;\n }\n\n protected async _init(config: IConfig) {\n this.config = config;\n this.timeline.reset(this);\n this.timeline.loggerProvider = this.config.loggerProvider;\n await this.runQueuedFunctions('q');\n this.isReady = true;\n }\n\n async runQueuedFunctions(queueName: 'q' | 'dispatchQ') {\n const queuedFunctions = this[queueName];\n this[queueName] = [];\n for (const queuedFunction of queuedFunctions) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const val: ReturnType<typeof returnWrapper> | Promise<any> = queuedFunction();\n if (val && 'promise' in val) {\n await val.promise;\n } else {\n await val;\n }\n }\n // Rerun queued functions if the queue has accrued more while awaiting promises\n if (this[queueName].length) {\n await this.runQueuedFunctions(queueName);\n }\n }\n\n track(eventInput: BaseEvent | string, eventProperties?: Record<string, any>, eventOptions?: EventOptions) {\n const event = createTrackEvent(eventInput, eventProperties, eventOptions);\n // Update client user properties immediately and synchronously\n this.userProperties = this.getOperationAppliedUserProperties(event.user_properties);\n return returnWrapper(this.dispatch(event));\n }\n\n logEvent = this.track.bind(this);\n\n identify(identify: IIdentify, eventOptions?: EventOptions) {\n const event = createIdentifyEvent(identify, eventOptions);\n // Update client user properties immediately and synchronously\n this.userProperties = this.getOperationAppliedUserProperties(event.user_properties);\n return returnWrapper(this.dispatch(event));\n }\n\n groupIdentify(groupType: string, groupName: string | string[], identify: IIdentify, eventOptions?: EventOptions) {\n const event = createGroupIdentifyEvent(groupType, groupName, identify, eventOptions);\n return returnWrapper(this.dispatch(event));\n }\n\n setGroup(groupType: string, groupName: string | string[], eventOptions?: EventOptions) {\n const event = createGroupEvent(groupType, groupName, eventOptions);\n // Update client user properties immediately and synchronously\n this.userProperties = this.getOperationAppliedUserProperties(event.user_properties);\n return returnWrapper(this.dispatch(event));\n }\n\n revenue(revenue: IRevenue, eventOptions?: EventOptions) {\n const event = createRevenueEvent(revenue, eventOptions);\n return returnWrapper(this.dispatch(event));\n }\n\n add(plugin: Plugin) {\n if (!this.isReady) {\n this.q.push(this._addPlugin.bind(this, plugin));\n return returnWrapper();\n }\n return this._addPlugin(plugin);\n }\n\n _addPlugin(plugin: Plugin) {\n return returnWrapper(this.timeline.register(plugin, this.config));\n }\n\n remove(pluginName: string) {\n if (!this.isReady) {\n this.q.push(this._removePlugin.bind(this, pluginName));\n return returnWrapper();\n }\n return this._removePlugin(pluginName);\n }\n\n _removePlugin(pluginName: string) {\n return returnWrapper(this.timeline.deregister(pluginName, this.config));\n }\n\n dispatchWithCallback(event: Event, callback: (result: Result) => void): void {\n if (!this.isReady) {\n return callback(buildResult(event, 0, CLIENT_NOT_INITIALIZED));\n }\n void this.process(event).then(callback);\n }\n\n async dispatch(event: Event): Promise<Result> {\n if (!this.isReady) {\n return new Promise<Result>((resolve) => {\n this.dispatchQ.push(this.dispatchWithCallback.bind(this, event, resolve));\n });\n }\n\n return this.process(event);\n }\n\n /**\n *\n * This method applies identify operations to user properties and\n * returns a single object representing the final user property state.\n *\n * This is a best-effort api that only supports $set, $clearAll, and $unset.\n * Other operations are not supported and are ignored.\n *\n * Operations are applied on top of current client state (this.userProperties).\n *\n * @param userProperties The new user properties object from identify() or setIdentity().\n * @returns A key-value object user properties without operations.\n *\n * @example\n * Input:\n * {\n * $set: { plan: 'premium' },\n * custom_flag: true\n * }\n *\n * Output:\n * {\n * plan: 'premium',\n * custom_flag: true\n * }\n */\n getOperationAppliedUserProperties(userProperties: UserProperties | undefined): { [key: string]: any } {\n const base = this.userProperties ?? {};\n const updatedProperties: { [key: string]: any } = { ...base };\n\n if (userProperties === undefined) {\n return updatedProperties;\n }\n\n // Keep non-operation keys for later merge\n const nonOpProperties: {\n [key in Exclude<string, IdentifyOperation>]: any;\n } = {};\n Object.keys(userProperties).forEach((key) => {\n if (!Object.values(IdentifyOperation).includes(key as IdentifyOperation)) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n nonOpProperties[key] = userProperties[key];\n }\n });\n\n OrderedIdentifyOperations.forEach((operation) => {\n // Skip when key is an operation.\n if (!Object.keys(userProperties).includes(operation)) return;\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const opProperties: IdentifyUserProperties = userProperties[operation];\n\n switch (operation) {\n case IdentifyOperation.CLEAR_ALL:\n // Due to operation order, the following line will never execute.\n /* istanbul ignore next */\n Object.keys(updatedProperties).forEach((prop) => {\n delete updatedProperties[prop];\n });\n break;\n case IdentifyOperation.UNSET:\n Object.keys(opProperties).forEach((prop) => {\n delete updatedProperties[prop];\n });\n break;\n case IdentifyOperation.SET:\n Object.assign(updatedProperties, opProperties);\n break;\n }\n });\n\n // Merge non-operation properties.\n // Custom properties should not be affected by operations.\n // https://github.com/amplitude/nova/blob/343f678ded83c032e83b189796b3c2be161b48f5/src/main/java/com/amplitude/userproperty/model/ModifyUserPropertiesIdent.java#L79-L83\n Object.assign(updatedProperties, nonOpProperties);\n\n return updatedProperties;\n }\n\n async process(event: Event): Promise<Result> {\n try {\n // skip event processing if opt out\n if (this.config.optOut) {\n return buildResult(event, 0, OPT_OUT_MESSAGE);\n }\n\n if (event.event_type === SpecialEventType.IDENTIFY) {\n // Do not update this.userProperties here.\n // It is only set synchronously in identify() or setIdentity()\n this.timeline.onIdentityChanged({ userProperties: this.userProperties });\n }\n\n const result = await this.timeline.push(event);\n\n result.code === 200\n ? this.config.loggerProvider.log(result.message)\n : result.code === 100\n ? this.config.loggerProvider.warn(result.message)\n : this.config.loggerProvider.error(result.message);\n\n return result;\n } catch (e) {\n const message = String(e);\n this.config.loggerProvider.error(message);\n const result = buildResult(event, 0, message);\n\n return result;\n }\n }\n\n setOptOut(optOut: boolean) {\n if (!this.isReady) {\n this.q.push(this._setOptOut.bind(this, Boolean(optOut)));\n return;\n }\n this._setOptOut(optOut);\n }\n\n _setOptOut(optOut: boolean) {\n if (this.config.optOut !== optOut) {\n this.config.optOut = Boolean(optOut);\n this.timeline.onOptOutChanged(optOut);\n }\n }\n\n flush() {\n return returnWrapper(this.timeline.flush());\n }\n\n plugin(name: string): Plugin | undefined {\n const plugin = this.timeline.plugins.find((plugin) => plugin.name === name);\n if (plugin === undefined) {\n this.config.loggerProvider.debug(`Cannot find plugin with name ${name}`);\n return undefined;\n }\n\n return plugin;\n }\n\n plugins<T extends Plugin>(pluginClass: { new (...args: any[]): T }): T[] {\n return this.timeline.plugins.filter((plugin) => plugin instanceof pluginClass) as T[];\n }\n}\n"]} | ||
| {"version":3,"file":"core-client.js","sourceRoot":"","sources":["../../src/core-client.ts"],"names":[],"mappings":";;;;AAIA,6CAM6B;AAC7B,uCAAkE;AAElE,6CAA2E;AAC3E,uCAAsC;AACtC,uDAM+B;AAC/B,yDAAqD;AACrD,yDAAuD;AAEvD;IAmBE,uBAAY,IAAiB;QAAjB,qBAAA,EAAA,iBAAiB;QAlBnB,iBAAY,GAAG,KAAK,CAAC;QAQ/B,YAAO,GAAG,KAAK,CAAC;QACN,MAAC,GAAmD,EAAE,CAAC;QACvD,cAAS,GAA4B,EAAE,CAAC;QAmDlD,aAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QA1C/B,IAAI,CAAC,QAAQ,GAAG,IAAI,mBAAQ,CAAC,IAAI,CAAC,CAAC;QACnC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAEe,6BAAK,GAArB,UAAsB,MAAe;;;;;wBACnC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;wBACrB,IAAI,CAAC,QAAQ,CAAC,K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IAAK,OAAA,MAAM,CAAC,IAAI,KAAK,IAAI,EAApB,CAAoB,CAAC,CAAC;QAC5E,IAAI,MAAM,KAAK,SAAS,EAAE;YACxB,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,uCAAgC,IAAI,CAAE,CAAC,CAAC;YACzE,OAAO,SAAS,CAAC;SAClB;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,+BAAO,GAAP,UAA0B,WAAwC;QAChE,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,UAAC,MAAM,IAAK,OAAA,MAAM,YAAY,WAAW,EAA7B,CAA6B,CAAQ,CAAC;IACxF,CAAC;IACH,oBAAC;AAAD,CAAC,AAjRD,IAiRC;AAjRY,sCAAa","sourcesContent":["import { Plugin } from './types/plugin';\nimport { IConfig } from './types/config/core-config';\nimport { BaseEvent, EventOptions } from './types/event/base-event';\nimport { Result } from './types/result';\nimport {\n Event,\n IdentifyOperation,\n IdentifyUserProperties,\n SpecialEventType,\n UserProperties,\n} from './types/event/event';\nimport { IIdentify, OrderedIdentifyOperations } from './identify';\nimport { IRevenue } from './revenue';\nimport { CLIENT_NOT_INITIALIZED, OPT_OUT_MESSAGE } from './types/messages';\nimport { Timeline } from './timeline';\nimport {\n createGroupEvent,\n createGroupIdentifyEvent,\n createIdentifyEvent,\n createRevenueEvent,\n createTrackEvent,\n} from './utils/event-builder';\nimport { buildResult } from './utils/result-builder';\nimport { returnWrapper } from './utils/return-wrapper';\nimport { CoreClient, PluginHost } from './types/client/core-client';\nexport class AmplitudeCore implements CoreClient, PluginHost {\n protected initializing = false;\n protected name: string;\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n config: IConfig;\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n timeline: Timeline;\n isReady = false;\n protected q: Array<CallableFunction | typeof returnWrapper> = [];\n protected dispatchQ: Array<CallableFunction> = [];\n\n /**\n * Current user properties (operation-applied, flat key-value).\n * Only used by client-side SDKs; server SDKs may leave this undefined.\n */\n userProperties: { [key: string]: any } | undefined;\n\n constructor(name = '$default') {\n this.timeline = new Timeline(this);\n this.name = name;\n }\n\n protected async _init(config: IConfig) {\n this.config = config;\n this.timeline.reset(this);\n this.timeline.loggerProvider = this.config.loggerProvider;\n do {\n await this.runQueuedFunctions('q');\n } while (this.q.length > 0);\n this.isReady = true;\n }\n\n async runQueuedFunctions(queueName: 'q' | 'dispatchQ') {\n const queuedFunctions = this[queueName];\n this[queueName] = [];\n for (const queuedFunction of queuedFunctions) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const val: ReturnType<typeof returnWrapper> | Promise<any> = queuedFunction();\n if (val && 'promise' in val) {\n await val.promise;\n } else {\n await val;\n }\n }\n\n // Rerun queued functions if the queue has accrued more while awaiting promises\n if (this[queueName].length) {\n await this.runQueuedFunctions(queueName);\n }\n }\n\n track(eventInput: BaseEvent | string, eventProperties?: Record<string, any>, eventOptions?: EventOptions) {\n const event = createTrackEvent(eventInput, eventProperties, eventOptions);\n // Update client user properties immediately and synchronously\n this.userProperties = this.getOperationAppliedUserProperties(event.user_properties);\n return returnWrapper(this.dispatch(event));\n }\n\n logEvent = this.track.bind(this);\n\n identify(identify: IIdentify, eventOptions?: EventOptions) {\n const event = createIdentifyEvent(identify, eventOptions);\n // Update client user properties immediately and synchronously\n this.userProperties = this.getOperationAppliedUserProperties(event.user_properties);\n return returnWrapper(this.dispatch(event));\n }\n\n groupIdentify(groupType: string, groupName: string | string[], identify: IIdentify, eventOptions?: EventOptions) {\n const event = createGroupIdentifyEvent(groupType, groupName, identify, eventOptions);\n return returnWrapper(this.dispatch(event));\n }\n\n setGroup(groupType: string, groupName: string | string[], eventOptions?: EventOptions) {\n const event = createGroupEvent(groupType, groupName, eventOptions);\n // Update client user properties immediately and synchronously\n this.userProperties = this.getOperationAppliedUserProperties(event.user_properties);\n return returnWrapper(this.dispatch(event));\n }\n\n revenue(revenue: IRevenue, eventOptions?: EventOptions) {\n const event = createRevenueEvent(revenue, eventOptions);\n return returnWrapper(this.dispatch(event));\n }\n\n add(plugin: Plugin) {\n if (!this.isReady) {\n this.q.push(this._addPlugin.bind(this, plugin));\n return returnWrapper();\n }\n return this._addPlugin(plugin);\n }\n\n _addPlugin(plugin: Plugin) {\n return returnWrapper(this.timeline.register(plugin, this.config));\n }\n\n remove(pluginName: string) {\n if (!this.isReady) {\n this.q.push(this._removePlugin.bind(this, pluginName));\n return returnWrapper();\n }\n return this._removePlugin(pluginName);\n }\n\n _removePlugin(pluginName: string) {\n return returnWrapper(this.timeline.deregister(pluginName, this.config));\n }\n\n dispatchWithCallback(event: Event, callback: (result: Result) => void): void {\n if (!this.isReady) {\n return callback(buildResult(event, 0, CLIENT_NOT_INITIALIZED));\n }\n void this.process(event).then(callback);\n }\n\n async dispatch(event: Event): Promise<Result> {\n if (!this.isReady) {\n return new Promise<Result>((resolve) => {\n this.dispatchQ.push(this.dispatchWithCallback.bind(this, event, resolve));\n });\n }\n\n return this.process(event);\n }\n\n /**\n *\n * This method applies identify operations to user properties and\n * returns a single object representing the final user property state.\n *\n * This is a best-effort api that only supports $set, $clearAll, and $unset.\n * Other operations are not supported and are ignored.\n *\n * Operations are applied on top of current client state (this.userProperties).\n *\n * @param userProperties The new user properties object from identify() or setIdentity().\n * @returns A key-value object user properties without operations.\n *\n * @example\n * Input:\n * {\n * $set: { plan: 'premium' },\n * custom_flag: true\n * }\n *\n * Output:\n * {\n * plan: 'premium',\n * custom_flag: true\n * }\n */\n getOperationAppliedUserProperties(userProperties: UserProperties | undefined): { [key: string]: any } {\n const base = this.userProperties ?? {};\n const updatedProperties: { [key: string]: any } = { ...base };\n\n if (userProperties === undefined) {\n return updatedProperties;\n }\n\n // Keep non-operation keys for later merge\n const nonOpProperties: {\n [key in Exclude<string, IdentifyOperation>]: any;\n } = {};\n Object.keys(userProperties).forEach((key) => {\n if (!Object.values(IdentifyOperation).includes(key as IdentifyOperation)) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n nonOpProperties[key] = userProperties[key];\n }\n });\n\n OrderedIdentifyOperations.forEach((operation) => {\n // Skip when key is an operation.\n if (!Object.keys(userProperties).includes(operation)) return;\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const opProperties: IdentifyUserProperties = userProperties[operation];\n\n switch (operation) {\n case IdentifyOperation.CLEAR_ALL:\n // Due to operation order, the following line will never execute.\n /* istanbul ignore next */\n Object.keys(updatedProperties).forEach((prop) => {\n delete updatedProperties[prop];\n });\n break;\n case IdentifyOperation.UNSET:\n Object.keys(opProperties).forEach((prop) => {\n delete updatedProperties[prop];\n });\n break;\n case IdentifyOperation.SET:\n Object.assign(updatedProperties, opProperties);\n break;\n }\n });\n\n // Merge non-operation properties.\n // Custom properties should not be affected by operations.\n // https://github.com/amplitude/nova/blob/343f678ded83c032e83b189796b3c2be161b48f5/src/main/java/com/amplitude/userproperty/model/ModifyUserPropertiesIdent.java#L79-L83\n Object.assign(updatedProperties, nonOpProperties);\n\n return updatedProperties;\n }\n\n async process(event: Event): Promise<Result> {\n try {\n // skip event processing if opt out\n if (this.config.optOut) {\n return buildResult(event, 0, OPT_OUT_MESSAGE);\n }\n\n if (event.event_type === SpecialEventType.IDENTIFY) {\n // Do not update this.userProperties here.\n // It is only set synchronously in identify() or setIdentity()\n this.timeline.onIdentityChanged({ userProperties: this.userProperties });\n }\n\n const result = await this.timeline.push(event);\n\n result.code === 200\n ? this.config.loggerProvider.log(result.message)\n : result.code === 100\n ? this.config.loggerProvider.warn(result.message)\n : this.config.loggerProvider.error(result.message);\n\n return result;\n } catch (e) {\n const message = String(e);\n this.config.loggerProvider.error(message);\n const result = buildResult(event, 0, message);\n\n return result;\n }\n }\n\n setOptOut(optOut: boolean) {\n if (!this.isReady) {\n this.q.push(this._setOptOut.bind(this, Boolean(optOut)));\n return;\n }\n this._setOptOut(optOut);\n }\n\n _setOptOut(optOut: boolean) {\n if (this.config.optOut !== optOut) {\n this.config.optOut = Boolean(optOut);\n this.timeline.onOptOutChanged(optOut);\n }\n }\n\n flush() {\n return returnWrapper(this.timeline.flush());\n }\n\n plugin(name: string): Plugin | undefined {\n const plugin = this.timeline.plugins.find((plugin) => plugin.name === name);\n if (plugin === undefined) {\n this.config.loggerProvider.debug(`Cannot find plugin with name ${name}`);\n return undefined;\n }\n\n return plugin;\n }\n\n plugins<T extends Plugin>(pluginClass: { new (...args: any[]): T }): T[] {\n return this.timeline.plugins.filter((plugin) => plugin instanceof pluginClass) as T[];\n }\n}\n"]} |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"diagnostics-storage.d.ts","sourceRoot":"","sources":["../../../src/diagnostics/diagnostics-storage.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAQtD,eAAO,MAAM,WAAW;;;;;;CAMd,CAAC;AAGX,eAAO,MAAM,aAAa;;CAEhB,CAAC;AAGX,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,WAAW;IAC1B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB,EA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AAC;QAC1B,cAAc,EAAE,eAAe,EAAE,CAAC;QAClC,MAAM,EAAE,WAAW,EAAE,CAAC;KACvB,CAAC;IA8BF;;OAEG;IAEH,OAAO,CAAC,eAAe;CASxB"} |
@@ -71,4 +71,8 @@ "use strict"; | ||
| }; | ||
| request.onupgradeneeded = function (event) { | ||
| var db = event.target.result; | ||
| request.onupgradeneeded = function () { | ||
| var db = request.result; | ||
| if (!db) { | ||
| _this.logger.debug('DiagnosticsStorage: Missing DB during upgrade.'); | ||
| return; | ||
| } | ||
| _this.createTables(db); | ||
@@ -75,0 +79,0 @@ }; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"diagnostics-storage.js","sourceRoot":"","sources":["../../../src/diagnostics/diagnostics-storage.ts"],"names":[],"mappings":";;;;AAAA,gDAAiD;AAIjD,IAAM,mCAAmC,GAAG,EAAE,CAAC;AAE/C,yBAAyB;AACzB,IAAM,UAAU,GAAG,CAAC,CAAC;AAErB,8CAA8C;AACjC,QAAA,WAAW,GAAG;IACzB,IAAI,EAAE,MAAM;IACZ,QAAQ,EAAE,UAAU;IACpB,UAAU,EAAE,YAAY;IACxB,MAAM,EAAE,QAAQ;IAChB,QAAQ,EAAE,UAAU,EAAE,uDAAuD;CACrE,CAAC;AAEX,kCAAkC;AACrB,QAAA,aAAa,GAAG;IAC3B,oBAAoB,EAAE,sBAAsB;CACpC,CAAC;AA4EX;;;GAGG;AACH;IAKE,4BAAY,MAAc,EAAE,MAAe;QAJ3C,cAAS,GAAgC,IAAI,CAAC;QAK5C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,0BAAmB,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CAAE,CAAC;IAC7D,CAAC;IAED;;;OAGG;IACI,8BAAW,GAAlB;;QACE,OAAO,CAAA,MAAA,IAAA,6BAAc,GAAE,0CAAE,SAAS,MAAK,SAAS,CAAC;IACnD,CAAC;IAEK,kCAAK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,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,cAAc,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAC;;;;;KAErE;IAED;;OAEG;IACH,0BAA0B;IAClB,4CAAe,GAAvB,UAA2B,WAA2B,EAAE,SAAiB;QACvE,OAAO,IAAI,OAAO,CAAC,UAAC,OAAO,EAAE,MAAM;YACjC,IAAM,KAAK,GAAG,WAAW,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;YACjD,IAAM,OAAO,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;YAE/B,OAAO,CAAC,SAAS,GAAG,cAAM,OAAA,OAAO,CAAC,OAAO,CAAC,MAAa,CAAC,EAA9B,CAA8B,CAAC;YACzD,OAAO,CAAC,OAAO,GAAG,cAAM,OAAA,MAAM,CAAC,IAAI,KAAK,CAAC,iCAA0B,SAAS,CAAE,CAAC,CAAC,EAAxD,CAAwD,CAAC;QACnF,CAAC,CAAC,CAAC;IACL,CAAC;IACH,yBAAC;AAAD,CAAC,AA1aD,IA0aC;AA1aY,gDAAkB","sourcesContent":["import { getGlobalScope } from '../global-scope';\nimport { ILogger } from '../logger';\nimport { HistogramStats } from './diagnostics-client';\n\nconst MAX_PERSISTENT_STORAGE_EVENTS_COUNT = 10;\n\n// Database configuration\nconst DB_VERSION = 1;\n\n// Table names for different diagnostics types\nexport const TABLE_NAMES = {\n TAGS: 'tags',\n COUNTERS: 'counters',\n HISTOGRAMS: 'histograms',\n EVENTS: 'events',\n INTERNAL: 'internal', // New table for internal storage like flush timestamps\n} as const;\n\n// Keys for internal storage table\nexport const INTERNAL_KEYS = {\n LAST_FLUSH_TIMESTAMP: 'last_flush_timestamp',\n} as const;\n\n// Record interfaces for each table\nexport interface TagRecord {\n key: string;\n value: string;\n}\n\nexport interface CounterRecord {\n key: string;\n value: number;\n}\n\nexport interface HistogramRecord {\n key: string;\n count: number;\n min: number;\n max: number;\n sum: number;\n}\n\nexport interface EventRecord {\n id?: number; // Auto-increment primary key\n event_name: string;\n time: number;\n event_properties: Record<string, any>;\n}\n\nexport interface InternalRecord {\n key: string;\n value: string;\n}\n\nexport interface IDiagnosticsStorage {\n /**\n * Set multiple tags in a single transaction (batch operation)\n * Promise never rejects - errors are logged and operation continues gracefully\n */\n setTags(tags: Record<string, string>): Promise<void>;\n /**\n * Increment multiple counters in a single transaction (batch operation)\n * Uses read-modify-write pattern to accumulate with existing values\n * Promise never rejects - errors are logged and operation continues gracefully\n */\n incrementCounters(counters: Record<string, number>): Promise<void>;\n /**\n * Set multiple histogram stats in a single transaction (batch operation)\n * Uses read-modify-write pattern to accumulate count/sum and update min/max with existing values\n * Promise never rejects - errors are logged and operation continues gracefully\n */\n setHistogramStats(\n histogramStats: Record<string, { count: number; min: number; max: number; sum: number }>,\n ): Promise<void>;\n /**\n * Add multiple event records in a single transaction (batch operation)\n * Promise never rejects - errors are logged and operation continues gracefully\n */\n addEventRecords(\n events: Array<{ event_name: string; time: number; event_properties: Record<string, any> }>,\n ): Promise<void>;\n\n setLastFlushTimestamp(timestamp: number): Promise<void>;\n\n getLastFlushTimestamp(): Promise<number | undefined>;\n\n /**\n * Get all data except internal data from storage and clear it\n */\n getAllAndClear(): Promise<{\n tags: TagRecord[];\n counters: CounterRecord[];\n histogramStats: HistogramRecord[];\n events: EventRecord[];\n }>;\n}\n\n/**\n * Purpose-specific IndexedDB storage for diagnostics data\n * Provides optimized methods for each type of diagnostics data\n */\nexport class DiagnosticsStorage implements IDiagnosticsStorage {\n dbPromise: Promise<IDBDatabase> | null = null;\n dbName: string;\n logger: ILogger;\n\n constructor(apiKey: string, logger: ILogger) {\n this.logger = logger;\n this.dbName = `AMP_diagnostics_${apiKey.substring(0, 10)}`;\n }\n\n /**\n * Check if IndexedDB is supported in the current environment\n * @returns true if IndexedDB is available, false otherwise\n */\n static isSupported(): boolean {\n return getGlobalScope()?.indexedDB !== undefined;\n }\n\n async getDB(): Promise<IDBDatabase> {\n if (!this.dbPromise) {\n this.dbPromise = this.openDB();\n }\n return this.dbPromise;\n }\n\n openDB(): Promise<IDBDatabase> {\n return new Promise((resolve, reject) => {\n const request = indexedDB.open(this.dbName, DB_VERSION);\n\n request.onerror = () => {\n // Clear dbPromise when it rejects for the first time\n this.dbPromise = null;\n reject(new Error('Failed to open IndexedDB'));\n };\n\n request.onsuccess = () => {\n const db = request.result;\n // Clear dbPromise when connection was on but went off later\n db.onclose = () => {\n this.dbPromise = null;\n this.logger.debug('DiagnosticsStorage: DB connection closed.');\n };\n\n db.onerror = (event) => {\n this.logger.debug('DiagnosticsStorage: A global database error occurred.', event);\n db.close();\n };\n resolve(db);\n };\n\n request.onupgradeneeded = (event) => {\n const db = (event.target as IDBOpenDBRequest).result;\n this.createTables(db);\n };\n });\n }\n\n createTables(db: IDBDatabase): void {\n // Create tags table\n if (!db.objectStoreNames.contains(TABLE_NAMES.TAGS)) {\n db.createObjectStore(TABLE_NAMES.TAGS, { keyPath: 'key' });\n }\n\n // Create counters table\n if (!db.objectStoreNames.contains(TABLE_NAMES.COUNTERS)) {\n db.createObjectStore(TABLE_NAMES.COUNTERS, { keyPath: 'key' });\n }\n\n // Create histograms table for storing histogram stats (count, min, max, sum)\n if (!db.objectStoreNames.contains(TABLE_NAMES.HISTOGRAMS)) {\n db.createObjectStore(TABLE_NAMES.HISTOGRAMS, {\n keyPath: 'key',\n });\n }\n\n // Create events table\n if (!db.objectStoreNames.contains(TABLE_NAMES.EVENTS)) {\n const eventsStore = db.createObjectStore(TABLE_NAMES.EVENTS, {\n keyPath: 'id',\n autoIncrement: true,\n });\n\n // Create index on time for chronological queries\n eventsStore.createIndex('time_idx', 'time', { unique: false });\n }\n\n // Create internal table for storing internal data like flush timestamps\n if (!db.objectStoreNames.contains(TABLE_NAMES.INTERNAL)) {\n db.createObjectStore(TABLE_NAMES.INTERNAL, { keyPath: 'key' });\n }\n }\n\n async setTags(tags: Record<string, string>): Promise<void> {\n try {\n if (Object.entries(tags).length === 0) {\n return;\n }\n\n const db = await this.getDB();\n const transaction = db.transaction([TABLE_NAMES.TAGS], 'readwrite');\n const store = transaction.objectStore(TABLE_NAMES.TAGS);\n\n return new Promise((resolve) => {\n const entries = Object.entries(tags);\n\n transaction.oncomplete = () => {\n resolve();\n };\n\n transaction.onabort = (event) => {\n this.logger.debug('DiagnosticsStorage: Failed to set tags', event);\n resolve();\n };\n\n entries.forEach(([key, value]) => {\n const putRequest = store.put({ key, value });\n\n putRequest.onerror = (event) => {\n this.logger.debug('DiagnosticsStorage: Failed to set tag', key, value, event);\n };\n });\n });\n } catch (error) {\n this.logger.debug('DiagnosticsStorage: Failed to set tags', error);\n }\n }\n\n async incrementCounters(counters: Record<string, number>): Promise<void> {\n try {\n if (Object.entries(counters).length === 0) {\n return;\n }\n\n const db = await this.getDB();\n const transaction = db.transaction([TABLE_NAMES.COUNTERS], 'readwrite');\n const store = transaction.objectStore(TABLE_NAMES.COUNTERS);\n\n return new Promise((resolve) => {\n const entries = Object.entries(counters);\n\n transaction.oncomplete = () => {\n resolve();\n };\n\n transaction.onabort = (event) => {\n this.logger.debug('DiagnosticsStorage: Failed to increment counters', event);\n resolve();\n };\n\n // Read existing values and update them\n entries.forEach(([key, incrementValue]) => {\n const getRequest = store.get(key);\n\n getRequest.onsuccess = () => {\n const existingRecord = getRequest.result as CounterRecord | undefined;\n /* istanbul ignore next */\n const existingValue = existingRecord ? existingRecord.value : 0;\n const putRequest = store.put({ key, value: existingValue + incrementValue });\n\n putRequest.onerror = (event) => {\n this.logger.debug('DiagnosticsStorage: Failed to update counter', key, event);\n };\n };\n\n getRequest.onerror = (event) => {\n this.logger.debug('DiagnosticsStorage: Failed to read existing counter', key, event);\n };\n });\n });\n } catch (error) {\n this.logger.debug('DiagnosticsStorage: Failed to increment counters', error);\n }\n }\n\n async setHistogramStats(histogramStats: Record<string, HistogramStats>): Promise<void> {\n try {\n if (Object.entries(histogramStats).length === 0) {\n return;\n }\n\n const db = await this.getDB();\n const transaction = db.transaction([TABLE_NAMES.HISTOGRAMS], 'readwrite');\n const store = transaction.objectStore(TABLE_NAMES.HISTOGRAMS);\n\n return new Promise((resolve) => {\n const entries = Object.entries(histogramStats);\n\n transaction.oncomplete = () => {\n resolve();\n };\n\n transaction.onabort = (event) => {\n this.logger.debug('DiagnosticsStorage: Failed to set histogram stats', event);\n resolve();\n };\n\n // Read existing values and update them\n entries.forEach(([key, newStats]) => {\n const getRequest = store.get(key);\n\n getRequest.onsuccess = () => {\n const existingRecord = getRequest.result as HistogramRecord | undefined;\n let updatedStats: HistogramRecord;\n\n /* istanbul ignore next */\n if (existingRecord) {\n // Accumulate with existing stats\n updatedStats = {\n key,\n count: existingRecord.count + newStats.count,\n min: Math.min(existingRecord.min, newStats.min),\n max: Math.max(existingRecord.max, newStats.max),\n sum: existingRecord.sum + newStats.sum,\n };\n } else {\n // Create new stats\n updatedStats = {\n key,\n count: newStats.count,\n min: newStats.min,\n max: newStats.max,\n sum: newStats.sum,\n };\n }\n\n const putRequest = store.put(updatedStats);\n\n putRequest.onerror = (event) => {\n this.logger.debug('DiagnosticsStorage: Failed to set histogram stats', key, event);\n };\n };\n\n getRequest.onerror = (event) => {\n this.logger.debug('DiagnosticsStorage: Failed to read existing histogram stats', key, event);\n };\n });\n });\n } catch (error) {\n this.logger.debug('DiagnosticsStorage: Failed to set histogram stats', error);\n }\n }\n\n async addEventRecords(\n events: Array<{ event_name: string; time: number; event_properties: Record<string, any> }>,\n ): Promise<void> {\n try {\n if (events.length === 0) {\n return;\n }\n\n const db = await this.getDB();\n const transaction = db.transaction([TABLE_NAMES.EVENTS], 'readwrite');\n const store = transaction.objectStore(TABLE_NAMES.EVENTS);\n\n return new Promise((resolve) => {\n transaction.oncomplete = () => {\n resolve();\n };\n\n /* istanbul ignore next */\n transaction.onabort = (event) => {\n this.logger.debug('DiagnosticsStorage: Failed to add event records', event);\n resolve();\n };\n\n // First, check how many events are currently stored\n const countRequest = store.count();\n\n countRequest.onsuccess = () => {\n const currentCount = countRequest.result;\n\n // Calculate how many events we can add\n const availableSlots = Math.max(0, MAX_PERSISTENT_STORAGE_EVENTS_COUNT - currentCount);\n\n if (availableSlots < events.length) {\n this.logger.debug(\n `DiagnosticsStorage: Only added ${availableSlots} of ${events.length} events due to storage limit`,\n );\n }\n\n // Only add events up to the available slots (take the least recent ones)\n events.slice(0, availableSlots).forEach((event) => {\n const request = store.add(event);\n\n request.onerror = (event) => {\n this.logger.debug('DiagnosticsStorage: Failed to add event record', event);\n };\n });\n };\n\n countRequest.onerror = (event) => {\n this.logger.debug('DiagnosticsStorage: Failed to count existing events', event);\n };\n });\n } catch (error) {\n this.logger.debug('DiagnosticsStorage: Failed to add event records', error);\n }\n }\n\n async setInternal(key: string, value: string): Promise<void> {\n try {\n const db = await this.getDB();\n const transaction = db.transaction([TABLE_NAMES.INTERNAL], 'readwrite');\n const store = transaction.objectStore(TABLE_NAMES.INTERNAL);\n\n return new Promise((resolve, reject) => {\n /* istanbul ignore next */\n transaction.onabort = () => reject(new Error('Failed to set internal value'));\n\n const request = store.put({ key, value });\n\n request.onsuccess = () => resolve();\n\n /* istanbul ignore next */\n request.onerror = () => reject(new Error('Failed to set internal value'));\n });\n } catch (error) {\n /* istanbul ignore next */\n this.logger.debug('DiagnosticsStorage: Failed to set internal value', error);\n }\n }\n\n async getInternal(key: string): Promise<InternalRecord | undefined> {\n try {\n const db = await this.getDB();\n const transaction = db.transaction([TABLE_NAMES.INTERNAL], 'readonly');\n const store = transaction.objectStore(TABLE_NAMES.INTERNAL);\n\n return new Promise((resolve, reject) => {\n /* istanbul ignore next */\n transaction.onabort = () => reject(new Error('Failed to get internal value'));\n\n const request = store.get(key);\n\n request.onsuccess = () => resolve(request.result as InternalRecord | undefined);\n\n /* istanbul ignore next */\n request.onerror = () => reject(new Error('Failed to get internal value'));\n });\n } catch (error) {\n this.logger.debug('DiagnosticsStorage: Failed to get internal value', error);\n return undefined;\n }\n }\n\n async getLastFlushTimestamp(): Promise<number | undefined> {\n try {\n const record = await this.getInternal(INTERNAL_KEYS.LAST_FLUSH_TIMESTAMP);\n return record ? parseInt(record.value, 10) : undefined;\n } catch (error) {\n /* istanbul ignore next */\n this.logger.debug('DiagnosticsStorage: Failed to get last flush timestamp', error);\n /* istanbul ignore next */\n return undefined;\n }\n }\n\n async setLastFlushTimestamp(timestamp: number): Promise<void> {\n try {\n await this.setInternal(INTERNAL_KEYS.LAST_FLUSH_TIMESTAMP, timestamp.toString());\n } catch (error) {\n /* istanbul ignore next */\n this.logger.debug('DiagnosticsStorage: Failed to set last flush timestamp', error);\n }\n }\n\n /* istanbul ignore next */\n clearTable(transaction: IDBTransaction, tableName: string): Promise<void> {\n return new Promise((resolve, reject) => {\n const store = transaction.objectStore(tableName);\n const request = store.clear();\n\n request.onsuccess = () => resolve();\n request.onerror = () => reject(new Error(`Failed to clear table ${tableName}`));\n });\n }\n\n /* istanbul ignore next */\n async getAllAndClear(): Promise<{\n tags: TagRecord[];\n counters: CounterRecord[];\n histogramStats: HistogramRecord[];\n events: EventRecord[];\n }> {\n try {\n const db = await this.getDB();\n const transaction = db.transaction(\n [TABLE_NAMES.TAGS, TABLE_NAMES.COUNTERS, TABLE_NAMES.HISTOGRAMS, TABLE_NAMES.EVENTS],\n 'readwrite',\n );\n\n // Get all data first\n const [tags, counters, histogramStats, events] = await Promise.all([\n this.getAllFromStore<TagRecord>(transaction, TABLE_NAMES.TAGS),\n this.getAllFromStore<CounterRecord>(transaction, TABLE_NAMES.COUNTERS),\n this.getAllFromStore<HistogramRecord>(transaction, TABLE_NAMES.HISTOGRAMS),\n this.getAllFromStore<EventRecord>(transaction, TABLE_NAMES.EVENTS),\n ]);\n\n // Clear all data in the same transaction\n await Promise.all([\n this.clearTable(transaction, TABLE_NAMES.COUNTERS),\n this.clearTable(transaction, TABLE_NAMES.HISTOGRAMS),\n this.clearTable(transaction, TABLE_NAMES.EVENTS),\n ]);\n\n return { tags, counters, histogramStats, events };\n } catch (error) {\n this.logger.debug('DiagnosticsStorage: Failed to get all and clear data', error);\n return { tags: [], counters: [], histogramStats: [], events: [] };\n }\n }\n\n /**\n * Helper method to get all records from a store within a transaction\n */\n /* istanbul ignore next */\n private getAllFromStore<T>(transaction: IDBTransaction, tableName: string): Promise<T[]> {\n return new Promise((resolve, reject) => {\n const store = transaction.objectStore(tableName);\n const request = store.getAll();\n\n request.onsuccess = () => resolve(request.result as T[]);\n request.onerror = () => reject(new Error(`Failed to get all from ${tableName}`));\n });\n }\n}\n"]} | ||
| {"version":3,"file":"diagnostics-storage.js","sourceRoot":"","sources":["../../../src/diagnostics/diagnostics-storage.ts"],"names":[],"mappings":";;;;AAAA,gDAAiD;AAIjD,IAAM,mCAAmC,GAAG,EAAE,CAAC;AAE/C,yBAAyB;AACzB,IAAM,UAAU,GAAG,CAAC,CAAC;AAErB,8CAA8C;AACjC,QAAA,WAAW,GAAG;IACzB,IAAI,EAAE,MAAM;IACZ,QAAQ,EAAE,UAAU;IACpB,UAAU,EAAE,YAAY;IACxB,MAAM,EAAE,QAAQ;IAChB,QAAQ,EAAE,UAAU,EAAE,uDAAuD;CACrE,CAAC;AAEX,kCAAkC;AACrB,QAAA,aAAa,GAAG;IAC3B,oBAAoB,EAAE,sBAAsB;CACpC,CAAC;AA4EX;;;GAGG;AACH;IAKE,4BAAY,MAAc,EAAE,MAAe;QAJ3C,cAAS,GAAgC,IAAI,CAAC;QAK5C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,0BAAmB,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CAAE,CAAC;IAC7D,CAAC;IAED;;;OAGG;IACI,8BAAW,GAAlB;;QACE,OAAO,CAAA,MAAA,IAAA,6BAAc,GAAE,0CAAE,SAAS,MAAK,SAAS,CAAC;IACnD,CAAC;IAEK,kCAAK,GAAX;;;gBACE,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;oBACnB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC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QAAQ,EAAE,EAAE,EAAE,cAAc,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAC;;;;;KAErE;IAED;;OAEG;IACH,0BAA0B;IAClB,4CAAe,GAAvB,UAA2B,WAA2B,EAAE,SAAiB;QACvE,OAAO,IAAI,OAAO,CAAC,UAAC,OAAO,EAAE,MAAM;YACjC,IAAM,KAAK,GAAG,WAAW,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;YACjD,IAAM,OAAO,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;YAE/B,OAAO,CAAC,SAAS,GAAG,cAAM,OAAA,OAAO,CAAC,OAAO,CAAC,MAAa,CAAC,EAA9B,CAA8B,CAAC;YACzD,OAAO,CAAC,OAAO,GAAG,cAAM,OAAA,MAAM,CAAC,IAAI,KAAK,CAAC,iCAA0B,SAAS,CAAE,CAAC,CAAC,EAAxD,CAAwD,CAAC;QACnF,CAAC,CAAC,CAAC;IACL,CAAC;IACH,yBAAC;AAAD,CAAC,AA9aD,IA8aC;AA9aY,gDAAkB","sourcesContent":["import { getGlobalScope } from '../global-scope';\nimport { ILogger } from '../logger';\nimport { HistogramStats } from './diagnostics-client';\n\nconst MAX_PERSISTENT_STORAGE_EVENTS_COUNT = 10;\n\n// Database configuration\nconst DB_VERSION = 1;\n\n// Table names for different diagnostics types\nexport const TABLE_NAMES = {\n TAGS: 'tags',\n COUNTERS: 'counters',\n HISTOGRAMS: 'histograms',\n EVENTS: 'events',\n INTERNAL: 'internal', // New table for internal storage like flush timestamps\n} as const;\n\n// Keys for internal storage table\nexport const INTERNAL_KEYS = {\n LAST_FLUSH_TIMESTAMP: 'last_flush_timestamp',\n} as const;\n\n// Record interfaces for each table\nexport interface TagRecord {\n key: string;\n value: string;\n}\n\nexport interface CounterRecord {\n key: string;\n value: number;\n}\n\nexport interface HistogramRecord {\n key: string;\n count: number;\n min: number;\n max: number;\n sum: number;\n}\n\nexport interface EventRecord {\n id?: number; // Auto-increment primary key\n event_name: string;\n time: number;\n event_properties: Record<string, any>;\n}\n\nexport interface InternalRecord {\n key: string;\n value: string;\n}\n\nexport interface IDiagnosticsStorage {\n /**\n * Set multiple tags in a single transaction (batch operation)\n * Promise never rejects - errors are logged and operation continues gracefully\n */\n setTags(tags: Record<string, string>): Promise<void>;\n /**\n * Increment multiple counters in a single transaction (batch operation)\n * Uses read-modify-write pattern to accumulate with existing values\n * Promise never rejects - errors are logged and operation continues gracefully\n */\n incrementCounters(counters: Record<string, number>): Promise<void>;\n /**\n * Set multiple histogram stats in a single transaction (batch operation)\n * Uses read-modify-write pattern to accumulate count/sum and update min/max with existing values\n * Promise never rejects - errors are logged and operation continues gracefully\n */\n setHistogramStats(\n histogramStats: Record<string, { count: number; min: number; max: number; sum: number }>,\n ): Promise<void>;\n /**\n * Add multiple event records in a single transaction (batch operation)\n * Promise never rejects - errors are logged and operation continues gracefully\n */\n addEventRecords(\n events: Array<{ event_name: string; time: number; event_properties: Record<string, any> }>,\n ): Promise<void>;\n\n setLastFlushTimestamp(timestamp: number): Promise<void>;\n\n getLastFlushTimestamp(): Promise<number | undefined>;\n\n /**\n * Get all data except internal data from storage and clear it\n */\n getAllAndClear(): Promise<{\n tags: TagRecord[];\n counters: CounterRecord[];\n histogramStats: HistogramRecord[];\n events: EventRecord[];\n }>;\n}\n\n/**\n * Purpose-specific IndexedDB storage for diagnostics data\n * Provides optimized methods for each type of diagnostics data\n */\nexport class DiagnosticsStorage implements IDiagnosticsStorage {\n dbPromise: Promise<IDBDatabase> | null = null;\n dbName: string;\n logger: ILogger;\n\n constructor(apiKey: string, logger: ILogger) {\n this.logger = logger;\n this.dbName = `AMP_diagnostics_${apiKey.substring(0, 10)}`;\n }\n\n /**\n * Check if IndexedDB is supported in the current environment\n * @returns true if IndexedDB is available, false otherwise\n */\n static isSupported(): boolean {\n return getGlobalScope()?.indexedDB !== undefined;\n }\n\n async getDB(): Promise<IDBDatabase> {\n if (!this.dbPromise) {\n this.dbPromise = this.openDB();\n }\n return this.dbPromise;\n }\n\n openDB(): Promise<IDBDatabase> {\n return new Promise((resolve, reject) => {\n const request = indexedDB.open(this.dbName, DB_VERSION);\n\n request.onerror = () => {\n // Clear dbPromise when it rejects for the first time\n this.dbPromise = null;\n reject(new Error('Failed to open IndexedDB'));\n };\n\n request.onsuccess = () => {\n const db = request.result;\n // Clear dbPromise when connection was on but went off later\n db.onclose = () => {\n this.dbPromise = null;\n this.logger.debug('DiagnosticsStorage: DB connection closed.');\n };\n\n db.onerror = (event) => {\n this.logger.debug('DiagnosticsStorage: A global database error occurred.', event);\n db.close();\n };\n resolve(db);\n };\n\n request.onupgradeneeded = () => {\n const db = request.result;\n if (!db) {\n this.logger.debug('DiagnosticsStorage: Missing DB during upgrade.');\n return;\n }\n this.createTables(db);\n };\n });\n }\n\n createTables(db: IDBDatabase): void {\n // Create tags table\n if (!db.objectStoreNames.contains(TABLE_NAMES.TAGS)) {\n db.createObjectStore(TABLE_NAMES.TAGS, { keyPath: 'key' });\n }\n\n // Create counters table\n if (!db.objectStoreNames.contains(TABLE_NAMES.COUNTERS)) {\n db.createObjectStore(TABLE_NAMES.COUNTERS, { keyPath: 'key' });\n }\n\n // Create histograms table for storing histogram stats (count, min, max, sum)\n if (!db.objectStoreNames.contains(TABLE_NAMES.HISTOGRAMS)) {\n db.createObjectStore(TABLE_NAMES.HISTOGRAMS, {\n keyPath: 'key',\n });\n }\n\n // Create events table\n if (!db.objectStoreNames.contains(TABLE_NAMES.EVENTS)) {\n const eventsStore = db.createObjectStore(TABLE_NAMES.EVENTS, {\n keyPath: 'id',\n autoIncrement: true,\n });\n\n // Create index on time for chronological queries\n eventsStore.createIndex('time_idx', 'time', { unique: false });\n }\n\n // Create internal table for storing internal data like flush timestamps\n if (!db.objectStoreNames.contains(TABLE_NAMES.INTERNAL)) {\n db.createObjectStore(TABLE_NAMES.INTERNAL, { keyPath: 'key' });\n }\n }\n\n async setTags(tags: Record<string, string>): Promise<void> {\n try {\n if (Object.entries(tags).length === 0) {\n return;\n }\n\n const db = await this.getDB();\n const transaction = db.transaction([TABLE_NAMES.TAGS], 'readwrite');\n const store = transaction.objectStore(TABLE_NAMES.TAGS);\n\n return new Promise((resolve) => {\n const entries = Object.entries(tags);\n\n transaction.oncomplete = () => {\n resolve();\n };\n\n transaction.onabort = (event) => {\n this.logger.debug('DiagnosticsStorage: Failed to set tags', event);\n resolve();\n };\n\n entries.forEach(([key, value]) => {\n const putRequest = store.put({ key, value });\n\n putRequest.onerror = (event) => {\n this.logger.debug('DiagnosticsStorage: Failed to set tag', key, value, event);\n };\n });\n });\n } catch (error) {\n this.logger.debug('DiagnosticsStorage: Failed to set tags', error);\n }\n }\n\n async incrementCounters(counters: Record<string, number>): Promise<void> {\n try {\n if (Object.entries(counters).length === 0) {\n return;\n }\n\n const db = await this.getDB();\n const transaction = db.transaction([TABLE_NAMES.COUNTERS], 'readwrite');\n const store = transaction.objectStore(TABLE_NAMES.COUNTERS);\n\n return new Promise((resolve) => {\n const entries = Object.entries(counters);\n\n transaction.oncomplete = () => {\n resolve();\n };\n\n transaction.onabort = (event) => {\n this.logger.debug('DiagnosticsStorage: Failed to increment counters', event);\n resolve();\n };\n\n // Read existing values and update them\n entries.forEach(([key, incrementValue]) => {\n const getRequest = store.get(key);\n\n getRequest.onsuccess = () => {\n const existingRecord = getRequest.result as CounterRecord | undefined;\n /* istanbul ignore next */\n const existingValue = existingRecord ? existingRecord.value : 0;\n const putRequest = store.put({ key, value: existingValue + incrementValue });\n\n putRequest.onerror = (event) => {\n this.logger.debug('DiagnosticsStorage: Failed to update counter', key, event);\n };\n };\n\n getRequest.onerror = (event) => {\n this.logger.debug('DiagnosticsStorage: Failed to read existing counter', key, event);\n };\n });\n });\n } catch (error) {\n this.logger.debug('DiagnosticsStorage: Failed to increment counters', error);\n }\n }\n\n async setHistogramStats(histogramStats: Record<string, HistogramStats>): Promise<void> {\n try {\n if (Object.entries(histogramStats).length === 0) {\n return;\n }\n\n const db = await this.getDB();\n const transaction = db.transaction([TABLE_NAMES.HISTOGRAMS], 'readwrite');\n const store = transaction.objectStore(TABLE_NAMES.HISTOGRAMS);\n\n return new Promise((resolve) => {\n const entries = Object.entries(histogramStats);\n\n transaction.oncomplete = () => {\n resolve();\n };\n\n transaction.onabort = (event) => {\n this.logger.debug('DiagnosticsStorage: Failed to set histogram stats', event);\n resolve();\n };\n\n // Read existing values and update them\n entries.forEach(([key, newStats]) => {\n const getRequest = store.get(key);\n\n getRequest.onsuccess = () => {\n const existingRecord = getRequest.result as HistogramRecord | undefined;\n let updatedStats: HistogramRecord;\n\n /* istanbul ignore next */\n if (existingRecord) {\n // Accumulate with existing stats\n updatedStats = {\n key,\n count: existingRecord.count + newStats.count,\n min: Math.min(existingRecord.min, newStats.min),\n max: Math.max(existingRecord.max, newStats.max),\n sum: existingRecord.sum + newStats.sum,\n };\n } else {\n // Create new stats\n updatedStats = {\n key,\n count: newStats.count,\n min: newStats.min,\n max: newStats.max,\n sum: newStats.sum,\n };\n }\n\n const putRequest = store.put(updatedStats);\n\n putRequest.onerror = (event) => {\n this.logger.debug('DiagnosticsStorage: Failed to set histogram stats', key, event);\n };\n };\n\n getRequest.onerror = (event) => {\n this.logger.debug('DiagnosticsStorage: Failed to read existing histogram stats', key, event);\n };\n });\n });\n } catch (error) {\n this.logger.debug('DiagnosticsStorage: Failed to set histogram stats', error);\n }\n }\n\n async addEventRecords(\n events: Array<{ event_name: string; time: number; event_properties: Record<string, any> }>,\n ): Promise<void> {\n try {\n if (events.length === 0) {\n return;\n }\n\n const db = await this.getDB();\n const transaction = db.transaction([TABLE_NAMES.EVENTS], 'readwrite');\n const store = transaction.objectStore(TABLE_NAMES.EVENTS);\n\n return new Promise((resolve) => {\n transaction.oncomplete = () => {\n resolve();\n };\n\n /* istanbul ignore next */\n transaction.onabort = (event) => {\n this.logger.debug('DiagnosticsStorage: Failed to add event records', event);\n resolve();\n };\n\n // First, check how many events are currently stored\n const countRequest = store.count();\n\n countRequest.onsuccess = () => {\n const currentCount = countRequest.result;\n\n // Calculate how many events we can add\n const availableSlots = Math.max(0, MAX_PERSISTENT_STORAGE_EVENTS_COUNT - currentCount);\n\n if (availableSlots < events.length) {\n this.logger.debug(\n `DiagnosticsStorage: Only added ${availableSlots} of ${events.length} events due to storage limit`,\n );\n }\n\n // Only add events up to the available slots (take the least recent ones)\n events.slice(0, availableSlots).forEach((event) => {\n const request = store.add(event);\n\n request.onerror = (event) => {\n this.logger.debug('DiagnosticsStorage: Failed to add event record', event);\n };\n });\n };\n\n countRequest.onerror = (event) => {\n this.logger.debug('DiagnosticsStorage: Failed to count existing events', event);\n };\n });\n } catch (error) {\n this.logger.debug('DiagnosticsStorage: Failed to add event records', error);\n }\n }\n\n async setInternal(key: string, value: string): Promise<void> {\n try {\n const db = await this.getDB();\n const transaction = db.transaction([TABLE_NAMES.INTERNAL], 'readwrite');\n const store = transaction.objectStore(TABLE_NAMES.INTERNAL);\n\n return new Promise((resolve, reject) => {\n /* istanbul ignore next */\n transaction.onabort = () => reject(new Error('Failed to set internal value'));\n\n const request = store.put({ key, value });\n\n request.onsuccess = () => resolve();\n\n /* istanbul ignore next */\n request.onerror = () => reject(new Error('Failed to set internal value'));\n });\n } catch (error) {\n /* istanbul ignore next */\n this.logger.debug('DiagnosticsStorage: Failed to set internal value', error);\n }\n }\n\n async getInternal(key: string): Promise<InternalRecord | undefined> {\n try {\n const db = await this.getDB();\n const transaction = db.transaction([TABLE_NAMES.INTERNAL], 'readonly');\n const store = transaction.objectStore(TABLE_NAMES.INTERNAL);\n\n return new Promise((resolve, reject) => {\n /* istanbul ignore next */\n transaction.onabort = () => reject(new Error('Failed to get internal value'));\n\n const request = store.get(key);\n\n request.onsuccess = () => resolve(request.result as InternalRecord | undefined);\n\n /* istanbul ignore next */\n request.onerror = () => reject(new Error('Failed to get internal value'));\n });\n } catch (error) {\n this.logger.debug('DiagnosticsStorage: Failed to get internal value', error);\n return undefined;\n }\n }\n\n async getLastFlushTimestamp(): Promise<number | undefined> {\n try {\n const record = await this.getInternal(INTERNAL_KEYS.LAST_FLUSH_TIMESTAMP);\n return record ? parseInt(record.value, 10) : undefined;\n } catch (error) {\n /* istanbul ignore next */\n this.logger.debug('DiagnosticsStorage: Failed to get last flush timestamp', error);\n /* istanbul ignore next */\n return undefined;\n }\n }\n\n async setLastFlushTimestamp(timestamp: number): Promise<void> {\n try {\n await this.setInternal(INTERNAL_KEYS.LAST_FLUSH_TIMESTAMP, timestamp.toString());\n } catch (error) {\n /* istanbul ignore next */\n this.logger.debug('DiagnosticsStorage: Failed to set last flush timestamp', error);\n }\n }\n\n /* istanbul ignore next */\n clearTable(transaction: IDBTransaction, tableName: string): Promise<void> {\n return new Promise((resolve, reject) => {\n const store = transaction.objectStore(tableName);\n const request = store.clear();\n\n request.onsuccess = () => resolve();\n request.onerror = () => reject(new Error(`Failed to clear table ${tableName}`));\n });\n }\n\n /* istanbul ignore next */\n async getAllAndClear(): Promise<{\n tags: TagRecord[];\n counters: CounterRecord[];\n histogramStats: HistogramRecord[];\n events: EventRecord[];\n }> {\n try {\n const db = await this.getDB();\n const transaction = db.transaction(\n [TABLE_NAMES.TAGS, TABLE_NAMES.COUNTERS, TABLE_NAMES.HISTOGRAMS, TABLE_NAMES.EVENTS],\n 'readwrite',\n );\n\n // Get all data first\n const [tags, counters, histogramStats, events] = await Promise.all([\n this.getAllFromStore<TagRecord>(transaction, TABLE_NAMES.TAGS),\n this.getAllFromStore<CounterRecord>(transaction, TABLE_NAMES.COUNTERS),\n this.getAllFromStore<HistogramRecord>(transaction, TABLE_NAMES.HISTOGRAMS),\n this.getAllFromStore<EventRecord>(transaction, TABLE_NAMES.EVENTS),\n ]);\n\n // Clear all data in the same transaction\n await Promise.all([\n this.clearTable(transaction, TABLE_NAMES.COUNTERS),\n this.clearTable(transaction, TABLE_NAMES.HISTOGRAMS),\n this.clearTable(transaction, TABLE_NAMES.EVENTS),\n ]);\n\n return { tags, counters, histogramStats, events };\n } catch (error) {\n this.logger.debug('DiagnosticsStorage: Failed to get all and clear data', error);\n return { tags: [], counters: [], histogramStats: [], events: [] };\n }\n }\n\n /**\n * Helper method to get all records from a store within a transaction\n */\n /* istanbul ignore next */\n private getAllFromStore<T>(transaction: IDBTransaction, tableName: string): Promise<T[]> {\n return new Promise((resolve, reject) => {\n const store = transaction.objectStore(tableName);\n const request = store.getAll();\n\n request.onsuccess = () => resolve(request.result as T[]);\n request.onerror = () => reject(new Error(`Failed to get all from ${tableName}`));\n });\n }\n}\n"]} |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"core-client.d.ts","sourceRoot":"","sources":["../../src/core-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EACL,KAAK,EAIL,cAAc,EACf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,SAAS,EAA6B,MAAM,YAAY,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAStC,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACpE,qBAAa,aAAc,YAAW,UAAU,EAAE,UAAU;IAC1D,SAAS,CAAC,YAAY,UAAS;IAC/B,SAAS,CAAC,IAAI,EAAE,MAAM,CAAC;IAGvB,MAAM,EAAE,OAAO,CAAC;IAGhB,QAAQ,EAAE,QAAQ,CAAC;IACnB,OAAO,UAAS;IAChB,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,gBAAgB,GAAG,OAAO,aAAa,CAAC,CAAM;IACjE,SAAS,CAAC,SAAS,EAA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AE,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,GAAG,IAAI;IAOtE,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC;IAU7C;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,iCAAiC,CAAC,cAAc,EAAE,cAAc,GAAG,SAAS,GAAG;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE;IAuD/F,OAAO,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC;IA+B5C,SAAS,CAAC,MAAM,EAAE,OAAO;IAQzB,UAAU,CAAC,MAAM,EAAE,OAAO;IAO1B,KAAK;IAIL,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAUxC,OAAO,CAAC,CAAC,SAAS,MAAM,EAAE,WAAW,EAAE;QAAE,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA;KAAE,GAAG,CAAC,EAAE;CAGzE"} |
@@ -28,5 +28,11 @@ import { __assign, __awaiter, __generator, __values } from "tslib"; | ||
| this.timeline.loggerProvider = this.config.loggerProvider; | ||
| return [4 /*yield*/, this.runQueuedFunctions('q')]; | ||
| case 1: | ||
| _a.label = 1; | ||
| case 1: return [4 /*yield*/, this.runQueuedFunctions('q')]; | ||
| case 2: | ||
| _a.sent(); | ||
| _a.label = 3; | ||
| case 3: | ||
| if (this.q.length > 0) return [3 /*break*/, 1]; | ||
| _a.label = 4; | ||
| case 4: | ||
| this.isReady = true; | ||
@@ -33,0 +39,0 @@ return [2 /*return*/]; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"core-client.js","sourceRoot":"","sources":["../../src/core-client.ts"],"names":[],"mappings":";AAIA,OAAO,EAEL,iBAAiB,EAEjB,gBAAgB,GAEjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAa,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAElE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,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;YACzD,OAAO;SACR;QACD,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IAC1B,CAAC;IAED,kCAAU,GAAV,UAAW,MAAe;QACxB,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,MAAM,EAAE;YACjC,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;YACrC,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;SACvC;IACH,CAAC;IAED,6BAAK,GAAL;QACE,OAAO,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;IAC9C,CAAC;IAED,8BAAM,GAAN,UAAO,IAAY;QACjB,IAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,UAAC,MAAM,IAAK,OAAA,MAAM,CAAC,IAAI,KAAK,IAAI,EAApB,CAAoB,CAAC,CAAC;QAC5E,IAAI,MAAM,KAAK,SAAS,EAAE;YACxB,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,uCAAgC,IAAI,CAAE,CAAC,CAAC;YACzE,OAAO,SAAS,CAAC;SAClB;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,+BAAO,GAAP,UAA0B,WAAwC;QAChE,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,UAAC,MAAM,IAAK,OAAA,MAAM,YAAY,WAAW,EAA7B,CAA6B,CAAQ,CAAC;IACxF,CAAC;IACH,oBAAC;AAAD,CAAC,AA9QD,IA8QC","sourcesContent":["import { Plugin } from './types/plugin';\nimport { IConfig } from './types/config/core-config';\nimport { BaseEvent, EventOptions } from './types/event/base-event';\nimport { Result } from './types/result';\nimport {\n Event,\n IdentifyOperation,\n IdentifyUserProperties,\n SpecialEventType,\n UserProperties,\n} from './types/event/event';\nimport { IIdentify, OrderedIdentifyOperations } from './identify';\nimport { IRevenue } from './revenue';\nimport { CLIENT_NOT_INITIALIZED, OPT_OUT_MESSAGE } from './types/messages';\nimport { Timeline } from './timeline';\nimport {\n createGroupEvent,\n createGroupIdentifyEvent,\n createIdentifyEvent,\n createRevenueEvent,\n createTrackEvent,\n} from './utils/event-builder';\nimport { buildResult } from './utils/result-builder';\nimport { returnWrapper } from './utils/return-wrapper';\nimport { CoreClient, PluginHost } from './types/client/core-client';\nexport class AmplitudeCore implements CoreClient, PluginHost {\n protected initializing = false;\n protected name: string;\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n config: IConfig;\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n timeline: Timeline;\n isReady = false;\n protected q: Array<CallableFunction | typeof returnWrapper> = [];\n protected dispatchQ: Array<CallableFunction> = [];\n\n /**\n * Current user properties (operation-applied, flat key-value).\n * Only used by client-side SDKs; server SDKs may leave this undefined.\n */\n userProperties: { [key: string]: any } | undefined;\n\n constructor(name = '$default') {\n this.timeline = new Timeline(this);\n this.name = name;\n }\n\n protected async _init(config: IConfig) {\n this.config = config;\n this.timeline.reset(this);\n this.timeline.loggerProvider = this.config.loggerProvider;\n await this.runQueuedFunctions('q');\n this.isReady = true;\n }\n\n async runQueuedFunctions(queueName: 'q' | 'dispatchQ') {\n const queuedFunctions = this[queueName];\n this[queueName] = [];\n for (const queuedFunction of queuedFunctions) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const val: ReturnType<typeof returnWrapper> | Promise<any> = queuedFunction();\n if (val && 'promise' in val) {\n await val.promise;\n } else {\n await val;\n }\n }\n // Rerun queued functions if the queue has accrued more while awaiting promises\n if (this[queueName].length) {\n await this.runQueuedFunctions(queueName);\n }\n }\n\n track(eventInput: BaseEvent | string, eventProperties?: Record<string, any>, eventOptions?: EventOptions) {\n const event = createTrackEvent(eventInput, eventProperties, eventOptions);\n // Update client user properties immediately and synchronously\n this.userProperties = this.getOperationAppliedUserProperties(event.user_properties);\n return returnWrapper(this.dispatch(event));\n }\n\n logEvent = this.track.bind(this);\n\n identify(identify: IIdentify, eventOptions?: EventOptions) {\n const event = createIdentifyEvent(identify, eventOptions);\n // Update client user properties immediately and synchronously\n this.userProperties = this.getOperationAppliedUserProperties(event.user_properties);\n return returnWrapper(this.dispatch(event));\n }\n\n groupIdentify(groupType: string, groupName: string | string[], identify: IIdentify, eventOptions?: EventOptions) {\n const event = createGroupIdentifyEvent(groupType, groupName, identify, eventOptions);\n return returnWrapper(this.dispatch(event));\n }\n\n setGroup(groupType: string, groupName: string | string[], eventOptions?: EventOptions) {\n const event = createGroupEvent(groupType, groupName, eventOptions);\n // Update client user properties immediately and synchronously\n this.userProperties = this.getOperationAppliedUserProperties(event.user_properties);\n return returnWrapper(this.dispatch(event));\n }\n\n revenue(revenue: IRevenue, eventOptions?: EventOptions) {\n const event = createRevenueEvent(revenue, eventOptions);\n return returnWrapper(this.dispatch(event));\n }\n\n add(plugin: Plugin) {\n if (!this.isReady) {\n this.q.push(this._addPlugin.bind(this, plugin));\n return returnWrapper();\n }\n return this._addPlugin(plugin);\n }\n\n _addPlugin(plugin: Plugin) {\n return returnWrapper(this.timeline.register(plugin, this.config));\n }\n\n remove(pluginName: string) {\n if (!this.isReady) {\n this.q.push(this._removePlugin.bind(this, pluginName));\n return returnWrapper();\n }\n return this._removePlugin(pluginName);\n }\n\n _removePlugin(pluginName: string) {\n return returnWrapper(this.timeline.deregister(pluginName, this.config));\n }\n\n dispatchWithCallback(event: Event, callback: (result: Result) => void): void {\n if (!this.isReady) {\n return callback(buildResult(event, 0, CLIENT_NOT_INITIALIZED));\n }\n void this.process(event).then(callback);\n }\n\n async dispatch(event: Event): Promise<Result> {\n if (!this.isReady) {\n return new Promise<Result>((resolve) => {\n this.dispatchQ.push(this.dispatchWithCallback.bind(this, event, resolve));\n });\n }\n\n return this.process(event);\n }\n\n /**\n *\n * This method applies identify operations to user properties and\n * returns a single object representing the final user property state.\n *\n * This is a best-effort api that only supports $set, $clearAll, and $unset.\n * Other operations are not supported and are ignored.\n *\n * Operations are applied on top of current client state (this.userProperties).\n *\n * @param userProperties The new user properties object from identify() or setIdentity().\n * @returns A key-value object user properties without operations.\n *\n * @example\n * Input:\n * {\n * $set: { plan: 'premium' },\n * custom_flag: true\n * }\n *\n * Output:\n * {\n * plan: 'premium',\n * custom_flag: true\n * }\n */\n getOperationAppliedUserProperties(userProperties: UserProperties | undefined): { [key: string]: any } {\n const base = this.userProperties ?? {};\n const updatedProperties: { [key: string]: any } = { ...base };\n\n if (userProperties === undefined) {\n return updatedProperties;\n }\n\n // Keep non-operation keys for later merge\n const nonOpProperties: {\n [key in Exclude<string, IdentifyOperation>]: any;\n } = {};\n Object.keys(userProperties).forEach((key) => {\n if (!Object.values(IdentifyOperation).includes(key as IdentifyOperation)) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n nonOpProperties[key] = userProperties[key];\n }\n });\n\n OrderedIdentifyOperations.forEach((operation) => {\n // Skip when key is an operation.\n if (!Object.keys(userProperties).includes(operation)) return;\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const opProperties: IdentifyUserProperties = userProperties[operation];\n\n switch (operation) {\n case IdentifyOperation.CLEAR_ALL:\n // Due to operation order, the following line will never execute.\n /* istanbul ignore next */\n Object.keys(updatedProperties).forEach((prop) => {\n delete updatedProperties[prop];\n });\n break;\n case IdentifyOperation.UNSET:\n Object.keys(opProperties).forEach((prop) => {\n delete updatedProperties[prop];\n });\n break;\n case IdentifyOperation.SET:\n Object.assign(updatedProperties, opProperties);\n break;\n }\n });\n\n // Merge non-operation properties.\n // Custom properties should not be affected by operations.\n // https://github.com/amplitude/nova/blob/343f678ded83c032e83b189796b3c2be161b48f5/src/main/java/com/amplitude/userproperty/model/ModifyUserPropertiesIdent.java#L79-L83\n Object.assign(updatedProperties, nonOpProperties);\n\n return updatedProperties;\n }\n\n async process(event: Event): Promise<Result> {\n try {\n // skip event processing if opt out\n if (this.config.optOut) {\n return buildResult(event, 0, OPT_OUT_MESSAGE);\n }\n\n if (event.event_type === SpecialEventType.IDENTIFY) {\n // Do not update this.userProperties here.\n // It is only set synchronously in identify() or setIdentity()\n this.timeline.onIdentityChanged({ userProperties: this.userProperties });\n }\n\n const result = await this.timeline.push(event);\n\n result.code === 200\n ? this.config.loggerProvider.log(result.message)\n : result.code === 100\n ? this.config.loggerProvider.warn(result.message)\n : this.config.loggerProvider.error(result.message);\n\n return result;\n } catch (e) {\n const message = String(e);\n this.config.loggerProvider.error(message);\n const result = buildResult(event, 0, message);\n\n return result;\n }\n }\n\n setOptOut(optOut: boolean) {\n if (!this.isReady) {\n this.q.push(this._setOptOut.bind(this, Boolean(optOut)));\n return;\n }\n this._setOptOut(optOut);\n }\n\n _setOptOut(optOut: boolean) {\n if (this.config.optOut !== optOut) {\n this.config.optOut = Boolean(optOut);\n this.timeline.onOptOutChanged(optOut);\n }\n }\n\n flush() {\n return returnWrapper(this.timeline.flush());\n }\n\n plugin(name: string): Plugin | undefined {\n const plugin = this.timeline.plugins.find((plugin) => plugin.name === name);\n if (plugin === undefined) {\n this.config.loggerProvider.debug(`Cannot find plugin with name ${name}`);\n return undefined;\n }\n\n return plugin;\n }\n\n plugins<T extends Plugin>(pluginClass: { new (...args: any[]): T }): T[] {\n return this.timeline.plugins.filter((plugin) => plugin instanceof pluginClass) as T[];\n }\n}\n"]} | ||
| {"version":3,"file":"core-client.js","sourceRoot":"","sources":["../../src/core-client.ts"],"names":[],"mappings":";AAIA,OAAO,EAEL,iBAAiB,EAEjB,gBAAgB,GAEjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAa,yBAAyB,EAAE,MAAM,YAAY,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import { BaseEvent, EventOptions } from './types/event/base-event';\nimport { Result } from './types/result';\nimport {\n Event,\n IdentifyOperation,\n IdentifyUserProperties,\n SpecialEventType,\n UserProperties,\n} from './types/event/event';\nimport { IIdentify, OrderedIdentifyOperations } from './identify';\nimport { IRevenue } from './revenue';\nimport { CLIENT_NOT_INITIALIZED, OPT_OUT_MESSAGE } from './types/messages';\nimport { Timeline } from './timeline';\nimport {\n createGroupEvent,\n createGroupIdentifyEvent,\n createIdentifyEvent,\n createRevenueEvent,\n createTrackEvent,\n} from './utils/event-builder';\nimport { buildResult } from './utils/result-builder';\nimport { returnWrapper } from './utils/return-wrapper';\nimport { CoreClient, PluginHost } from './types/client/core-client';\nexport class AmplitudeCore implements CoreClient, PluginHost {\n protected initializing = false;\n protected name: string;\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n config: IConfig;\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n timeline: Timeline;\n isReady = false;\n protected q: Array<CallableFunction | typeof returnWrapper> = [];\n protected dispatchQ: Array<CallableFunction> = [];\n\n /**\n * Current user properties (operation-applied, flat key-value).\n * Only used by client-side SDKs; server SDKs may leave this undefined.\n */\n userProperties: { [key: string]: any } | undefined;\n\n constructor(name = '$default') {\n this.timeline = new Timeline(this);\n this.name = name;\n }\n\n protected async _init(config: IConfig) {\n this.config = config;\n this.timeline.reset(this);\n this.timeline.loggerProvider = this.config.loggerProvider;\n do {\n await this.runQueuedFunctions('q');\n } while (this.q.length > 0);\n this.isReady = true;\n }\n\n async runQueuedFunctions(queueName: 'q' | 'dispatchQ') {\n const queuedFunctions = this[queueName];\n this[queueName] = [];\n for (const queuedFunction of queuedFunctions) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const val: ReturnType<typeof returnWrapper> | Promise<any> = queuedFunction();\n if (val && 'promise' in val) {\n await val.promise;\n } else {\n await val;\n }\n }\n\n // Rerun queued functions if the queue has accrued more while awaiting promises\n if (this[queueName].length) {\n await this.runQueuedFunctions(queueName);\n }\n }\n\n track(eventInput: BaseEvent | string, eventProperties?: Record<string, any>, eventOptions?: EventOptions) {\n const event = createTrackEvent(eventInput, eventProperties, eventOptions);\n // Update client user properties immediately and synchronously\n this.userProperties = this.getOperationAppliedUserProperties(event.user_properties);\n return returnWrapper(this.dispatch(event));\n }\n\n logEvent = this.track.bind(this);\n\n identify(identify: IIdentify, eventOptions?: EventOptions) {\n const event = createIdentifyEvent(identify, eventOptions);\n // Update client user properties immediately and synchronously\n this.userProperties = this.getOperationAppliedUserProperties(event.user_properties);\n return returnWrapper(this.dispatch(event));\n }\n\n groupIdentify(groupType: string, groupName: string | string[], identify: IIdentify, eventOptions?: EventOptions) {\n const event = createGroupIdentifyEvent(groupType, groupName, identify, eventOptions);\n return returnWrapper(this.dispatch(event));\n }\n\n setGroup(groupType: string, groupName: string | string[], eventOptions?: EventOptions) {\n const event = createGroupEvent(groupType, groupName, eventOptions);\n // Update client user properties immediately and synchronously\n this.userProperties = this.getOperationAppliedUserProperties(event.user_properties);\n return returnWrapper(this.dispatch(event));\n }\n\n revenue(revenue: IRevenue, eventOptions?: EventOptions) {\n const event = createRevenueEvent(revenue, eventOptions);\n return returnWrapper(this.dispatch(event));\n }\n\n add(plugin: Plugin) {\n if (!this.isReady) {\n this.q.push(this._addPlugin.bind(this, plugin));\n return returnWrapper();\n }\n return this._addPlugin(plugin);\n }\n\n _addPlugin(plugin: Plugin) {\n return returnWrapper(this.timeline.register(plugin, this.config));\n }\n\n remove(pluginName: string) {\n if (!this.isReady) {\n this.q.push(this._removePlugin.bind(this, pluginName));\n return returnWrapper();\n }\n return this._removePlugin(pluginName);\n }\n\n _removePlugin(pluginName: string) {\n return returnWrapper(this.timeline.deregister(pluginName, this.config));\n }\n\n dispatchWithCallback(event: Event, callback: (result: Result) => void): void {\n if (!this.isReady) {\n return callback(buildResult(event, 0, CLIENT_NOT_INITIALIZED));\n }\n void this.process(event).then(callback);\n }\n\n async dispatch(event: Event): Promise<Result> {\n if (!this.isReady) {\n return new Promise<Result>((resolve) => {\n this.dispatchQ.push(this.dispatchWithCallback.bind(this, event, resolve));\n });\n }\n\n return this.process(event);\n }\n\n /**\n *\n * This method applies identify operations to user properties and\n * returns a single object representing the final user property state.\n *\n * This is a best-effort api that only supports $set, $clearAll, and $unset.\n * Other operations are not supported and are ignored.\n *\n * Operations are applied on top of current client state (this.userProperties).\n *\n * @param userProperties The new user properties object from identify() or setIdentity().\n * @returns A key-value object user properties without operations.\n *\n * @example\n * Input:\n * {\n * $set: { plan: 'premium' },\n * custom_flag: true\n * }\n *\n * Output:\n * {\n * plan: 'premium',\n * custom_flag: true\n * }\n */\n getOperationAppliedUserProperties(userProperties: UserProperties | undefined): { [key: string]: any } {\n const base = this.userProperties ?? {};\n const updatedProperties: { [key: string]: any } = { ...base };\n\n if (userProperties === undefined) {\n return updatedProperties;\n }\n\n // Keep non-operation keys for later merge\n const nonOpProperties: {\n [key in Exclude<string, IdentifyOperation>]: any;\n } = {};\n Object.keys(userProperties).forEach((key) => {\n if (!Object.values(IdentifyOperation).includes(key as IdentifyOperation)) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n nonOpProperties[key] = userProperties[key];\n }\n });\n\n OrderedIdentifyOperations.forEach((operation) => {\n // Skip when key is an operation.\n if (!Object.keys(userProperties).includes(operation)) return;\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const opProperties: IdentifyUserProperties = userProperties[operation];\n\n switch (operation) {\n case IdentifyOperation.CLEAR_ALL:\n // Due to operation order, the following line will never execute.\n /* istanbul ignore next */\n Object.keys(updatedProperties).forEach((prop) => {\n delete updatedProperties[prop];\n });\n break;\n case IdentifyOperation.UNSET:\n Object.keys(opProperties).forEach((prop) => {\n delete updatedProperties[prop];\n });\n break;\n case IdentifyOperation.SET:\n Object.assign(updatedProperties, opProperties);\n break;\n }\n });\n\n // Merge non-operation properties.\n // Custom properties should not be affected by operations.\n // https://github.com/amplitude/nova/blob/343f678ded83c032e83b189796b3c2be161b48f5/src/main/java/com/amplitude/userproperty/model/ModifyUserPropertiesIdent.java#L79-L83\n Object.assign(updatedProperties, nonOpProperties);\n\n return updatedProperties;\n }\n\n async process(event: Event): Promise<Result> {\n try {\n // skip event processing if opt out\n if (this.config.optOut) {\n return buildResult(event, 0, OPT_OUT_MESSAGE);\n }\n\n if (event.event_type === SpecialEventType.IDENTIFY) {\n // Do not update this.userProperties here.\n // It is only set synchronously in identify() or setIdentity()\n this.timeline.onIdentityChanged({ userProperties: this.userProperties });\n }\n\n const result = await this.timeline.push(event);\n\n result.code === 200\n ? this.config.loggerProvider.log(result.message)\n : result.code === 100\n ? this.config.loggerProvider.warn(result.message)\n : this.config.loggerProvider.error(result.message);\n\n return result;\n } catch (e) {\n const message = String(e);\n this.config.loggerProvider.error(message);\n const result = buildResult(event, 0, message);\n\n return result;\n }\n }\n\n setOptOut(optOut: boolean) {\n if (!this.isReady) {\n this.q.push(this._setOptOut.bind(this, Boolean(optOut)));\n return;\n }\n this._setOptOut(optOut);\n }\n\n _setOptOut(optOut: boolean) {\n if (this.config.optOut !== optOut) {\n this.config.optOut = Boolean(optOut);\n this.timeline.onOptOutChanged(optOut);\n }\n }\n\n flush() {\n return returnWrapper(this.timeline.flush());\n }\n\n plugin(name: string): Plugin | undefined {\n const plugin = this.timeline.plugins.find((plugin) => plugin.name === name);\n if (plugin === undefined) {\n this.config.loggerProvider.debug(`Cannot find plugin with name ${name}`);\n return undefined;\n }\n\n return plugin;\n }\n\n plugins<T extends Plugin>(pluginClass: { new (...args: any[]): T }): T[] {\n return this.timeline.plugins.filter((plugin) => plugin instanceof pluginClass) as T[];\n }\n}\n"]} |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"diagnostics-storage.d.ts","sourceRoot":"","sources":["../../../src/diagnostics/diagnostics-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AAe,CACnB,MAAM,EAAE,KAAK,CAAC;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;KAAE,CAAC,GACzF,OAAO,CAAC,IAAI,CAAC;IAuDV,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAuBtD,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC;IAuB7D,qBAAqB,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAYpD,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAU7D,UAAU,CAAC,WAAW,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAWnE,cAAc,IAAI,OAAO,CAAC;QAC9B,IAAI,EAAE,SAAS,EAAE,CAAC;QAClB,QAAQ,EAAE,aAAa,EAAE,CAAC;QAC1B,cAAc,EAAE,eAAe,EAAE,CAAC;QAClC,MAAM,EAAE,WAAW,EAAE,CAAC;KACvB,CAAC;IA8BF;;OAEG;IAEH,OAAO,CAAC,eAAe;CASxB"} |
@@ -68,4 +68,8 @@ import { __awaiter, __generator, __read } from "tslib"; | ||
| }; | ||
| request.onupgradeneeded = function (event) { | ||
| var db = event.target.result; | ||
| request.onupgradeneeded = function () { | ||
| var db = request.result; | ||
| if (!db) { | ||
| _this.logger.debug('DiagnosticsStorage: Missing DB during upgrade.'); | ||
| return; | ||
| } | ||
| _this.createTables(db); | ||
@@ -72,0 +76,0 @@ }; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"diagnostics-storage.js","sourceRoot":"","sources":["../../../src/diagnostics/diagnostics-storage.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iB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C,IAAI,KAAK,CAAC,iCAA0B,SAAS,CAAE,CAAC,CAAC,EAAxD,CAAwD,CAAC;QACnF,CAAC,CAAC,CAAC;IACL,CAAC;IACH,yBAAC;AAAD,CAAC,AA1aD,IA0aC","sourcesContent":["import { getGlobalScope } from '../global-scope';\nimport { ILogger } from '../logger';\nimport { HistogramStats } from './diagnostics-client';\n\nconst MAX_PERSISTENT_STORAGE_EVENTS_COUNT = 10;\n\n// Database configuration\nconst DB_VERSION = 1;\n\n// Table names for different diagnostics types\nexport const TABLE_NAMES = {\n TAGS: 'tags',\n COUNTERS: 'counters',\n HISTOGRAMS: 'histograms',\n EVENTS: 'events',\n INTERNAL: 'internal', // New table for internal storage like flush timestamps\n} as const;\n\n// Keys for internal storage table\nexport const INTERNAL_KEYS = {\n LAST_FLUSH_TIMESTAMP: 'last_flush_timestamp',\n} as const;\n\n// Record interfaces for each table\nexport interface TagRecord {\n key: string;\n value: string;\n}\n\nexport interface CounterRecord {\n key: string;\n value: number;\n}\n\nexport interface HistogramRecord {\n key: string;\n count: number;\n min: number;\n max: number;\n sum: number;\n}\n\nexport interface EventRecord {\n id?: number; // Auto-increment primary key\n event_name: string;\n time: number;\n event_properties: Record<string, any>;\n}\n\nexport interface InternalRecord {\n key: string;\n value: string;\n}\n\nexport interface IDiagnosticsStorage {\n /**\n * Set multiple tags in a single transaction (batch operation)\n * Promise never rejects - errors are logged and operation continues gracefully\n */\n setTags(tags: Record<string, string>): Promise<void>;\n /**\n * Increment multiple counters in a single transaction (batch operation)\n * Uses read-modify-write pattern to accumulate with existing values\n * Promise never rejects - errors are logged and operation continues gracefully\n */\n incrementCounters(counters: Record<string, number>): Promise<void>;\n /**\n * Set multiple histogram stats in a single transaction (batch operation)\n * Uses read-modify-write pattern to accumulate count/sum and update min/max with existing values\n * Promise never rejects - errors are logged and operation continues gracefully\n */\n setHistogramStats(\n histogramStats: Record<string, { count: number; min: number; max: number; sum: number }>,\n ): Promise<void>;\n /**\n * Add multiple event records in a single transaction (batch operation)\n * Promise never rejects - errors are logged and operation continues gracefully\n */\n addEventRecords(\n events: Array<{ event_name: string; time: number; event_properties: Record<string, any> }>,\n ): Promise<void>;\n\n setLastFlushTimestamp(timestamp: number): Promise<void>;\n\n getLastFlushTimestamp(): Promise<number | undefined>;\n\n /**\n * Get all data except internal data from storage and clear it\n */\n getAllAndClear(): Promise<{\n tags: TagRecord[];\n counters: CounterRecord[];\n histogramStats: HistogramRecord[];\n events: EventRecord[];\n }>;\n}\n\n/**\n * Purpose-specific IndexedDB storage for diagnostics data\n * Provides optimized methods for each type of diagnostics data\n */\nexport class DiagnosticsStorage implements IDiagnosticsStorage {\n dbPromise: Promise<IDBDatabase> | null = null;\n dbName: string;\n logger: ILogger;\n\n constructor(apiKey: string, logger: ILogger) {\n this.logger = logger;\n this.dbName = `AMP_diagnostics_${apiKey.substring(0, 10)}`;\n }\n\n /**\n * Check if IndexedDB is supported in the current environment\n * @returns true if IndexedDB is available, false otherwise\n */\n static isSupported(): boolean {\n return getGlobalScope()?.indexedDB !== undefined;\n }\n\n async getDB(): Promise<IDBDatabase> {\n if (!this.dbPromise) {\n this.dbPromise = this.openDB();\n }\n return this.dbPromise;\n }\n\n openDB(): Promise<IDBDatabase> {\n return new Promise((resolve, reject) => {\n const request = indexedDB.open(this.dbName, DB_VERSION);\n\n request.onerror = () => {\n // Clear dbPromise when it rejects for the first time\n this.dbPromise = null;\n reject(new Error('Failed to open IndexedDB'));\n };\n\n request.onsuccess = () => {\n const db = request.result;\n // Clear dbPromise when connection was on but went off later\n db.onclose = () => {\n this.dbPromise = null;\n this.logger.debug('DiagnosticsStorage: DB connection closed.');\n };\n\n db.onerror = (event) => {\n this.logger.debug('DiagnosticsStorage: A global database error occurred.', event);\n db.close();\n };\n resolve(db);\n };\n\n request.onupgradeneeded = (event) => {\n const db = (event.target as IDBOpenDBRequest).result;\n this.createTables(db);\n };\n });\n }\n\n createTables(db: IDBDatabase): void {\n // Create tags table\n if (!db.objectStoreNames.contains(TABLE_NAMES.TAGS)) {\n db.createObjectStore(TABLE_NAMES.TAGS, { keyPath: 'key' });\n }\n\n // Create counters table\n if (!db.objectStoreNames.contains(TABLE_NAMES.COUNTERS)) {\n db.createObjectStore(TABLE_NAMES.COUNTERS, { keyPath: 'key' });\n }\n\n // Create histograms table for storing histogram stats (count, min, max, sum)\n if (!db.objectStoreNames.contains(TABLE_NAMES.HISTOGRAMS)) {\n db.createObjectStore(TABLE_NAMES.HISTOGRAMS, {\n keyPath: 'key',\n });\n }\n\n // Create events table\n if (!db.objectStoreNames.contains(TABLE_NAMES.EVENTS)) {\n const eventsStore = db.createObjectStore(TABLE_NAMES.EVENTS, {\n keyPath: 'id',\n autoIncrement: true,\n });\n\n // Create index on time for chronological queries\n eventsStore.createIndex('time_idx', 'time', { unique: false });\n }\n\n // Create internal table for storing internal data like flush timestamps\n if (!db.objectStoreNames.contains(TABLE_NAMES.INTERNAL)) {\n db.createObjectStore(TABLE_NAMES.INTERNAL, { keyPath: 'key' });\n }\n }\n\n async setTags(tags: Record<string, string>): Promise<void> {\n try {\n if (Object.entries(tags).length === 0) {\n return;\n }\n\n const db = await this.getDB();\n const transaction = db.transaction([TABLE_NAMES.TAGS], 'readwrite');\n const store = transaction.objectStore(TABLE_NAMES.TAGS);\n\n return new Promise((resolve) => {\n const entries = Object.entries(tags);\n\n transaction.oncomplete = () => {\n resolve();\n };\n\n transaction.onabort = (event) => {\n this.logger.debug('DiagnosticsStorage: Failed to set tags', event);\n resolve();\n };\n\n entries.forEach(([key, value]) => {\n const putRequest = store.put({ key, value });\n\n putRequest.onerror = (event) => {\n this.logger.debug('DiagnosticsStorage: Failed to set tag', key, value, event);\n };\n });\n });\n } catch (error) {\n this.logger.debug('DiagnosticsStorage: Failed to set tags', error);\n }\n }\n\n async incrementCounters(counters: Record<string, number>): Promise<void> {\n try {\n if (Object.entries(counters).length === 0) {\n return;\n }\n\n const db = await this.getDB();\n const transaction = db.transaction([TABLE_NAMES.COUNTERS], 'readwrite');\n const store = transaction.objectStore(TABLE_NAMES.COUNTERS);\n\n return new Promise((resolve) => {\n const entries = Object.entries(counters);\n\n transaction.oncomplete = () => {\n resolve();\n };\n\n transaction.onabort = (event) => {\n this.logger.debug('DiagnosticsStorage: Failed to increment counters', event);\n resolve();\n };\n\n // Read existing values and update them\n entries.forEach(([key, incrementValue]) => {\n const getRequest = store.get(key);\n\n getRequest.onsuccess = () => {\n const existingRecord = getRequest.result as CounterRecord | undefined;\n /* istanbul ignore next */\n const existingValue = existingRecord ? existingRecord.value : 0;\n const putRequest = store.put({ key, value: existingValue + incrementValue });\n\n putRequest.onerror = (event) => {\n this.logger.debug('DiagnosticsStorage: Failed to update counter', key, event);\n };\n };\n\n getRequest.onerror = (event) => {\n this.logger.debug('DiagnosticsStorage: Failed to read existing counter', key, event);\n };\n });\n });\n } catch (error) {\n this.logger.debug('DiagnosticsStorage: Failed to increment counters', error);\n }\n }\n\n async setHistogramStats(histogramStats: Record<string, HistogramStats>): Promise<void> {\n try {\n if (Object.entries(histogramStats).length === 0) {\n return;\n }\n\n const db = await this.getDB();\n const transaction = db.transaction([TABLE_NAMES.HISTOGRAMS], 'readwrite');\n const store = transaction.objectStore(TABLE_NAMES.HISTOGRAMS);\n\n return new Promise((resolve) => {\n const entries = Object.entries(histogramStats);\n\n transaction.oncomplete = () => {\n resolve();\n };\n\n transaction.onabort = (event) => {\n this.logger.debug('DiagnosticsStorage: Failed to set histogram stats', event);\n resolve();\n };\n\n // Read existing values and update them\n entries.forEach(([key, newStats]) => {\n const getRequest = store.get(key);\n\n getRequest.onsuccess = () => {\n const existingRecord = getRequest.result as HistogramRecord | undefined;\n let updatedStats: HistogramRecord;\n\n /* istanbul ignore next */\n if (existingRecord) {\n // Accumulate with existing stats\n updatedStats = {\n key,\n count: existingRecord.count + newStats.count,\n min: Math.min(existingRecord.min, newStats.min),\n max: Math.max(existingRecord.max, newStats.max),\n sum: existingRecord.sum + newStats.sum,\n };\n } else {\n // Create new stats\n updatedStats = {\n key,\n count: newStats.count,\n min: newStats.min,\n max: newStats.max,\n sum: newStats.sum,\n };\n }\n\n const putRequest = store.put(updatedStats);\n\n putRequest.onerror = (event) => {\n this.logger.debug('DiagnosticsStorage: Failed to set histogram stats', key, event);\n };\n };\n\n getRequest.onerror = (event) => {\n this.logger.debug('DiagnosticsStorage: Failed to read existing histogram stats', key, event);\n };\n });\n });\n } catch (error) {\n this.logger.debug('DiagnosticsStorage: Failed to set histogram stats', error);\n }\n }\n\n async addEventRecords(\n events: Array<{ event_name: string; time: number; event_properties: Record<string, any> }>,\n ): Promise<void> {\n try {\n if (events.length === 0) {\n return;\n }\n\n const db = await this.getDB();\n const transaction = db.transaction([TABLE_NAMES.EVENTS], 'readwrite');\n const store = transaction.objectStore(TABLE_NAMES.EVENTS);\n\n return new Promise((resolve) => {\n transaction.oncomplete = () => {\n resolve();\n };\n\n /* istanbul ignore next */\n transaction.onabort = (event) => {\n this.logger.debug('DiagnosticsStorage: Failed to add event records', event);\n resolve();\n };\n\n // First, check how many events are currently stored\n const countRequest = store.count();\n\n countRequest.onsuccess = () => {\n const currentCount = countRequest.result;\n\n // Calculate how many events we can add\n const availableSlots = Math.max(0, MAX_PERSISTENT_STORAGE_EVENTS_COUNT - currentCount);\n\n if (availableSlots < events.length) {\n this.logger.debug(\n `DiagnosticsStorage: Only added ${availableSlots} of ${events.length} events due to storage limit`,\n );\n }\n\n // Only add events up to the available slots (take the least recent ones)\n events.slice(0, availableSlots).forEach((event) => {\n const request = store.add(event);\n\n request.onerror = (event) => {\n this.logger.debug('DiagnosticsStorage: Failed to add event record', event);\n };\n });\n };\n\n countRequest.onerror = (event) => {\n this.logger.debug('DiagnosticsStorage: Failed to count existing events', event);\n };\n });\n } catch (error) {\n this.logger.debug('DiagnosticsStorage: Failed to add event records', error);\n }\n }\n\n async setInternal(key: string, value: string): Promise<void> {\n try {\n const db = await this.getDB();\n const transaction = db.transaction([TABLE_NAMES.INTERNAL], 'readwrite');\n const store = transaction.objectStore(TABLE_NAMES.INTERNAL);\n\n return new Promise((resolve, reject) => {\n /* istanbul ignore next */\n transaction.onabort = () => reject(new Error('Failed to set internal value'));\n\n const request = store.put({ key, value });\n\n request.onsuccess = () => resolve();\n\n /* istanbul ignore next */\n request.onerror = () => reject(new Error('Failed to set internal value'));\n });\n } catch (error) {\n /* istanbul ignore next */\n this.logger.debug('DiagnosticsStorage: Failed to set internal value', error);\n }\n }\n\n async getInternal(key: string): Promise<InternalRecord | undefined> {\n try {\n const db = await this.getDB();\n const transaction = db.transaction([TABLE_NAMES.INTERNAL], 'readonly');\n const store = transaction.objectStore(TABLE_NAMES.INTERNAL);\n\n return new Promise((resolve, reject) => {\n /* istanbul ignore next */\n transaction.onabort = () => reject(new Error('Failed to get internal value'));\n\n const request = store.get(key);\n\n request.onsuccess = () => resolve(request.result as InternalRecord | undefined);\n\n /* istanbul ignore next */\n request.onerror = () => reject(new Error('Failed to get internal value'));\n });\n } catch (error) {\n this.logger.debug('DiagnosticsStorage: Failed to get internal value', error);\n return undefined;\n }\n }\n\n async getLastFlushTimestamp(): Promise<number | undefined> {\n try {\n const record = await this.getInternal(INTERNAL_KEYS.LAST_FLUSH_TIMESTAMP);\n return record ? parseInt(record.value, 10) : undefined;\n } catch (error) {\n /* istanbul ignore next */\n this.logger.debug('DiagnosticsStorage: Failed to get last flush timestamp', error);\n /* istanbul ignore next */\n return undefined;\n }\n }\n\n async setLastFlushTimestamp(timestamp: number): Promise<void> {\n try {\n await this.setInternal(INTERNAL_KEYS.LAST_FLUSH_TIMESTAMP, timestamp.toString());\n } catch (error) {\n /* istanbul ignore next */\n this.logger.debug('DiagnosticsStorage: Failed to set last flush timestamp', error);\n }\n }\n\n /* istanbul ignore next */\n clearTable(transaction: IDBTransaction, tableName: string): Promise<void> {\n return new Promise((resolve, reject) => {\n const store = transaction.objectStore(tableName);\n const request = store.clear();\n\n request.onsuccess = () => resolve();\n request.onerror = () => reject(new Error(`Failed to clear table ${tableName}`));\n });\n }\n\n /* istanbul ignore next */\n async getAllAndClear(): Promise<{\n tags: TagRecord[];\n counters: CounterRecord[];\n histogramStats: HistogramRecord[];\n events: EventRecord[];\n }> {\n try {\n const db = await this.getDB();\n const transaction = db.transaction(\n [TABLE_NAMES.TAGS, TABLE_NAMES.COUNTERS, TABLE_NAMES.HISTOGRAMS, TABLE_NAMES.EVENTS],\n 'readwrite',\n );\n\n // Get all data first\n const [tags, counters, histogramStats, events] = await Promise.all([\n this.getAllFromStore<TagRecord>(transaction, TABLE_NAMES.TAGS),\n this.getAllFromStore<CounterRecord>(transaction, TABLE_NAMES.COUNTERS),\n this.getAllFromStore<HistogramRecord>(transaction, TABLE_NAMES.HISTOGRAMS),\n this.getAllFromStore<EventRecord>(transaction, TABLE_NAMES.EVENTS),\n ]);\n\n // Clear all data in the same transaction\n await Promise.all([\n this.clearTable(transaction, TABLE_NAMES.COUNTERS),\n this.clearTable(transaction, TABLE_NAMES.HISTOGRAMS),\n this.clearTable(transaction, TABLE_NAMES.EVENTS),\n ]);\n\n return { tags, counters, histogramStats, events };\n } catch (error) {\n this.logger.debug('DiagnosticsStorage: Failed to get all and clear data', error);\n return { tags: [], counters: [], histogramStats: [], events: [] };\n }\n }\n\n /**\n * Helper method to get all records from a store within a transaction\n */\n /* istanbul ignore next */\n private getAllFromStore<T>(transaction: IDBTransaction, tableName: string): Promise<T[]> {\n return new Promise((resolve, reject) => {\n const store = transaction.objectStore(tableName);\n const request = store.getAll();\n\n request.onsuccess = () => resolve(request.result as T[]);\n request.onerror = () => reject(new Error(`Failed to get all from ${tableName}`));\n });\n }\n}\n"]} | ||
| {"version":3,"file":"diagnostics-storage.js","sourceRoot":"","sources":["../../../src/diagnostics/diagnostics-storage.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,IAAM,mCAAmC,GAAG,EAAE,CAAC;AAE/C,yBAAyB;AACzB,IAAM,UAAU,GAAG,CAAC,CAAC;AAErB,8CAA8C;AAC9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AAE,CAAC,CAAC,EAAxD,CAAwD,CAAC;QACnF,CAAC,CAAC,CAAC;IACL,CAAC;IACH,yBAAC;AAAD,CAAC,AA9aD,IA8aC","sourcesContent":["import { getGlobalScope } from '../global-scope';\nimport { ILogger } from '../logger';\nimport { HistogramStats } from './diagnostics-client';\n\nconst MAX_PERSISTENT_STORAGE_EVENTS_COUNT = 10;\n\n// Database configuration\nconst DB_VERSION = 1;\n\n// Table names for different diagnostics types\nexport const TABLE_NAMES = {\n TAGS: 'tags',\n COUNTERS: 'counters',\n HISTOGRAMS: 'histograms',\n EVENTS: 'events',\n INTERNAL: 'internal', // New table for internal storage like flush timestamps\n} as const;\n\n// Keys for internal storage table\nexport const INTERNAL_KEYS = {\n LAST_FLUSH_TIMESTAMP: 'last_flush_timestamp',\n} as const;\n\n// Record interfaces for each table\nexport interface TagRecord {\n key: string;\n value: string;\n}\n\nexport interface CounterRecord {\n key: string;\n value: number;\n}\n\nexport interface HistogramRecord {\n key: string;\n count: number;\n min: number;\n max: number;\n sum: number;\n}\n\nexport interface EventRecord {\n id?: number; // Auto-increment primary key\n event_name: string;\n time: number;\n event_properties: Record<string, any>;\n}\n\nexport interface InternalRecord {\n key: string;\n value: string;\n}\n\nexport interface IDiagnosticsStorage {\n /**\n * Set multiple tags in a single transaction (batch operation)\n * Promise never rejects - errors are logged and operation continues gracefully\n */\n setTags(tags: Record<string, string>): Promise<void>;\n /**\n * Increment multiple counters in a single transaction (batch operation)\n * Uses read-modify-write pattern to accumulate with existing values\n * Promise never rejects - errors are logged and operation continues gracefully\n */\n incrementCounters(counters: Record<string, number>): Promise<void>;\n /**\n * Set multiple histogram stats in a single transaction (batch operation)\n * Uses read-modify-write pattern to accumulate count/sum and update min/max with existing values\n * Promise never rejects - errors are logged and operation continues gracefully\n */\n setHistogramStats(\n histogramStats: Record<string, { count: number; min: number; max: number; sum: number }>,\n ): Promise<void>;\n /**\n * Add multiple event records in a single transaction (batch operation)\n * Promise never rejects - errors are logged and operation continues gracefully\n */\n addEventRecords(\n events: Array<{ event_name: string; time: number; event_properties: Record<string, any> }>,\n ): Promise<void>;\n\n setLastFlushTimestamp(timestamp: number): Promise<void>;\n\n getLastFlushTimestamp(): Promise<number | undefined>;\n\n /**\n * Get all data except internal data from storage and clear it\n */\n getAllAndClear(): Promise<{\n tags: TagRecord[];\n counters: CounterRecord[];\n histogramStats: HistogramRecord[];\n events: EventRecord[];\n }>;\n}\n\n/**\n * Purpose-specific IndexedDB storage for diagnostics data\n * Provides optimized methods for each type of diagnostics data\n */\nexport class DiagnosticsStorage implements IDiagnosticsStorage {\n dbPromise: Promise<IDBDatabase> | null = null;\n dbName: string;\n logger: ILogger;\n\n constructor(apiKey: string, logger: ILogger) {\n this.logger = logger;\n this.dbName = `AMP_diagnostics_${apiKey.substring(0, 10)}`;\n }\n\n /**\n * Check if IndexedDB is supported in the current environment\n * @returns true if IndexedDB is available, false otherwise\n */\n static isSupported(): boolean {\n return getGlobalScope()?.indexedDB !== undefined;\n }\n\n async getDB(): Promise<IDBDatabase> {\n if (!this.dbPromise) {\n this.dbPromise = this.openDB();\n }\n return this.dbPromise;\n }\n\n openDB(): Promise<IDBDatabase> {\n return new Promise((resolve, reject) => {\n const request = indexedDB.open(this.dbName, DB_VERSION);\n\n request.onerror = () => {\n // Clear dbPromise when it rejects for the first time\n this.dbPromise = null;\n reject(new Error('Failed to open IndexedDB'));\n };\n\n request.onsuccess = () => {\n const db = request.result;\n // Clear dbPromise when connection was on but went off later\n db.onclose = () => {\n this.dbPromise = null;\n this.logger.debug('DiagnosticsStorage: DB connection closed.');\n };\n\n db.onerror = (event) => {\n this.logger.debug('DiagnosticsStorage: A global database error occurred.', event);\n db.close();\n };\n resolve(db);\n };\n\n request.onupgradeneeded = () => {\n const db = request.result;\n if (!db) {\n this.logger.debug('DiagnosticsStorage: Missing DB during upgrade.');\n return;\n }\n this.createTables(db);\n };\n });\n }\n\n createTables(db: IDBDatabase): void {\n // Create tags table\n if (!db.objectStoreNames.contains(TABLE_NAMES.TAGS)) {\n db.createObjectStore(TABLE_NAMES.TAGS, { keyPath: 'key' });\n }\n\n // Create counters table\n if (!db.objectStoreNames.contains(TABLE_NAMES.COUNTERS)) {\n db.createObjectStore(TABLE_NAMES.COUNTERS, { keyPath: 'key' });\n }\n\n // Create histograms table for storing histogram stats (count, min, max, sum)\n if (!db.objectStoreNames.contains(TABLE_NAMES.HISTOGRAMS)) {\n db.createObjectStore(TABLE_NAMES.HISTOGRAMS, {\n keyPath: 'key',\n });\n }\n\n // Create events table\n if (!db.objectStoreNames.contains(TABLE_NAMES.EVENTS)) {\n const eventsStore = db.createObjectStore(TABLE_NAMES.EVENTS, {\n keyPath: 'id',\n autoIncrement: true,\n });\n\n // Create index on time for chronological queries\n eventsStore.createIndex('time_idx', 'time', { unique: false });\n }\n\n // Create internal table for storing internal data like flush timestamps\n if (!db.objectStoreNames.contains(TABLE_NAMES.INTERNAL)) {\n db.createObjectStore(TABLE_NAMES.INTERNAL, { keyPath: 'key' });\n }\n }\n\n async setTags(tags: Record<string, string>): Promise<void> {\n try {\n if (Object.entries(tags).length === 0) {\n return;\n }\n\n const db = await this.getDB();\n const transaction = db.transaction([TABLE_NAMES.TAGS], 'readwrite');\n const store = transaction.objectStore(TABLE_NAMES.TAGS);\n\n return new Promise((resolve) => {\n const entries = Object.entries(tags);\n\n transaction.oncomplete = () => {\n resolve();\n };\n\n transaction.onabort = (event) => {\n this.logger.debug('DiagnosticsStorage: Failed to set tags', event);\n resolve();\n };\n\n entries.forEach(([key, value]) => {\n const putRequest = store.put({ key, value });\n\n putRequest.onerror = (event) => {\n this.logger.debug('DiagnosticsStorage: Failed to set tag', key, value, event);\n };\n });\n });\n } catch (error) {\n this.logger.debug('DiagnosticsStorage: Failed to set tags', error);\n }\n }\n\n async incrementCounters(counters: Record<string, number>): Promise<void> {\n try {\n if (Object.entries(counters).length === 0) {\n return;\n }\n\n const db = await this.getDB();\n const transaction = db.transaction([TABLE_NAMES.COUNTERS], 'readwrite');\n const store = transaction.objectStore(TABLE_NAMES.COUNTERS);\n\n return new Promise((resolve) => {\n const entries = Object.entries(counters);\n\n transaction.oncomplete = () => {\n resolve();\n };\n\n transaction.onabort = (event) => {\n this.logger.debug('DiagnosticsStorage: Failed to increment counters', event);\n resolve();\n };\n\n // Read existing values and update them\n entries.forEach(([key, incrementValue]) => {\n const getRequest = store.get(key);\n\n getRequest.onsuccess = () => {\n const existingRecord = getRequest.result as CounterRecord | undefined;\n /* istanbul ignore next */\n const existingValue = existingRecord ? existingRecord.value : 0;\n const putRequest = store.put({ key, value: existingValue + incrementValue });\n\n putRequest.onerror = (event) => {\n this.logger.debug('DiagnosticsStorage: Failed to update counter', key, event);\n };\n };\n\n getRequest.onerror = (event) => {\n this.logger.debug('DiagnosticsStorage: Failed to read existing counter', key, event);\n };\n });\n });\n } catch (error) {\n this.logger.debug('DiagnosticsStorage: Failed to increment counters', error);\n }\n }\n\n async setHistogramStats(histogramStats: Record<string, HistogramStats>): Promise<void> {\n try {\n if (Object.entries(histogramStats).length === 0) {\n return;\n }\n\n const db = await this.getDB();\n const transaction = db.transaction([TABLE_NAMES.HISTOGRAMS], 'readwrite');\n const store = transaction.objectStore(TABLE_NAMES.HISTOGRAMS);\n\n return new Promise((resolve) => {\n const entries = Object.entries(histogramStats);\n\n transaction.oncomplete = () => {\n resolve();\n };\n\n transaction.onabort = (event) => {\n this.logger.debug('DiagnosticsStorage: Failed to set histogram stats', event);\n resolve();\n };\n\n // Read existing values and update them\n entries.forEach(([key, newStats]) => {\n const getRequest = store.get(key);\n\n getRequest.onsuccess = () => {\n const existingRecord = getRequest.result as HistogramRecord | undefined;\n let updatedStats: HistogramRecord;\n\n /* istanbul ignore next */\n if (existingRecord) {\n // Accumulate with existing stats\n updatedStats = {\n key,\n count: existingRecord.count + newStats.count,\n min: Math.min(existingRecord.min, newStats.min),\n max: Math.max(existingRecord.max, newStats.max),\n sum: existingRecord.sum + newStats.sum,\n };\n } else {\n // Create new stats\n updatedStats = {\n key,\n count: newStats.count,\n min: newStats.min,\n max: newStats.max,\n sum: newStats.sum,\n };\n }\n\n const putRequest = store.put(updatedStats);\n\n putRequest.onerror = (event) => {\n this.logger.debug('DiagnosticsStorage: Failed to set histogram stats', key, event);\n };\n };\n\n getRequest.onerror = (event) => {\n this.logger.debug('DiagnosticsStorage: Failed to read existing histogram stats', key, event);\n };\n });\n });\n } catch (error) {\n this.logger.debug('DiagnosticsStorage: Failed to set histogram stats', error);\n }\n }\n\n async addEventRecords(\n events: Array<{ event_name: string; time: number; event_properties: Record<string, any> }>,\n ): Promise<void> {\n try {\n if (events.length === 0) {\n return;\n }\n\n const db = await this.getDB();\n const transaction = db.transaction([TABLE_NAMES.EVENTS], 'readwrite');\n const store = transaction.objectStore(TABLE_NAMES.EVENTS);\n\n return new Promise((resolve) => {\n transaction.oncomplete = () => {\n resolve();\n };\n\n /* istanbul ignore next */\n transaction.onabort = (event) => {\n this.logger.debug('DiagnosticsStorage: Failed to add event records', event);\n resolve();\n };\n\n // First, check how many events are currently stored\n const countRequest = store.count();\n\n countRequest.onsuccess = () => {\n const currentCount = countRequest.result;\n\n // Calculate how many events we can add\n const availableSlots = Math.max(0, MAX_PERSISTENT_STORAGE_EVENTS_COUNT - currentCount);\n\n if (availableSlots < events.length) {\n this.logger.debug(\n `DiagnosticsStorage: Only added ${availableSlots} of ${events.length} events due to storage limit`,\n );\n }\n\n // Only add events up to the available slots (take the least recent ones)\n events.slice(0, availableSlots).forEach((event) => {\n const request = store.add(event);\n\n request.onerror = (event) => {\n this.logger.debug('DiagnosticsStorage: Failed to add event record', event);\n };\n });\n };\n\n countRequest.onerror = (event) => {\n this.logger.debug('DiagnosticsStorage: Failed to count existing events', event);\n };\n });\n } catch (error) {\n this.logger.debug('DiagnosticsStorage: Failed to add event records', error);\n }\n }\n\n async setInternal(key: string, value: string): Promise<void> {\n try {\n const db = await this.getDB();\n const transaction = db.transaction([TABLE_NAMES.INTERNAL], 'readwrite');\n const store = transaction.objectStore(TABLE_NAMES.INTERNAL);\n\n return new Promise((resolve, reject) => {\n /* istanbul ignore next */\n transaction.onabort = () => reject(new Error('Failed to set internal value'));\n\n const request = store.put({ key, value });\n\n request.onsuccess = () => resolve();\n\n /* istanbul ignore next */\n request.onerror = () => reject(new Error('Failed to set internal value'));\n });\n } catch (error) {\n /* istanbul ignore next */\n this.logger.debug('DiagnosticsStorage: Failed to set internal value', error);\n }\n }\n\n async getInternal(key: string): Promise<InternalRecord | undefined> {\n try {\n const db = await this.getDB();\n const transaction = db.transaction([TABLE_NAMES.INTERNAL], 'readonly');\n const store = transaction.objectStore(TABLE_NAMES.INTERNAL);\n\n return new Promise((resolve, reject) => {\n /* istanbul ignore next */\n transaction.onabort = () => reject(new Error('Failed to get internal value'));\n\n const request = store.get(key);\n\n request.onsuccess = () => resolve(request.result as InternalRecord | undefined);\n\n /* istanbul ignore next */\n request.onerror = () => reject(new Error('Failed to get internal value'));\n });\n } catch (error) {\n this.logger.debug('DiagnosticsStorage: Failed to get internal value', error);\n return undefined;\n }\n }\n\n async getLastFlushTimestamp(): Promise<number | undefined> {\n try {\n const record = await this.getInternal(INTERNAL_KEYS.LAST_FLUSH_TIMESTAMP);\n return record ? parseInt(record.value, 10) : undefined;\n } catch (error) {\n /* istanbul ignore next */\n this.logger.debug('DiagnosticsStorage: Failed to get last flush timestamp', error);\n /* istanbul ignore next */\n return undefined;\n }\n }\n\n async setLastFlushTimestamp(timestamp: number): Promise<void> {\n try {\n await this.setInternal(INTERNAL_KEYS.LAST_FLUSH_TIMESTAMP, timestamp.toString());\n } catch (error) {\n /* istanbul ignore next */\n this.logger.debug('DiagnosticsStorage: Failed to set last flush timestamp', error);\n }\n }\n\n /* istanbul ignore next */\n clearTable(transaction: IDBTransaction, tableName: string): Promise<void> {\n return new Promise((resolve, reject) => {\n const store = transaction.objectStore(tableName);\n const request = store.clear();\n\n request.onsuccess = () => resolve();\n request.onerror = () => reject(new Error(`Failed to clear table ${tableName}`));\n });\n }\n\n /* istanbul ignore next */\n async getAllAndClear(): Promise<{\n tags: TagRecord[];\n counters: CounterRecord[];\n histogramStats: HistogramRecord[];\n events: EventRecord[];\n }> {\n try {\n const db = await this.getDB();\n const transaction = db.transaction(\n [TABLE_NAMES.TAGS, TABLE_NAMES.COUNTERS, TABLE_NAMES.HISTOGRAMS, TABLE_NAMES.EVENTS],\n 'readwrite',\n );\n\n // Get all data first\n const [tags, counters, histogramStats, events] = await Promise.all([\n this.getAllFromStore<TagRecord>(transaction, TABLE_NAMES.TAGS),\n this.getAllFromStore<CounterRecord>(transaction, TABLE_NAMES.COUNTERS),\n this.getAllFromStore<HistogramRecord>(transaction, TABLE_NAMES.HISTOGRAMS),\n this.getAllFromStore<EventRecord>(transaction, TABLE_NAMES.EVENTS),\n ]);\n\n // Clear all data in the same transaction\n await Promise.all([\n this.clearTable(transaction, TABLE_NAMES.COUNTERS),\n this.clearTable(transaction, TABLE_NAMES.HISTOGRAMS),\n this.clearTable(transaction, TABLE_NAMES.EVENTS),\n ]);\n\n return { tags, counters, histogramStats, events };\n } catch (error) {\n this.logger.debug('DiagnosticsStorage: Failed to get all and clear data', error);\n return { tags: [], counters: [], histogramStats: [], events: [] };\n }\n }\n\n /**\n * Helper method to get all records from a store within a transaction\n */\n /* istanbul ignore next */\n private getAllFromStore<T>(transaction: IDBTransaction, tableName: string): Promise<T[]> {\n return new Promise((resolve, reject) => {\n const store = transaction.objectStore(tableName);\n const request = store.getAll();\n\n request.onsuccess = () => resolve(request.result as T[]);\n request.onerror = () => reject(new Error(`Failed to get all from ${tableName}`));\n });\n }\n}\n"]} |
+1
-1
| { | ||
| "name": "@amplitude/analytics-core", | ||
| "version": "2.52.1", | ||
| "version": "2.52.2", | ||
| "description": "", | ||
@@ -5,0 +5,0 @@ "author": "Amplitude Inc", |
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
2106452
0.06%21533
0.09%