Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions channels/offline-channel-js/src/Helpers/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,21 @@
// Licensed under the MIT License.

import { EventPersistence } from "@microsoft/applicationinsights-common";
import { INotificationManager, ITelemetryItem, NotificationManager, generateW3CId } from "@microsoft/applicationinsights-core-js";
import { isString, objKeys, strSubstr } from "@nevware21/ts-utils";
import {
INotificationManager, ITelemetryItem, NotificationManager, eLoggingSeverity, generateW3CId
} from "@microsoft/applicationinsights-core-js";
import { isNumber, isString, objKeys, strSubstr } from "@nevware21/ts-utils";
import { IPostTransmissionTelemetryItem } from "../Interfaces/IInMemoryBatch";
import { isValidPersistenceLevel } from "../Providers/IndexDbProvider";

/**
* Checks if the value is a valid EventPersistence.
* @param {enum} value - The value that needs to be checked.
* @return {boolean} True if the value is in EventPersistence, false otherwise.
*/
export function isValidPersistenceLevel(value: EventPersistence | number): boolean {
return (isNumber(value) && value >= eLoggingSeverity.DISABLED && value <= EventPersistence.Critical);
}


// Endpoint schema
// <prefix>.<suffix>
Expand Down
3 changes: 1 addition & 2 deletions channels/offline-channel-js/src/OfflineChannel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
import { IPromise, ITaskScheduler, createAsyncPromise, createTaskScheduler } from "@nevware21/ts-async";
import { ITimerHandler, isFunction, isString, objDeepFreeze, scheduleTimeout } from "@nevware21/ts-utils";
import {
EVT_DISCARD_STR, EVT_SENT_STR, EVT_STORE_STR, batchDropNotification, callNotification, isGreaterThanZero
EVT_DISCARD_STR, EVT_SENT_STR, EVT_STORE_STR, batchDropNotification, callNotification, isGreaterThanZero, isValidPersistenceLevel
} from "./Helpers/Utils";
import { InMemoryBatch } from "./InMemoryBatch";
import { IPostTransmissionTelemetryItem } from "./Interfaces/IInMemoryBatch";
Expand All @@ -26,7 +26,6 @@ import {
ILocalStorageProviderContext, IOfflineChannelConfiguration, IOfflineSenderConfig, IStorageTelemetryItem, eStorageProviders
} from "./Interfaces/IOfflineProvider";
import { OfflineBatchHandler } from "./OfflineBatchHandler";
import { isValidPersistenceLevel } from "./Providers/IndexDbProvider";
import { Sender } from "./Sender";

const version = "#version#";
Expand Down
15 changes: 2 additions & 13 deletions channels/offline-channel-js/src/Providers/IndexDbProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
// Licensed under the MIT License.

import dynamicProto from "@microsoft/dynamicproto-js";
import { EventPersistence } from "@microsoft/applicationinsights-common";
import {
INotificationManager, IProcessTelemetryContext, IUnloadHookContainer, eBatchDiscardedReason, eLoggingSeverity, isNotNullOrUndefined,
isNumber, isString, newGuid, onConfigChange
INotificationManager, IProcessTelemetryContext, IUnloadHookContainer, eBatchDiscardedReason, isNotNullOrUndefined, isString, newGuid,
onConfigChange
} from "@microsoft/applicationinsights-core-js";
import { IPromise, createAsyncAllPromise, createAsyncPromise, doAwait, doAwaitResponse } from "@nevware21/ts-async";
import { batchDropNotification, getEndpointDomain, getTimeFromId, getTimeId } from "../Helpers/Utils";
Expand All @@ -30,16 +29,6 @@ export const DbVersion = 1; // The Current version of th
export const EventObjectStoreName = "Evts";


/**
* Checks if the value is a valid EventPersistence.
* @param {enum} value - The value that needs to be checked.
* @return {boolean} True if the value is in EventPersistence, false otherwise.
*/
export function isValidPersistenceLevel(value: EventPersistence | number): boolean {
return (isNumber(value) && value >= eLoggingSeverity.DISABLED && value <= EventPersistence.Critical);
}


/**
* The format of the data stored in the iKey objectStore
*/
Expand Down