@microsoft/applicationinsights-common 3.3.6-nightly3.2502-13 → 3.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.
- package/browser/es5/applicationinsights-common.cjs.js +164 -196
- package/browser/es5/applicationinsights-common.cjs.js.map +1 -1
- package/browser/es5/applicationinsights-common.cjs.min.js +2 -2
- package/browser/es5/applicationinsights-common.cjs.min.js.map +1 -1
- package/browser/es5/applicationinsights-common.gbl.js +166 -198
- package/browser/es5/applicationinsights-common.gbl.js.map +1 -1
- package/browser/es5/applicationinsights-common.gbl.min.js +2 -2
- package/browser/es5/applicationinsights-common.gbl.min.js.map +1 -1
- package/browser/es5/applicationinsights-common.integrity.json +25 -25
- package/browser/es5/applicationinsights-common.js +166 -198
- package/browser/es5/applicationinsights-common.js.map +1 -1
- package/browser/es5/applicationinsights-common.min.js +2 -2
- package/browser/es5/applicationinsights-common.min.js.map +1 -1
- package/dist/es5/applicationinsights-common.js +164 -196
- package/dist/es5/applicationinsights-common.js.map +1 -1
- package/dist/es5/applicationinsights-common.min.js +2 -2
- package/dist/es5/applicationinsights-common.min.js.map +1 -1
- package/dist-es5/ConnectionStringParser.js +1 -1
- package/dist-es5/Constants.js +1 -1
- package/dist-es5/DomHelperFuncs.js +1 -1
- package/dist-es5/Enums.js +1 -1
- package/dist-es5/HelperFuncs.js +7 -6
- package/dist-es5/HelperFuncs.js.map +1 -1
- package/dist-es5/Interfaces/ConnectionString.js +1 -1
- package/dist-es5/Interfaces/Context/IApplication.js +1 -1
- package/dist-es5/Interfaces/Context/IDevice.js +1 -1
- package/dist-es5/Interfaces/Context/IInternal.js +1 -1
- package/dist-es5/Interfaces/Context/ILocation.js +1 -1
- package/dist-es5/Interfaces/Context/IOperatingSystem.js +1 -1
- package/dist-es5/Interfaces/Context/ISample.js +1 -1
- package/dist-es5/Interfaces/Context/ISession.js +1 -1
- package/dist-es5/Interfaces/Context/ISessionManager.js +1 -1
- package/dist-es5/Interfaces/Context/ITelemetryTrace.js +1 -1
- package/dist-es5/Interfaces/Context/IUser.js +1 -1
- package/dist-es5/Interfaces/Context/IWeb.js +1 -1
- package/dist-es5/Interfaces/Contracts/AvailabilityData.js +1 -1
- package/dist-es5/Interfaces/Contracts/ContextTagKeys.js +1 -1
- package/dist-es5/Interfaces/Contracts/DataPointType.js +1 -1
- package/dist-es5/Interfaces/Contracts/DependencyKind.js +1 -1
- package/dist-es5/Interfaces/Contracts/DependencySourceType.js +1 -1
- package/dist-es5/Interfaces/Contracts/IBase.js +1 -1
- package/dist-es5/Interfaces/Contracts/IData.js +1 -1
- package/dist-es5/Interfaces/Contracts/IDataPoint.js +1 -1
- package/dist-es5/Interfaces/Contracts/IDomain.js +1 -1
- package/dist-es5/Interfaces/Contracts/IEnvelope.js +1 -1
- package/dist-es5/Interfaces/Contracts/IEventData.js +1 -1
- package/dist-es5/Interfaces/Contracts/IExceptionData.js +1 -1
- package/dist-es5/Interfaces/Contracts/IExceptionDetails.js +1 -1
- package/dist-es5/Interfaces/Contracts/IMessageData.js +1 -1
- package/dist-es5/Interfaces/Contracts/IMetricData.js +1 -1
- package/dist-es5/Interfaces/Contracts/IPageViewData.js +1 -1
- package/dist-es5/Interfaces/Contracts/IPageViewPerfData.js +1 -1
- package/dist-es5/Interfaces/Contracts/IRemoteDependencyData.js +1 -1
- package/dist-es5/Interfaces/Contracts/IStackFrame.js +1 -1
- package/dist-es5/Interfaces/Contracts/RequestData.js +1 -1
- package/dist-es5/Interfaces/Contracts/SeverityLevel.js +1 -1
- package/dist-es5/Interfaces/IAppInsights.js +1 -1
- package/dist-es5/Interfaces/IConfig.js +1 -1
- package/dist-es5/Interfaces/ICorrelationConfig.js +1 -1
- package/dist-es5/Interfaces/IDependencyTelemetry.js +1 -1
- package/dist-es5/Interfaces/IEventTelemetry.js +1 -1
- package/dist-es5/Interfaces/IExceptionTelemetry.js +1 -1
- package/dist-es5/Interfaces/IMetricTelemetry.js +1 -1
- package/dist-es5/Interfaces/IPageViewPerformanceTelemetry.js +1 -1
- package/dist-es5/Interfaces/IPageViewTelemetry.js +1 -1
- package/dist-es5/Interfaces/IPartC.js +1 -1
- package/dist-es5/Interfaces/IPropertiesPlugin.js +1 -1
- package/dist-es5/Interfaces/IRequestContext.js +1 -1
- package/dist-es5/Interfaces/IStorageBuffer.js +1 -1
- package/dist-es5/Interfaces/ITelemetryContext.js +1 -1
- package/dist-es5/Interfaces/IThrottleMgr.js +1 -1
- package/dist-es5/Interfaces/ITraceTelemetry.js +1 -1
- package/dist-es5/Interfaces/PartAExtensions.js +1 -1
- package/dist-es5/Interfaces/Telemetry/IEnvelope.js +1 -1
- package/dist-es5/Interfaces/Telemetry/ISerializable.js +1 -1
- package/dist-es5/Offline.js +2 -3
- package/dist-es5/Offline.js.map +1 -1
- package/dist-es5/RequestResponseHeaders.js +1 -1
- package/dist-es5/StorageHelperFuncs.js +3 -3
- package/dist-es5/StorageHelperFuncs.js.map +1 -1
- package/dist-es5/Telemetry/Common/Data.js +1 -1
- package/dist-es5/Telemetry/Common/DataPoint.js +1 -1
- package/dist-es5/Telemetry/Common/DataSanitizer.js +1 -1
- package/dist-es5/Telemetry/Common/Envelope.js +1 -1
- package/dist-es5/Telemetry/Event.js +1 -1
- package/dist-es5/Telemetry/Exception.js +50 -55
- package/dist-es5/Telemetry/Exception.js.map +1 -1
- package/dist-es5/Telemetry/Metric.js +1 -1
- package/dist-es5/Telemetry/PageView.js +1 -1
- package/dist-es5/Telemetry/PageViewPerformance.js +3 -3
- package/dist-es5/Telemetry/PageViewPerformance.js.map +1 -1
- package/dist-es5/Telemetry/RemoteDependencyData.js +1 -1
- package/dist-es5/Telemetry/Trace.js +1 -1
- package/dist-es5/TelemetryItemCreator.js +11 -14
- package/dist-es5/TelemetryItemCreator.js.map +1 -1
- package/dist-es5/ThrottleMgr.js +16 -16
- package/dist-es5/ThrottleMgr.js.map +1 -1
- package/dist-es5/UrlHelperFuncs.js +1 -1
- package/dist-es5/Util.js +1 -1
- package/dist-es5/__DynamicConstants.js +15 -24
- package/dist-es5/__DynamicConstants.js.map +1 -1
- package/dist-es5/applicationinsights-common.js +1 -1
- package/package.json +3 -3
- package/types/applicationinsights-common.d.ts +1 -1
- package/types/applicationinsights-common.namespaced.d.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TelemetryItemCreator.js.map","sources":["TelemetryItemCreator.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\nimport { isNullOrUndefined, objForEachKey, throwError, toISOString } from \"@microsoft/applicationinsights-core-js\";\r\nimport { strIkey, strNotSpecified } from \"./Constants\";\r\nimport { dataSanitizeString } from \"./Telemetry/Common/DataSanitizer\";\r\
|
|
1
|
+
{"version":3,"file":"TelemetryItemCreator.js.map","sources":["TelemetryItemCreator.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\nimport { isNullOrUndefined, objForEachKey, throwError, toISOString } from \"@microsoft/applicationinsights-core-js\";\r\nimport { strIkey, strNotSpecified } from \"./Constants\";\r\nimport { dataSanitizeString } from \"./Telemetry/Common/DataSanitizer\";\r\n/**\r\n * Create a telemetry item that the 1DS channel understands\r\n * @param item - domain specific properties; part B\r\n * @param baseType - telemetry item type. ie PageViewData\r\n * @param envelopeName - Name of the envelope, e.g., `Microsoft.ApplicationInsights.\\<instrumentation key\\>.PageView`.\r\n * @param customProperties - user defined custom properties; part C\r\n * @param systemProperties - system properties that are added to the context; part A\r\n * @returns ITelemetryItem that is sent to channel\r\n */\r\nexport function createTelemetryItem(item, baseType, envelopeName, logger, customProperties, systemProperties) {\r\n envelopeName = dataSanitizeString(logger, envelopeName) || strNotSpecified;\r\n if (isNullOrUndefined(item) ||\r\n isNullOrUndefined(baseType) ||\r\n isNullOrUndefined(envelopeName)) {\r\n throwError(\"Input doesn't contain all required fields\");\r\n }\r\n var iKey = \"\";\r\n if (item[strIkey]) {\r\n iKey = item[strIkey];\r\n delete item[strIkey];\r\n }\r\n var telemetryItem = {\r\n name: envelopeName,\r\n time: toISOString(new Date()),\r\n iKey: iKey,\r\n ext: systemProperties ? systemProperties : {},\r\n tags: [],\r\n data: {},\r\n baseType: baseType,\r\n baseData: item // Part B\r\n };\r\n // Part C\r\n if (!isNullOrUndefined(customProperties)) {\r\n objForEachKey(customProperties, function (prop, value) {\r\n telemetryItem.data[prop] = value;\r\n });\r\n }\r\n return telemetryItem;\r\n}\r\nvar TelemetryItemCreator = /** @class */ (function () {\r\n function TelemetryItemCreator() {\r\n }\r\n /**\r\n * Create a telemetry item that the 1DS channel understands\r\n * @param item - domain specific properties; part B\r\n * @param baseType - telemetry item type. ie PageViewData\r\n * @param envelopeName - Name of the envelope (e.g., Microsoft.ApplicationInsights.[instrumentationKey].PageView).\r\n * @param customProperties - user defined custom properties; part C\r\n * @param systemProperties - system properties that are added to the context; part A\r\n * @returns ITelemetryItem that is sent to channel\r\n */\r\n TelemetryItemCreator.create = createTelemetryItem;\r\n return TelemetryItemCreator;\r\n}());\r\nexport { TelemetryItemCreator };\r\n//# sourceMappingURL=TelemetryItemCreator.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"}
|
package/dist-es5/ThrottleMgr.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Application Insights JavaScript SDK - Common, 3.3.6-nightly3.
|
|
2
|
+
* Application Insights JavaScript SDK - Common, 3.3.6-nightly3.2503-01
|
|
3
3
|
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
4
|
*/
|
|
5
5
|
import { _throwInternal, arrIndexOf, isNotNullOrUndefined, isNullOrUndefined, onConfigChange, randomValue, safeGetLogger, strTrim } from "@microsoft/applicationinsights-core-js";
|
|
6
|
-
import { arrForEach, objForEachKey } from "@nevware21/ts-utils";
|
|
6
|
+
import { arrForEach, mathFloor, mathMin, objForEachKey } from "@nevware21/ts-utils";
|
|
7
7
|
import { utlCanUseLocalStorage, utlGetLocalStorage, utlSetLocalStorage } from "./StorageHelperFuncs";
|
|
8
|
-
import { _DYN_COUNT,
|
|
8
|
+
import { _DYN_COUNT, _DYN_GET_UTCDATE, _DYN_LENGTH, _DYN_MESSAGE, _DYN_PRE_TRIGGER_DATE, _DYN_STRINGIFY } from "./__DynamicConstants";
|
|
9
9
|
var THROTTLE_STORAGE_PREFIX = "appInsightsThrottle";
|
|
10
10
|
var ThrottleMgr = /** @class */ (function () {
|
|
11
11
|
function ThrottleMgr(core, namePrefix) {
|
|
@@ -128,7 +128,7 @@ var ThrottleMgr = /** @class */ (function () {
|
|
|
128
128
|
var isTriggered = _isTrigger(msgID);
|
|
129
129
|
try {
|
|
130
130
|
if (canThrottle && !isTriggered) {
|
|
131
|
-
number =
|
|
131
|
+
number = mathMin(cfg.limit.maxSendNumber, localStorageObj[_DYN_COUNT /* @min:%2ecount */] + 1);
|
|
132
132
|
localStorageObj[_DYN_COUNT /* @min:%2ecount */] = 0;
|
|
133
133
|
throttled = true;
|
|
134
134
|
_isTriggered[msgID] = true;
|
|
@@ -155,7 +155,7 @@ var ThrottleMgr = /** @class */ (function () {
|
|
|
155
155
|
else {
|
|
156
156
|
if (!!saveUnsentMsg) {
|
|
157
157
|
var queue = _getQueueByKey(msgID);
|
|
158
|
-
queue
|
|
158
|
+
queue.push({
|
|
159
159
|
msgID: msgID,
|
|
160
160
|
message: message,
|
|
161
161
|
severity: severity
|
|
@@ -189,10 +189,10 @@ var ThrottleMgr = /** @class */ (function () {
|
|
|
189
189
|
try {
|
|
190
190
|
var cfg = config || {};
|
|
191
191
|
var curCfg = {};
|
|
192
|
-
curCfg
|
|
193
|
-
var configInterval = cfg
|
|
192
|
+
curCfg.disabled = !!cfg.disabled;
|
|
193
|
+
var configInterval = cfg.interval || {};
|
|
194
194
|
_isSpecificDaysGiven = (configInterval === null || configInterval === void 0 ? void 0 : configInterval.daysOfMonth) && (configInterval === null || configInterval === void 0 ? void 0 : configInterval.daysOfMonth[_DYN_LENGTH /* @min:%2elength */]) > 0;
|
|
195
|
-
curCfg
|
|
195
|
+
curCfg.interval = _getIntervalConfig(configInterval);
|
|
196
196
|
var limit = {
|
|
197
197
|
samplingRate: ((_a = cfg.limit) === null || _a === void 0 ? void 0 : _a.samplingRate) || 100,
|
|
198
198
|
// dafault: every time sent only 1 event
|
|
@@ -214,7 +214,7 @@ var ThrottleMgr = /** @class */ (function () {
|
|
|
214
214
|
interval.monthInterval = 3;
|
|
215
215
|
if (!_isSpecificDaysGiven) {
|
|
216
216
|
// default: send data on 28th
|
|
217
|
-
interval
|
|
217
|
+
interval.daysOfMonth = [28];
|
|
218
218
|
_isSpecificDaysGiven = true;
|
|
219
219
|
}
|
|
220
220
|
}
|
|
@@ -227,10 +227,10 @@ var ThrottleMgr = /** @class */ (function () {
|
|
|
227
227
|
return interval;
|
|
228
228
|
}
|
|
229
229
|
function _canThrottle(config, canUseLocalStorage, localStorageObj) {
|
|
230
|
-
if (config && !config
|
|
230
|
+
if (config && !config.disabled && canUseLocalStorage && isNotNullOrUndefined(localStorageObj)) {
|
|
231
231
|
var curDate = _getThrottleDate();
|
|
232
|
-
var date = localStorageObj
|
|
233
|
-
var interval = config
|
|
232
|
+
var date = localStorageObj.date;
|
|
233
|
+
var interval = config.interval;
|
|
234
234
|
var monthCheck = 1;
|
|
235
235
|
if (interval === null || interval === void 0 ? void 0 : interval.monthInterval) {
|
|
236
236
|
var monthExpand = (curDate.getUTCFullYear() - date.getUTCFullYear()) * 12 + curDate.getUTCMonth() - date.getUTCMonth();
|
|
@@ -238,10 +238,10 @@ var ThrottleMgr = /** @class */ (function () {
|
|
|
238
238
|
}
|
|
239
239
|
var dayCheck = 1;
|
|
240
240
|
if (_isSpecificDaysGiven) {
|
|
241
|
-
dayCheck = arrIndexOf(interval
|
|
241
|
+
dayCheck = arrIndexOf(interval.daysOfMonth, curDate[_DYN_GET_UTCDATE /* @min:%2egetUTCDate */]());
|
|
242
242
|
}
|
|
243
243
|
else if (interval === null || interval === void 0 ? void 0 : interval.dayInterval) {
|
|
244
|
-
var daySpan =
|
|
244
|
+
var daySpan = mathFloor((curDate.getTime() - date.getTime()) / 86400000);
|
|
245
245
|
dayCheck = _checkInterval(interval.dayInterval, 0, daySpan);
|
|
246
246
|
}
|
|
247
247
|
return monthCheck >= 0 && dayCheck >= 0;
|
|
@@ -280,7 +280,7 @@ var ThrottleMgr = /** @class */ (function () {
|
|
|
280
280
|
if (value) {
|
|
281
281
|
var obj = JSON.parse(value);
|
|
282
282
|
var curObj = {
|
|
283
|
-
date: _getThrottleDate(obj
|
|
283
|
+
date: _getThrottleDate(obj.date) || storageObj.date,
|
|
284
284
|
count: obj[_DYN_COUNT /* @min:%2ecount */] || storageObj[_DYN_COUNT /* @min:%2ecount */],
|
|
285
285
|
preTriggerDate: obj.preTriggerDate ? _getThrottleDate(obj[_DYN_PRE_TRIGGER_DATE /* @min:%2epreTriggerDate */]) : undefined
|
|
286
286
|
};
|
|
@@ -330,7 +330,7 @@ var ThrottleMgr = /** @class */ (function () {
|
|
|
330
330
|
return 1;
|
|
331
331
|
}
|
|
332
332
|
// count from start year
|
|
333
|
-
return (current >= start) && (current - start) % interval == 0 ?
|
|
333
|
+
return (current >= start) && (current - start) % interval == 0 ? mathFloor((current - start) / interval) + 1 : -1;
|
|
334
334
|
}
|
|
335
335
|
function _sendMessage(msgID, logger, message, severity) {
|
|
336
336
|
_throwInternal(logger, severity || 1 /* eLoggingSeverity.CRITICAL */, msgID, message);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThrottleMgr.js.map","sources":["ThrottleMgr.js"],"sourcesContent":["import { _throwInternal, arrIndexOf, isNotNullOrUndefined, isNullOrUndefined, onConfigChange, randomValue, safeGetLogger, strTrim } from \"@microsoft/applicationinsights-core-js\";\r\nimport { arrForEach, objForEachKey } from \"@nevware21/ts-utils\";\r\nimport { utlCanUseLocalStorage, utlGetLocalStorage, utlSetLocalStorage } from \"./StorageHelperFuncs\";\r\nimport { _DYN_COUNT, _DYN_DATE, _DYN_DAYS_OF_MONTH, _DYN_DISABLED, _DYN_GET_UTCDATE, _DYN_INTERVAL, _DYN_LENGTH, _DYN_MESSAGE, _DYN_PRE_TRIGGER_DATE, _DYN_PUSH, _DYN_STRINGIFY } from \"./__DynamicConstants\";\r\nvar THROTTLE_STORAGE_PREFIX = \"appInsightsThrottle\";\r\nvar ThrottleMgr = /** @class */ (function () {\r\n function ThrottleMgr(core, namePrefix) {\r\n var _self = this;\r\n var _canUseLocalStorage;\r\n var _logger;\r\n var _config;\r\n var _localStorageObj;\r\n var _isTriggered; //_isTriggered is to make sure that we only trigger throttle once a day\r\n var _namePrefix;\r\n var _queue;\r\n var _isReady = false;\r\n var _isSpecificDaysGiven = false;\r\n _initConfig();\r\n // Special internal method to allow the unit tests and DebugPlugin to hook embedded objects\r\n _self[\"_getDbgPlgTargets\"] = function () {\r\n return [_queue];\r\n };\r\n _self.getConfig = function () {\r\n return _config;\r\n };\r\n /**\r\n * Check if it is the correct day to send message.\r\n * If _isTriggered is true, even if canThrottle returns true, message will not be sent,\r\n * because we only allow triggering sendMessage() once a day.\r\n * @returns if the current date is the valid date to send message\r\n */\r\n _self.canThrottle = function (msgId) {\r\n var localObj = _getLocalStorageObjByKey(msgId);\r\n var cfg = _getCfgByKey(msgId);\r\n return _canThrottle(cfg, _canUseLocalStorage, localObj);\r\n };\r\n /**\r\n * Check if throttle is triggered on current day(UTC)\r\n * if canThrottle returns false, isTriggered will return false\r\n * @returns if throttle is triggered on current day(UTC)\r\n */\r\n _self.isTriggered = function (msgId) {\r\n return _isTrigger(msgId);\r\n };\r\n /**\r\n * Before isReady set to true, all message will be stored in queue.\r\n * Message will only be sent out after isReady set to true.\r\n * Initial and default value: false\r\n * @returns isReady state\r\n */\r\n _self.isReady = function () {\r\n return _isReady;\r\n };\r\n /**\r\n * Flush all message with given message key in queue with isReady state set to true.\r\n * @returns if message queue is flushed\r\n */\r\n _self.flush = function (msgId) {\r\n try {\r\n var queue = _getQueueByKey(msgId);\r\n if (queue && queue[_DYN_LENGTH /* @min:%2elength */] > 0) {\r\n var items = queue.slice(0);\r\n _queue[msgId] = [];\r\n arrForEach(items, function (item) {\r\n _flushMessage(item.msgID, item[_DYN_MESSAGE /* @min:%2emessage */], item.severity, false);\r\n });\r\n return true;\r\n }\r\n }\r\n catch (err) {\r\n // eslint-disable-next-line no-empty\r\n }\r\n return false;\r\n };\r\n /**\r\n * Flush all message in queue with isReady state set to true.\r\n * @returns if message queue is flushed\r\n */\r\n _self.flushAll = function () {\r\n try {\r\n if (_queue) {\r\n var result_1 = true;\r\n objForEachKey(_queue, function (key) {\r\n var isFlushed = _self.flush(parseInt(key));\r\n result_1 = result_1 && isFlushed;\r\n });\r\n return result_1;\r\n }\r\n }\r\n catch (err) {\r\n // eslint-disable-next-line no-empty\r\n }\r\n return false;\r\n };\r\n /**\r\n * Set isReady State\r\n * if isReady set to true, message queue will be flushed automatically.\r\n * @param isReady - isReady State\r\n * @pa\r\n * @returns if message queue is flushed\r\n */\r\n _self.onReadyState = function (isReady, flushAll) {\r\n if (flushAll === void 0) { flushAll = true; }\r\n _isReady = isNullOrUndefined(isReady) ? true : isReady;\r\n if (_isReady && flushAll) {\r\n return _self.flushAll();\r\n }\r\n return null;\r\n };\r\n _self.sendMessage = function (msgID, message, severity) {\r\n return _flushMessage(msgID, message, severity, true);\r\n };\r\n function _flushMessage(msgID, message, severity, saveUnsentMsg) {\r\n if (_isReady) {\r\n var isSampledIn = _canSampledIn(msgID);\r\n if (!isSampledIn) {\r\n return;\r\n }\r\n var cfg = _getCfgByKey(msgID);\r\n var localStorageObj = _getLocalStorageObjByKey(msgID);\r\n var canThrottle = _canThrottle(cfg, _canUseLocalStorage, localStorageObj);\r\n var throttled = false;\r\n var number = 0;\r\n var isTriggered = _isTrigger(msgID);\r\n try {\r\n if (canThrottle && !isTriggered) {\r\n number = Math.min(cfg.limit.maxSendNumber, localStorageObj[_DYN_COUNT /* @min:%2ecount */] + 1);\r\n localStorageObj[_DYN_COUNT /* @min:%2ecount */] = 0;\r\n throttled = true;\r\n _isTriggered[msgID] = true;\r\n localStorageObj[_DYN_PRE_TRIGGER_DATE /* @min:%2epreTriggerDate */] = new Date();\r\n }\r\n else {\r\n _isTriggered[msgID] = canThrottle;\r\n localStorageObj[_DYN_COUNT /* @min:%2ecount */] += 1;\r\n }\r\n var localStorageName = _getLocalStorageName(msgID);\r\n _resetLocalStorage(_logger, localStorageName, localStorageObj);\r\n for (var i = 0; i < number; i++) {\r\n _sendMessage(msgID, _logger, message, severity);\r\n }\r\n }\r\n catch (e) {\r\n // eslint-disable-next-line no-empty\r\n }\r\n return {\r\n isThrottled: throttled,\r\n throttleNum: number\r\n };\r\n }\r\n else {\r\n if (!!saveUnsentMsg) {\r\n var queue = _getQueueByKey(msgID);\r\n queue[_DYN_PUSH /* @min:%2epush */]({\r\n msgID: msgID,\r\n message: message,\r\n severity: severity\r\n });\r\n }\r\n }\r\n return null;\r\n }\r\n function _initConfig() {\r\n _logger = safeGetLogger(core);\r\n _isTriggered = {};\r\n _localStorageObj = {};\r\n _queue = {};\r\n _config = {};\r\n _setCfgByKey(109 /* _eInternalMessageId.DefaultThrottleMsgKey */);\r\n _namePrefix = isNotNullOrUndefined(namePrefix) ? namePrefix : \"\";\r\n core.addUnloadHook(onConfigChange(core.config, function (details) {\r\n var coreConfig = details.cfg;\r\n _canUseLocalStorage = utlCanUseLocalStorage();\r\n var configMgr = coreConfig.throttleMgrCfg || {};\r\n objForEachKey(configMgr, function (key, cfg) {\r\n _setCfgByKey(parseInt(key), cfg);\r\n });\r\n }));\r\n }\r\n function _getCfgByKey(msgID) {\r\n return _config[msgID] || _config[109 /* _eInternalMessageId.DefaultThrottleMsgKey */];\r\n }\r\n function _setCfgByKey(msgID, config) {\r\n var _a, _b;\r\n try {\r\n var cfg = config || {};\r\n var curCfg = {};\r\n curCfg[_DYN_DISABLED /* @min:%2edisabled */] = !!cfg[_DYN_DISABLED /* @min:%2edisabled */];\r\n var configInterval = cfg[_DYN_INTERVAL /* @min:%2einterval */] || {};\r\n _isSpecificDaysGiven = (configInterval === null || configInterval === void 0 ? void 0 : configInterval.daysOfMonth) && (configInterval === null || configInterval === void 0 ? void 0 : configInterval.daysOfMonth[_DYN_LENGTH /* @min:%2elength */]) > 0;\r\n curCfg[_DYN_INTERVAL /* @min:%2einterval */] = _getIntervalConfig(configInterval);\r\n var limit = {\r\n samplingRate: ((_a = cfg.limit) === null || _a === void 0 ? void 0 : _a.samplingRate) || 100,\r\n // dafault: every time sent only 1 event\r\n maxSendNumber: ((_b = cfg.limit) === null || _b === void 0 ? void 0 : _b.maxSendNumber) || 1\r\n };\r\n curCfg.limit = limit;\r\n _config[msgID] = curCfg;\r\n }\r\n catch (e) {\r\n // eslint-disable-next-line no-empty\r\n }\r\n }\r\n function _getIntervalConfig(interval) {\r\n interval = interval || {};\r\n var monthInterval = interval === null || interval === void 0 ? void 0 : interval.monthInterval;\r\n var dayInterval = interval === null || interval === void 0 ? void 0 : interval.dayInterval;\r\n // default: send data every 3 month each year\r\n if (isNullOrUndefined(monthInterval) && isNullOrUndefined(dayInterval)) {\r\n interval.monthInterval = 3;\r\n if (!_isSpecificDaysGiven) {\r\n // default: send data on 28th\r\n interval[_DYN_DAYS_OF_MONTH /* @min:%2edaysOfMonth */] = [28];\r\n _isSpecificDaysGiven = true;\r\n }\r\n }\r\n interval = {\r\n // dafault: sent every three months\r\n monthInterval: interval === null || interval === void 0 ? void 0 : interval.monthInterval,\r\n dayInterval: interval === null || interval === void 0 ? void 0 : interval.dayInterval,\r\n daysOfMonth: interval === null || interval === void 0 ? void 0 : interval.daysOfMonth\r\n };\r\n return interval;\r\n }\r\n function _canThrottle(config, canUseLocalStorage, localStorageObj) {\r\n if (config && !config[_DYN_DISABLED /* @min:%2edisabled */] && canUseLocalStorage && isNotNullOrUndefined(localStorageObj)) {\r\n var curDate = _getThrottleDate();\r\n var date = localStorageObj[_DYN_DATE /* @min:%2edate */];\r\n var interval = config[_DYN_INTERVAL /* @min:%2einterval */];\r\n var monthCheck = 1;\r\n if (interval === null || interval === void 0 ? void 0 : interval.monthInterval) {\r\n var monthExpand = (curDate.getUTCFullYear() - date.getUTCFullYear()) * 12 + curDate.getUTCMonth() - date.getUTCMonth();\r\n monthCheck = _checkInterval(interval.monthInterval, 0, monthExpand);\r\n }\r\n var dayCheck = 1;\r\n if (_isSpecificDaysGiven) {\r\n dayCheck = arrIndexOf(interval[_DYN_DAYS_OF_MONTH /* @min:%2edaysOfMonth */], curDate[_DYN_GET_UTCDATE /* @min:%2egetUTCDate */]());\r\n }\r\n else if (interval === null || interval === void 0 ? void 0 : interval.dayInterval) {\r\n var daySpan = Math.floor((curDate.getTime() - date.getTime()) / 86400000);\r\n dayCheck = _checkInterval(interval.dayInterval, 0, daySpan);\r\n }\r\n return monthCheck >= 0 && dayCheck >= 0;\r\n }\r\n return false;\r\n }\r\n function _getLocalStorageName(msgKey, prefix) {\r\n var fix = isNotNullOrUndefined(prefix) ? prefix : \"\";\r\n if (msgKey) {\r\n return THROTTLE_STORAGE_PREFIX + fix + \"-\" + msgKey;\r\n }\r\n return null;\r\n }\r\n // returns if throttle is triggered on current Date\r\n function _isTriggeredOnCurDate(preTriggerDate) {\r\n try {\r\n if (preTriggerDate) {\r\n var curDate = new Date();\r\n return preTriggerDate.getUTCFullYear() === curDate.getUTCFullYear() &&\r\n preTriggerDate.getUTCMonth() === curDate.getUTCMonth() &&\r\n preTriggerDate[_DYN_GET_UTCDATE /* @min:%2egetUTCDate */]() === curDate[_DYN_GET_UTCDATE /* @min:%2egetUTCDate */]();\r\n }\r\n }\r\n catch (e) {\r\n // eslint-disable-next-line no-empty\r\n }\r\n return false;\r\n }\r\n // transfer local storage string value to object that identifies start date, current count and preTriggerDate\r\n function _getLocalStorageObj(value, logger, storageName) {\r\n try {\r\n var storageObj = {\r\n date: _getThrottleDate(),\r\n count: 0\r\n };\r\n if (value) {\r\n var obj = JSON.parse(value);\r\n var curObj = {\r\n date: _getThrottleDate(obj[_DYN_DATE /* @min:%2edate */]) || storageObj[_DYN_DATE /* @min:%2edate */],\r\n count: obj[_DYN_COUNT /* @min:%2ecount */] || storageObj[_DYN_COUNT /* @min:%2ecount */],\r\n preTriggerDate: obj.preTriggerDate ? _getThrottleDate(obj[_DYN_PRE_TRIGGER_DATE /* @min:%2epreTriggerDate */]) : undefined\r\n };\r\n return curObj;\r\n }\r\n else {\r\n _resetLocalStorage(logger, storageName, storageObj);\r\n return storageObj;\r\n }\r\n }\r\n catch (e) {\r\n // eslint-disable-next-line no-empty\r\n }\r\n return null;\r\n }\r\n // if datestr is not defined, current date will be returned\r\n function _getThrottleDate(dateStr) {\r\n // if new Date() can't be created through the provided dateStr, null will be returned.\r\n try {\r\n if (dateStr) {\r\n var date = new Date(dateStr);\r\n //make sure it is a valid Date Object\r\n if (!isNaN(date.getDate())) {\r\n return date;\r\n }\r\n }\r\n else {\r\n return new Date();\r\n }\r\n }\r\n catch (e) {\r\n // eslint-disable-next-line no-empty\r\n }\r\n return null;\r\n }\r\n function _resetLocalStorage(logger, storageName, obj) {\r\n try {\r\n return utlSetLocalStorage(logger, storageName, strTrim(JSON[_DYN_STRINGIFY /* @min:%2estringify */](obj)));\r\n }\r\n catch (e) {\r\n // eslint-disable-next-line no-empty\r\n }\r\n return false;\r\n }\r\n function _checkInterval(interval, start, current) {\r\n if (interval <= 0) {\r\n return 1;\r\n }\r\n // count from start year\r\n return (current >= start) && (current - start) % interval == 0 ? Math.floor((current - start) / interval) + 1 : -1;\r\n }\r\n function _sendMessage(msgID, logger, message, severity) {\r\n _throwInternal(logger, severity || 1 /* eLoggingSeverity.CRITICAL */, msgID, message);\r\n }\r\n // NOTE: config.limit.samplingRate is set to 4 decimal places,\r\n // so config.limit.samplingRate = 1 means 0.0001%\r\n function _canSampledIn(msgID) {\r\n try {\r\n var cfg = _getCfgByKey(msgID);\r\n return randomValue(1000000) <= cfg.limit.samplingRate;\r\n }\r\n catch (e) {\r\n // eslint-disable-next-line no-empty\r\n }\r\n return false;\r\n }\r\n function _getLocalStorageObjByKey(key) {\r\n try {\r\n var curObj = _localStorageObj[key];\r\n if (!curObj) {\r\n var localStorageName = _getLocalStorageName(key, _namePrefix);\r\n curObj = _getLocalStorageObj(utlGetLocalStorage(_logger, localStorageName), _logger, localStorageName);\r\n _localStorageObj[key] = curObj;\r\n }\r\n return _localStorageObj[key];\r\n }\r\n catch (e) {\r\n // eslint-disable-next-line no-empty\r\n }\r\n return null;\r\n }\r\n function _isTrigger(key) {\r\n var isTrigger = _isTriggered[key];\r\n if (isNullOrUndefined(isTrigger)) {\r\n isTrigger = false;\r\n var localStorageObj = _getLocalStorageObjByKey(key);\r\n if (localStorageObj) {\r\n isTrigger = _isTriggeredOnCurDate(localStorageObj[_DYN_PRE_TRIGGER_DATE /* @min:%2epreTriggerDate */]);\r\n }\r\n _isTriggered[key] = isTrigger;\r\n }\r\n return _isTriggered[key];\r\n }\r\n function _getQueueByKey(key) {\r\n _queue = _queue || {};\r\n if (isNullOrUndefined(_queue[key])) {\r\n _queue[key] = [];\r\n }\r\n return _queue[key];\r\n }\r\n }\r\n return ThrottleMgr;\r\n}());\r\nexport { ThrottleMgr };\r\n//# sourceMappingURL=ThrottleMgr.js.map"],"names":[],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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":"ThrottleMgr.js.map","sources":["ThrottleMgr.js"],"sourcesContent":["import { _throwInternal, arrIndexOf, isNotNullOrUndefined, isNullOrUndefined, onConfigChange, randomValue, safeGetLogger, strTrim } from \"@microsoft/applicationinsights-core-js\";\r\nimport { arrForEach, mathFloor, mathMin, objForEachKey } from \"@nevware21/ts-utils\";\r\nimport { utlCanUseLocalStorage, utlGetLocalStorage, utlSetLocalStorage } from \"./StorageHelperFuncs\";\r\nimport { _DYN_COUNT, _DYN_GET_UTCDATE, _DYN_LENGTH, _DYN_MESSAGE, _DYN_PRE_TRIGGER_DATE, _DYN_STRINGIFY } from \"./__DynamicConstants\";\r\nvar THROTTLE_STORAGE_PREFIX = \"appInsightsThrottle\";\r\nvar ThrottleMgr = /** @class */ (function () {\r\n function ThrottleMgr(core, namePrefix) {\r\n var _self = this;\r\n var _canUseLocalStorage;\r\n var _logger;\r\n var _config;\r\n var _localStorageObj;\r\n var _isTriggered; //_isTriggered is to make sure that we only trigger throttle once a day\r\n var _namePrefix;\r\n var _queue;\r\n var _isReady = false;\r\n var _isSpecificDaysGiven = false;\r\n _initConfig();\r\n // Special internal method to allow the unit tests and DebugPlugin to hook embedded objects\r\n _self[\"_getDbgPlgTargets\"] = function () {\r\n return [_queue];\r\n };\r\n _self.getConfig = function () {\r\n return _config;\r\n };\r\n /**\r\n * Check if it is the correct day to send message.\r\n * If _isTriggered is true, even if canThrottle returns true, message will not be sent,\r\n * because we only allow triggering sendMessage() once a day.\r\n * @returns if the current date is the valid date to send message\r\n */\r\n _self.canThrottle = function (msgId) {\r\n var localObj = _getLocalStorageObjByKey(msgId);\r\n var cfg = _getCfgByKey(msgId);\r\n return _canThrottle(cfg, _canUseLocalStorage, localObj);\r\n };\r\n /**\r\n * Check if throttle is triggered on current day(UTC)\r\n * if canThrottle returns false, isTriggered will return false\r\n * @returns if throttle is triggered on current day(UTC)\r\n */\r\n _self.isTriggered = function (msgId) {\r\n return _isTrigger(msgId);\r\n };\r\n /**\r\n * Before isReady set to true, all message will be stored in queue.\r\n * Message will only be sent out after isReady set to true.\r\n * Initial and default value: false\r\n * @returns isReady state\r\n */\r\n _self.isReady = function () {\r\n return _isReady;\r\n };\r\n /**\r\n * Flush all message with given message key in queue with isReady state set to true.\r\n * @returns if message queue is flushed\r\n */\r\n _self.flush = function (msgId) {\r\n try {\r\n var queue = _getQueueByKey(msgId);\r\n if (queue && queue[_DYN_LENGTH /* @min:%2elength */] > 0) {\r\n var items = queue.slice(0);\r\n _queue[msgId] = [];\r\n arrForEach(items, function (item) {\r\n _flushMessage(item.msgID, item[_DYN_MESSAGE /* @min:%2emessage */], item.severity, false);\r\n });\r\n return true;\r\n }\r\n }\r\n catch (err) {\r\n // eslint-disable-next-line no-empty\r\n }\r\n return false;\r\n };\r\n /**\r\n * Flush all message in queue with isReady state set to true.\r\n * @returns if message queue is flushed\r\n */\r\n _self.flushAll = function () {\r\n try {\r\n if (_queue) {\r\n var result_1 = true;\r\n objForEachKey(_queue, function (key) {\r\n var isFlushed = _self.flush(parseInt(key));\r\n result_1 = result_1 && isFlushed;\r\n });\r\n return result_1;\r\n }\r\n }\r\n catch (err) {\r\n // eslint-disable-next-line no-empty\r\n }\r\n return false;\r\n };\r\n /**\r\n * Set isReady State\r\n * if isReady set to true, message queue will be flushed automatically.\r\n * @param isReady - isReady State\r\n * @pa\r\n * @returns if message queue is flushed\r\n */\r\n _self.onReadyState = function (isReady, flushAll) {\r\n if (flushAll === void 0) { flushAll = true; }\r\n _isReady = isNullOrUndefined(isReady) ? true : isReady;\r\n if (_isReady && flushAll) {\r\n return _self.flushAll();\r\n }\r\n return null;\r\n };\r\n _self.sendMessage = function (msgID, message, severity) {\r\n return _flushMessage(msgID, message, severity, true);\r\n };\r\n function _flushMessage(msgID, message, severity, saveUnsentMsg) {\r\n if (_isReady) {\r\n var isSampledIn = _canSampledIn(msgID);\r\n if (!isSampledIn) {\r\n return;\r\n }\r\n var cfg = _getCfgByKey(msgID);\r\n var localStorageObj = _getLocalStorageObjByKey(msgID);\r\n var canThrottle = _canThrottle(cfg, _canUseLocalStorage, localStorageObj);\r\n var throttled = false;\r\n var number = 0;\r\n var isTriggered = _isTrigger(msgID);\r\n try {\r\n if (canThrottle && !isTriggered) {\r\n number = mathMin(cfg.limit.maxSendNumber, localStorageObj[_DYN_COUNT /* @min:%2ecount */] + 1);\r\n localStorageObj[_DYN_COUNT /* @min:%2ecount */] = 0;\r\n throttled = true;\r\n _isTriggered[msgID] = true;\r\n localStorageObj[_DYN_PRE_TRIGGER_DATE /* @min:%2epreTriggerDate */] = new Date();\r\n }\r\n else {\r\n _isTriggered[msgID] = canThrottle;\r\n localStorageObj[_DYN_COUNT /* @min:%2ecount */] += 1;\r\n }\r\n var localStorageName = _getLocalStorageName(msgID);\r\n _resetLocalStorage(_logger, localStorageName, localStorageObj);\r\n for (var i = 0; i < number; i++) {\r\n _sendMessage(msgID, _logger, message, severity);\r\n }\r\n }\r\n catch (e) {\r\n // eslint-disable-next-line no-empty\r\n }\r\n return {\r\n isThrottled: throttled,\r\n throttleNum: number\r\n };\r\n }\r\n else {\r\n if (!!saveUnsentMsg) {\r\n var queue = _getQueueByKey(msgID);\r\n queue.push({\r\n msgID: msgID,\r\n message: message,\r\n severity: severity\r\n });\r\n }\r\n }\r\n return null;\r\n }\r\n function _initConfig() {\r\n _logger = safeGetLogger(core);\r\n _isTriggered = {};\r\n _localStorageObj = {};\r\n _queue = {};\r\n _config = {};\r\n _setCfgByKey(109 /* _eInternalMessageId.DefaultThrottleMsgKey */);\r\n _namePrefix = isNotNullOrUndefined(namePrefix) ? namePrefix : \"\";\r\n core.addUnloadHook(onConfigChange(core.config, function (details) {\r\n var coreConfig = details.cfg;\r\n _canUseLocalStorage = utlCanUseLocalStorage();\r\n var configMgr = coreConfig.throttleMgrCfg || {};\r\n objForEachKey(configMgr, function (key, cfg) {\r\n _setCfgByKey(parseInt(key), cfg);\r\n });\r\n }));\r\n }\r\n function _getCfgByKey(msgID) {\r\n return _config[msgID] || _config[109 /* _eInternalMessageId.DefaultThrottleMsgKey */];\r\n }\r\n function _setCfgByKey(msgID, config) {\r\n var _a, _b;\r\n try {\r\n var cfg = config || {};\r\n var curCfg = {};\r\n curCfg.disabled = !!cfg.disabled;\r\n var configInterval = cfg.interval || {};\r\n _isSpecificDaysGiven = (configInterval === null || configInterval === void 0 ? void 0 : configInterval.daysOfMonth) && (configInterval === null || configInterval === void 0 ? void 0 : configInterval.daysOfMonth[_DYN_LENGTH /* @min:%2elength */]) > 0;\r\n curCfg.interval = _getIntervalConfig(configInterval);\r\n var limit = {\r\n samplingRate: ((_a = cfg.limit) === null || _a === void 0 ? void 0 : _a.samplingRate) || 100,\r\n // dafault: every time sent only 1 event\r\n maxSendNumber: ((_b = cfg.limit) === null || _b === void 0 ? void 0 : _b.maxSendNumber) || 1\r\n };\r\n curCfg.limit = limit;\r\n _config[msgID] = curCfg;\r\n }\r\n catch (e) {\r\n // eslint-disable-next-line no-empty\r\n }\r\n }\r\n function _getIntervalConfig(interval) {\r\n interval = interval || {};\r\n var monthInterval = interval === null || interval === void 0 ? void 0 : interval.monthInterval;\r\n var dayInterval = interval === null || interval === void 0 ? void 0 : interval.dayInterval;\r\n // default: send data every 3 month each year\r\n if (isNullOrUndefined(monthInterval) && isNullOrUndefined(dayInterval)) {\r\n interval.monthInterval = 3;\r\n if (!_isSpecificDaysGiven) {\r\n // default: send data on 28th\r\n interval.daysOfMonth = [28];\r\n _isSpecificDaysGiven = true;\r\n }\r\n }\r\n interval = {\r\n // dafault: sent every three months\r\n monthInterval: interval === null || interval === void 0 ? void 0 : interval.monthInterval,\r\n dayInterval: interval === null || interval === void 0 ? void 0 : interval.dayInterval,\r\n daysOfMonth: interval === null || interval === void 0 ? void 0 : interval.daysOfMonth\r\n };\r\n return interval;\r\n }\r\n function _canThrottle(config, canUseLocalStorage, localStorageObj) {\r\n if (config && !config.disabled && canUseLocalStorage && isNotNullOrUndefined(localStorageObj)) {\r\n var curDate = _getThrottleDate();\r\n var date = localStorageObj.date;\r\n var interval = config.interval;\r\n var monthCheck = 1;\r\n if (interval === null || interval === void 0 ? void 0 : interval.monthInterval) {\r\n var monthExpand = (curDate.getUTCFullYear() - date.getUTCFullYear()) * 12 + curDate.getUTCMonth() - date.getUTCMonth();\r\n monthCheck = _checkInterval(interval.monthInterval, 0, monthExpand);\r\n }\r\n var dayCheck = 1;\r\n if (_isSpecificDaysGiven) {\r\n dayCheck = arrIndexOf(interval.daysOfMonth, curDate[_DYN_GET_UTCDATE /* @min:%2egetUTCDate */]());\r\n }\r\n else if (interval === null || interval === void 0 ? void 0 : interval.dayInterval) {\r\n var daySpan = mathFloor((curDate.getTime() - date.getTime()) / 86400000);\r\n dayCheck = _checkInterval(interval.dayInterval, 0, daySpan);\r\n }\r\n return monthCheck >= 0 && dayCheck >= 0;\r\n }\r\n return false;\r\n }\r\n function _getLocalStorageName(msgKey, prefix) {\r\n var fix = isNotNullOrUndefined(prefix) ? prefix : \"\";\r\n if (msgKey) {\r\n return THROTTLE_STORAGE_PREFIX + fix + \"-\" + msgKey;\r\n }\r\n return null;\r\n }\r\n // returns if throttle is triggered on current Date\r\n function _isTriggeredOnCurDate(preTriggerDate) {\r\n try {\r\n if (preTriggerDate) {\r\n var curDate = new Date();\r\n return preTriggerDate.getUTCFullYear() === curDate.getUTCFullYear() &&\r\n preTriggerDate.getUTCMonth() === curDate.getUTCMonth() &&\r\n preTriggerDate[_DYN_GET_UTCDATE /* @min:%2egetUTCDate */]() === curDate[_DYN_GET_UTCDATE /* @min:%2egetUTCDate */]();\r\n }\r\n }\r\n catch (e) {\r\n // eslint-disable-next-line no-empty\r\n }\r\n return false;\r\n }\r\n // transfer local storage string value to object that identifies start date, current count and preTriggerDate\r\n function _getLocalStorageObj(value, logger, storageName) {\r\n try {\r\n var storageObj = {\r\n date: _getThrottleDate(),\r\n count: 0\r\n };\r\n if (value) {\r\n var obj = JSON.parse(value);\r\n var curObj = {\r\n date: _getThrottleDate(obj.date) || storageObj.date,\r\n count: obj[_DYN_COUNT /* @min:%2ecount */] || storageObj[_DYN_COUNT /* @min:%2ecount */],\r\n preTriggerDate: obj.preTriggerDate ? _getThrottleDate(obj[_DYN_PRE_TRIGGER_DATE /* @min:%2epreTriggerDate */]) : undefined\r\n };\r\n return curObj;\r\n }\r\n else {\r\n _resetLocalStorage(logger, storageName, storageObj);\r\n return storageObj;\r\n }\r\n }\r\n catch (e) {\r\n // eslint-disable-next-line no-empty\r\n }\r\n return null;\r\n }\r\n // if datestr is not defined, current date will be returned\r\n function _getThrottleDate(dateStr) {\r\n // if new Date() can't be created through the provided dateStr, null will be returned.\r\n try {\r\n if (dateStr) {\r\n var date = new Date(dateStr);\r\n //make sure it is a valid Date Object\r\n if (!isNaN(date.getDate())) {\r\n return date;\r\n }\r\n }\r\n else {\r\n return new Date();\r\n }\r\n }\r\n catch (e) {\r\n // eslint-disable-next-line no-empty\r\n }\r\n return null;\r\n }\r\n function _resetLocalStorage(logger, storageName, obj) {\r\n try {\r\n return utlSetLocalStorage(logger, storageName, strTrim(JSON[_DYN_STRINGIFY /* @min:%2estringify */](obj)));\r\n }\r\n catch (e) {\r\n // eslint-disable-next-line no-empty\r\n }\r\n return false;\r\n }\r\n function _checkInterval(interval, start, current) {\r\n if (interval <= 0) {\r\n return 1;\r\n }\r\n // count from start year\r\n return (current >= start) && (current - start) % interval == 0 ? mathFloor((current - start) / interval) + 1 : -1;\r\n }\r\n function _sendMessage(msgID, logger, message, severity) {\r\n _throwInternal(logger, severity || 1 /* eLoggingSeverity.CRITICAL */, msgID, message);\r\n }\r\n // NOTE: config.limit.samplingRate is set to 4 decimal places,\r\n // so config.limit.samplingRate = 1 means 0.0001%\r\n function _canSampledIn(msgID) {\r\n try {\r\n var cfg = _getCfgByKey(msgID);\r\n return randomValue(1000000) <= cfg.limit.samplingRate;\r\n }\r\n catch (e) {\r\n // eslint-disable-next-line no-empty\r\n }\r\n return false;\r\n }\r\n function _getLocalStorageObjByKey(key) {\r\n try {\r\n var curObj = _localStorageObj[key];\r\n if (!curObj) {\r\n var localStorageName = _getLocalStorageName(key, _namePrefix);\r\n curObj = _getLocalStorageObj(utlGetLocalStorage(_logger, localStorageName), _logger, localStorageName);\r\n _localStorageObj[key] = curObj;\r\n }\r\n return _localStorageObj[key];\r\n }\r\n catch (e) {\r\n // eslint-disable-next-line no-empty\r\n }\r\n return null;\r\n }\r\n function _isTrigger(key) {\r\n var isTrigger = _isTriggered[key];\r\n if (isNullOrUndefined(isTrigger)) {\r\n isTrigger = false;\r\n var localStorageObj = _getLocalStorageObjByKey(key);\r\n if (localStorageObj) {\r\n isTrigger = _isTriggeredOnCurDate(localStorageObj[_DYN_PRE_TRIGGER_DATE /* @min:%2epreTriggerDate */]);\r\n }\r\n _isTriggered[key] = isTrigger;\r\n }\r\n return _isTriggered[key];\r\n }\r\n function _getQueueByKey(key) {\r\n _queue = _queue || {};\r\n if (isNullOrUndefined(_queue[key])) {\r\n _queue[key] = [];\r\n }\r\n return _queue[key];\r\n }\r\n }\r\n return ThrottleMgr;\r\n}());\r\nexport { ThrottleMgr };\r\n//# sourceMappingURL=ThrottleMgr.js.map"],"names":[],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
|
package/dist-es5/Util.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Application Insights JavaScript SDK - Common, 3.3.6-nightly3.
|
|
2
|
+
* Application Insights JavaScript SDK - Common, 3.3.6-nightly3.2503-01
|
|
3
3
|
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -8,46 +8,37 @@
|
|
|
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
|
|
13
|
-
//
|
|
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
|
+
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
14
14
|
export var _DYN_SPLIT = "split"; // Count: 6
|
|
15
15
|
export var _DYN_LENGTH = "length"; // Count: 46
|
|
16
16
|
export var _DYN_TO_LOWER_CASE = "toLowerCase"; // Count: 6
|
|
17
17
|
export var _DYN_INGESTIONENDPOINT = "ingestionendpoint"; // Count: 6
|
|
18
18
|
export var _DYN_TO_STRING = "toString"; // Count: 8
|
|
19
|
-
export var _DYN_PUSH = "push"; // Count: 5
|
|
20
19
|
export var _DYN_REMOVE_ITEM = "removeItem"; // Count: 3
|
|
21
|
-
export var
|
|
22
|
-
export var
|
|
23
|
-
export var _DYN_COUNT = "count"; // Count: 8
|
|
20
|
+
export var _DYN_MESSAGE = "message"; // Count: 5
|
|
21
|
+
export var _DYN_COUNT = "count"; // Count: 6
|
|
24
22
|
export var _DYN_PRE_TRIGGER_DATE = "preTriggerDate"; // Count: 4
|
|
25
|
-
export var _DYN_DISABLED = "disabled"; // Count: 3
|
|
26
|
-
export var _DYN_INTERVAL = "interval"; // Count: 3
|
|
27
|
-
export var _DYN_DAYS_OF_MONTH = "daysOfMonth"; // Count: 3
|
|
28
|
-
export var _DYN_DATE = "date"; // Count: 5
|
|
29
23
|
export var _DYN_GET_UTCDATE = "getUTCDate"; // Count: 3
|
|
30
24
|
export var _DYN_STRINGIFY = "stringify"; // Count: 4
|
|
31
25
|
export var _DYN_PATHNAME = "pathname"; // Count: 4
|
|
32
26
|
export var _DYN_MATCH = "match"; // Count: 5
|
|
33
27
|
export var _DYN_CORRELATION_HEADER_E0 = "correlationHeaderExcludePatterns"; // Count: 2
|
|
28
|
+
export var _DYN_NAME = "name"; // Count: 10
|
|
34
29
|
export var _DYN_EXTENSION_CONFIG = "extensionConfig"; // Count: 4
|
|
35
|
-
export var
|
|
36
|
-
export var _DYN_PARSED_STACK = "parsedStack"; // Count: 9
|
|
37
|
-
export var _DYN_PROPERTIES = "properties"; // Count: 9
|
|
30
|
+
export var _DYN_PROPERTIES = "properties"; // Count: 10
|
|
38
31
|
export var _DYN_MEASUREMENTS = "measurements"; // Count: 9
|
|
39
|
-
export var _DYN_SIZE_IN_BYTES = "sizeInBytes"; // Count:
|
|
40
|
-
export var _DYN_TYPE_NAME = "typeName"; // Count:
|
|
32
|
+
export var _DYN_SIZE_IN_BYTES = "sizeInBytes"; // Count: 4
|
|
33
|
+
export var _DYN_TYPE_NAME = "typeName"; // Count: 5
|
|
34
|
+
export var _DYN_EXCEPTIONS = "exceptions"; // Count: 5
|
|
41
35
|
export var _DYN_SEVERITY_LEVEL = "severityLevel"; // Count: 5
|
|
42
36
|
export var _DYN_PROBLEM_GROUP = "problemGroup"; // Count: 3
|
|
43
|
-
export var
|
|
37
|
+
export var _DYN_PARSED_STACK = "parsedStack"; // Count: 6
|
|
44
38
|
export var _DYN_HAS_FULL_STACK = "hasFullStack"; // Count: 5
|
|
45
|
-
export var _DYN_ASSEMBLY = "assembly"; // Count:
|
|
46
|
-
export var _DYN_FILE_NAME = "fileName"; // Count:
|
|
47
|
-
export var _DYN_LINE = "line"; // Count:
|
|
48
|
-
export var _DYN_METHOD = "method"; // Count: 6
|
|
49
|
-
export var _DYN_LEVEL = "level"; // Count: 5
|
|
39
|
+
export var _DYN_ASSEMBLY = "assembly"; // Count: 4
|
|
40
|
+
export var _DYN_FILE_NAME = "fileName"; // Count: 9
|
|
41
|
+
export var _DYN_LINE = "line"; // Count: 6
|
|
50
42
|
export var _DYN_AI_DATA_CONTRACT = "aiDataContract"; // Count: 4
|
|
51
43
|
export var _DYN_DURATION = "duration"; // Count: 4
|
|
52
|
-
export var _DYN_RECEIVED_RESPONSE = "receivedResponse"; // Count: 2
|
|
53
44
|
//# sourceMappingURL=__DynamicConstants.js.map
|
|
@@ -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//
|
|
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_SPLIT = \"split\"; // Count: 6\r\nexport var _DYN_LENGTH = \"length\"; // Count: 46\r\nexport var _DYN_TO_LOWER_CASE = \"toLowerCase\"; // Count: 6\r\nexport var _DYN_INGESTIONENDPOINT = \"ingestionendpoint\"; // Count: 6\r\nexport var _DYN_TO_STRING = \"toString\"; // Count: 8\r\nexport var _DYN_REMOVE_ITEM = \"removeItem\"; // Count: 3\r\nexport var _DYN_MESSAGE = \"message\"; // Count: 5\r\nexport var _DYN_COUNT = \"count\"; // Count: 6\r\nexport var _DYN_PRE_TRIGGER_DATE = \"preTriggerDate\"; // Count: 4\r\nexport var _DYN_GET_UTCDATE = \"getUTCDate\"; // Count: 3\r\nexport var _DYN_STRINGIFY = \"stringify\"; // Count: 4\r\nexport var _DYN_PATHNAME = \"pathname\"; // Count: 4\r\nexport var _DYN_MATCH = \"match\"; // Count: 5\r\nexport var _DYN_CORRELATION_HEADER_E0 = \"correlationHeaderExcludePatterns\"; // Count: 2\r\nexport var _DYN_NAME = \"name\"; // Count: 10\r\nexport var _DYN_EXTENSION_CONFIG = \"extensionConfig\"; // Count: 4\r\nexport var _DYN_PROPERTIES = \"properties\"; // Count: 10\r\nexport var _DYN_MEASUREMENTS = \"measurements\"; // Count: 9\r\nexport var _DYN_SIZE_IN_BYTES = \"sizeInBytes\"; // Count: 4\r\nexport var _DYN_TYPE_NAME = \"typeName\"; // Count: 5\r\nexport var _DYN_EXCEPTIONS = \"exceptions\"; // Count: 5\r\nexport var _DYN_SEVERITY_LEVEL = \"severityLevel\"; // Count: 5\r\nexport var _DYN_PROBLEM_GROUP = \"problemGroup\"; // Count: 3\r\nexport var _DYN_PARSED_STACK = \"parsedStack\"; // Count: 6\r\nexport var _DYN_HAS_FULL_STACK = \"hasFullStack\"; // Count: 5\r\nexport var _DYN_ASSEMBLY = \"assembly\"; // Count: 4\r\nexport var _DYN_FILE_NAME = \"fileName\"; // Count: 9\r\nexport var _DYN_LINE = \"line\"; // Count: 6\r\nexport var _DYN_AI_DATA_CONTRACT = \"aiDataContract\"; // Count: 4\r\nexport var _DYN_DURATION = \"duration\"; // Count: 4\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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@microsoft/applicationinsights-common",
|
|
3
|
-
"version": "3.3.6-nightly3.
|
|
3
|
+
"version": "3.3.6-nightly3.2503-01",
|
|
4
4
|
"description": "Microsoft Application Insights Common JavaScript Library",
|
|
5
5
|
"homepage": "https://github.com/microsoft/ApplicationInsights-JS#readme",
|
|
6
6
|
"author": "Microsoft Application Insights Team",
|
|
@@ -56,9 +56,9 @@
|
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
58
|
"@microsoft/applicationinsights-shims": "3.0.1",
|
|
59
|
-
"@microsoft/applicationinsights-core-js": "3.3.6-nightly3.
|
|
59
|
+
"@microsoft/applicationinsights-core-js": "3.3.6-nightly3.2503-01",
|
|
60
60
|
"@microsoft/dynamicproto-js": "^2.0.3",
|
|
61
|
-
"@nevware21/ts-utils": ">= 0.11.
|
|
61
|
+
"@nevware21/ts-utils": ">= 0.11.8 < 2.x"
|
|
62
62
|
},
|
|
63
63
|
"license": "MIT",
|
|
64
64
|
"publishConfig": {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Microsoft Application Insights Common JavaScript Library, 3.3.6-nightly3.
|
|
2
|
+
* Microsoft Application Insights Common JavaScript Library, 3.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 Common JavaScript Library, 3.3.6-nightly3.
|
|
2
|
+
* Microsoft Application Insights Common JavaScript Library, 3.3.6-nightly3.2503-01
|
|
3
3
|
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* Microsoft Application Insights Team
|