From 767790b9011cc032dd9a9763fa7e6714de1cd527 Mon Sep 17 00:00:00 2001 From: Karlie-777 <79606506+Karlie-777@users.noreply.github.com> Date: Wed, 29 May 2024 11:49:23 -0700 Subject: [PATCH] add enum (#2356) --- .../src/Interfaces/IOfflineBatch.ts | 27 ++++++++++++++++--- .../src/Interfaces/IOfflineProvider.ts | 9 ++++++- .../applicationinsights-offlinechannel-js.ts | 4 +-- 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/channels/offline-channel-js/src/Interfaces/IOfflineBatch.ts b/channels/offline-channel-js/src/Interfaces/IOfflineBatch.ts index a3d77938c..0e5965f72 100644 --- a/channels/offline-channel-js/src/Interfaces/IOfflineBatch.ts +++ b/channels/offline-channel-js/src/Interfaces/IOfflineBatch.ts @@ -3,7 +3,8 @@ import { IOfflineListener } from "@microsoft/applicationinsights-common"; import { - IPayloadData, IProcessTelemetryUnloadContext, ITelemetryUnloadState, IXHROverride + IPayloadData, IProcessTelemetryUnloadContext, ITelemetryUnloadState, IXHROverride, + createEnumStyle } from "@microsoft/applicationinsights-core-js"; import { IPromise } from "@nevware21/ts-async"; @@ -35,19 +36,39 @@ export const enum eStorageType { SessionStorage = 2, IndexDb = 3 } + +export const StorageType = createEnumStyle({ + Unknown: eStorageType.Unknown, + LocalStorage: eStorageType.LocalStorage, + SessionStorage: eStorageType.SessionStorage, + IndexDb: eStorageType.IndexDb +}); +export type StorageType = number | eStorageType; export const enum eBatchSendStatus { Complete = 1, Retry = 2, Drop = 3, Failure = 4 - } +} +export const BatchSendStatus = createEnumStyle({ + Complete: eBatchSendStatus.Complete, + Retry: eBatchSendStatus.Retry, + Drop: eBatchSendStatus.Drop, + Failure: eBatchSendStatus.Failure +}); +export type BatchSendStatus = number | eBatchSendStatus; export const enum eBatchStoreStatus { Success = 1, Failure = 2 - } +} +export const BatchStoreStatus = createEnumStyle({ + Success: eBatchStoreStatus.Success, + Failure: eBatchStoreStatus.Failure +}); +export type BatchStoreStatus = number | eBatchStoreStatus; export interface IOfflineBatchHandlerCfg { batchMaxSize?: number; // default 10000 diff --git a/channels/offline-channel-js/src/Interfaces/IOfflineProvider.ts b/channels/offline-channel-js/src/Interfaces/IOfflineProvider.ts index ac1bb201f..293787e77 100644 --- a/channels/offline-channel-js/src/Interfaces/IOfflineProvider.ts +++ b/channels/offline-channel-js/src/Interfaces/IOfflineProvider.ts @@ -2,7 +2,7 @@ // Licensed under the MIT License. import { EventPersistence } from "@microsoft/applicationinsights-common"; -import { INotificationManager, IPayloadData, IProcessTelemetryContext, IXHROverride } from "@microsoft/applicationinsights-core-js"; +import { INotificationManager, IPayloadData, IProcessTelemetryContext, IXHROverride, createEnumStyle } from "@microsoft/applicationinsights-core-js"; import { IPromise } from "@nevware21/ts-async"; /** @@ -25,6 +25,13 @@ export const enum eStorageProviders { IndexedDb = 3 } +export const StorageProviders = createEnumStyle({ + LocalStorage: eStorageProviders.LocalStorage, + SessionStorage: eStorageProviders.SessionStorage, + IndexedDb: eStorageProviders.IndexedDb +}); +export type StorageProviders = number | eStorageProviders; + /** * The IOfflineChannelConfiguration interface defines the configuration options for offline channel, * supports offline events storage, retrieval and re-sending. diff --git a/channels/offline-channel-js/src/applicationinsights-offlinechannel-js.ts b/channels/offline-channel-js/src/applicationinsights-offlinechannel-js.ts index 1a1ae70b5..7e166d100 100644 --- a/channels/offline-channel-js/src/applicationinsights-offlinechannel-js.ts +++ b/channels/offline-channel-js/src/applicationinsights-offlinechannel-js.ts @@ -1,10 +1,10 @@ export { IInMemoryBatch, IPostTransmissionTelemetryItem } from "./Interfaces/IInMemoryBatch"; export { IOfflineBatchCleanResponse, IOfflineBatchHandler, IOfflineBatchHandlerCfg, IOfflineBatchResponse, - IOfflineBatchStoreResponse, eBatchSendStatus, eBatchStoreStatus, eStorageType, + IOfflineBatchStoreResponse, eBatchSendStatus, BatchSendStatus, eBatchStoreStatus, BatchStoreStatus, eStorageType, StorageType, OfflineBatchSendCallback, OfflineBatchStoreCallback,OfflineBatchCallback, createDefaultOfflineDetector, createNoopOfflineDetector, IOfflineDetector, IOfflineDetectorCfg } from "./Interfaces/IOfflineBatch"; export {IOfflineChannelConfiguration, ILocalStorageProviderContext, IOfflineProvider, IOfflineSenderConfig, IStorageTelemetryItem, - eStorageProviders } from "./Interfaces/IOfflineProvider"; + eStorageProviders, StorageProviders } from "./Interfaces/IOfflineProvider"; export { WebStorageProvider } from "./Providers/WebStorageProvider"; export { IndexedDbProvider } from "./Providers/IndexDbProvider"; export { OfflineBatchHandler } from "./OfflineBatchHandler";