@microsoft/applicationinsights-offlinechannel-js 0.3.6-nightly3.2502-13 → 0.3.6-nightly3.2503-01

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.
Files changed (32) hide show
  1. package/dist/es5/applicationinsights-offlinechannel-js.js +199 -253
  2. package/dist/es5/applicationinsights-offlinechannel-js.js.map +1 -1
  3. package/dist/es5/applicationinsights-offlinechannel-js.min.js +2 -2
  4. package/dist/es5/applicationinsights-offlinechannel-js.min.js.map +1 -1
  5. package/dist-es5/Helpers/Utils.js +4 -4
  6. package/dist-es5/Helpers/Utils.js.map +1 -1
  7. package/dist-es5/InMemoryBatch.js +4 -4
  8. package/dist-es5/InMemoryBatch.js.map +1 -1
  9. package/dist-es5/Interfaces/IInMemoryBatch.js +1 -1
  10. package/dist-es5/Interfaces/IOfflineBatch.js +1 -1
  11. package/dist-es5/Interfaces/IOfflineIndexDb.js +1 -1
  12. package/dist-es5/Interfaces/IOfflineProvider.js +1 -1
  13. package/dist-es5/Interfaces/ISender.js +1 -1
  14. package/dist-es5/OfflineBatchHandler.js +5 -5
  15. package/dist-es5/OfflineBatchHandler.js.map +1 -1
  16. package/dist-es5/OfflineChannel.js +20 -20
  17. package/dist-es5/OfflineChannel.js.map +1 -1
  18. package/dist-es5/PayloadHelper.js +1 -1
  19. package/dist-es5/Providers/IndexDbHelper.js +54 -63
  20. package/dist-es5/Providers/IndexDbHelper.js.map +1 -1
  21. package/dist-es5/Providers/IndexDbProvider.js +10 -10
  22. package/dist-es5/Providers/IndexDbProvider.js.map +1 -1
  23. package/dist-es5/Providers/WebStorageProvider.js +8 -8
  24. package/dist-es5/Providers/WebStorageProvider.js.map +1 -1
  25. package/dist-es5/Sender.js +14 -15
  26. package/dist-es5/Sender.js.map +1 -1
  27. package/dist-es5/__DynamicConstants.js +6 -25
  28. package/dist-es5/__DynamicConstants.js.map +1 -1
  29. package/dist-es5/applicationinsights-offlinechannel-js.js +1 -1
  30. package/package.json +4 -4
  31. package/types/applicationinsights-offlinechannel-js.d.ts +1 -1
  32. package/types/applicationinsights-offlinechannel-js.namespaced.d.ts +1 -1
@@ -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 = 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 - The key to associate with the database\r\n * @param db - The database\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_EVTS, _DYN_GET_NEXT_BATCH, _DYN_GET_TIME, _DYN_INITIALIZE, _DYN_IS_ARR, _DYN_LAST_ACCESS_TIME, _DYN_LENGTH, _DYN_MAX_CRITICAL_EVTS_DR3, _DYN_NOTIFICATION_MGR, _DYN_PUSH, _DYN_REMOVE_EVENTS, _DYN_REMOVE_ITEM, _DYN_STORAGE_CONFIG, _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.name === \"QuotaExceededError\" || // everything except Firefox\r\n e.code === 1014 || e.name === \"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.itemCtx;\r\n _payloadHelper = new PayloadHelper(itemCtx[_DYN_DIAG_LOG /* @min:%2ediagLog */]());\r\n _endpoint = getEndpointDomain(endpointUrl || providerContext.endpoint);\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.inStorageMaxTime || 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.storageKeyPrefix || 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 - The key to associate with the database\r\n * @param db - The database\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.6-nightly3.2502-13
2
+ * Application Insights JavaScript SDK - Offline Channel, 0.3.6-nightly3.2503-01
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -8,11 +8,11 @@ import dynamicProto from "@microsoft/dynamicproto-js";
8
8
  import { BreezeChannelIdentifier, utlSetStoragePrefix } from "@microsoft/applicationinsights-common";
9
9
  import { SenderPostManager, _throwInternal, createProcessTelemetryContext, formatErrorMessageXdr, getResponseText, onConfigChange, parseResponse, prependTransports } from "@microsoft/applicationinsights-core-js";
10
10
  import { isFunction } from "@nevware21/ts-utils";
11
- import { _DYN_ENABLE_SEND_PROMISE, _DYN_GET_EXT_CFG, _DYN_INITIALIZE, _DYN_IS_COMPLETELY_IDLE, _DYN_SEND_POST } from "./__DynamicConstants";
11
+ import { _DYN_INITIALIZE, _DYN_IS_COMPLETELY_IDLE } from "./__DynamicConstants";
12
12
  var DefaultOfflineIdentifier = "OfflineChannel";
13
13
  var PostChannelId = "PostChannel";
14
14
  function isOverrideFn(httpXHROverride) {
15
- return httpXHROverride && httpXHROverride[_DYN_SEND_POST /* @min:%2esendPOST */];
15
+ return httpXHROverride && httpXHROverride.sendPOST;
16
16
  }
