@microsoft/applicationinsights-offlinechannel-js 0.3.1-nightly3.2407-14 → 0.3.1-nightly3.2407-16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"WebStorageProvider.js.map","sources":["WebStorageProvider.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\nimport dynamicProto from \"@microsoft/dynamicproto-js\";\r\nimport { getGlobal, getJSON, isNotNullOrUndefined, onConfigChange } from \"@microsoft/applicationinsights-core-js\";\r\nimport { createAsyncRejectedPromise } from \"@nevware21/ts-async\";\r\nimport { batchDropNotification, forEachMap, getEndpointDomain, getTimeFromId, getTimeId } from \"../Helpers/Utils\";\r\nimport { PayloadHelper } from \"../PayloadHelper\";\r\nimport { _DYN_ADD_EVENT, _DYN_CLEAR, _DYN_CRITICAL_CNT, _DYN_DIAG_LOG, _DYN_ENDPOINT, _DYN_EVTS, _DYN_GET_NEXT_BATCH, _DYN_GET_TIME, _DYN_INITIALIZE, _DYN_IN_STORAGE_MAX_TIME, _DYN_IS_ARR, _DYN_ITEM_CTX, _DYN_LAST_ACCESS_TIME, _DYN_LENGTH, _DYN_MAX_CRITICAL_EVTS_DR3, _DYN_NAME, _DYN_NOTIFICATION_MGR, _DYN_PUSH, _DYN_REMOVE_EVENTS, _DYN_REMOVE_ITEM, _DYN_STORAGE_CONFIG, _DYN_STORAGE_KEY_PREFIX, _DYN_SUPPORTS_SYNC_REQUES4, _DYN_TEARDOWN, _DYN__EVENTS_TO_DROP_PER_2 } from \"../__DynamicConstants\";\r\n//TODO: move all const to one file\r\nvar EventsToDropAtOneTime = 10;\r\nvar Version = \"1\";\r\nvar DefaultStorageKey = \"AIOffline\";\r\nvar DefaultMaxStorageSizeInBytes = 5000000;\r\nvar MaxCriticalEvtsDropCnt = 2;\r\nvar DefaultMaxInStorageTime = 10080000; //7*24*60*60*1000 7days\r\n// Private helper methods that are not exposed as class methods\r\nfunction _isQuotaExceeded(storage, e) {\r\n var result = false;\r\n if (e instanceof DOMException) {\r\n // test name field too, because code might not be present\r\n if (e.code === 22 || e[_DYN_NAME /* @min:%2ename */] === \"QuotaExceededError\" || // everything except Firefox\r\n e.code === 1014 || e[_DYN_NAME /* @min:%2ename */] === \"NS_ERROR_DOM_QUOTA_REACHED\") { // Firefox\r\n if (storage && storage[_DYN_LENGTH /* @min:%2elength */] !== 0) {\r\n // acknowledge QuotaExceededError only if there's something already stored\r\n result = true;\r\n }\r\n }\r\n }\r\n return result;\r\n}\r\n/**\r\n* Check and return that the storage type exists and has space to use\r\n*/\r\nfunction _getAvailableStorage(type) {\r\n var global = getGlobal() || {};\r\n var storage = null;\r\n try {\r\n storage = (global[type]);\r\n if (storage) {\r\n var x = \"__storage_test__\";\r\n storage.setItem(x, x);\r\n storage[_DYN_REMOVE_ITEM /* @min:%2eremoveItem */](x);\r\n }\r\n }\r\n catch (e) {\r\n if (!_isQuotaExceeded(storage, e)) {\r\n // If not Quota exception then assume not available\r\n storage = null;\r\n }\r\n }\r\n return storage;\r\n}\r\n// will drop batches with no critical evts first\r\nfunction _dropEventsUpToPersistence(maxCnt, events, eventsToDropAtOneTime) {\r\n var dropKeys = [];\r\n var persistenceCnt = 0;\r\n var droppedEvents = 0;\r\n while (persistenceCnt <= maxCnt && droppedEvents < eventsToDropAtOneTime) {\r\n forEachMap(events, function (evt, key) {\r\n if (evt[_DYN_CRITICAL_CNT /* @min:%2ecriticalCnt */] === persistenceCnt) {\r\n dropKeys[_DYN_PUSH /* @min:%2epush */](key);\r\n droppedEvents++;\r\n }\r\n return (droppedEvents < eventsToDropAtOneTime);\r\n });\r\n if (droppedEvents > 0) {\r\n for (var lp = 0; lp < dropKeys[_DYN_LENGTH /* @min:%2elength */]; lp++) {\r\n delete events[dropKeys[lp]];\r\n }\r\n return droppedEvents;\r\n }\r\n persistenceCnt++;\r\n }\r\n return droppedEvents;\r\n}\r\nfunction _dropMaxTimeEvents(maxStorageTime, events, eventsToDropAtOneTime, mgr) {\r\n var dropKeys = [];\r\n var droppedEvents = 0;\r\n var currentTime = (new Date())[_DYN_GET_TIME /* @min:%2egetTime */]() + 1; // handle appended random float number\r\n var minStartTime = (currentTime - maxStorageTime);\r\n try {\r\n forEachMap(events, function (evt, key) {\r\n var id = getTimeFromId(key);\r\n if (id <= minStartTime) {\r\n dropKeys[_DYN_PUSH /* @min:%2epush */](key);\r\n droppedEvents++;\r\n }\r\n return (droppedEvents < eventsToDropAtOneTime);\r\n });\r\n if (droppedEvents > 0) {\r\n for (var lp = 0; lp < dropKeys[_DYN_LENGTH /* @min:%2elength */]; lp++) {\r\n delete events[dropKeys[lp]];\r\n }\r\n if (mgr) {\r\n batchDropNotification(mgr, droppedEvents, 3 /* eBatchDiscardedReason.MaxInStorageTimeExceeded */);\r\n }\r\n return true;\r\n }\r\n }\r\n catch (e) {\r\n // catch drop events error\r\n }\r\n return droppedEvents > 0;\r\n}\r\n/**\r\n * Class that implements storing of events using the WebStorage Api ((window||globalThis||self).localstorage, (window||globalThis||self).sessionStorage).\r\n */\r\nvar WebStorageProvider = /** @class */ (function () {\r\n /**\r\n * Creates a WebStorageProvider using the provider storageType\r\n * @param storageType The type of Storage provider, normal values are \"localStorage\" or \"sessionStorage\"\r\n */\r\n function WebStorageProvider(storageType, id, unloadHookContainer) {\r\n dynamicProto(WebStorageProvider, this, function (_this) {\r\n var _storage = null;\r\n var _storageKeyPrefix = DefaultStorageKey;\r\n var _maxStorageSizeInBytes = DefaultMaxStorageSizeInBytes;\r\n var _payloadHelper = null;\r\n var _storageKey = null;\r\n var _endpoint = null;\r\n var _maxStorageTime = null;\r\n var _eventDropPerTime = null;\r\n var _maxCriticalCnt = null;\r\n var _notificationManager = null;\r\n _this.id = id;\r\n _storage = _getAvailableStorage(storageType) || null;\r\n _this[\"_getDbgPlgTargets\"] = function () {\r\n return [_storageKey, _maxStorageSizeInBytes, _maxStorageTime];\r\n };\r\n _this[_DYN_INITIALIZE /* @min:%2einitialize */] = function (providerContext, endpointUrl) {\r\n if (!_storage) {\r\n return false;\r\n }\r\n var storageConfig = providerContext[_DYN_STORAGE_CONFIG /* @min:%2estorageConfig */];\r\n var itemCtx = providerContext[_DYN_ITEM_CTX /* @min:%2eitemCtx */];\r\n _payloadHelper = new PayloadHelper(itemCtx[_DYN_DIAG_LOG /* @min:%2ediagLog */]());\r\n _endpoint = getEndpointDomain(endpointUrl || providerContext[_DYN_ENDPOINT /* @min:%2eendpoint */]);\r\n var autoClean = !!storageConfig.autoClean;\r\n _notificationManager = providerContext[_DYN_NOTIFICATION_MGR /* @min:%2enotificationMgr */];\r\n var unloadHook = onConfigChange(storageConfig, function () {\r\n _maxStorageSizeInBytes = storageConfig.maxStorageSizeInBytes || DefaultMaxStorageSizeInBytes; // value checks and defaults should be applied during core config\r\n _maxStorageTime = storageConfig[_DYN_IN_STORAGE_MAX_TIME /* @min:%2einStorageMaxTime */] || DefaultMaxInStorageTime; // TODO: handle 0\r\n var dropNum = storageConfig[_DYN__EVENTS_TO_DROP_PER_2 /* @min:%2eEventsToDropPerTime */];\r\n _eventDropPerTime = isNotNullOrUndefined(dropNum) ? dropNum : EventsToDropAtOneTime;\r\n _maxCriticalCnt = storageConfig[_DYN_MAX_CRITICAL_EVTS_DR3 /* @min:%2emaxCriticalEvtsDropCnt */] || MaxCriticalEvtsDropCnt;\r\n });\r\n unloadHookContainer && unloadHookContainer.add(unloadHook);\r\n // currently, won't handle endpoint change here\r\n // new endpoint will open a new db\r\n // endpoint change will be handled at offline batch level\r\n // namePrefix should not contain any \"_\"\r\n _storageKeyPrefix = storageConfig[_DYN_STORAGE_KEY_PREFIX /* @min:%2estorageKeyPrefix */] || DefaultStorageKey;\r\n _storageKey = _storageKeyPrefix + \"_\" + Version + \"_\" + _endpoint;\r\n if (autoClean) {\r\n // won't wait response here\r\n _this.clean();\r\n }\r\n // TODO: handle versoin Upgrade\r\n //_checkVersion();\r\n return true;\r\n };\r\n /**\r\n * Identifies whether this storage provider support synchronous requests\r\n */\r\n _this[_DYN_SUPPORTS_SYNC_REQUES4 /* @min:%2esupportsSyncRequests */] = function () {\r\n return true;\r\n };\r\n /**\r\n * Get all of the currently cached events from the storage mechanism\r\n */\r\n _this.getAllEvents = function (cnt) {\r\n try {\r\n if (!_storage) {\r\n // if not init, return null\r\n return;\r\n }\r\n return _getEvts(cnt);\r\n }\r\n catch (e) {\r\n return createAsyncRejectedPromise(e);\r\n }\r\n };\r\n /**\r\n * Get Next cached event from the storage mechanism\r\n */\r\n _this[_DYN_GET_NEXT_BATCH /* @min:%2egetNextBatch */] = function () {\r\n try {\r\n if (!_storage) {\r\n // if not init, return null\r\n return;\r\n }\r\n // set ordered to true, to make sure to get earliest events first\r\n return _getEvts(1, true);\r\n }\r\n catch (e) {\r\n return createAsyncRejectedPromise(e);\r\n }\r\n };\r\n function _getEvts(cnt, ordered) {\r\n var allItems = [];\r\n var theStore = _fetchStoredDb(_storageKey).db;\r\n if (theStore) {\r\n var events = theStore[_DYN_EVTS /* @min:%2eevts */];\r\n forEachMap(events, function (evt) {\r\n if (evt) {\r\n if (evt[_DYN_IS_ARR /* @min:%2eisArr */]) {\r\n evt = _payloadHelper.base64ToArr(evt);\r\n }\r\n allItems[_DYN_PUSH /* @min:%2epush */](evt);\r\n }\r\n if (cnt && allItems && allItems[_DYN_LENGTH /* @min:%2elength */] == cnt) {\r\n return false;\r\n }\r\n return true;\r\n }, ordered);\r\n }\r\n return allItems;\r\n }\r\n /**\r\n * Stores the value into the storage using the specified key.\r\n * @param key - The key value to use for the value\r\n * @param value - The actual value of the request\r\n */\r\n _this[_DYN_ADD_EVENT /* @min:%2eaddEvent */] = function (key, evt, itemCtx) {\r\n try {\r\n var theStore = _fetchStoredDb(_storageKey);\r\n evt.id = evt.id || getTimeId();\r\n evt[_DYN_CRITICAL_CNT /* @min:%2ecriticalCnt */] = evt[_DYN_CRITICAL_CNT /* @min:%2ecriticalCnt */] || 0;\r\n var events = theStore.db[_DYN_EVTS /* @min:%2eevts */];\r\n var id_1 = evt.id;\r\n if (evt && evt[_DYN_IS_ARR /* @min:%2eisArr */]) {\r\n evt = _payloadHelper.base64ToStr(evt);\r\n }\r\n var preDroppedCnt = 0;\r\n // eslint-disable-next-line no-constant-condition\r\n while (true && evt) {\r\n events[id_1] = evt;\r\n if (_updateStoredDb(theStore)) {\r\n // Database successfully updated\r\n if (preDroppedCnt && _notificationManager) {\r\n // only send notification when batches are updated successfully in storage\r\n batchDropNotification(_notificationManager, preDroppedCnt, 2 /* eBatchDiscardedReason.CleanStorage */);\r\n }\r\n return evt;\r\n }\r\n // Could not not add events to storage assuming its full, so drop events to make space\r\n // or max size exceeded\r\n delete events[id_1];\r\n var droppedCnt = _dropEventsUpToPersistence(_maxCriticalCnt, events, _eventDropPerTime);\r\n preDroppedCnt += droppedCnt;\r\n if (!droppedCnt) {\r\n // Can't free any space for event\r\n return createAsyncRejectedPromise(new Error(\"Unable to free up event space\"));\r\n }\r\n }\r\n }\r\n catch (e) {\r\n return createAsyncRejectedPromise(e);\r\n }\r\n };\r\n /**\r\n * Removes the value associated with the provided key\r\n * @param evts - The events to be removed\r\n */\r\n _this[_DYN_REMOVE_EVENTS /* @min:%2eremoveEvents */] = function (evts) {\r\n try {\r\n var theStore = _fetchStoredDb(_storageKey, false);\r\n var currentDb = theStore.db;\r\n if (currentDb) {\r\n var events = currentDb[_DYN_EVTS /* @min:%2eevts */];\r\n try {\r\n for (var i = 0; i < evts[_DYN_LENGTH /* @min:%2elength */]; ++i) {\r\n var evt = evts[i];\r\n delete events[evt.id];\r\n }\r\n // Update takes care of removing the DB if it's completely empty now\r\n if (_updateStoredDb(theStore)) {\r\n return evts;\r\n }\r\n }\r\n catch (e) {\r\n // Storage corrupted\r\n }\r\n // failure here so try and remove db to unblock following events\r\n evts = _clearDatabase(theStore.key);\r\n }\r\n return evts;\r\n }\r\n catch (e) {\r\n return createAsyncRejectedPromise(e);\r\n }\r\n };\r\n /**\r\n * Removes all entries from the storage provider for the current endpoint and returns them as part of the response, if there are any.\r\n */\r\n _this[_DYN_CLEAR /* @min:%2eclear */] = function () {\r\n try {\r\n var removedItems_1 = [];\r\n var theStore = _fetchStoredDb(_storageKey, false);\r\n var storedDb = theStore.db;\r\n if (storedDb) {\r\n var events_1 = storedDb[_DYN_EVTS /* @min:%2eevts */];\r\n forEachMap(events_1, function (evt) {\r\n if (evt) {\r\n delete events_1[evt.id];\r\n removedItems_1[_DYN_PUSH /* @min:%2epush */](evt);\r\n }\r\n return true;\r\n });\r\n _updateStoredDb(theStore);\r\n }\r\n return removedItems_1;\r\n }\r\n catch (e) {\r\n // Unable to clear the database\r\n return createAsyncRejectedPromise(e);\r\n }\r\n };\r\n _this.clean = function () {\r\n var storeDetails = _fetchStoredDb(_storageKey, false);\r\n var currentDb = storeDetails.db;\r\n if (currentDb) {\r\n var events = currentDb[_DYN_EVTS /* @min:%2eevts */];\r\n try {\r\n var isDropped = _dropMaxTimeEvents(_maxStorageTime, events, _eventDropPerTime, _notificationManager);\r\n if (isDropped) {\r\n return _updateStoredDb(storeDetails);\r\n }\r\n return true;\r\n }\r\n catch (e) {\r\n // should not throw errors here\r\n // because we don't want to block following process\r\n }\r\n return false;\r\n }\r\n };\r\n /**\r\n * Shuts-down the telemetry plugin. This is usually called when telemetry is shut down.\r\n * This attempts to update the lastAccessTime for any storedDb\r\n */\r\n _this[_DYN_TEARDOWN /* @min:%2eteardown */] = function () {\r\n try {\r\n var theStore = _fetchStoredDb(_storageKey, false);\r\n var storedDb = theStore.db;\r\n if (storedDb) {\r\n // reset the last access time\r\n storedDb[_DYN_LAST_ACCESS_TIME /* @min:%2elastAccessTime */] = 0;\r\n _updateStoredDb(theStore, false);\r\n }\r\n }\r\n catch (e) {\r\n // Add diagnostic logging\r\n }\r\n };\r\n /**\r\n * @ignore\r\n * Creates a new json store with the StorageJSON (may be null), a null db value indicates that the store\r\n * associated with the key is empty and should be removed.\r\n * @param dbKey\r\n * @param forceRemove\r\n */\r\n function _newStore(dbKey, db) {\r\n return {\r\n key: dbKey,\r\n db: db\r\n };\r\n }\r\n function _fetchStoredDb(dbKey, returnDefault) {\r\n var _a;\r\n if (returnDefault === void 0) { returnDefault = true; }\r\n var dbToStore = null;\r\n if (_storage) {\r\n var previousDb = _storage.getItem(dbKey);\r\n if (previousDb) {\r\n try {\r\n dbToStore = getJSON().parse(previousDb);\r\n }\r\n catch (e) {\r\n // storage corrupted\r\n _storage[_DYN_REMOVE_ITEM /* @min:%2eremoveItem */](dbKey);\r\n }\r\n }\r\n if (returnDefault && !dbToStore) {\r\n // Create and return a default empty database\r\n dbToStore = (_a = {\r\n evts: {}\r\n },\r\n _a[_DYN_LAST_ACCESS_TIME /* @min:lastAccessTime */] = 0,\r\n _a);\r\n }\r\n }\r\n return _newStore(dbKey, dbToStore);\r\n }\r\n function _updateStoredDb(jsonStore, updateLastAccessTime) {\r\n if (updateLastAccessTime === void 0) { updateLastAccessTime = true; }\r\n //let removeDb = true;\r\n var dbToStore = jsonStore.db;\r\n if (dbToStore) {\r\n if (updateLastAccessTime) {\r\n // Update the last access time\r\n dbToStore.lastAccessTime = (new Date())[_DYN_GET_TIME /* @min:%2egetTime */]();\r\n }\r\n }\r\n try {\r\n var jsonString = getJSON().stringify(dbToStore);\r\n if (jsonString[_DYN_LENGTH /* @min:%2elength */] > _maxStorageSizeInBytes) {\r\n // We can't store the database as it would exceed the configured max size\r\n return false;\r\n }\r\n _storage && _storage.setItem(jsonStore.key, jsonString);\r\n //}\r\n }\r\n catch (e) {\r\n // catch exception due to trying to store or clear JSON\r\n // We could not store the database\r\n return false;\r\n }\r\n return true;\r\n }\r\n function _clearDatabase(dbKey) {\r\n var removedItems = [];\r\n var storeDetails = _fetchStoredDb(dbKey, false);\r\n var currentDb = storeDetails.db;\r\n if (currentDb) {\r\n var events = currentDb[_DYN_EVTS /* @min:%2eevts */];\r\n try {\r\n forEachMap(events, function (evt) {\r\n if (evt) {\r\n removedItems[_DYN_PUSH /* @min:%2epush */](evt);\r\n }\r\n return true;\r\n });\r\n }\r\n catch (e) {\r\n // catch exception due to trying to store or clear JSON\r\n }\r\n // Remove the entire stored database\r\n _storage && _storage[_DYN_REMOVE_ITEM /* @min:%2eremoveItem */](storeDetails.key);\r\n }\r\n return removedItems;\r\n }\r\n });\r\n }\r\n /**\r\n * Initializes the provider using the config\r\n * @param providerContext The provider context that should be used to initialize the provider\r\n * @returns True if the provider is initialized and available for use otherwise false\r\n */\r\n WebStorageProvider.prototype.initialize = function (providerContext) {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n return false;\r\n };\r\n /**\r\n * Identifies whether this storage provider support synchronous requests\r\n */\r\n WebStorageProvider.prototype.supportsSyncRequests = function () {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n return false;\r\n };\r\n /**\r\n * Get all of the currently cached events from the storage mechanism\r\n */\r\n WebStorageProvider.prototype.getAllEvents = function (cnt) {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n return null;\r\n };\r\n /**\r\n * Get the Next one cached batch from the storage mechanism\r\n */\r\n WebStorageProvider.prototype.getNextBatch = function () {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n return null;\r\n };\r\n /**\r\n * Stores the value into the storage using the specified key.\r\n * @param key - The key value to use for the value\r\n * @param evt - The actual event of the request\r\n * @param itemCtx - This is the context for the current request, ITelemetryPlugin instances\r\n * can optionally use this to access the current core instance or define / pass additional information\r\n * to later plugins (vs appending items to the telemetry item)\r\n */\r\n WebStorageProvider.prototype.addEvent = function (key, evt, itemCtx) {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n return;\r\n };\r\n /**\r\n * Removes the value associated with the provided key\r\n * @param evts - The events to be removed\r\n */\r\n WebStorageProvider.prototype.removeEvents = function (evts) {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n return;\r\n };\r\n /**\r\n * Removes all entries from the storage provider, if there are any.\r\n */\r\n WebStorageProvider.prototype.clear = function () {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n return;\r\n };\r\n /**\r\n * Removes all entries with stroage time longer than inStorageMaxTime from the storage provider\r\n */\r\n WebStorageProvider.prototype.clean = function () {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n return;\r\n };\r\n /**\r\n * Shuts-down the telemetry plugin. This is usually called when telemetry is shut down.\r\n */\r\n WebStorageProvider.prototype.teardown = function () {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n };\r\n return WebStorageProvider;\r\n}());\r\nexport { WebStorageProvider };\r\n//# sourceMappingURL=WebStorageProvider.js.map"],"names":[],"mappings":";;;;AAA4D;AAC1B;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;0DAqEM,CAAC;;;;;8BACuB;AAC9B;AACA;AACA"}
1
+ {"version":3,"file":"WebStorageProvider.js.map","sources":["WebStorageProvider.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\nimport dynamicProto from \"@microsoft/dynamicproto-js\";\r\nimport { getGlobal, getJSON, isNotNullOrUndefined, onConfigChange } from \"@microsoft/applicationinsights-core-js\";\r\nimport { createAsyncRejectedPromise } from \"@nevware21/ts-async\";\r\nimport { batchDropNotification, forEachMap, getEndpointDomain, getTimeFromId, getTimeId } from \"../Helpers/Utils\";\r\nimport { PayloadHelper } from \"../PayloadHelper\";\r\nimport { _DYN_ADD_EVENT, _DYN_CLEAR, _DYN_CRITICAL_CNT, _DYN_DIAG_LOG, _DYN_ENDPOINT, _DYN_EVTS, _DYN_GET_NEXT_BATCH, _DYN_GET_TIME, _DYN_INITIALIZE, _DYN_IN_STORAGE_MAX_TIME, _DYN_IS_ARR, _DYN_ITEM_CTX, _DYN_LAST_ACCESS_TIME, _DYN_LENGTH, _DYN_MAX_CRITICAL_EVTS_DR3, _DYN_NAME, _DYN_NOTIFICATION_MGR, _DYN_PUSH, _DYN_REMOVE_EVENTS, _DYN_REMOVE_ITEM, _DYN_STORAGE_CONFIG, _DYN_STORAGE_KEY_PREFIX, _DYN_SUPPORTS_SYNC_REQUES4, _DYN_TEARDOWN, _DYN__EVENTS_TO_DROP_PER_2 } from \"../__DynamicConstants\";\r\n//TODO: move all const to one file\r\nvar EventsToDropAtOneTime = 10;\r\nvar Version = \"1\";\r\nvar DefaultStorageKey = \"AIOffline\";\r\nvar DefaultMaxStorageSizeInBytes = 5000000;\r\nvar MaxCriticalEvtsDropCnt = 2;\r\nvar DefaultMaxInStorageTime = 604800000; //7*24*60*60*1000 7days\r\n// Private helper methods that are not exposed as class methods\r\nfunction _isQuotaExceeded(storage, e) {\r\n var result = false;\r\n if (e instanceof DOMException) {\r\n // test name field too, because code might not be present\r\n if (e.code === 22 || e[_DYN_NAME /* @min:%2ename */] === \"QuotaExceededError\" || // everything except Firefox\r\n e.code === 1014 || e[_DYN_NAME /* @min:%2ename */] === \"NS_ERROR_DOM_QUOTA_REACHED\") { // Firefox\r\n if (storage && storage[_DYN_LENGTH /* @min:%2elength */] !== 0) {\r\n // acknowledge QuotaExceededError only if there's something already stored\r\n result = true;\r\n }\r\n }\r\n }\r\n return result;\r\n}\r\n/**\r\n* Check and return that the storage type exists and has space to use\r\n*/\r\nfunction _getAvailableStorage(type) {\r\n var global = getGlobal() || {};\r\n var storage = null;\r\n try {\r\n storage = (global[type]);\r\n if (storage) {\r\n var x = \"__storage_test__\";\r\n storage.setItem(x, x);\r\n storage[_DYN_REMOVE_ITEM /* @min:%2eremoveItem */](x);\r\n }\r\n }\r\n catch (e) {\r\n if (!_isQuotaExceeded(storage, e)) {\r\n // If not Quota exception then assume not available\r\n storage = null;\r\n }\r\n }\r\n return storage;\r\n}\r\n// will drop batches with no critical evts first\r\nfunction _dropEventsUpToPersistence(maxCnt, events, eventsToDropAtOneTime) {\r\n var dropKeys = [];\r\n var persistenceCnt = 0;\r\n var droppedEvents = 0;\r\n while (persistenceCnt <= maxCnt && droppedEvents < eventsToDropAtOneTime) {\r\n forEachMap(events, function (evt, key) {\r\n if (evt[_DYN_CRITICAL_CNT /* @min:%2ecriticalCnt */] === persistenceCnt) {\r\n dropKeys[_DYN_PUSH /* @min:%2epush */](key);\r\n droppedEvents++;\r\n }\r\n return (droppedEvents < eventsToDropAtOneTime);\r\n });\r\n if (droppedEvents > 0) {\r\n for (var lp = 0; lp < dropKeys[_DYN_LENGTH /* @min:%2elength */]; lp++) {\r\n delete events[dropKeys[lp]];\r\n }\r\n return droppedEvents;\r\n }\r\n persistenceCnt++;\r\n }\r\n return droppedEvents;\r\n}\r\nfunction _dropMaxTimeEvents(maxStorageTime, events, eventsToDropAtOneTime, mgr) {\r\n var dropKeys = [];\r\n var droppedEvents = 0;\r\n var currentTime = (new Date())[_DYN_GET_TIME /* @min:%2egetTime */]() + 1; // handle appended random float number\r\n var minStartTime = (currentTime - maxStorageTime);\r\n try {\r\n forEachMap(events, function (evt, key) {\r\n var id = getTimeFromId(key);\r\n if (id <= minStartTime) {\r\n dropKeys[_DYN_PUSH /* @min:%2epush */](key);\r\n droppedEvents++;\r\n }\r\n return (droppedEvents < eventsToDropAtOneTime);\r\n });\r\n if (droppedEvents > 0) {\r\n for (var lp = 0; lp < dropKeys[_DYN_LENGTH /* @min:%2elength */]; lp++) {\r\n delete events[dropKeys[lp]];\r\n }\r\n if (mgr) {\r\n batchDropNotification(mgr, droppedEvents, 3 /* eBatchDiscardedReason.MaxInStorageTimeExceeded */);\r\n }\r\n return true;\r\n }\r\n }\r\n catch (e) {\r\n // catch drop events error\r\n }\r\n return droppedEvents > 0;\r\n}\r\n/**\r\n * Class that implements storing of events using the WebStorage Api ((window||globalThis||self).localstorage, (window||globalThis||self).sessionStorage).\r\n */\r\nvar WebStorageProvider = /** @class */ (function () {\r\n /**\r\n * Creates a WebStorageProvider using the provider storageType\r\n * @param storageType The type of Storage provider, normal values are \"localStorage\" or \"sessionStorage\"\r\n */\r\n function WebStorageProvider(storageType, id, unloadHookContainer) {\r\n dynamicProto(WebStorageProvider, this, function (_this) {\r\n var _storage = null;\r\n var _storageKeyPrefix = DefaultStorageKey;\r\n var _maxStorageSizeInBytes = DefaultMaxStorageSizeInBytes;\r\n var _payloadHelper = null;\r\n var _storageKey = null;\r\n var _endpoint = null;\r\n var _maxStorageTime = null;\r\n var _eventDropPerTime = null;\r\n var _maxCriticalCnt = null;\r\n var _notificationManager = null;\r\n _this.id = id;\r\n _storage = _getAvailableStorage(storageType) || null;\r\n _this[\"_getDbgPlgTargets\"] = function () {\r\n return [_storageKey, _maxStorageSizeInBytes, _maxStorageTime];\r\n };\r\n _this[_DYN_INITIALIZE /* @min:%2einitialize */] = function (providerContext, endpointUrl) {\r\n if (!_storage) {\r\n return false;\r\n }\r\n var storageConfig = providerContext[_DYN_STORAGE_CONFIG /* @min:%2estorageConfig */];\r\n var itemCtx = providerContext[_DYN_ITEM_CTX /* @min:%2eitemCtx */];\r\n _payloadHelper = new PayloadHelper(itemCtx[_DYN_DIAG_LOG /* @min:%2ediagLog */]());\r\n _endpoint = getEndpointDomain(endpointUrl || providerContext[_DYN_ENDPOINT /* @min:%2eendpoint */]);\r\n var autoClean = !!storageConfig.autoClean;\r\n _notificationManager = providerContext[_DYN_NOTIFICATION_MGR /* @min:%2enotificationMgr */];\r\n var unloadHook = onConfigChange(storageConfig, function () {\r\n _maxStorageSizeInBytes = storageConfig.maxStorageSizeInBytes || DefaultMaxStorageSizeInBytes; // value checks and defaults should be applied during core config\r\n _maxStorageTime = storageConfig[_DYN_IN_STORAGE_MAX_TIME /* @min:%2einStorageMaxTime */] || DefaultMaxInStorageTime; // TODO: handle 0\r\n var dropNum = storageConfig[_DYN__EVENTS_TO_DROP_PER_2 /* @min:%2eEventsToDropPerTime */];\r\n _eventDropPerTime = isNotNullOrUndefined(dropNum) ? dropNum : EventsToDropAtOneTime;\r\n _maxCriticalCnt = storageConfig[_DYN_MAX_CRITICAL_EVTS_DR3 /* @min:%2emaxCriticalEvtsDropCnt */] || MaxCriticalEvtsDropCnt;\r\n });\r\n unloadHookContainer && unloadHookContainer.add(unloadHook);\r\n // currently, won't handle endpoint change here\r\n // new endpoint will open a new db\r\n // endpoint change will be handled at offline batch level\r\n // namePrefix should not contain any \"_\"\r\n _storageKeyPrefix = storageConfig[_DYN_STORAGE_KEY_PREFIX /* @min:%2estorageKeyPrefix */] || DefaultStorageKey;\r\n _storageKey = _storageKeyPrefix + \"_\" + Version + \"_\" + _endpoint;\r\n if (autoClean) {\r\n // won't wait response here\r\n _this.clean();\r\n }\r\n // TODO: handle versoin Upgrade\r\n //_checkVersion();\r\n return true;\r\n };\r\n /**\r\n * Identifies whether this storage provider support synchronous requests\r\n */\r\n _this[_DYN_SUPPORTS_SYNC_REQUES4 /* @min:%2esupportsSyncRequests */] = function () {\r\n return true;\r\n };\r\n /**\r\n * Get all of the currently cached events from the storage mechanism\r\n */\r\n _this.getAllEvents = function (cnt) {\r\n try {\r\n if (!_storage) {\r\n // if not init, return null\r\n return;\r\n }\r\n return _getEvts(cnt);\r\n }\r\n catch (e) {\r\n return createAsyncRejectedPromise(e);\r\n }\r\n };\r\n /**\r\n * Get Next cached event from the storage mechanism\r\n */\r\n _this[_DYN_GET_NEXT_BATCH /* @min:%2egetNextBatch */] = function () {\r\n try {\r\n if (!_storage) {\r\n // if not init, return null\r\n return;\r\n }\r\n // set ordered to true, to make sure to get earliest events first\r\n return _getEvts(1, true);\r\n }\r\n catch (e) {\r\n return createAsyncRejectedPromise(e);\r\n }\r\n };\r\n function _getEvts(cnt, ordered) {\r\n var allItems = [];\r\n var theStore = _fetchStoredDb(_storageKey).db;\r\n if (theStore) {\r\n var events = theStore[_DYN_EVTS /* @min:%2eevts */];\r\n forEachMap(events, function (evt) {\r\n if (evt) {\r\n if (evt[_DYN_IS_ARR /* @min:%2eisArr */]) {\r\n evt = _payloadHelper.base64ToArr(evt);\r\n }\r\n allItems[_DYN_PUSH /* @min:%2epush */](evt);\r\n }\r\n if (cnt && allItems && allItems[_DYN_LENGTH /* @min:%2elength */] == cnt) {\r\n return false;\r\n }\r\n return true;\r\n }, ordered);\r\n }\r\n return allItems;\r\n }\r\n /**\r\n * Stores the value into the storage using the specified key.\r\n * @param key - The key value to use for the value\r\n * @param value - The actual value of the request\r\n */\r\n _this[_DYN_ADD_EVENT /* @min:%2eaddEvent */] = function (key, evt, itemCtx) {\r\n try {\r\n var theStore = _fetchStoredDb(_storageKey);\r\n evt.id = evt.id || getTimeId();\r\n evt[_DYN_CRITICAL_CNT /* @min:%2ecriticalCnt */] = evt[_DYN_CRITICAL_CNT /* @min:%2ecriticalCnt */] || 0;\r\n var events = theStore.db[_DYN_EVTS /* @min:%2eevts */];\r\n var id_1 = evt.id;\r\n if (evt && evt[_DYN_IS_ARR /* @min:%2eisArr */]) {\r\n evt = _payloadHelper.base64ToStr(evt);\r\n }\r\n var preDroppedCnt = 0;\r\n // eslint-disable-next-line no-constant-condition\r\n while (true && evt) {\r\n events[id_1] = evt;\r\n if (_updateStoredDb(theStore)) {\r\n // Database successfully updated\r\n if (preDroppedCnt && _notificationManager) {\r\n // only send notification when batches are updated successfully in storage\r\n batchDropNotification(_notificationManager, preDroppedCnt, 2 /* eBatchDiscardedReason.CleanStorage */);\r\n }\r\n return evt;\r\n }\r\n // Could not not add events to storage assuming its full, so drop events to make space\r\n // or max size exceeded\r\n delete events[id_1];\r\n var droppedCnt = _dropEventsUpToPersistence(_maxCriticalCnt, events, _eventDropPerTime);\r\n preDroppedCnt += droppedCnt;\r\n if (!droppedCnt) {\r\n // Can't free any space for event\r\n return createAsyncRejectedPromise(new Error(\"Unable to free up event space\"));\r\n }\r\n }\r\n }\r\n catch (e) {\r\n return createAsyncRejectedPromise(e);\r\n }\r\n };\r\n /**\r\n * Removes the value associated with the provided key\r\n * @param evts - The events to be removed\r\n */\r\n _this[_DYN_REMOVE_EVENTS /* @min:%2eremoveEvents */] = function (evts) {\r\n try {\r\n var theStore = _fetchStoredDb(_storageKey, false);\r\n var currentDb = theStore.db;\r\n if (currentDb) {\r\n var events = currentDb[_DYN_EVTS /* @min:%2eevts */];\r\n try {\r\n for (var i = 0; i < evts[_DYN_LENGTH /* @min:%2elength */]; ++i) {\r\n var evt = evts[i];\r\n delete events[evt.id];\r\n }\r\n // Update takes care of removing the DB if it's completely empty now\r\n if (_updateStoredDb(theStore)) {\r\n return evts;\r\n }\r\n }\r\n catch (e) {\r\n // Storage corrupted\r\n }\r\n // failure here so try and remove db to unblock following events\r\n evts = _clearDatabase(theStore.key);\r\n }\r\n return evts;\r\n }\r\n catch (e) {\r\n return createAsyncRejectedPromise(e);\r\n }\r\n };\r\n /**\r\n * Removes all entries from the storage provider for the current endpoint and returns them as part of the response, if there are any.\r\n */\r\n _this[_DYN_CLEAR /* @min:%2eclear */] = function () {\r\n try {\r\n var removedItems_1 = [];\r\n var theStore = _fetchStoredDb(_storageKey, false);\r\n var storedDb = theStore.db;\r\n if (storedDb) {\r\n var events_1 = storedDb[_DYN_EVTS /* @min:%2eevts */];\r\n forEachMap(events_1, function (evt) {\r\n if (evt) {\r\n delete events_1[evt.id];\r\n removedItems_1[_DYN_PUSH /* @min:%2epush */](evt);\r\n }\r\n return true;\r\n });\r\n _updateStoredDb(theStore);\r\n }\r\n return removedItems_1;\r\n }\r\n catch (e) {\r\n // Unable to clear the database\r\n return createAsyncRejectedPromise(e);\r\n }\r\n };\r\n _this.clean = function () {\r\n var storeDetails = _fetchStoredDb(_storageKey, false);\r\n var currentDb = storeDetails.db;\r\n if (currentDb) {\r\n var events = currentDb[_DYN_EVTS /* @min:%2eevts */];\r\n try {\r\n var isDropped = _dropMaxTimeEvents(_maxStorageTime, events, _eventDropPerTime, _notificationManager);\r\n if (isDropped) {\r\n return _updateStoredDb(storeDetails);\r\n }\r\n return true;\r\n }\r\n catch (e) {\r\n // should not throw errors here\r\n // because we don't want to block following process\r\n }\r\n return false;\r\n }\r\n };\r\n /**\r\n * Shuts-down the telemetry plugin. This is usually called when telemetry is shut down.\r\n * This attempts to update the lastAccessTime for any storedDb\r\n */\r\n _this[_DYN_TEARDOWN /* @min:%2eteardown */] = function () {\r\n try {\r\n var theStore = _fetchStoredDb(_storageKey, false);\r\n var storedDb = theStore.db;\r\n if (storedDb) {\r\n // reset the last access time\r\n storedDb[_DYN_LAST_ACCESS_TIME /* @min:%2elastAccessTime */] = 0;\r\n _updateStoredDb(theStore, false);\r\n }\r\n }\r\n catch (e) {\r\n // Add diagnostic logging\r\n }\r\n };\r\n /**\r\n * @ignore\r\n * Creates a new json store with the StorageJSON (may be null), a null db value indicates that the store\r\n * associated with the key is empty and should be removed.\r\n * @param dbKey\r\n * @param forceRemove\r\n */\r\n function _newStore(dbKey, db) {\r\n return {\r\n key: dbKey,\r\n db: db\r\n };\r\n }\r\n function _fetchStoredDb(dbKey, returnDefault) {\r\n var _a;\r\n if (returnDefault === void 0) { returnDefault = true; }\r\n var dbToStore = null;\r\n if (_storage) {\r\n var previousDb = _storage.getItem(dbKey);\r\n if (previousDb) {\r\n try {\r\n dbToStore = getJSON().parse(previousDb);\r\n }\r\n catch (e) {\r\n // storage corrupted\r\n _storage[_DYN_REMOVE_ITEM /* @min:%2eremoveItem */](dbKey);\r\n }\r\n }\r\n if (returnDefault && !dbToStore) {\r\n // Create and return a default empty database\r\n dbToStore = (_a = {\r\n evts: {}\r\n },\r\n _a[_DYN_LAST_ACCESS_TIME /* @min:lastAccessTime */] = 0,\r\n _a);\r\n }\r\n }\r\n return _newStore(dbKey, dbToStore);\r\n }\r\n function _updateStoredDb(jsonStore, updateLastAccessTime) {\r\n if (updateLastAccessTime === void 0) { updateLastAccessTime = true; }\r\n //let removeDb = true;\r\n var dbToStore = jsonStore.db;\r\n if (dbToStore) {\r\n if (updateLastAccessTime) {\r\n // Update the last access time\r\n dbToStore.lastAccessTime = (new Date())[_DYN_GET_TIME /* @min:%2egetTime */]();\r\n }\r\n }\r\n try {\r\n var jsonString = getJSON().stringify(dbToStore);\r\n if (jsonString[_DYN_LENGTH /* @min:%2elength */] > _maxStorageSizeInBytes) {\r\n // We can't store the database as it would exceed the configured max size\r\n return false;\r\n }\r\n _storage && _storage.setItem(jsonStore.key, jsonString);\r\n //}\r\n }\r\n catch (e) {\r\n // catch exception due to trying to store or clear JSON\r\n // We could not store the database\r\n return false;\r\n }\r\n return true;\r\n }\r\n function _clearDatabase(dbKey) {\r\n var removedItems = [];\r\n var storeDetails = _fetchStoredDb(dbKey, false);\r\n var currentDb = storeDetails.db;\r\n if (currentDb) {\r\n var events = currentDb[_DYN_EVTS /* @min:%2eevts */];\r\n try {\r\n forEachMap(events, function (evt) {\r\n if (evt) {\r\n removedItems[_DYN_PUSH /* @min:%2epush */](evt);\r\n }\r\n return true;\r\n });\r\n }\r\n catch (e) {\r\n // catch exception due to trying to store or clear JSON\r\n }\r\n // Remove the entire stored database\r\n _storage && _storage[_DYN_REMOVE_ITEM /* @min:%2eremoveItem */](storeDetails.key);\r\n }\r\n return removedItems;\r\n }\r\n });\r\n }\r\n /**\r\n * Initializes the provider using the config\r\n * @param providerContext The provider context that should be used to initialize the provider\r\n * @returns True if the provider is initialized and available for use otherwise false\r\n */\r\n WebStorageProvider.prototype.initialize = function (providerContext) {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n return false;\r\n };\r\n /**\r\n * Identifies whether this storage provider support synchronous requests\r\n */\r\n WebStorageProvider.prototype.supportsSyncRequests = function () {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n return false;\r\n };\r\n /**\r\n * Get all of the currently cached events from the storage mechanism\r\n */\r\n WebStorageProvider.prototype.getAllEvents = function (cnt) {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n return null;\r\n };\r\n /**\r\n * Get the Next one cached batch from the storage mechanism\r\n */\r\n WebStorageProvider.prototype.getNextBatch = function () {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n return null;\r\n };\r\n /**\r\n * Stores the value into the storage using the specified key.\r\n * @param key - The key value to use for the value\r\n * @param evt - The actual event of the request\r\n * @param itemCtx - This is the context for the current request, ITelemetryPlugin instances\r\n * can optionally use this to access the current core instance or define / pass additional information\r\n * to later plugins (vs appending items to the telemetry item)\r\n */\r\n WebStorageProvider.prototype.addEvent = function (key, evt, itemCtx) {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n return;\r\n };\r\n /**\r\n * Removes the value associated with the provided key\r\n * @param evts - The events to be removed\r\n */\r\n WebStorageProvider.prototype.removeEvents = function (evts) {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n return;\r\n };\r\n /**\r\n * Removes all entries from the storage provider, if there are any.\r\n */\r\n WebStorageProvider.prototype.clear = function () {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n return;\r\n };\r\n /**\r\n * Removes all entries with stroage time longer than inStorageMaxTime from the storage provider\r\n */\r\n WebStorageProvider.prototype.clean = function () {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n return;\r\n };\r\n /**\r\n * Shuts-down the telemetry plugin. This is usually called when telemetry is shut down.\r\n */\r\n WebStorageProvider.prototype.teardown = function () {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n };\r\n return WebStorageProvider;\r\n}());\r\nexport { WebStorageProvider };\r\n//# sourceMappingURL=WebStorageProvider.js.map"],"names":[],"mappings":";;;;AAA4D;AAC1B;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;0DAqEM,CAAC;;;;;8BACuB;AAC9B;AACA;AACA"}
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Offline Channel, 0.3.1-nightly3.2407-14
2
+ * Application Insights JavaScript SDK - Offline Channel, 0.3.1-nightly3.2407-16
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Offline Channel, 0.3.1-nightly3.2407-14
2
+ * Application Insights JavaScript SDK - Offline Channel, 0.3.1-nightly3.2407-16
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Offline Channel, 0.3.1-nightly3.2407-14
2
+ * Application Insights JavaScript SDK - Offline Channel, 0.3.1-nightly3.2407-16
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
  export { BatchSendStatus, BatchStoreStatus, StorageType } from "./Interfaces/IOfflineBatch";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microsoft/applicationinsights-offlinechannel-js",
