@microsoft/applicationinsights-common 2.8.9-nightly.2210-05 → 2.8.9
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/applicationinsights-common.integrity.json +9 -9
- package/browser/applicationinsights-common.js +223 -5
- package/browser/applicationinsights-common.js.map +1 -1
- package/browser/applicationinsights-common.min.js +2 -2
- package/browser/applicationinsights-common.min.js.map +1 -1
- package/dist/applicationinsights-common.api.json +2736 -1864
- package/dist/applicationinsights-common.api.md +65 -0
- package/dist/applicationinsights-common.d.ts +118 -1
- package/dist/applicationinsights-common.js +223 -5
- package/dist/applicationinsights-common.js.map +1 -1
- package/dist/applicationinsights-common.min.js +2 -2
- package/dist/applicationinsights-common.min.js.map +1 -1
- package/dist/applicationinsights-common.rollup.d.ts +118 -1
- package/dist-esm/ConnectionStringParser.js +1 -1
- package/dist-esm/Constants.js +1 -1
- package/dist-esm/DomHelperFuncs.js +1 -1
- package/dist-esm/Enums.js +1 -1
- package/dist-esm/HelperFuncs.js +1 -1
- package/dist-esm/Interfaces/ConnectionString.js +1 -1
- package/dist-esm/Interfaces/Context/IApplication.js +1 -1
- package/dist-esm/Interfaces/Context/IDevice.js +1 -1
- package/dist-esm/Interfaces/Context/IInternal.js +1 -1
- package/dist-esm/Interfaces/Context/ILocation.js +1 -1
- package/dist-esm/Interfaces/Context/IOperatingSystem.js +1 -1
- package/dist-esm/Interfaces/Context/ISample.js +1 -1
- package/dist-esm/Interfaces/Context/ISession.js +1 -1
- package/dist-esm/Interfaces/Context/ITelemetryTrace.js +1 -1
- package/dist-esm/Interfaces/Context/IUser.js +1 -1
- package/dist-esm/Interfaces/Context/IWeb.js +1 -1
- package/dist-esm/Interfaces/Contracts/AvailabilityData.js +1 -1
- package/dist-esm/Interfaces/Contracts/ContextTagKeys.js +1 -1
- package/dist-esm/Interfaces/Contracts/DataPointType.js +1 -1
- package/dist-esm/Interfaces/Contracts/DependencyKind.js +1 -1
- package/dist-esm/Interfaces/Contracts/DependencySourceType.js +1 -1
- package/dist-esm/Interfaces/Contracts/IBase.js +1 -1
- package/dist-esm/Interfaces/Contracts/IData.js +1 -1
- package/dist-esm/Interfaces/Contracts/IDataPoint.js +1 -1
- package/dist-esm/Interfaces/Contracts/IDomain.js +1 -1
- package/dist-esm/Interfaces/Contracts/IEnvelope.js +1 -1
- package/dist-esm/Interfaces/Contracts/IEventData.js +1 -1
- package/dist-esm/Interfaces/Contracts/IExceptionData.js +1 -1
- package/dist-esm/Interfaces/Contracts/IExceptionDetails.js +1 -1
- package/dist-esm/Interfaces/Contracts/IMessageData.js +1 -1
- package/dist-esm/Interfaces/Contracts/IMetricData.js +1 -1
- package/dist-esm/Interfaces/Contracts/IPageViewData.js +1 -1
- package/dist-esm/Interfaces/Contracts/IPageViewPerfData.js +1 -1
- package/dist-esm/Interfaces/Contracts/IRemoteDependencyData.js +1 -1
- package/dist-esm/Interfaces/Contracts/IStackFrame.js +1 -1
- package/dist-esm/Interfaces/Contracts/RequestData.js +1 -1
- package/dist-esm/Interfaces/Contracts/SeverityLevel.js +1 -1
- package/dist-esm/Interfaces/IAppInsights.js +1 -1
- package/dist-esm/Interfaces/IChannelControlsAI.js +1 -1
- package/dist-esm/Interfaces/IConfig.js +1 -1
- package/dist-esm/Interfaces/ICorrelationConfig.js +1 -1
- package/dist-esm/Interfaces/IDependencyTelemetry.js +1 -1
- package/dist-esm/Interfaces/IEventTelemetry.js +1 -1
- package/dist-esm/Interfaces/IExceptionTelemetry.js +1 -1
- package/dist-esm/Interfaces/IMetricTelemetry.js +1 -1
- package/dist-esm/Interfaces/IPageViewPerformanceTelemetry.js +1 -1
- package/dist-esm/Interfaces/IPageViewTelemetry.js +1 -1
- package/dist-esm/Interfaces/IPartC.js +1 -1
- package/dist-esm/Interfaces/IPropertiesPlugin.js +1 -1
- package/dist-esm/Interfaces/IRequestContext.js +1 -1
- package/dist-esm/Interfaces/ITelemetryContext.js +1 -1
- package/dist-esm/Interfaces/IThrottleMgr.js +6 -0
- package/dist-esm/Interfaces/IThrottleMgr.js.map +1 -0
- package/dist-esm/Interfaces/ITraceTelemetry.js +1 -1
- package/dist-esm/Interfaces/PartAExtensions.js +1 -1
- package/dist-esm/Interfaces/Telemetry/IEnvelope.js +1 -1
- package/dist-esm/Interfaces/Telemetry/ISerializable.js +1 -1
- package/dist-esm/RequestResponseHeaders.js +1 -1
- package/dist-esm/StorageHelperFuncs.js +1 -1
- package/dist-esm/Telemetry/Common/Data.js +1 -1
- package/dist-esm/Telemetry/Common/DataPoint.js +1 -1
- package/dist-esm/Telemetry/Common/DataSanitizer.js +1 -1
- package/dist-esm/Telemetry/Common/Envelope.js +1 -1
- package/dist-esm/Telemetry/Event.js +1 -1
- package/dist-esm/Telemetry/Exception.js +1 -1
- package/dist-esm/Telemetry/Metric.js +3 -3
- package/dist-esm/Telemetry/Metric.js.map +1 -1
- package/dist-esm/Telemetry/PageView.js +1 -1
- package/dist-esm/Telemetry/PageViewPerformance.js +1 -1
- package/dist-esm/Telemetry/RemoteDependencyData.js +1 -1
- package/dist-esm/Telemetry/Trace.js +1 -1
- package/dist-esm/TelemetryItemCreator.js +1 -1
- package/dist-esm/ThrottleMgr.js +259 -0
- package/dist-esm/ThrottleMgr.js.map +1 -0
- package/dist-esm/UrlHelperFuncs.js +1 -1
- package/dist-esm/Util.js +1 -1
- package/dist-esm/__DynamicConstants.js +10 -4
- package/dist-esm/__DynamicConstants.js.map +1 -1
- package/dist-esm/applicationinsights-common.js +2 -1
- package/dist-esm/applicationinsights-common.js.map +1 -1
- package/package.json +58 -60
- package/src/Enums.ts +6 -0
- package/src/Interfaces/IThrottleMgr.ts +109 -0
- package/src/ThrottleMgr.ts +285 -0
- package/src/__DynamicConstants.ts +9 -3
- package/src/applicationinsights-common.ts +3 -1
- package/types/Enums.d.ts +5 -0
- package/types/Interfaces/IThrottleMgr.d.ts +94 -0
- package/types/ThrottleMgr.d.ts +12 -0
- package/types/__DynamicConstants.d.ts +8 -2
- package/types/applicationinsights-common.d.ts +3 -1
|
@@ -6,9 +6,11 @@
|
|
|
6
6
|
|
|
7
7
|
import { createTraceParent } from '@microsoft/applicationinsights-core-js';
|
|
8
8
|
import { _eInternalMessageId } from '@microsoft/applicationinsights-core-js';
|
|
9
|
+
import { eLoggingSeverity } from '@microsoft/applicationinsights-core-js';
|
|
9
10
|
import { EnumValue } from '@microsoft/applicationinsights-core-js';
|
|
10
11
|
import { findW3cTraceParent } from '@microsoft/applicationinsights-core-js';
|
|
11
12
|
import { formatTraceParent } from '@microsoft/applicationinsights-core-js';
|
|
13
|
+
import { IAppInsightsCore } from '@microsoft/applicationinsights-core-js';
|
|
12
14
|
import { IChannelControls } from '@microsoft/applicationinsights-core-js';
|
|
13
15
|
import { IConfiguration } from '@microsoft/applicationinsights-core-js';
|
|
14
16
|
import { ICookieMgr } from '@microsoft/applicationinsights-core-js';
|
|
@@ -889,6 +891,50 @@ export interface ITelemetryTrace {
|
|
|
889
891
|
traceState?: ITraceState;
|
|
890
892
|
}
|
|
891
893
|
|
|
894
|
+
// @public
|
|
895
|
+
export interface IThrottleInterval {
|
|
896
|
+
dayInterval?: number;
|
|
897
|
+
maxTimesPerMonth?: number;
|
|
898
|
+
monthInterval?: number;
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
// @public
|
|
902
|
+
export interface IThrottleLimit {
|
|
903
|
+
maxSendNumber?: number;
|
|
904
|
+
samplingRate?: number;
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
// @public
|
|
908
|
+
export interface IThrottleLocalStorageObj {
|
|
909
|
+
count: number;
|
|
910
|
+
date: Date;
|
|
911
|
+
preTriggerDate?: Date;
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
// @public
|
|
915
|
+
export interface IThrottleMgrConfig {
|
|
916
|
+
disabled?: boolean;
|
|
917
|
+
interval?: IThrottleInterval;
|
|
918
|
+
limit?: IThrottleLimit;
|
|
919
|
+
msgKey: IThrottleMsgKey;
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
// @public (undocumented)
|
|
923
|
+
export const enum IThrottleMsgKey {
|
|
924
|
+
// (undocumented)
|
|
925
|
+
cdnDeprecate = 2,
|
|
926
|
+
// (undocumented)
|
|
927
|
+
default = 0,
|
|
928
|
+
// (undocumented)
|
|
929
|
+
ikeyDeprecate = 1
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
// @public
|
|
933
|
+
export interface IThrottleResult {
|
|
934
|
+
isThrottled: boolean;
|
|
935
|
+
throttleNum: number;
|
|
936
|
+
}
|
|
937
|
+
|
|
892
938
|
export { ITraceParent }
|
|
893
939
|
|
|
894
940
|
// @public (undocumented)
|
|
@@ -1201,6 +1247,25 @@ export class TelemetryItemCreator {
|
|
|
1201
1247
|
static create: typeof createTelemetryItem;
|
|
1202
1248
|
}
|
|
1203
1249
|
|
|
1250
|
+
// @public (undocumented)
|
|
1251
|
+
export class ThrottleMgr {
|
|
1252
|
+
constructor(throttleMgr?: IThrottleMgrConfig, core?: IAppInsightsCore, namePrefix?: string);
|
|
1253
|
+
// (undocumented)
|
|
1254
|
+
canThrottle: () => boolean;
|
|
1255
|
+
// (undocumented)
|
|
1256
|
+
flush: () => boolean;
|
|
1257
|
+
// (undocumented)
|
|
1258
|
+
getConfig: () => IThrottleMgrConfig;
|
|
1259
|
+
// (undocumented)
|
|
1260
|
+
isReady: () => boolean;
|
|
1261
|
+
// (undocumented)
|
|
1262
|
+
isTriggered: () => boolean;
|
|
1263
|
+
// (undocumented)
|
|
1264
|
+
onReadyState: (isReady?: boolean) => boolean;
|
|
1265
|
+
// (undocumented)
|
|
1266
|
+
sendMessage: (msgID: _eInternalMessageId, message: string, severity?: eLoggingSeverity) => IThrottleResult | null;
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1204
1269
|
// Warning: (ae-forgotten-export) The symbol "IMessageData" needs to be exported by the entry point applicationinsights-common.d.ts
|
|
1205
1270
|
//
|
|
1206
1271
|
// @public (undocumented)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Microsoft Application Insights Common JavaScript Library, 2.8.9
|
|
2
|
+
* Microsoft Application Insights Common JavaScript Library, 2.8.9
|
|
3
3
|
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* Microsoft Application Insights Team
|
|
@@ -9,9 +9,11 @@
|
|
|
9
9
|
declare namespace ApplicationInsights {
|
|
10
10
|
import { createTraceParent } from '@microsoft/applicationinsights-core-js';
|
|
11
11
|
import { _eInternalMessageId } from '@microsoft/applicationinsights-core-js';
|
|
12
|
+
import { eLoggingSeverity } from '@microsoft/applicationinsights-core-js';
|
|
12
13
|
import { EnumValue } from '@microsoft/applicationinsights-core-js';
|
|
13
14
|
import { findW3cTraceParent } from '@microsoft/applicationinsights-core-js';
|
|
14
15
|
import { formatTraceParent } from '@microsoft/applicationinsights-core-js';
|
|
16
|
+
import { IAppInsightsCore } from '@microsoft/applicationinsights-core-js';
|
|
15
17
|
import { IChannelControls } from '@microsoft/applicationinsights-core-js';
|
|
16
18
|
import { IConfiguration } from '@microsoft/applicationinsights-core-js';
|
|
17
19
|
import { ICookieMgr } from '@microsoft/applicationinsights-core-js';
|
|
@@ -2029,6 +2031,110 @@ declare namespace ApplicationInsights {
|
|
|
2029
2031
|
name?: string;
|
|
2030
2032
|
}
|
|
2031
2033
|
|
|
2034
|
+
/**
|
|
2035
|
+
* Identifies frequency of items sent
|
|
2036
|
+
* Default: send data on 28th every 3 month each year
|
|
2037
|
+
*/
|
|
2038
|
+
interface IThrottleInterval {
|
|
2039
|
+
/**
|
|
2040
|
+
* Identifies month interval that items can be sent
|
|
2041
|
+
* For example, if it is set to 2 and start date is in Jan, items will be sent out every two months (Jan, March, May etc.)
|
|
2042
|
+
* Default: 3
|
|
2043
|
+
*/
|
|
2044
|
+
monthInterval?: number;
|
|
2045
|
+
/**
|
|
2046
|
+
* Identifies days that items can be sent within a month
|
|
2047
|
+
* Default: 28
|
|
2048
|
+
*/
|
|
2049
|
+
dayInterval?: number;
|
|
2050
|
+
/**
|
|
2051
|
+
* Identifies max times items can be sent within a month
|
|
2052
|
+
* Default: 1
|
|
2053
|
+
*/
|
|
2054
|
+
maxTimesPerMonth?: number;
|
|
2055
|
+
}
|
|
2056
|
+
|
|
2057
|
+
/**
|
|
2058
|
+
* Identifies limit number/percentage of items sent per time
|
|
2059
|
+
* If both are provided, minimum number between the two will be used
|
|
2060
|
+
*/
|
|
2061
|
+
interface IThrottleLimit {
|
|
2062
|
+
/**
|
|
2063
|
+
* Identifies sampling percentage of items per time
|
|
2064
|
+
* The percentage is set to 4 decimal places, for example: 1 means 0.0001%
|
|
2065
|
+
* Default: 100 (0.01%)
|
|
2066
|
+
*/
|
|
2067
|
+
samplingRate?: number;
|
|
2068
|
+
/**
|
|
2069
|
+
* Identifies limit number of items per time
|
|
2070
|
+
* Default: 1
|
|
2071
|
+
*/
|
|
2072
|
+
maxSendNumber?: number;
|
|
2073
|
+
}
|
|
2074
|
+
|
|
2075
|
+
/**
|
|
2076
|
+
* Identifies object for local storage
|
|
2077
|
+
*/
|
|
2078
|
+
interface IThrottleLocalStorageObj {
|
|
2079
|
+
/**
|
|
2080
|
+
* Identifies start date
|
|
2081
|
+
*/
|
|
2082
|
+
date: Date;
|
|
2083
|
+
/**
|
|
2084
|
+
* Identifies current count
|
|
2085
|
+
*/
|
|
2086
|
+
count: number;
|
|
2087
|
+
/**
|
|
2088
|
+
* identifies previous triggered throttle date
|
|
2089
|
+
*/
|
|
2090
|
+
preTriggerDate?: Date;
|
|
2091
|
+
}
|
|
2092
|
+
|
|
2093
|
+
/**
|
|
2094
|
+
* Identifies basic config
|
|
2095
|
+
*/
|
|
2096
|
+
interface IThrottleMgrConfig {
|
|
2097
|
+
/**
|
|
2098
|
+
* Identifies message key to be used for local storage key
|
|
2099
|
+
*/
|
|
2100
|
+
msgKey: IThrottleMsgKey;
|
|
2101
|
+
/**
|
|
2102
|
+
* Identifies if throttle is disabled
|
|
2103
|
+
* Default: false
|
|
2104
|
+
*/
|
|
2105
|
+
disabled?: boolean;
|
|
2106
|
+
/**
|
|
2107
|
+
* Identifies limit number/percentage of items sent per time
|
|
2108
|
+
*/
|
|
2109
|
+
limit?: IThrottleLimit;
|
|
2110
|
+
/**
|
|
2111
|
+
* Identifies frequency of items sent
|
|
2112
|
+
* Default: send data on 28th every 3 month each year
|
|
2113
|
+
*/
|
|
2114
|
+
interval?: IThrottleInterval;
|
|
2115
|
+
}
|
|
2116
|
+
|
|
2117
|
+
const enum IThrottleMsgKey {
|
|
2118
|
+
default = 0,
|
|
2119
|
+
ikeyDeprecate = 1,
|
|
2120
|
+
cdnDeprecate = 2
|
|
2121
|
+
}
|
|
2122
|
+
|
|
2123
|
+
/**
|
|
2124
|
+
* Identifies throttle result
|
|
2125
|
+
*/
|
|
2126
|
+
interface IThrottleResult {
|
|
2127
|
+
/**
|
|
2128
|
+
* Identifies if items are sent
|
|
2129
|
+
*/
|
|
2130
|
+
isThrottled: boolean;
|
|
2131
|
+
/**
|
|
2132
|
+
* Identifies numbers of items are sent
|
|
2133
|
+
* if isThrottled is false, it will be set to 0
|
|
2134
|
+
*/
|
|
2135
|
+
throttleNum: number;
|
|
2136
|
+
}
|
|
2137
|
+
|
|
2032
2138
|
export { ITraceParent }
|
|
2033
2139
|
|
|
2034
2140
|
interface ITraceState {
|
|
@@ -2596,6 +2702,17 @@ declare namespace ApplicationInsights {
|
|
|
2596
2702
|
static create: typeof createTelemetryItem;
|
|
2597
2703
|
}
|
|
2598
2704
|
|
|
2705
|
+
class ThrottleMgr {
|
|
2706
|
+
canThrottle: () => boolean;
|
|
2707
|
+
sendMessage: (msgID: _eInternalMessageId, message: string, severity?: eLoggingSeverity) => IThrottleResult | null;
|
|
2708
|
+
getConfig: () => IThrottleMgrConfig;
|
|
2709
|
+
isTriggered: () => boolean;
|
|
2710
|
+
isReady: () => boolean;
|
|
2711
|
+
onReadyState: (isReady?: boolean) => boolean;
|
|
2712
|
+
flush: () => boolean;
|
|
2713
|
+
constructor(throttleMgr?: IThrottleMgrConfig, core?: IAppInsightsCore, namePrefix?: string);
|
|
2714
|
+
}
|
|
2715
|
+
|
|
2599
2716
|
class Trace implements IMessageData, ISerializable {
|
|
2600
2717
|
static envelopeType: string;
|
|
2601
2718
|
static dataType: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Application Insights JavaScript SDK - Common, 2.8.9
|
|
2
|
+
* Application Insights JavaScript SDK - Common, 2.8.9
|
|
3
3
|
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
4
|
*/
|
|
5
5
|
(function (global, factory) {
|
|
@@ -102,6 +102,7 @@
|
|
|
102
102
|
|
|
103
103
|
var _DYN_NAME$1 = "name";
|
|
104
104
|
var _DYN_PUSH = "push";
|
|
105
|
+
var _DYN_LOGGER = "logger";
|
|
105
106
|
var _DYN_LENGTH$1 = "length";
|
|
106
107
|
var _DYN_MESSAGE_ID = "messageId";
|
|
107
108
|
var _DYN_MESSAGE$1 = "message";
|
|
@@ -973,6 +974,9 @@
|
|
|
973
974
|
_InternalLogMessage.dataType = "MessageData";
|
|
974
975
|
return _InternalLogMessage;
|
|
975
976
|
}());
|
|
977
|
+
function safeGetLogger(core, config) {
|
|
978
|
+
return (core || {})[_DYN_LOGGER ] || new DiagnosticLogger(config);
|
|
979
|
+
}
|
|
976
980
|
var DiagnosticLogger = /** @class */ (function () {
|
|
977
981
|
function DiagnosticLogger(config) {
|
|
978
982
|
this.identifier = "DiagnosticLogger";
|
|
@@ -1172,7 +1176,7 @@
|
|
|
1172
1176
|
}
|
|
1173
1177
|
|
|
1174
1178
|
var _objDefineProperty = ObjDefineProperty;
|
|
1175
|
-
var version =
|
|
1179
|
+
var version = '2.8.9';
|
|
1176
1180
|
var instanceName = "." + newId(6);
|
|
1177
1181
|
var _dataUid = 0;
|
|
1178
1182
|
function _createAccessor(target, prop, value) {
|
|
@@ -1846,6 +1850,14 @@
|
|
|
1846
1850
|
var _DYN_TO_STRING = "toString";
|
|
1847
1851
|
var _DYN_REMOVE_ITEM = "removeItem";
|
|
1848
1852
|
var _DYN_NAME = "name";
|
|
1853
|
+
var _DYN_MESSAGE = "message";
|
|
1854
|
+
var _DYN_COUNT = "count";
|
|
1855
|
+
var _DYN_PRE_TRIGGER_DATE = "preTriggerDate";
|
|
1856
|
+
var _DYN_DISABLED = "disabled";
|
|
1857
|
+
var _DYN_DATE = "date";
|
|
1858
|
+
var _DYN_GET_UTCDATE = "getUTCDate";
|
|
1859
|
+
var _DYN_MAX_TIMES_PER_MONTH = "maxTimesPerMonth";
|
|
1860
|
+
var _DYN_STRINGIFY = "stringify";
|
|
1849
1861
|
var _DYN_PATHNAME = "pathname";
|
|
1850
1862
|
var _DYN_CORRELATION_HEADER_E0 = "correlationHeaderExcludePatterns";
|
|
1851
1863
|
var _DYN_INDEX_OF = "indexOf";
|
|
@@ -1854,8 +1866,6 @@
|
|
|
1854
1866
|
var _DYN_PARSED_STACK = "parsedStack";
|
|
1855
1867
|
var _DYN_PROPERTIES = "properties";
|
|
1856
1868
|
var _DYN_MEASUREMENTS = "measurements";
|
|
1857
|
-
var _DYN_STRINGIFY = "stringify";
|
|
1858
|
-
var _DYN_MESSAGE = "message";
|
|
1859
1869
|
var _DYN_SIZE_IN_BYTES = "sizeInBytes";
|
|
1860
1870
|
var _DYN_TYPE_NAME = "typeName";
|
|
1861
1871
|
var _DYN_SEVERITY_LEVEL = "severityLevel";
|
|
@@ -2497,6 +2507,213 @@
|
|
|
2497
2507
|
};
|
|
2498
2508
|
}
|
|
2499
2509
|
|
|
2510
|
+
var THROTTLE_STORAGE_PREFIX = "appInsightsThrottle";
|
|
2511
|
+
var ThrottleMgr = /** @class */ (function () {
|
|
2512
|
+
function ThrottleMgr(throttleMgr, core, namePrefix) {
|
|
2513
|
+
var _self = this;
|
|
2514
|
+
var _canUseLocalStorage;
|
|
2515
|
+
var _logger;
|
|
2516
|
+
var _config;
|
|
2517
|
+
var _localStorageName;
|
|
2518
|
+
var _localStorageObj;
|
|
2519
|
+
var _isTriggered;
|
|
2520
|
+
var _namePrefix;
|
|
2521
|
+
var _queue;
|
|
2522
|
+
var _isReady = false;
|
|
2523
|
+
_initConfig();
|
|
2524
|
+
_self.getConfig = function () {
|
|
2525
|
+
return _config;
|
|
2526
|
+
};
|
|
2527
|
+
_self.canThrottle = function () {
|
|
2528
|
+
return _canThrottle(_config, _canUseLocalStorage, _localStorageObj);
|
|
2529
|
+
};
|
|
2530
|
+
_self.isTriggered = function () {
|
|
2531
|
+
return _isTriggered;
|
|
2532
|
+
};
|
|
2533
|
+
_self.isReady = function () {
|
|
2534
|
+
return _isReady;
|
|
2535
|
+
};
|
|
2536
|
+
_self.flush = function () {
|
|
2537
|
+
try {
|
|
2538
|
+
if (_isReady && _queue[_DYN_LENGTH ] > 0) {
|
|
2539
|
+
arrForEach(_queue, function (item) {
|
|
2540
|
+
_self.sendMessage(item.msgID, item[_DYN_MESSAGE ], item.severity);
|
|
2541
|
+
});
|
|
2542
|
+
return true;
|
|
2543
|
+
}
|
|
2544
|
+
}
|
|
2545
|
+
catch (err) {
|
|
2546
|
+
}
|
|
2547
|
+
return false;
|
|
2548
|
+
};
|
|
2549
|
+
_self.onReadyState = function (isReady) {
|
|
2550
|
+
_isReady = isNullOrUndefined(isReady) ? true : isReady;
|
|
2551
|
+
return _self.flush();
|
|
2552
|
+
};
|
|
2553
|
+
_self.sendMessage = function (msgID, message, severity) {
|
|
2554
|
+
if (_isReady) {
|
|
2555
|
+
var isSampledIn = _canSampledIn();
|
|
2556
|
+
if (!isSampledIn) {
|
|
2557
|
+
return;
|
|
2558
|
+
}
|
|
2559
|
+
var canThrottle = _canThrottle(_config, _canUseLocalStorage, _localStorageObj);
|
|
2560
|
+
var throttled = false;
|
|
2561
|
+
var number = 0;
|
|
2562
|
+
try {
|
|
2563
|
+
if (canThrottle && !_isTriggered) {
|
|
2564
|
+
number = Math.min(_config.limit.maxSendNumber, _localStorageObj[_DYN_COUNT ] + 1);
|
|
2565
|
+
_localStorageObj[_DYN_COUNT ] = 0;
|
|
2566
|
+
throttled = true;
|
|
2567
|
+
_isTriggered = true;
|
|
2568
|
+
_localStorageObj[_DYN_PRE_TRIGGER_DATE ] = new Date();
|
|
2569
|
+
}
|
|
2570
|
+
else {
|
|
2571
|
+
_isTriggered = canThrottle;
|
|
2572
|
+
_localStorageObj[_DYN_COUNT ] += 1;
|
|
2573
|
+
}
|
|
2574
|
+
_resetLocalStorage(_logger, _localStorageName, _localStorageObj);
|
|
2575
|
+
for (var i = 0; i < number; i++) {
|
|
2576
|
+
_sendMessage(msgID, _logger, message, severity);
|
|
2577
|
+
}
|
|
2578
|
+
}
|
|
2579
|
+
catch (e) {
|
|
2580
|
+
}
|
|
2581
|
+
return {
|
|
2582
|
+
isThrottled: throttled,
|
|
2583
|
+
throttleNum: number
|
|
2584
|
+
};
|
|
2585
|
+
}
|
|
2586
|
+
else {
|
|
2587
|
+
_queue.push({
|
|
2588
|
+
msgID: msgID,
|
|
2589
|
+
message: message,
|
|
2590
|
+
severity: severity
|
|
2591
|
+
});
|
|
2592
|
+
}
|
|
2593
|
+
return null;
|
|
2594
|
+
};
|
|
2595
|
+
function _initConfig() {
|
|
2596
|
+
var _a, _b, _c, _d, _e;
|
|
2597
|
+
_canUseLocalStorage = utlCanUseLocalStorage();
|
|
2598
|
+
_logger = safeGetLogger(core);
|
|
2599
|
+
_isTriggered = false;
|
|
2600
|
+
_namePrefix = isNotNullOrUndefined(namePrefix) ? namePrefix : "";
|
|
2601
|
+
_queue = [];
|
|
2602
|
+
var configMgr = throttleMgr;
|
|
2603
|
+
_config = {};
|
|
2604
|
+
_config[_DYN_DISABLED ] = !!configMgr[_DYN_DISABLED ];
|
|
2605
|
+
_config.msgKey = configMgr.msgKey;
|
|
2606
|
+
var interval = {
|
|
2607
|
+
monthInterval: ((_a = configMgr.interval) === null || _a === void 0 ? void 0 : _a.monthInterval) || 3,
|
|
2608
|
+
dayInterval: ((_b = configMgr.interval) === null || _b === void 0 ? void 0 : _b.dayInterval) || 28,
|
|
2609
|
+
maxTimesPerMonth: ((_c = configMgr.interval) === null || _c === void 0 ? void 0 : _c.maxTimesPerMonth) || 1
|
|
2610
|
+
};
|
|
2611
|
+
_config.interval = interval;
|
|
2612
|
+
var limit = {
|
|
2613
|
+
samplingRate: ((_d = configMgr.limit) === null || _d === void 0 ? void 0 : _d.samplingRate) || 100,
|
|
2614
|
+
maxSendNumber: ((_e = configMgr.limit) === null || _e === void 0 ? void 0 : _e.maxSendNumber) || 1
|
|
2615
|
+
};
|
|
2616
|
+
_config.limit = limit;
|
|
2617
|
+
_localStorageName = _getLocalStorageName(_config.msgKey, _namePrefix);
|
|
2618
|
+
if (_canUseLocalStorage && _localStorageName) {
|
|
2619
|
+
_localStorageObj = _getLocalStorageObj(utlGetLocalStorage(_logger, _localStorageName), _logger, _localStorageName);
|
|
2620
|
+
}
|
|
2621
|
+
if (_localStorageObj) {
|
|
2622
|
+
_isTriggered = _isTriggeredOnCurDate(_localStorageObj[_DYN_PRE_TRIGGER_DATE ]);
|
|
2623
|
+
}
|
|
2624
|
+
}
|
|
2625
|
+
function _canThrottle(config, canUseLocalStorage, localStorageObj) {
|
|
2626
|
+
if (!config[_DYN_DISABLED ] && canUseLocalStorage && isNotNullOrUndefined(localStorageObj)) {
|
|
2627
|
+
var curDate = _getThrottleDate();
|
|
2628
|
+
var date = localStorageObj[_DYN_DATE ];
|
|
2629
|
+
var interval = config.interval;
|
|
2630
|
+
var monthExpand = (curDate.getUTCFullYear() - date.getUTCFullYear()) * 12 + curDate.getUTCMonth() - date.getUTCMonth();
|
|
2631
|
+
var monthCheck = _checkInterval(interval.monthInterval, 0, monthExpand);
|
|
2632
|
+
var dayCheck = _checkInterval(interval.dayInterval, 0, curDate[_DYN_GET_UTCDATE ]()) - 1;
|
|
2633
|
+
return monthCheck >= 0 && dayCheck >= 0 && dayCheck <= config.interval[_DYN_MAX_TIMES_PER_MONTH ];
|
|
2634
|
+
}
|
|
2635
|
+
return false;
|
|
2636
|
+
}
|
|
2637
|
+
function _getLocalStorageName(msgKey, prefix) {
|
|
2638
|
+
var fix = isNotNullOrUndefined(prefix) ? prefix : "";
|
|
2639
|
+
if (msgKey) {
|
|
2640
|
+
return THROTTLE_STORAGE_PREFIX + fix + "-" + msgKey;
|
|
2641
|
+
}
|
|
2642
|
+
return null;
|
|
2643
|
+
}
|
|
2644
|
+
function _isTriggeredOnCurDate(preTriggerDate) {
|
|
2645
|
+
try {
|
|
2646
|
+
if (preTriggerDate) {
|
|
2647
|
+
var curDate = new Date();
|
|
2648
|
+
return preTriggerDate.getUTCFullYear() === curDate.getUTCFullYear() &&
|
|
2649
|
+
preTriggerDate.getUTCMonth() === curDate.getUTCMonth() &&
|
|
2650
|
+
preTriggerDate[_DYN_GET_UTCDATE ]() === curDate[_DYN_GET_UTCDATE ]();
|
|
2651
|
+
}
|
|
2652
|
+
}
|
|
2653
|
+
catch (e) {
|
|
2654
|
+
}
|
|
2655
|
+
return false;
|
|
2656
|
+
}
|
|
2657
|
+
function _getLocalStorageObj(value, logger, storageName) {
|
|
2658
|
+
try {
|
|
2659
|
+
var storageObj = {
|
|
2660
|
+
date: _getThrottleDate(),
|
|
2661
|
+
count: 0
|
|
2662
|
+
};
|
|
2663
|
+
if (value) {
|
|
2664
|
+
var obj = JSON.parse(value);
|
|
2665
|
+
return {
|
|
2666
|
+
date: _getThrottleDate(obj[_DYN_DATE ]) || storageObj[_DYN_DATE ],
|
|
2667
|
+
count: obj[_DYN_COUNT ] || storageObj[_DYN_COUNT ],
|
|
2668
|
+
preTriggerDate: obj.preTriggerDate ? _getThrottleDate(obj[_DYN_PRE_TRIGGER_DATE ]) : undefined
|
|
2669
|
+
};
|
|
2670
|
+
}
|
|
2671
|
+
else {
|
|
2672
|
+
_resetLocalStorage(logger, storageName, storageObj);
|
|
2673
|
+
return storageObj;
|
|
2674
|
+
}
|
|
2675
|
+
}
|
|
2676
|
+
catch (e) {
|
|
2677
|
+
}
|
|
2678
|
+
return null;
|
|
2679
|
+
}
|
|
2680
|
+
function _getThrottleDate(dateStr) {
|
|
2681
|
+
try {
|
|
2682
|
+
if (dateStr) {
|
|
2683
|
+
var date = new Date(dateStr);
|
|
2684
|
+
if (!isNaN(date.getDate())) {
|
|
2685
|
+
return date;
|
|
2686
|
+
}
|
|
2687
|
+
}
|
|
2688
|
+
else {
|
|
2689
|
+
return new Date();
|
|
2690
|
+
}
|
|
2691
|
+
}
|
|
2692
|
+
catch (e) {
|
|
2693
|
+
}
|
|
2694
|
+
return null;
|
|
2695
|
+
}
|
|
2696
|
+
function _resetLocalStorage(logger, storageName, obj) {
|
|
2697
|
+
try {
|
|
2698
|
+
return utlSetLocalStorage(logger, storageName, strTrim(JSON[_DYN_STRINGIFY ](obj)));
|
|
2699
|
+
}
|
|
2700
|
+
catch (e) {
|
|
2701
|
+
}
|
|
2702
|
+
return false;
|
|
2703
|
+
}
|
|
2704
|
+
function _checkInterval(interval, start, current) {
|
|
2705
|
+
return (current >= start) && (current - start) % interval == 0 ? Math.floor((current - start) / interval) + 1 : -1;
|
|
2706
|
+
}
|
|
2707
|
+
function _sendMessage(msgID, logger, message, severity) {
|
|
2708
|
+
_throwInternal(logger, severity || 1 , msgID, message);
|
|
2709
|
+
}
|
|
2710
|
+
function _canSampledIn() {
|
|
2711
|
+
return randomValue(1000000) <= _config.limit.samplingRate;
|
|
2712
|
+
}
|
|
2713
|
+
}
|
|
2714
|
+
return ThrottleMgr;
|
|
2715
|
+
}());
|
|
2716
|
+
|
|
2500
2717
|
var _FIELDS_SEPARATOR = ";";
|
|
2501
2718
|
var _FIELD_KEY_VALUE_SEPARATOR = "=";
|
|
2502
2719
|
function parseConnectionString(connectionString) {
|
|
@@ -3059,7 +3276,7 @@
|
|
|
3059
3276
|
var _self = this;
|
|
3060
3277
|
_self.ver = 2;
|
|
3061
3278
|
var dataPoint = new DataPoint();
|
|
3062
|
-
dataPoint
|
|
3279
|
+
dataPoint[_DYN_COUNT ] = count > 0 ? count : undefined;
|
|
3063
3280
|
dataPoint.max = isNaN(max) || max === null ? undefined : max;
|
|
3064
3281
|
dataPoint.min = isNaN(min) || min === null ? undefined : min;
|
|
3065
3282
|
dataPoint[_DYN_NAME ] = dataSanitizeString(logger, name) || strNotSpecified;
|
|
@@ -3407,6 +3624,7 @@
|
|
|
3407
3624
|
exports.SampleRate = SampleRate;
|
|
3408
3625
|
exports.SeverityLevel = SeverityLevel;
|
|
3409
3626
|
exports.TelemetryItemCreator = TelemetryItemCreator;
|
|
3627
|
+
exports.ThrottleMgr = ThrottleMgr;
|
|
3410
3628
|
exports.Trace = Trace;
|
|
3411
3629
|
exports.UrlHelper = UrlHelper;
|
|
3412
3630
|
exports.Util = Util;
|