17
17
  var Sender = /** @class */ (function () {
18
18
  function Sender() {
@@ -62,21 +62,21 @@ var Sender = /** @class */ (function () {
62
62
  utlSetStoragePrefix(config.storagePrefix);
63
63
  }
64
64
  var ctx = createProcessTelemetryContext(null, config, core);
65
- var offlineCfg = ctx[_DYN_GET_EXT_CFG /* @min:%2egetExtCfg */](DefaultOfflineIdentifier);
65
+ var offlineCfg = ctx.getExtCfg(DefaultOfflineIdentifier);
66
66
  _onlineChannelId = channelId || BreezeChannelIdentifier;
67
- var senderConfig = ctx[_DYN_GET_EXT_CFG /* @min:%2egetExtCfg */](_onlineChannelId, {});
67
+ var senderConfig = ctx.getExtCfg(_onlineChannelId, {});
68
68
  var offlineSenderCfg = offlineCfg.senderCfg || {};
69
69
  _fetchCredentials = null;
70
70
  if (_onlineChannelId == PostChannelId) {
71
71
  _isOneDs = true;
72
- var channelConfig = ctx[_DYN_GET_EXT_CFG /* @min:%2egetExtCfg */](PostChannelId);
72
+ var channelConfig = ctx.getExtCfg(PostChannelId);
73
73
  if (channelConfig && channelConfig["fetchCredentials"]) {
74
74
  _fetchCredentials = channelConfig["fetchCredentials"];
75
75
  }
76
76
  }
77
77
  _alwaysUseCustomSend = offlineSenderCfg.alwaysUseXhrOverride;
78
78
  // default true
79
- _enableSendPromise = !(senderConfig[_DYN_ENABLE_SEND_PROMISE /* @min:%2eenableSendPromise */] === false);
79
+ _enableSendPromise = !(senderConfig.enableSendPromise === false);
80
80
  var xhrOverride = offlineSenderCfg.httpXHROverride || senderConfig.httpXHROverride;
81
81
  var customInterface = isOverrideFn(xhrOverride) ? xhrOverride : null;
82
82
  _disableCredentials = !customInterface && _isOneDs;
@@ -127,14 +127,13 @@ var Sender = /** @class */ (function () {
127
127
  _doOnComplete(onComplete, 200, {}, res);
128
128
  }
129
129
  function _getSendPostMgrConfig() {
130
- var _a;
131
- var config = (_a = {},
132
- _a[_DYN_ENABLE_SEND_PROMISE /* @min:enableSendPromise */] = _enableSendPromise,
133
- _a.isOneDs = _isOneDs,
134
- _a.disableCredentials = _disableCredentials,
135
- _a.fetchCredentials = _fetchCredentials,
136
- _a.senderOnCompleteCallBack = _getOnCompleteFuncs(),
137
- _a);
130
+ var config = {
131
+ enableSendPromise: _enableSendPromise,
132
+ isOneDs: _isOneDs,
133
+ disableCredentials: _disableCredentials,
134
+ fetchCredentials: _fetchCredentials,
135
+ senderOnCompleteCallBack: _getOnCompleteFuncs()
136
+ };
138
137
  return config;
139
138
  }
140
139
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"Sender.js.map","sources":["Sender.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 { BreezeChannelIdentifier, utlSetStoragePrefix } from \"@microsoft/applicationinsights-common\";\r\nimport { SenderPostManager, _throwInternal, createProcessTelemetryContext, formatErrorMessageXdr, getResponseText, onConfigChange, parseResponse, prependTransports } from \"@microsoft/applicationinsights-core-js\";\r\nimport { isFunction } from \"@nevware21/ts-utils\";\r\nimport { _DYN_ENABLE_SEND_PROMISE, _DYN_GET_EXT_CFG, _DYN_INITIALIZE, _DYN_IS_COMPLETELY_IDLE, _DYN_SEND_POST } from \"./__DynamicConstants\";\r\nvar DefaultOfflineIdentifier = \"OfflineChannel\";\r\nvar PostChannelId = \"PostChannel\";\r\nfunction isOverrideFn(httpXHROverride) {\r\n return httpXHROverride && httpXHROverride[_DYN_SEND_POST /* @min:%2esendPOST */];\r\n}\r\nvar Sender = /** @class */ (function () {\r\n function Sender() {\r\n var _consecutiveErrors; // How many times in a row a retryable error condition has occurred.\r\n var _retryAt; // The time to retry at in milliseconds from 1970/01/01 (this makes the timer calculation easy).\r\n var _paused; // Flag indicating that the sending should be paused\r\n var _enableSendPromise;\r\n var _alwaysUseCustomSend;\r\n var _isInitialized;\r\n var _diagLog;\r\n var _core;\r\n var _httpInterface;\r\n var _onlineChannelId;\r\n var _isOneDs;\r\n var _sendPostMgr;\r\n var _disableCredentials;\r\n var _fetchCredentials;\r\n dynamicProto(Sender, this, function (_self, _base) {\r\n //let _sendCredentials = true; // for 1ds\r\n _initDefaults();\r\n _self.pause = function () {\r\n _clearScheduledTimer();\r\n _paused = true;\r\n };\r\n _self.resume = function () {\r\n if (_paused) {\r\n _paused = false;\r\n _retryAt = null;\r\n }\r\n };\r\n _self.getXhrInst = function (sync) {\r\n // unload events will be saved. so not return unload interface\r\n return _httpInterface;\r\n };\r\n _self[_DYN_INITIALIZE /* @min:%2einitialize */] = function (config, core, cxt, diagLog, channelId, unloadHookContainer) {\r\n _diagLog = diagLog || core.logger;\r\n if (_isInitialized) {\r\n _throwInternal(_diagLog, 1 /* eLoggingSeverity.CRITICAL */, 28 /* _eInternalMessageId.SenderNotInitialized */, \"Sender is already initialized\");\r\n }\r\n _core = core;\r\n _consecutiveErrors = 0;\r\n _retryAt = null;\r\n // This function will be re-called whenever any referenced configuration is changed\r\n var hook = onConfigChange(config, function (details) {\r\n var config = details.cfg;\r\n if (config.storagePrefix) {\r\n utlSetStoragePrefix(config.storagePrefix);\r\n }\r\n var ctx = createProcessTelemetryContext(null, config, core);\r\n var offlineCfg = ctx[_DYN_GET_EXT_CFG /* @min:%2egetExtCfg */](DefaultOfflineIdentifier);\r\n _onlineChannelId = channelId || BreezeChannelIdentifier;\r\n var senderConfig = ctx[_DYN_GET_EXT_CFG /* @min:%2egetExtCfg */](_onlineChannelId, {});\r\n var offlineSenderCfg = offlineCfg.senderCfg || {};\r\n _fetchCredentials = null;\r\n if (_onlineChannelId == PostChannelId) {\r\n _isOneDs = true;\r\n var channelConfig = ctx[_DYN_GET_EXT_CFG /* @min:%2egetExtCfg */](PostChannelId);\r\n if (channelConfig && channelConfig[\"fetchCredentials\"]) {\r\n _fetchCredentials = channelConfig[\"fetchCredentials\"];\r\n }\r\n }\r\n _alwaysUseCustomSend = offlineSenderCfg.alwaysUseXhrOverride;\r\n // default true\r\n _enableSendPromise = !(senderConfig[_DYN_ENABLE_SEND_PROMISE /* @min:%2eenableSendPromise */] === false);\r\n var xhrOverride = offlineSenderCfg.httpXHROverride || senderConfig.httpXHROverride;\r\n var customInterface = isOverrideFn(xhrOverride) ? xhrOverride : null;\r\n _disableCredentials = !customInterface && _isOneDs;\r\n var sendPostMgrConfig = _getSendPostMgrConfig();\r\n if (!_sendPostMgr) {\r\n _sendPostMgr = new SenderPostManager();\r\n _sendPostMgr[_DYN_INITIALIZE /* @min:%2einitialize */](sendPostMgrConfig, _diagLog);\r\n }\r\n else {\r\n _sendPostMgr.SetConfig(sendPostMgrConfig);\r\n }\r\n var httpInterface = null;\r\n var customTransPorts = offlineSenderCfg.transports || senderConfig.transports || [];\r\n var theTransports = prependTransports([1 /* TransportType.Xhr */, 2 /* TransportType.Fetch */, 3 /* TransportType.Beacon */], customTransPorts);\r\n httpInterface = _sendPostMgr.getSenderInst(theTransports, false);\r\n var xhrInterface = _sendPostMgr.getFallbackInst();\r\n httpInterface = _alwaysUseCustomSend ? customInterface : (httpInterface || customInterface || xhrInterface);\r\n _httpInterface = httpInterface || xhrInterface;\r\n });\r\n unloadHookContainer && unloadHookContainer.add(hook);\r\n };\r\n _self[_DYN_IS_COMPLETELY_IDLE /* @min:%2eisCompletelyIdle */] = function () {\r\n var syncPayload = 0;\r\n try {\r\n var senderPlugin = _core.getPlugin(_onlineChannelId).plugin;\r\n if (senderPlugin && isFunction(senderPlugin[_DYN_IS_COMPLETELY_IDLE /* @min:%2eisCompletelyIdle */])) {\r\n if (!senderPlugin[_DYN_IS_COMPLETELY_IDLE /* @min:%2eisCompletelyIdle */]()) {\r\n return false;\r\n }\r\n }\r\n if (_sendPostMgr) {\r\n syncPayload = _sendPostMgr.getSyncFetchPayload();\r\n }\r\n }\r\n catch (e) {\r\n // if can't get idle status of online sender, then isidle status only depends on offine sender idle status\r\n }\r\n return !_paused && syncPayload === 0;\r\n };\r\n // partial 206, parse payload (not send again)\r\n _self._doTeardown = function (unloadCtx, unloadState) {\r\n _initDefaults();\r\n };\r\n /**\r\n * success handler\r\n */\r\n function _onSuccess(res, onComplete) {\r\n _doOnComplete(onComplete, 200, {}, res);\r\n }\r\n function _getSendPostMgrConfig() {\r\n var _a;\r\n var config = (_a = {},\r\n _a[_DYN_ENABLE_SEND_PROMISE /* @min:enableSendPromise */] = _enableSendPromise,\r\n _a.isOneDs = _isOneDs,\r\n _a.disableCredentials = _disableCredentials,\r\n _a.fetchCredentials = _fetchCredentials,\r\n _a.senderOnCompleteCallBack = _getOnCompleteFuncs(),\r\n _a);\r\n return config;\r\n }\r\n /**\r\n * error handler\r\n */\r\n function _onError(message, onComplete) {\r\n _throwInternal(_diagLog, 2 /* eLoggingSeverity.WARNING */, 26 /* _eInternalMessageId.OnError */, \"Failed to send telemetry.\", { message: message });\r\n _doOnComplete(onComplete, 400, {});\r\n }\r\n function _getOnCompleteFuncs() {\r\n var funcs = {\r\n xdrOnComplete: function (response, oncomplete) {\r\n return _xdrOnLoad(response, oncomplete);\r\n },\r\n fetchOnComplete: function (response, onComplete, resValue) {\r\n var status = response.status;\r\n return _handleResponse(onComplete, status, {}, resValue);\r\n },\r\n xhrOnComplete: function (request, oncomplete) {\r\n var response = getResponseText(request);\r\n return _handleResponse(oncomplete, request.status, {}, response);\r\n }\r\n };\r\n return funcs;\r\n }\r\n function _doOnComplete(oncomplete, status, headers, response) {\r\n try {\r\n oncomplete && oncomplete(status, headers, response);\r\n }\r\n catch (e) {\r\n // eslint-disable-next-line no-empty\r\n }\r\n }\r\n function _handleResponse(oncomplete, status, headers, response) {\r\n if (status == 206 && !_isOneDs) {\r\n // for breeze, 206 is partially success, currently consider success\r\n // TODO: handle partial success\r\n _doOnComplete(oncomplete, 200, headers, response); // TODO: doc (support partial success)-> partial success add known issue (breeze)\r\n }\r\n else if (status == 204 && _isOneDs) {\r\n // one collector\r\n _doOnComplete(oncomplete, 200, headers, response);\r\n }\r\n else {\r\n _doOnComplete(oncomplete, status, headers, response);\r\n }\r\n }\r\n function _clearScheduledTimer() {\r\n _retryAt = null;\r\n }\r\n /**\r\n * xdr state changes\r\n */\r\n function _xdrOnLoad(xdr, oncomplete) {\r\n var responseText = getResponseText(xdr);\r\n if (xdr && (responseText + \"\" === \"200\" || responseText === \"\")) {\r\n _consecutiveErrors = 0;\r\n _onSuccess(responseText, oncomplete);\r\n }\r\n else {\r\n var results = parseResponse(responseText, _diagLog);\r\n if (results && results.itemsAccepted) {\r\n // TODO: onPartial success for appInsights\r\n _onSuccess(responseText, oncomplete);\r\n }\r\n else {\r\n _onError(formatErrorMessageXdr(xdr), oncomplete);\r\n }\r\n }\r\n }\r\n function _initDefaults() {\r\n _self._appId = null;\r\n _consecutiveErrors = 0;\r\n _retryAt = null;\r\n _paused = false;\r\n _isInitialized = false;\r\n _core = null;\r\n _onlineChannelId = null;\r\n _sendPostMgr = null;\r\n }\r\n });\r\n }\r\n /**\r\n * Pause the sending (transmission) of events, this will cause all events to be batched only until the maximum limits are\r\n * hit at which point new events are dropped. Will also cause events to NOT be sent during page unload, so if Session storage\r\n * is disabled events will be lost.\r\n */\r\n Sender.prototype.pause = function () {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n /**\r\n * Resume the sending (transmission) of events, this will restart the timer and any batched events will be sent using the normal\r\n * send interval.\r\n */\r\n Sender.prototype.resume = function () {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n Sender.prototype.initialize = function (config, core, cxt, diagLog, channelId, unloadHookContainer) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n /**\r\n * Trigger the immediate send of buffered data; If executing asynchronously (the default) this may (not required) return\r\n * an [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html) that will resolve once the\r\n * send is complete. The actual implementation of the `IPromise` will be a native Promise (if supported) or the default\r\n * as supplied by [ts-async library](https://github.com/nevware21/ts-async)\r\n * @param async - Indicates if the events should be sent asynchronously\r\n * @param forcedSender - Indicates the forcedSender, undefined if not passed\r\n * @returns - Nothing or optionally, if occurring asynchronously a [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html)\r\n * which will be resolved (or reject) once the send is complete, the [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html)\r\n * should only be returned when async is true.\r\n */\r\n Sender.prototype.triggerSend = function (async, forcedSender, sendReason) {\r\n if (async === void 0) { async = true; }\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n /**\r\n * Check if there are no active requests being sent.\r\n * @returns True if idle, false otherwise.\r\n */\r\n Sender.prototype.isCompletelyIdle = 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 current xhr instance\r\n */\r\n Sender.prototype.getXhrInst = function (sync) {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n return null;\r\n };\r\n Sender.prototype._doTeardown = function (unloadCtx, unloadState) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n return Sender;\r\n}());\r\nexport { Sender };\r\n//# sourceMappingURL=Sender.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;;;;;;iDAkDM,CAAC;;;;;kBACW;AAClB;AACA;AACA"}
1
+ {"version":3,"file":"Sender.js.map","sources":["Sender.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 { BreezeChannelIdentifier, utlSetStoragePrefix } from \"@microsoft/applicationinsights-common\";\r\nimport { SenderPostManager, _throwInternal, createProcessTelemetryContext, formatErrorMessageXdr, getResponseText, onConfigChange, parseResponse, prependTransports } from \"@microsoft/applicationinsights-core-js\";\r\nimport { isFunction } from \"@nevware21/ts-utils\";\r\nimport { _DYN_INITIALIZE, _DYN_IS_COMPLETELY_IDLE } from \"./__DynamicConstants\";\r\nvar DefaultOfflineIdentifier = \"OfflineChannel\";\r\nvar PostChannelId = \"PostChannel\";\r\nfunction isOverrideFn(httpXHROverride) {\r\n return httpXHROverride && httpXHROverride.sendPOST;\r\n}\r\nvar Sender = /** @class */ (function () {\r\n function Sender() {\r\n var _consecutiveErrors; // How many times in a row a retryable error condition has occurred.\r\n var _retryAt; // The time to retry at in milliseconds from 1970/01/01 (this makes the timer calculation easy).\r\n var _paused; // Flag indicating that the sending should be paused\r\n var _enableSendPromise;\r\n var _alwaysUseCustomSend;\r\n var _isInitialized;\r\n var _diagLog;\r\n var _core;\r\n var _httpInterface;\r\n var _onlineChannelId;\r\n var _isOneDs;\r\n var _sendPostMgr;\r\n var _disableCredentials;\r\n var _fetchCredentials;\r\n dynamicProto(Sender, this, function (_self, _base) {\r\n //let _sendCredentials = true; // for 1ds\r\n _initDefaults();\r\n _self.pause = function () {\r\n _clearScheduledTimer();\r\n _paused = true;\r\n };\r\n _self.resume = function () {\r\n if (_paused) {\r\n _paused = false;\r\n _retryAt = null;\r\n }\r\n };\r\n _self.getXhrInst = function (sync) {\r\n // unload events will be saved. so not return unload interface\r\n return _httpInterface;\r\n };\r\n _self[_DYN_INITIALIZE /* @min:%2einitialize */] = function (config, core, cxt, diagLog, channelId, unloadHookContainer) {\r\n _diagLog = diagLog || core.logger;\r\n if (_isInitialized) {\r\n _throwInternal(_diagLog, 1 /* eLoggingSeverity.CRITICAL */, 28 /* _eInternalMessageId.SenderNotInitialized */, \"Sender is already initialized\");\r\n }\r\n _core = core;\r\n _consecutiveErrors = 0;\r\n _retryAt = null;\r\n // This function will be re-called whenever any referenced configuration is changed\r\n var hook = onConfigChange(config, function (details) {\r\n var config = details.cfg;\r\n if (config.storagePrefix) {\r\n utlSetStoragePrefix(config.storagePrefix);\r\n }\r\n var ctx = createProcessTelemetryContext(null, config, core);\r\n var offlineCfg = ctx.getExtCfg(DefaultOfflineIdentifier);\r\n _onlineChannelId = channelId || BreezeChannelIdentifier;\r\n var senderConfig = ctx.getExtCfg(_onlineChannelId, {});\r\n var offlineSenderCfg = offlineCfg.senderCfg || {};\r\n _fetchCredentials = null;\r\n if (_onlineChannelId == PostChannelId) {\r\n _isOneDs = true;\r\n var channelConfig = ctx.getExtCfg(PostChannelId);\r\n if (channelConfig && channelConfig[\"fetchCredentials\"]) {\r\n _fetchCredentials = channelConfig[\"fetchCredentials\"];\r\n }\r\n }\r\n _alwaysUseCustomSend = offlineSenderCfg.alwaysUseXhrOverride;\r\n // default true\r\n _enableSendPromise = !(senderConfig.enableSendPromise === false);\r\n var xhrOverride = offlineSenderCfg.httpXHROverride || senderConfig.httpXHROverride;\r\n var customInterface = isOverrideFn(xhrOverride) ? xhrOverride : null;\r\n _disableCredentials = !customInterface && _isOneDs;\r\n var sendPostMgrConfig = _getSendPostMgrConfig();\r\n if (!_sendPostMgr) {\r\n _sendPostMgr = new SenderPostManager();\r\n _sendPostMgr[_DYN_INITIALIZE /* @min:%2einitialize */](sendPostMgrConfig, _diagLog);\r\n }\r\n else {\r\n _sendPostMgr.SetConfig(sendPostMgrConfig);\r\n }\r\n var httpInterface = null;\r\n var customTransPorts = offlineSenderCfg.transports || senderConfig.transports || [];\r\n var theTransports = prependTransports([1 /* TransportType.Xhr */, 2 /* TransportType.Fetch */, 3 /* TransportType.Beacon */], customTransPorts);\r\n httpInterface = _sendPostMgr.getSenderInst(theTransports, false);\r\n var xhrInterface = _sendPostMgr.getFallbackInst();\r\n httpInterface = _alwaysUseCustomSend ? customInterface : (httpInterface || customInterface || xhrInterface);\r\n _httpInterface = httpInterface || xhrInterface;\r\n });\r\n unloadHookContainer && unloadHookContainer.add(hook);\r\n };\r\n _self[_DYN_IS_COMPLETELY_IDLE /* @min:%2eisCompletelyIdle */] = function () {\r\n var syncPayload = 0;\r\n try {\r\n var senderPlugin = _core.getPlugin(_onlineChannelId).plugin;\r\n if (senderPlugin && isFunction(senderPlugin[_DYN_IS_COMPLETELY_IDLE /* @min:%2eisCompletelyIdle */])) {\r\n if (!senderPlugin[_DYN_IS_COMPLETELY_IDLE /* @min:%2eisCompletelyIdle */]()) {\r\n return false;\r\n }\r\n }\r\n if (_sendPostMgr) {\r\n syncPayload = _sendPostMgr.getSyncFetchPayload();\r\n }\r\n }\r\n catch (e) {\r\n // if can't get idle status of online sender, then isidle status only depends on offine sender idle status\r\n }\r\n return !_paused && syncPayload === 0;\r\n };\r\n // partial 206, parse payload (not send again)\r\n _self._doTeardown = function (unloadCtx, unloadState) {\r\n _initDefaults();\r\n };\r\n /**\r\n * success handler\r\n */\r\n function _onSuccess(res, onComplete) {\r\n _doOnComplete(onComplete, 200, {}, res);\r\n }\r\n function _getSendPostMgrConfig() {\r\n var config = {\r\n enableSendPromise: _enableSendPromise,\r\n isOneDs: _isOneDs,\r\n disableCredentials: _disableCredentials,\r\n fetchCredentials: _fetchCredentials,\r\n senderOnCompleteCallBack: _getOnCompleteFuncs()\r\n };\r\n return config;\r\n }\r\n /**\r\n * error handler\r\n */\r\n function _onError(message, onComplete) {\r\n _throwInternal(_diagLog, 2 /* eLoggingSeverity.WARNING */, 26 /* _eInternalMessageId.OnError */, \"Failed to send telemetry.\", { message: message });\r\n _doOnComplete(onComplete, 400, {});\r\n }\r\n function _getOnCompleteFuncs() {\r\n var funcs = {\r\n xdrOnComplete: function (response, oncomplete) {\r\n return _xdrOnLoad(response, oncomplete);\r\n },\r\n fetchOnComplete: function (response, onComplete, resValue) {\r\n var status = response.status;\r\n return _handleResponse(onComplete, status, {}, resValue);\r\n },\r\n xhrOnComplete: function (request, oncomplete) {\r\n var response = getResponseText(request);\r\n return _handleResponse(oncomplete, request.status, {}, response);\r\n }\r\n };\r\n return funcs;\r\n }\r\n function _doOnComplete(oncomplete, status, headers, response) {\r\n try {\r\n oncomplete && oncomplete(status, headers, response);\r\n }\r\n catch (e) {\r\n // eslint-disable-next-line no-empty\r\n }\r\n }\r\n function _handleResponse(oncomplete, status, headers, response) {\r\n if (status == 206 && !_isOneDs) {\r\n // for breeze, 206 is partially success, currently consider success\r\n // TODO: handle partial success\r\n _doOnComplete(oncomplete, 200, headers, response); // TODO: doc (support partial success)-> partial success add known issue (breeze)\r\n }\r\n else if (status == 204 && _isOneDs) {\r\n // one collector\r\n _doOnComplete(oncomplete, 200, headers, response);\r\n }\r\n else {\r\n _doOnComplete(oncomplete, status, headers, response);\r\n }\r\n }\r\n function _clearScheduledTimer() {\r\n _retryAt = null;\r\n }\r\n /**\r\n * xdr state changes\r\n */\r\n function _xdrOnLoad(xdr, oncomplete) {\r\n var responseText = getResponseText(xdr);\r\n if (xdr && (responseText + \"\" === \"200\" || responseText === \"\")) {\r\n _consecutiveErrors = 0;\r\n _onSuccess(responseText, oncomplete);\r\n }\r\n else {\r\n var results = parseResponse(responseText, _diagLog);\r\n if (results && results.itemsAccepted) {\r\n // TODO: onPartial success for appInsights\r\n _onSuccess(responseText, oncomplete);\r\n }\r\n else {\r\n _onError(formatErrorMessageXdr(xdr), oncomplete);\r\n }\r\n }\r\n }\r\n function _initDefaults() {\r\n _self._appId = null;\r\n _consecutiveErrors = 0;\r\n _retryAt = null;\r\n _paused = false;\r\n _isInitialized = false;\r\n _core = null;\r\n _onlineChannelId = null;\r\n _sendPostMgr = null;\r\n }\r\n });\r\n }\r\n /**\r\n * Pause the sending (transmission) of events, this will cause all events to be batched only until the maximum limits are\r\n * hit at which point new events are dropped. Will also cause events to NOT be sent during page unload, so if Session storage\r\n * is disabled events will be lost.\r\n */\r\n Sender.prototype.pause = function () {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n /**\r\n * Resume the sending (transmission) of events, this will restart the timer and any batched events will be sent using the normal\r\n * send interval.\r\n */\r\n Sender.prototype.resume = function () {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n Sender.prototype.initialize = function (config, core, cxt, diagLog, channelId, unloadHookContainer) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n /**\r\n * Trigger the immediate send of buffered data; If executing asynchronously (the default) this may (not required) return\r\n * an [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html) that will resolve once the\r\n * send is complete. The actual implementation of the `IPromise` will be a native Promise (if supported) or the default\r\n * as supplied by [ts-async library](https://github.com/nevware21/ts-async)\r\n * @param async - Indicates if the events should be sent asynchronously\r\n * @param forcedSender - Indicates the forcedSender, undefined if not passed\r\n * @returns - Nothing or optionally, if occurring asynchronously a [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html)\r\n * which will be resolved (or reject) once the send is complete, the [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html)\r\n * should only be returned when async is true.\r\n */\r\n Sender.prototype.triggerSend = function (async, forcedSender, sendReason) {\r\n if (async === void 0) { async = true; }\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n /**\r\n * Check if there are no active requests being sent.\r\n * @returns True if idle, false otherwise.\r\n */\r\n Sender.prototype.isCompletelyIdle = 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 current xhr instance\r\n */\r\n Sender.prototype.getXhrInst = function (sync) {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n return null;\r\n };\r\n Sender.prototype._doTeardown = function (unloadCtx, unloadState) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n return Sender;\r\n}());\r\nexport { Sender };\r\n//# sourceMappingURL=Sender.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;;;;;;iDAkDM,CAAC;;;;;kBACW;AAClB;AACA;AACA"}
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Offline Channel, 0.3.6-nightly3.2502-13
2
+ * Application Insights JavaScript SDK - Offline Channel, 0.3.6-nightly3.2503-01
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -8,36 +8,29 @@
8
8
  // ##############################################################
9
9
  // AUTO GENERATED FILE: This file is Auto Generated during build.
10
10
  // ##############################################################
11
- // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12
- // Note: DON'T Export these const from the package as we are still targeting ES3 this will export a mutable variables that someone could change!!!
13
- // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
14
- export var _DYN_ENDPOINT = "endpoint"; // Count: 4
11
+ // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12
+ // Note: DON'T Export these const from the package as we are still targeting ES5 which can result in a mutable variables that someone could change!!!
13
+ // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
15
14
  export var _DYN_ADD_EVENT = "addEvent"; // Count: 6
16
15
  export var _DYN_PUSH = "push"; // Count: 18
17
16
  export var _DYN_LENGTH = "length"; // Count: 52
18
17
  export var _DYN_CLEAR = "clear"; // Count: 5
19
18
  export var _DYN_GET_ITEMS = "getItems"; // Count: 4
20
19
  export var _DYN_SPLIT = "split"; // Count: 5
21
- export var _DYN_SPLICE = "splice"; // Count: 4
22
20
  export var _DYN_INITIALIZE = "initialize"; // Count: 11
23
21
  export var _DYN_DIAG_LOG = "diagLog"; // Count: 6
24
- export var _DYN_ITEM_CTX = "itemCtx"; // Count: 4
25
22
  export var _DYN_STORAGE_CONFIG = "storageConfig"; // Count: 4
26
- export var _DYN_VALUE = "value"; // Count: 12
23
+ export var _DYN_VALUE = "value"; // Count: 10
27
24
  export var _DYN_REJECTED = "rejected"; // Count: 6
28
25
  export var _DYN_SEND_NEXT_BATCH = "sendNextBatch"; // Count: 3
29
26
  export var _DYN_GET_NEXT_BATCH = "getNextBatch"; // Count: 5
30
27
  export var _DYN_REMOVE_EVENTS = "removeEvents"; // Count: 3
31
28
  export var _DYN_DATA = "data"; // Count: 11
32
- export var _DYN_SEND_POST = "sendPOST"; // Count: 3
33
29
  export var _DYN_ATTEMP_CNT = "attempCnt"; // Count: 4
34
30
  export var _DYN_STATE = "state"; // Count: 9
35
31
  export var _DYN_TEARDOWN = "teardown"; // Count: 6
36
32
  export var _DYN_IS_ARR = "isArr"; // Count: 5
37
33
  export var _DYN_INDEX_OF = "indexOf"; // Count: 9
38
- export var _DYN__CRITICAL = "Critical"; // Count: 3
39
- export var _DYN__NORMAL = "Normal"; // Count: 4
40
- export var _DYN_IS_ONLINE = "isOnline"; // Count: 3
41
34
  export var _DYN_CANCEL = "cancel"; // Count: 5
42
35
  export var _DYN_PROCESS_NEXT = "processNext"; // Count: 3
43
36
  export var _DYN_PERSISTENCE = "persistence"; // Count: 11
@@ -45,36 +38,24 @@ export var _DYN_ONUNLOAD_FLUSH = "onunloadFlush"; // Count: 3
45
38
  export var _DYN_BATCH_HANDLER = "batchHandler"; // Count: 5
46
39
  export var _DYN_MIN_PERSISTENCE_CACH0 = "minPersistenceCacheLevel"; // Count: 2
47
40
  export var _DYN_REFRESH = "refresh"; // Count: 4
48
- export var _DYN_CREATE_ONE_DSPAYLOAD = "createOneDSPayload"; // Count: 2
49
41
  export var _DYN_CRITICAL_CNT = "criticalCnt"; // Count: 8
50
42
  export var _DYN_IS_COMPLETELY_IDLE = "isCompletelyIdle"; // Count: 5
51
43
  export var _DYN_INSTRUMENTATION_KEY = "instrumentationKey"; // Count: 4
52
- export var _DYN_GET_OFFLINE_SUPPORT = "getOfflineSupport"; // Count: 2
53
44
  export var _DYN_OVERRIDE_INSTRUMENTA1 = "overrideInstrumentationKey"; // Count: 2
54
45
  export var _DYN_NOTIFICATION_MGR = "notificationMgr"; // Count: 3
55
46
  export var _DYN_TO_STRING = "toString"; // Count: 5
56
- export var _DYN_GET_EXT_CFG = "getExtCfg"; // Count: 3
57
- export var _DYN_ENABLE_SEND_PROMISE = "enableSendPromise"; // Count: 2
58
47
  export var _DYN_CHAR_CODE_AT = "charCodeAt"; // Count: 3
59
48
  export var _DYN_CHAR_AT = "charAt"; // Count: 8
60
49
  export var _DYN_FROM_CHAR_CODE = "fromCharCode"; // Count: 3
61
50
  export var _DYN_GET_TIME = "getTime"; // Count: 5
62
- export var _DYN_NAME = "name"; // Count: 7
63
51
  export var _DYN_DB_HDL = "dbHdl"; // Count: 7
64
52
  export var _DYN_IS_AVAILABLE = "isAvailable"; // Count: 8
65
53
  export var _DYN_TRANSACTION = "transaction"; // Count: 5
66
- export var _DYN_OPEN_STORE = "openStore"; // Count: 3
67
54
  export var _DYN_OPEN_CURSOR = "openCursor"; // Count: 3
68
- export var _DYN_DB_NAME = "dbName"; // Count: 5
69
- export var _DYN_REMOVE = "remove"; // Count: 4
70
55
  export var _DYN_ONERROR = "onerror"; // Count: 9
71
56
  export var _DYN_ONSUCCESS = "onsuccess"; // Count: 7
72
57
  export var _DYN_THEN = "then"; // Count: 12
73
- export var _DYN_KEY_RANGE = "keyRange"; // Count: 3
74
- export var _DYN_CONTINUE = "continue"; // Count: 7
75
- export var _DYN_SUBSTRING = "substring"; // Count: 3
76
- export var _DYN_STORAGE_KEY_PREFIX = "storageKeyPrefix"; // Count: 2
77
- export var _DYN_IN_STORAGE_MAX_TIME = "inStorageMaxTime"; // Count: 2
58
+ export var _DYN_CONTINUE = "continue"; // Count: 6
78
59
  export var _DYN__EVENTS_TO_DROP_PER_2 = "EventsToDropPerTime"; // Count: 2
79
60
  export var _DYN_MAX_CRITICAL_EVTS_DR3 = "maxCriticalEvtsDropCnt"; // Count: 2
80
61
  export var _DYN_SUPPORTS_SYNC_REQUES4 = "supportsSyncRequests"; // Count: 2
@@ -1 +1 @@
1
- {"version":3,"file":"__DynamicConstants.js.map","sources":["__DynamicConstants.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\n// @skip-file-minify\r\n// ##############################################################\r\n// AUTO GENERATED FILE: This file is Auto Generated during build.\r\n// ##############################################################\r\n// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\r\n// Note: DON'T Export these const from the package as we are still targeting ES3 this will export a mutable variables that someone could change!!!\r\n// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\r\nexport var _DYN_ENDPOINT = \"endpoint\"; // Count: 4\r\nexport var _DYN_ADD_EVENT = \"addEvent\"; // Count: 6\r\nexport var _DYN_PUSH = \"push\"; // Count: 18\r\nexport var _DYN_LENGTH = \"length\"; // Count: 52\r\nexport var _DYN_CLEAR = \"clear\"; // Count: 5\r\nexport var _DYN_GET_ITEMS = \"getItems\"; // Count: 4\r\nexport var _DYN_SPLIT = \"split\"; // Count: 5\r\nexport var _DYN_SPLICE = \"splice\"; // Count: 4\r\nexport var _DYN_INITIALIZE = \"initialize\"; // Count: 11\r\nexport var _DYN_DIAG_LOG = \"diagLog\"; // Count: 6\r\nexport var _DYN_ITEM_CTX = \"itemCtx\"; // Count: 4\r\nexport var _DYN_STORAGE_CONFIG = \"storageConfig\"; // Count: 4\r\nexport var _DYN_VALUE = \"value\"; // Count: 12\r\nexport var _DYN_REJECTED = \"rejected\"; // Count: 6\r\nexport var _DYN_SEND_NEXT_BATCH = \"sendNextBatch\"; // Count: 3\r\nexport var _DYN_GET_NEXT_BATCH = \"getNextBatch\"; // Count: 5\r\nexport var _DYN_REMOVE_EVENTS = \"removeEvents\"; // Count: 3\r\nexport var _DYN_DATA = \"data\"; // Count: 11\r\nexport var _DYN_SEND_POST = \"sendPOST\"; // Count: 3\r\nexport var _DYN_ATTEMP_CNT = \"attempCnt\"; // Count: 4\r\nexport var _DYN_STATE = \"state\"; // Count: 9\r\nexport var _DYN_TEARDOWN = \"teardown\"; // Count: 6\r\nexport var _DYN_IS_ARR = \"isArr\"; // Count: 5\r\nexport var _DYN_INDEX_OF = \"indexOf\"; // Count: 9\r\nexport var _DYN__CRITICAL = \"Critical\"; // Count: 3\r\nexport var _DYN__NORMAL = \"Normal\"; // Count: 4\r\nexport var _DYN_IS_ONLINE = \"isOnline\"; // Count: 3\r\nexport var _DYN_CANCEL = \"cancel\"; // Count: 5\r\nexport var _DYN_PROCESS_NEXT = \"processNext\"; // Count: 3\r\nexport var _DYN_PERSISTENCE = \"persistence\"; // Count: 11\r\nexport var _DYN_ONUNLOAD_FLUSH = \"onunloadFlush\"; // Count: 3\r\nexport var _DYN_BATCH_HANDLER = \"batchHandler\"; // Count: 5\r\nexport var _DYN_MIN_PERSISTENCE_CACH0 = \"minPersistenceCacheLevel\"; // Count: 2\r\nexport var _DYN_REFRESH = \"refresh\"; // Count: 4\r\nexport var _DYN_CREATE_ONE_DSPAYLOAD = \"createOneDSPayload\"; // Count: 2\r\nexport var _DYN_CRITICAL_CNT = \"criticalCnt\"; // Count: 8\r\nexport var _DYN_IS_COMPLETELY_IDLE = \"isCompletelyIdle\"; // Count: 5\r\nexport var _DYN_INSTRUMENTATION_KEY = \"instrumentationKey\"; // Count: 4\r\nexport var _DYN_GET_OFFLINE_SUPPORT = \"getOfflineSupport\"; // Count: 2\r\nexport var _DYN_OVERRIDE_INSTRUMENTA1 = \"overrideInstrumentationKey\"; // Count: 2\r\nexport var _DYN_NOTIFICATION_MGR = \"notificationMgr\"; // Count: 3\r\nexport var _DYN_TO_STRING = \"toString\"; // Count: 5\r\nexport var _DYN_GET_EXT_CFG = \"getExtCfg\"; // Count: 3\r\nexport var _DYN_ENABLE_SEND_PROMISE = \"enableSendPromise\"; // Count: 2\r\nexport var _DYN_CHAR_CODE_AT = \"charCodeAt\"; // Count: 3\r\nexport var _DYN_CHAR_AT = \"charAt\"; // Count: 8\r\nexport var _DYN_FROM_CHAR_CODE = \"fromCharCode\"; // Count: 3\r\nexport var _DYN_GET_TIME = \"getTime\"; // Count: 5\r\nexport var _DYN_NAME = \"name\"; // Count: 7\r\nexport var _DYN_DB_HDL = \"dbHdl\"; // Count: 7\r\nexport var _DYN_IS_AVAILABLE = \"isAvailable\"; // Count: 8\r\nexport var _DYN_TRANSACTION = \"transaction\"; // Count: 5\r\nexport var _DYN_OPEN_STORE = \"openStore\"; // Count: 3\r\nexport var _DYN_OPEN_CURSOR = \"openCursor\"; // Count: 3\r\nexport var _DYN_DB_NAME = \"dbName\"; // Count: 5\r\nexport var _DYN_REMOVE = \"remove\"; // Count: 4\r\nexport var _DYN_ONERROR = \"onerror\"; // Count: 9\r\nexport var _DYN_ONSUCCESS = \"onsuccess\"; // Count: 7\r\nexport var _DYN_THEN = \"then\"; // Count: 12\r\nexport var _DYN_KEY_RANGE = \"keyRange\"; // Count: 3\r\nexport var _DYN_CONTINUE = \"continue\"; // Count: 7\r\nexport var _DYN_SUBSTRING = \"substring\"; // Count: 3\r\nexport var _DYN_STORAGE_KEY_PREFIX = \"storageKeyPrefix\"; // Count: 2\r\nexport var _DYN_IN_STORAGE_MAX_TIME = \"inStorageMaxTime\"; // Count: 2\r\nexport var _DYN__EVENTS_TO_DROP_PER_2 = \"EventsToDropPerTime\"; // Count: 2\r\nexport var _DYN_MAX_CRITICAL_EVTS_DR3 = \"maxCriticalEvtsDropCnt\"; // Count: 2\r\nexport var _DYN_SUPPORTS_SYNC_REQUES4 = \"supportsSyncRequests\"; // Count: 2\r\nexport var _DYN_REMOVE_ITEM = \"removeItem\"; // Count: 3\r\nexport var _DYN_EVTS = \"evts\"; // Count: 6\r\nexport var _DYN_LAST_ACCESS_TIME = \"lastAccessTime\"; // Count: 3\r\n//# sourceMappingURL=__DynamicConstants.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"}
1
+ {"version":3,"file":"__DynamicConstants.js.map","sources":["__DynamicConstants.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\n// @skip-file-minify\r\n// ##############################################################\r\n// AUTO GENERATED FILE: This file is Auto Generated during build.\r\n// ##############################################################\r\n// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\r\n// Note: DON'T Export these const from the package as we are still targeting ES5 which can result in a mutable variables that someone could change!!!\r\n// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\r\nexport var _DYN_ADD_EVENT = \"addEvent\"; // Count: 6\r\nexport var _DYN_PUSH = \"push\"; // Count: 18\r\nexport var _DYN_LENGTH = \"length\"; // Count: 52\r\nexport var _DYN_CLEAR = \"clear\"; // Count: 5\r\nexport var _DYN_GET_ITEMS = \"getItems\"; // Count: 4\r\nexport var _DYN_SPLIT = \"split\"; // Count: 5\r\nexport var _DYN_INITIALIZE = \"initialize\"; // Count: 11\r\nexport var _DYN_DIAG_LOG = \"diagLog\"; // Count: 6\r\nexport var _DYN_STORAGE_CONFIG = \"storageConfig\"; // Count: 4\r\nexport var _DYN_VALUE = \"value\"; // Count: 10\r\nexport var _DYN_REJECTED = \"rejected\"; // Count: 6\r\nexport var _DYN_SEND_NEXT_BATCH = \"sendNextBatch\"; // Count: 3\r\nexport var _DYN_GET_NEXT_BATCH = \"getNextBatch\"; // Count: 5\r\nexport var _DYN_REMOVE_EVENTS = \"removeEvents\"; // Count: 3\r\nexport var _DYN_DATA = \"data\"; // Count: 11\r\nexport var _DYN_ATTEMP_CNT = \"attempCnt\"; // Count: 4\r\nexport var _DYN_STATE = \"state\"; // Count: 9\r\nexport var _DYN_TEARDOWN = \"teardown\"; // Count: 6\r\nexport var _DYN_IS_ARR = \"isArr\"; // Count: 5\r\nexport var _DYN_INDEX_OF = \"indexOf\"; // Count: 9\r\nexport var _DYN_CANCEL = \"cancel\"; // Count: 5\r\nexport var _DYN_PROCESS_NEXT = \"processNext\"; // Count: 3\r\nexport var _DYN_PERSISTENCE = \"persistence\"; // Count: 11\r\nexport var _DYN_ONUNLOAD_FLUSH = \"onunloadFlush\"; // Count: 3\r\nexport var _DYN_BATCH_HANDLER = \"batchHandler\"; // Count: 5\r\nexport var _DYN_MIN_PERSISTENCE_CACH0 = \"minPersistenceCacheLevel\"; // Count: 2\r\nexport var _DYN_REFRESH = \"refresh\"; // Count: 4\r\nexport var _DYN_CRITICAL_CNT = \"criticalCnt\"; // Count: 8\r\nexport var _DYN_IS_COMPLETELY_IDLE = \"isCompletelyIdle\"; // Count: 5\r\nexport var _DYN_INSTRUMENTATION_KEY = \"instrumentationKey\"; // Count: 4\r\nexport var _DYN_OVERRIDE_INSTRUMENTA1 = \"overrideInstrumentationKey\"; // Count: 2\r\nexport var _DYN_NOTIFICATION_MGR = \"notificationMgr\"; // Count: 3\r\nexport var _DYN_TO_STRING = \"toString\"; // Count: 5\r\nexport var _DYN_CHAR_CODE_AT = \"charCodeAt\"; // Count: 3\r\nexport var _DYN_CHAR_AT = \"charAt\"; // Count: 8\r\nexport var _DYN_FROM_CHAR_CODE = \"fromCharCode\"; // Count: 3\r\nexport var _DYN_GET_TIME = \"getTime\"; // Count: 5\r\nexport var _DYN_DB_HDL = \"dbHdl\"; // Count: 7\r\nexport var _DYN_IS_AVAILABLE = \"isAvailable\"; // Count: 8\r\nexport var _DYN_TRANSACTION = \"transaction\"; // Count: 5\r\nexport var _DYN_OPEN_CURSOR = \"openCursor\"; // Count: 3\r\nexport var _DYN_ONERROR = \"onerror\"; // Count: 9\r\nexport var _DYN_ONSUCCESS = \"onsuccess\"; // Count: 7\r\nexport var _DYN_THEN = \"then\"; // Count: 12\r\nexport var _DYN_CONTINUE = \"continue\"; // Count: 6\r\nexport var _DYN__EVENTS_TO_DROP_PER_2 = \"EventsToDropPerTime\"; // Count: 2\r\nexport var _DYN_MAX_CRITICAL_EVTS_DR3 = \"maxCriticalEvtsDropCnt\"; // Count: 2\r\nexport var _DYN_SUPPORTS_SYNC_REQUES4 = \"supportsSyncRequests\"; // Count: 2\r\nexport var _DYN_REMOVE_ITEM = \"removeItem\"; // Count: 3\r\nexport var _DYN_EVTS = \"evts\"; // Count: 6\r\nexport var _DYN_LAST_ACCESS_TIME = \"lastAccessTime\"; // Count: 3\r\n//# sourceMappingURL=__DynamicConstants.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"}
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Offline Channel, 0.3.6-nightly3.2502-13
2
+ * Application Insights JavaScript SDK - Offline Channel, 0.3.6-nightly3.2503-01
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.6-nightly3.2502-13",
3
+ "version": "0.3.6-nightly3.2503-01",
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",
@@ -31,9 +31,9 @@
31
31
  "dependencies": {
32
32
  "@microsoft/dynamicproto-js": "^2.0.3",
33
33
  "@microsoft/applicationinsights-shims": "3.0.1",
34
- "@microsoft/applicationinsights-core-js": "3.3.6-nightly3.2502-13",
35
- "@microsoft/applicationinsights-common": "3.3.6-nightly3.2502-13",
36
- "@nevware21/ts-utils": ">= 0.11.6 < 2.x",
34
+ "@microsoft/applicationinsights-core-js": "3.3.6-nightly3.2503-01",
35
+ "@microsoft/applicationinsights-common": "3.3.6-nightly3.2503-01",
36
+ "@nevware21/ts-utils": ">= 0.11.8 < 2.x",
37
37
  "@nevware21/ts-async": ">= 0.5.4 < 2.x"
38
38
  },
39
39
  "peerDependencies": {
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Microsoft Application Insights JavaScript SDK Offline Channel, 0.3.6-nightly3.2502-13
2
+ * Microsoft Application Insights JavaScript SDK Offline Channel, 0.3.6-nightly3.2503-01
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  *
5
5
  * Microsoft Application Insights Team
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Microsoft Application Insights JavaScript SDK Offline Channel, 0.3.6-nightly3.2502-13
2
+ * Microsoft Application Insights JavaScript SDK Offline Channel, 0.3.6-nightly3.2503-01
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  *
5
5
  * Microsoft Application Insights Team