3
- "version": "0.3.1-nightly3.2407-14",
3
+ "version": "0.3.1-nightly3.2407-16",
4
4
  "description": "Microsoft Application Insights JavaScript SDK Offline Channel",
5
5
  "homepage": "https://github.com/microsoft/ApplicationInsights-JS#readme",
6
6
  "author": "Microsoft Application Insights Team",
@@ -28,8 +28,8 @@
28
28
  "dependencies": {
29
29
  "@microsoft/dynamicproto-js": "^2.0.3",
30
30
  "@microsoft/applicationinsights-shims": "3.0.1",
31
- "@microsoft/applicationinsights-core-js": "3.3.1-nightly3.2407-14",
32
- "@microsoft/applicationinsights-common": "3.3.1-nightly3.2407-14",
31
+ "@microsoft/applicationinsights-core-js": "3.3.1-nightly3.2407-16",
32
+ "@microsoft/applicationinsights-common": "3.3.1-nightly3.2407-16",
33
33
  "@nevware21/ts-utils": ">= 0.11.3 < 2.x",
34
34
  "@nevware21/ts-async": ">= 0.5.2 < 2.x"
35
35
  },
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Microsoft Application Insights JavaScript SDK Offline Channel, 0.3.1-nightly3.2407-14
2
+ * Microsoft Application Insights JavaScript SDK Offline Channel, 0.3.1-nightly3.2407-16
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  *
5
5
  * Microsoft Application Insights Team
@@ -303,7 +303,8 @@ export declare interface IOfflineChannelConfiguration {
303
303
  inMemoMaxTime?: number;
304
304
  /**
305
305
  * [Optional] Identifies the maximum time in ms that items should be in persistent storage.
306
- * default: 10080000 (around 7days)
306
+ * default: 10080000 (around 2.8 hours) for versions <= 3.3.0
307
+ * default: 604800000 (around 7days) for versions > 3.3.0
307
308
  */
308
309
  inStorageMaxTime?: number;
309
310
  /**
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Microsoft Application Insights JavaScript SDK Offline Channel, 0.3.1-nightly3.2407-14
2
+ * Microsoft Application Insights JavaScript SDK Offline Channel, 0.3.1-nightly3.2407-16
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  *
5
5
  * Microsoft Application Insights Team
@@ -1881,7 +1881,8 @@ declare namespace ApplicationInsights {
1881
1881
  inMemoMaxTime?: number;
1882
1882
  /**
1883
1883
  * [Optional] Identifies the maximum time in ms that items should be in persistent storage.
1884
- * default: 10080000 (around 7days)
1884
+ * default: 10080000 (around 2.8 hours) for versions <= 3.3.0
1885
+ * default: 604800000 (around 7days) for versions > 3.3.0
1885
1886
  */
1886
1887
  inStorageMaxTime?: number;
1887
1888
  /**