@microsoft/applicationinsights-core-js 2.7.0-beta.1 → 2.7.1-nightly.202110-04
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-core-js.integrity.json +9 -9
- package/browser/applicationinsights-core-js.js +110 -17
- package/browser/applicationinsights-core-js.js.map +1 -1
- package/browser/applicationinsights-core-js.min.js +2 -2
- package/browser/applicationinsights-core-js.min.js.map +1 -1
- package/dist/applicationinsights-core-js.api.json +182 -1
- package/dist/applicationinsights-core-js.api.md +15 -0
- package/dist/applicationinsights-core-js.d.ts +27 -1
- package/dist/applicationinsights-core-js.js +110 -17
- package/dist/applicationinsights-core-js.js.map +1 -1
- package/dist/applicationinsights-core-js.min.js +2 -2
- package/dist/applicationinsights-core-js.min.js.map +1 -1
- package/dist/applicationinsights-core-js.rollup.d.ts +27 -1
- package/dist-esm/JavaScriptSDK/AppInsightsCore.js +21 -3
- package/dist-esm/JavaScriptSDK/AppInsightsCore.js.map +1 -1
- package/dist-esm/JavaScriptSDK/BaseCore.js +3 -3
- package/dist-esm/JavaScriptSDK/BaseCore.js.map +1 -1
- package/dist-esm/JavaScriptSDK/BaseTelemetryPlugin.js +2 -2
- package/dist-esm/JavaScriptSDK/BaseTelemetryPlugin.js.map +1 -1
- package/dist-esm/JavaScriptSDK/ChannelController.js +1 -2
- package/dist-esm/JavaScriptSDK/ChannelController.js.map +1 -1
- package/dist-esm/JavaScriptSDK/Constants.js +1 -1
- package/dist-esm/JavaScriptSDK/CookieMgr.js +1 -1
- package/dist-esm/JavaScriptSDK/CoreUtils.js +2 -2
- package/dist-esm/JavaScriptSDK/CoreUtils.js.map +1 -1
- package/dist-esm/JavaScriptSDK/DiagnosticLogger.js +1 -1
- package/dist-esm/JavaScriptSDK/EnvUtils.js +86 -3
- package/dist-esm/JavaScriptSDK/EnvUtils.js.map +1 -1
- package/dist-esm/JavaScriptSDK/HelperFuncs.js +27 -17
- package/dist-esm/JavaScriptSDK/HelperFuncs.js.map +1 -1
- package/dist-esm/JavaScriptSDK/InstrumentHooks.js +1 -2
- package/dist-esm/JavaScriptSDK/InstrumentHooks.js.map +1 -1
- package/dist-esm/JavaScriptSDK/NotificationManager.js +1 -1
- package/dist-esm/JavaScriptSDK/PerfManager.js +1 -1
- package/dist-esm/JavaScriptSDK/ProcessTelemetryContext.js +1 -1
- package/dist-esm/JavaScriptSDK/RandomHelper.js +1 -1
- package/dist-esm/JavaScriptSDK/TelemetryHelpers.js +2 -2
- package/dist-esm/JavaScriptSDK/TelemetryHelpers.js.map +1 -1
- package/dist-esm/JavaScriptSDK/TelemetryPluginChain.js +4 -3
- package/dist-esm/JavaScriptSDK/TelemetryPluginChain.js.map +1 -1
- package/dist-esm/JavaScriptSDK.Enums/EventsDiscardedReason.js +1 -1
- package/dist-esm/JavaScriptSDK.Enums/LoggingEnums.js +1 -1
- package/dist-esm/JavaScriptSDK.Enums/SendRequestReason.js +1 -2
- package/dist-esm/JavaScriptSDK.Enums/SendRequestReason.js.map +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/IAppInsightsCore.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/IChannelControls.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/IConfiguration.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/ICookieMgr.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/IDiagnosticLogger.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/IInstrumentHooks.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/INotificationListener.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/INotificationManager.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/IPerfEvent.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/IPerfManager.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/IProcessTelemetryContext.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryItem.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryPlugin.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryPluginChain.js +1 -1
- package/dist-esm/applicationinsights-core-js.js +2 -2
- package/dist-esm/applicationinsights-core-js.js.map +1 -1
- package/package.json +70 -70
- package/src/JavaScriptSDK/AppInsightsCore.ts +27 -6
- package/src/JavaScriptSDK/BaseCore.ts +3 -3
- package/src/JavaScriptSDK/BaseTelemetryPlugin.ts +4 -4
- package/src/JavaScriptSDK/ChannelController.ts +3 -3
- package/src/JavaScriptSDK/CookieMgr.ts +6 -6
- package/src/JavaScriptSDK/CoreUtils.ts +20 -20
- package/src/JavaScriptSDK/DiagnosticLogger.ts +1 -2
- package/src/JavaScriptSDK/EnvUtils.ts +115 -21
- package/src/JavaScriptSDK/HelperFuncs.ts +41 -29
- package/src/JavaScriptSDK/InstrumentHooks.ts +1 -1
- package/src/JavaScriptSDK/NotificationManager.ts +1 -1
- package/src/JavaScriptSDK/PerfManager.ts +8 -8
- package/src/JavaScriptSDK/ProcessTelemetryContext.ts +1 -1
- package/src/JavaScriptSDK/RandomHelper.ts +1 -1
- package/src/JavaScriptSDK/TelemetryHelpers.ts +4 -4
- package/src/JavaScriptSDK/TelemetryPluginChain.ts +4 -3
- package/src/JavaScriptSDK.Enums/EventsDiscardedReason.ts +1 -1
- package/src/JavaScriptSDK.Enums/SendRequestReason.ts +1 -1
- package/src/JavaScriptSDK.Interfaces/IAppInsightsCore.ts +3 -1
- package/src/JavaScriptSDK.Interfaces/IChannelControls.ts +2 -2
- package/src/JavaScriptSDK.Interfaces/IConfiguration.ts +6 -6
- package/src/JavaScriptSDK.Interfaces/ICookieMgr.ts +1 -1
- package/src/JavaScriptSDK.Interfaces/IInstrumentHooks.ts +2 -2
- package/src/JavaScriptSDK.Interfaces/INotificationListener.ts +1 -1
- package/src/JavaScriptSDK.Interfaces/INotificationManager.ts +1 -1
- package/src/JavaScriptSDK.Interfaces/IPerfEvent.ts +1 -1
- package/src/JavaScriptSDK.Interfaces/IPerfManager.ts +2 -2
- package/src/JavaScriptSDK.Interfaces/IProcessTelemetryContext.ts +1 -1
- package/src/JavaScriptSDK.Interfaces/ITelemetryItem.ts +1 -1
- package/src/JavaScriptSDK.Interfaces/ITelemetryPlugin.ts +4 -4
- package/src/JavaScriptSDK.Interfaces/ITelemetryPluginChain.ts +1 -1
- package/types/JavaScriptSDK/AppInsightsCore.d.ts +4 -0
- package/types/JavaScriptSDK/EnvUtils.d.ts +17 -0
- package/types/JavaScriptSDK.Interfaces/IAppInsightsCore.d.ts +1 -0
- package/types/applicationinsights-core-js.d.ts +1 -1
- package/types/tsdoc-metadata.json +1 -1
|
@@ -2,15 +2,18 @@
|
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
3
|
"use strict";
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
getGlobal, strShimUndefined, strShimObject, strShimPrototype
|
|
5
|
+
import {
|
|
6
|
+
getGlobal, strShimUndefined, strShimObject, strShimPrototype
|
|
7
7
|
} from "@microsoft/applicationinsights-shims";
|
|
8
|
-
import { isString, strContains } from "./HelperFuncs";
|
|
8
|
+
import { isString, isUndefined, strContains } from "./HelperFuncs";
|
|
9
|
+
|
|
10
|
+
// TypeScript removed this interface so we need to declare the global so we can check for it's existence.
|
|
11
|
+
declare var XDomainRequest: any;
|
|
9
12
|
|
|
10
13
|
/**
|
|
11
14
|
* This file exists to hold environment utilities that are required to check and
|
|
12
15
|
* validate the current operating environment. Unless otherwise required, please
|
|
13
|
-
* only defined methods (functions) in this class so that users of these
|
|
16
|
+
* only use defined methods (functions) in this class so that users of these
|
|
14
17
|
* functions/properties only need to include those that are used within their own modules.
|
|
15
18
|
*/
|
|
16
19
|
|
|
@@ -31,10 +34,41 @@ const strTrident = "trident/";
|
|
|
31
34
|
let _isTrident: boolean = null;
|
|
32
35
|
let _navUserAgentCheck: string = null;
|
|
33
36
|
let _enableMocks = false;
|
|
37
|
+
let _useXDomainRequest: boolean | null = null;
|
|
38
|
+
let _beaconsSupported: boolean | null = null;
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
function _hasProperty(theClass: any, property: string) {
|
|
42
|
+
let supported = false;
|
|
43
|
+
if (theClass) {
|
|
44
|
+
try {
|
|
45
|
+
supported = property in theClass;
|
|
46
|
+
if (!supported) {
|
|
47
|
+
let proto = theClass[strShimPrototype];
|
|
48
|
+
if (proto) {
|
|
49
|
+
supported = property in proto;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
} catch (e) {
|
|
53
|
+
// Do Nothing
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (!supported) {
|
|
57
|
+
try {
|
|
58
|
+
let tmp = new theClass();
|
|
59
|
+
supported = !isUndefined(tmp[property]);
|
|
60
|
+
} catch (e) {
|
|
61
|
+
// Do Nothing
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return supported;
|
|
67
|
+
}
|
|
34
68
|
|
|
35
69
|
/**
|
|
36
70
|
* Enable the lookup of test mock objects if requested
|
|
37
|
-
* @param enabled
|
|
71
|
+
* @param enabled
|
|
38
72
|
*/
|
|
39
73
|
export function setEnableEnvMocks(enabled: boolean) {
|
|
40
74
|
_enableMocks = enabled;
|
|
@@ -60,9 +94,9 @@ export function getGlobalInst<T>(name:string): T {
|
|
|
60
94
|
}
|
|
61
95
|
|
|
62
96
|
/**
|
|
63
|
-
* Checks if window object is available, this is required as we support the API running without a
|
|
64
|
-
* window /document (eg. Node server, electron webworkers) and if we attempt to assign a window
|
|
65
|
-
* object to a local variable or pass as an argument an "Uncaught ReferenceError: window is not defined"
|
|
97
|
+
* Checks if window object is available, this is required as we support the API running without a
|
|
98
|
+
* window /document (eg. Node server, electron webworkers) and if we attempt to assign a window
|
|
99
|
+
* object to a local variable or pass as an argument an "Uncaught ReferenceError: window is not defined"
|
|
66
100
|
* exception will be thrown.
|
|
67
101
|
* Defined as a function to support lazy / late binding environments.
|
|
68
102
|
*/
|
|
@@ -85,9 +119,9 @@ export function getWindow(): Window | null {
|
|
|
85
119
|
}
|
|
86
120
|
|
|
87
121
|
/**
|
|
88
|
-
* Checks if document object is available, this is required as we support the API running without a
|
|
89
|
-
* window /document (eg. Node server, electron webworkers) and if we attempt to assign a document
|
|
90
|
-
* object to a local variable or pass as an argument an "Uncaught ReferenceError: document is not defined"
|
|
122
|
+
* Checks if document object is available, this is required as we support the API running without a
|
|
123
|
+
* window /document (eg. Node server, electron webworkers) and if we attempt to assign a document
|
|
124
|
+
* object to a local variable or pass as an argument an "Uncaught ReferenceError: document is not defined"
|
|
91
125
|
* exception will be thrown.
|
|
92
126
|
* Defined as a function to support lazy / late binding environments.
|
|
93
127
|
*/
|
|
@@ -110,9 +144,9 @@ export function getDocument(): Document | null {
|
|
|
110
144
|
|
|
111
145
|
|
|
112
146
|
/**
|
|
113
|
-
* Checks if navigator object is available, this is required as we support the API running without a
|
|
114
|
-
* window /document (eg. Node server, electron webworkers) and if we attempt to assign a navigator
|
|
115
|
-
* object to a local variable or pass as an argument an "Uncaught ReferenceError: navigator is not defined"
|
|
147
|
+
* Checks if navigator object is available, this is required as we support the API running without a
|
|
148
|
+
* window /document (eg. Node server, electron webworkers) and if we attempt to assign a navigator
|
|
149
|
+
* object to a local variable or pass as an argument an "Uncaught ReferenceError: navigator is not defined"
|
|
116
150
|
* exception will be thrown.
|
|
117
151
|
* Defined as a function to support lazy / late binding environments.
|
|
118
152
|
*/
|
|
@@ -134,9 +168,9 @@ export function getNavigator(): Navigator | null {
|
|
|
134
168
|
}
|
|
135
169
|
|
|
136
170
|
/**
|
|
137
|
-
* Checks if history object is available, this is required as we support the API running without a
|
|
138
|
-
* window /document (eg. Node server, electron webworkers) and if we attempt to assign a history
|
|
139
|
-
* object to a local variable or pass as an argument an "Uncaught ReferenceError: history is not defined"
|
|
171
|
+
* Checks if history object is available, this is required as we support the API running without a
|
|
172
|
+
* window /document (eg. Node server, electron webworkers) and if we attempt to assign a history
|
|
173
|
+
* object to a local variable or pass as an argument an "Uncaught ReferenceError: history is not defined"
|
|
140
174
|
* exception will be thrown.
|
|
141
175
|
* Defined as a function to support lazy / late binding environments.
|
|
142
176
|
*/
|
|
@@ -198,9 +232,9 @@ export function getPerformance(): Performance | null {
|
|
|
198
232
|
}
|
|
199
233
|
|
|
200
234
|
/**
|
|
201
|
-
* Checks if JSON object is available, this is required as we support the API running without a
|
|
202
|
-
* window /document (eg. Node server, electron webworkers) and if we attempt to assign a history
|
|
203
|
-
* object to a local variable or pass as an argument an "Uncaught ReferenceError: JSON is not defined"
|
|
235
|
+
* Checks if JSON object is available, this is required as we support the API running without a
|
|
236
|
+
* window /document (eg. Node server, electron webworkers) and if we attempt to assign a history
|
|
237
|
+
* object to a local variable or pass as an argument an "Uncaught ReferenceError: JSON is not defined"
|
|
204
238
|
* exception will be thrown.
|
|
205
239
|
* Defined as a function to support lazy / late binding environments.
|
|
206
240
|
*/
|
|
@@ -308,8 +342,68 @@ export function isSafari(userAgentStr ?: string) {
|
|
|
308
342
|
if (!userAgentStr || !isString(userAgentStr)) {
|
|
309
343
|
let navigator = getNavigator() || ({} as Navigator);
|
|
310
344
|
userAgentStr = navigator ? (navigator.userAgent || "").toLowerCase() : "";
|
|
311
|
-
}
|
|
345
|
+
}
|
|
312
346
|
|
|
313
347
|
var ua = (userAgentStr || "").toLowerCase();
|
|
314
348
|
return (ua.indexOf('safari') >= 0);
|
|
315
349
|
}
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* Checks if HTML5 Beacons are supported in the current environment.
|
|
353
|
+
* @returns True if supported, false otherwise.
|
|
354
|
+
*/
|
|
355
|
+
export function isBeaconsSupported(): boolean {
|
|
356
|
+
if (_beaconsSupported === null) {
|
|
357
|
+
_beaconsSupported = hasNavigator() && Boolean(getNavigator().sendBeacon);
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
return _beaconsSupported;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* Checks if the Fetch API is supported in the current environment.
|
|
365
|
+
* @param withKeepAlive - [Optional] If True, check if fetch is available and it supports the keepalive feature, otherwise only check if fetch is supported
|
|
366
|
+
* @returns True if supported, otherwise false
|
|
367
|
+
*/
|
|
368
|
+
export function isFetchSupported(withKeepAlive?: boolean): boolean {
|
|
369
|
+
let isSupported = false;
|
|
370
|
+
try {
|
|
371
|
+
const fetchApi = getGlobalInst("fetch");
|
|
372
|
+
isSupported = !!fetchApi;
|
|
373
|
+
const request = getGlobalInst("Request");
|
|
374
|
+
if (isSupported && withKeepAlive && request) {
|
|
375
|
+
isSupported = _hasProperty(request, "keepalive");
|
|
376
|
+
}
|
|
377
|
+
} catch (e) {
|
|
378
|
+
// Just Swallow any failure during availability checks
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
return isSupported;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
export function useXDomainRequest(): boolean | undefined {
|
|
385
|
+
if (_useXDomainRequest === null) {
|
|
386
|
+
_useXDomainRequest = (typeof XDomainRequest !== undefined);
|
|
387
|
+
if (_useXDomainRequest && isXhrSupported()) {
|
|
388
|
+
_useXDomainRequest = _useXDomainRequest && !_hasProperty(getGlobalInst("XMLHttpRequest"), "withCredentials");
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
return _useXDomainRequest;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* Checks if XMLHttpRequest is supported
|
|
397
|
+
* @returns True if supported, otherwise false
|
|
398
|
+
*/
|
|
399
|
+
export function isXhrSupported(): boolean {
|
|
400
|
+
let isSupported = false;
|
|
401
|
+
try {
|
|
402
|
+
const xmlHttpRequest = getGlobalInst("XMLHttpRequest");
|
|
403
|
+
isSupported = !!xmlHttpRequest;
|
|
404
|
+
} catch (e) {
|
|
405
|
+
// Just Swallow any failure during availability checks
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
return isSupported;
|
|
409
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
4
|
strShimUndefined, strShimObject, strShimFunction, throwTypeError,
|
|
5
5
|
ObjClass, ObjProto, ObjAssign, ObjHasOwnProperty, ObjDefineProperty
|
|
6
6
|
} from "@microsoft/applicationinsights-shims";
|
|
@@ -24,11 +24,11 @@ export function objToString(obj: any) {
|
|
|
24
24
|
|
|
25
25
|
export function isTypeof(value: any, theType: string): boolean {
|
|
26
26
|
return typeof value === theType;
|
|
27
|
-
}
|
|
27
|
+
}
|
|
28
28
|
|
|
29
29
|
export function isUndefined(value: any): boolean {
|
|
30
30
|
return value === undefined || typeof value === strShimUndefined;
|
|
31
|
-
}
|
|
31
|
+
}
|
|
32
32
|
|
|
33
33
|
export function isNotUndefined(value: any): boolean {
|
|
34
34
|
return !isUndefined(value);
|
|
@@ -44,17 +44,17 @@ export function isNotNullOrUndefined(value: any): boolean {
|
|
|
44
44
|
|
|
45
45
|
export function hasOwnProperty(obj: any, prop: string): boolean {
|
|
46
46
|
return obj && ObjHasOwnProperty.call(obj, prop);
|
|
47
|
-
}
|
|
47
|
+
}
|
|
48
48
|
|
|
49
49
|
export function isObject(value: any): boolean {
|
|
50
50
|
// Changing to inline for performance
|
|
51
51
|
return typeof value === strShimObject;
|
|
52
|
-
}
|
|
52
|
+
}
|
|
53
53
|
|
|
54
54
|
export function isFunction(value: any): value is Function {
|
|
55
55
|
// Changing to inline for performance
|
|
56
56
|
return typeof value === strShimFunction;
|
|
57
|
-
}
|
|
57
|
+
}
|
|
58
58
|
|
|
59
59
|
/**
|
|
60
60
|
* Binds the specified function to an event, so that the function gets called whenever the event fires on the object
|
|
@@ -73,7 +73,7 @@ export function attachEvent(obj: any, eventNameWithoutOn: string, handlerRef: an
|
|
|
73
73
|
obj[strAddEventHelper](eventNameWithoutOn, handlerRef, useCapture);
|
|
74
74
|
result = true;
|
|
75
75
|
} else if (!isNullOrUndefined(obj[strAttachEvent])) {
|
|
76
|
-
// IE before version 9
|
|
76
|
+
// IE before version 9
|
|
77
77
|
obj[strAttachEvent](strOnPrefix + eventNameWithoutOn, handlerRef);
|
|
78
78
|
result = true;
|
|
79
79
|
}
|
|
@@ -124,7 +124,7 @@ export function normalizeJsName(name: string): string {
|
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
/**
|
|
127
|
-
* This is a helper function for the equivalent of arForEach(objKeys(target), callbackFn), this is a
|
|
127
|
+
* This is a helper function for the equivalent of arForEach(objKeys(target), callbackFn), this is a
|
|
128
128
|
* performance optimization to avoid the creation of a new array for large objects
|
|
129
129
|
* @param target The target object to find and process the keys
|
|
130
130
|
* @param callbackfn The function to call with the details
|
|
@@ -165,7 +165,7 @@ export function strEndsWith(value: string, search: string) {
|
|
|
165
165
|
}
|
|
166
166
|
|
|
167
167
|
return false;
|
|
168
|
-
}
|
|
168
|
+
}
|
|
169
169
|
|
|
170
170
|
/**
|
|
171
171
|
* The strStartsWith() method determines whether a string starts with the characters of the specified string, returning true or false as appropriate.
|
|
@@ -302,12 +302,16 @@ export function toISOString(date: Date) {
|
|
|
302
302
|
*/
|
|
303
303
|
export function arrForEach<T>(arr: T[], callbackfn: (value: T, index?: number, array?: T[]) => void|number, thisArg?: any): void {
|
|
304
304
|
let len = arr.length;
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
if (
|
|
308
|
-
|
|
305
|
+
try {
|
|
306
|
+
for (let idx = 0; idx < len; idx++) {
|
|
307
|
+
if (idx in arr) {
|
|
308
|
+
if (callbackfn.call(thisArg || arr, arr[idx], idx, arr) === -1) {
|
|
309
|
+
break;
|
|
310
|
+
}
|
|
309
311
|
}
|
|
310
312
|
}
|
|
313
|
+
} catch (e) {
|
|
314
|
+
// This can happen with some native browser objects, but should not happen for the type we are checking for
|
|
311
315
|
}
|
|
312
316
|
}
|
|
313
317
|
|
|
@@ -322,19 +326,23 @@ export function arrForEach<T>(arr: T[], callbackfn: (value: T, index?: number, a
|
|
|
322
326
|
export function arrIndexOf<T>(arr: T[], searchElement: T, fromIndex?: number): number {
|
|
323
327
|
let len = arr.length;
|
|
324
328
|
let from = fromIndex || 0;
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
329
|
+
try {
|
|
330
|
+
for (let lp = Math.max(from >= 0 ? from : len - Math.abs(from), 0); lp < len; lp++) {
|
|
331
|
+
if (lp in arr && arr[lp] === searchElement) {
|
|
332
|
+
return lp;
|
|
333
|
+
}
|
|
328
334
|
}
|
|
335
|
+
} catch (e) {
|
|
336
|
+
// This can happen with some native browser objects, but should not happen for the type we are checking for
|
|
329
337
|
}
|
|
330
338
|
|
|
331
339
|
return -1;
|
|
332
340
|
}
|
|
333
341
|
|
|
334
342
|
/**
|
|
335
|
-
* Calls a defined callback function on each element of an array, and returns an array that contains the results. This helper exists
|
|
336
|
-
* to avoid adding a polyfil for older browsers that do not define Array.prototype.xxxx (eg. ES3 only, IE8) just in case any page
|
|
337
|
-
* checks for presence/absence of the prototype implementation. Note: For consistency this will not use the Array.prototype.xxxx
|
|
343
|
+
* Calls a defined callback function on each element of an array, and returns an array that contains the results. This helper exists
|
|
344
|
+
* to avoid adding a polyfil for older browsers that do not define Array.prototype.xxxx (eg. ES3 only, IE8) just in case any page
|
|
345
|
+
* checks for presence/absence of the prototype implementation. Note: For consistency this will not use the Array.prototype.xxxx
|
|
338
346
|
* implementation if it exists as this would cause a testing requirement to test with and without the implementations
|
|
339
347
|
* @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.
|
|
340
348
|
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
|
|
@@ -344,10 +352,14 @@ export function arrMap<T, R>(arr: T[], callbackfn: (value: T, index?: number, ar
|
|
|
344
352
|
let _this = thisArg || arr;
|
|
345
353
|
let results = new Array(len);
|
|
346
354
|
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
355
|
+
try {
|
|
356
|
+
for (let lp = 0; lp < len; lp++) {
|
|
357
|
+
if (lp in arr) {
|
|
358
|
+
results[lp] = callbackfn.call(_this, arr[lp], arr);
|
|
359
|
+
}
|
|
350
360
|
}
|
|
361
|
+
} catch (e) {
|
|
362
|
+
// This can happen with some native browser objects, but should not happen for the type we are checking for
|
|
351
363
|
}
|
|
352
364
|
|
|
353
365
|
return results;
|
|
@@ -356,7 +368,7 @@ export function arrMap<T, R>(arr: T[], callbackfn: (value: T, index?: number, ar
|
|
|
356
368
|
/**
|
|
357
369
|
* Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is
|
|
358
370
|
* provided as an argument in the next call to the callback function. This helper exists to avoid adding a polyfil for older browsers that do not define
|
|
359
|
-
* Array.prototype.xxxx (eg. ES3 only, IE8) just in case any page checks for presence/absence of the prototype implementation. Note: For consistency
|
|
371
|
+
* Array.prototype.xxxx (eg. ES3 only, IE8) just in case any page checks for presence/absence of the prototype implementation. Note: For consistency
|
|
360
372
|
* this will not use the Array.prototype.xxxx implementation if it exists as this would cause a testing requirement to test with and without the implementations
|
|
361
373
|
* @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array.
|
|
362
374
|
* @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.
|
|
@@ -410,7 +422,7 @@ let _objKeysDontEnums = [
|
|
|
410
422
|
];
|
|
411
423
|
|
|
412
424
|
/**
|
|
413
|
-
* Returns the names of the enumerable string properties and methods of an object. This helper exists to avoid adding a polyfil for older browsers
|
|
425
|
+
* Returns the names of the enumerable string properties and methods of an object. This helper exists to avoid adding a polyfil for older browsers
|
|
414
426
|
* that do not define Object.keys eg. ES3 only, IE8 just in case any page checks for presence/absence of the prototype implementation.
|
|
415
427
|
* Note: For consistency this will not use the Object.keys implementation if it exists as this would cause a testing requirement to test with and without the implementations
|
|
416
428
|
* @param obj Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.
|
|
@@ -578,14 +590,14 @@ export function throwError(message: string): never {
|
|
|
578
590
|
}
|
|
579
591
|
|
|
580
592
|
/**
|
|
581
|
-
* Effectively assigns all enumerable properties (not just own properties) and functions (including inherited prototype) from
|
|
593
|
+
* Effectively assigns all enumerable properties (not just own properties) and functions (including inherited prototype) from
|
|
582
594
|
* the source object to the target, it attempts to use proxy getters / setters (if possible) and proxy functions to avoid potential
|
|
583
595
|
* implementation issues by assigning prototype functions as instance ones
|
|
584
|
-
*
|
|
596
|
+
*
|
|
585
597
|
* This method is the primary method used to "update" the snippet proxy with the ultimate implementations.
|
|
586
|
-
*
|
|
598
|
+
*
|
|
587
599
|
* Special ES3 Notes:
|
|
588
|
-
* Updates (setting) of direct property values on the target or indirectly on the source object WILL NOT WORK PROPERLY, updates to the
|
|
600
|
+
* Updates (setting) of direct property values on the target or indirectly on the source object WILL NOT WORK PROPERLY, updates to the
|
|
589
601
|
* properties of "referenced" object will work (target.context.newValue = 10 => will be reflected in the source.context as it's the
|
|
590
602
|
* same object). ES3 Failures: assigning target.myProp = 3 -> Won't change source.myProp = 3, likewise the reverse would also fail.
|
|
591
603
|
* @param target - The target object to be assigned with the source properties and functions
|
|
@@ -637,7 +649,7 @@ export function proxyAssign(target: any, source: any, chkSet?: (name: string, is
|
|
|
637
649
|
/**
|
|
638
650
|
* Simpler helper to create a dynamic class that implements the interface and populates the values with the defaults.
|
|
639
651
|
* Only instance properties (hasOwnProperty) values are copied from the defaults to the new instance
|
|
640
|
-
* @param defaults Simple helper
|
|
652
|
+
* @param defaults Simple helper
|
|
641
653
|
*/
|
|
642
654
|
export function createClassFromInterface<T>(defaults?: T) {
|
|
643
655
|
return class {
|
|
@@ -151,7 +151,7 @@ export class NotificationManager implements INotificationManager {
|
|
|
151
151
|
/**
|
|
152
152
|
* [Optional] This event is sent if you have enabled perf events, they are primarily used to track internal performance testing and debugging
|
|
153
153
|
* the event can be displayed via the debug plugin extension.
|
|
154
|
-
* @param perfEvent
|
|
154
|
+
* @param perfEvent
|
|
155
155
|
*/
|
|
156
156
|
perfEvent?(perfEvent: IPerfEvent): void;
|
|
157
157
|
}
|
|
@@ -37,7 +37,7 @@ export class PerfEvent implements IPerfEvent {
|
|
|
37
37
|
isAsync: boolean;
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
|
-
* Identifies the total inclusive time spent for this event, including the time spent for child events,
|
|
40
|
+
* Identifies the total inclusive time spent for this event, including the time spent for child events,
|
|
41
41
|
* this will be undefined until the event is completed
|
|
42
42
|
*/
|
|
43
43
|
time?: number;
|
|
@@ -57,7 +57,7 @@ export class PerfEvent implements IPerfEvent {
|
|
|
57
57
|
|
|
58
58
|
setCtx?: (key: string, value: any) => void;
|
|
59
59
|
|
|
60
|
-
complete: () => void;
|
|
60
|
+
complete: () => void;
|
|
61
61
|
|
|
62
62
|
constructor(name: string, payloadDetails: () => any, isAsync: boolean) {
|
|
63
63
|
let _self = this;
|
|
@@ -104,11 +104,11 @@ export class PerfEvent implements IPerfEvent {
|
|
|
104
104
|
_self.isChildEvt = (): boolean => true;
|
|
105
105
|
}
|
|
106
106
|
_self[key] = value;
|
|
107
|
-
}
|
|
107
|
+
}
|
|
108
108
|
else if (key === PerfEvent.ChildrenContextKey) {
|
|
109
109
|
_self[key] = value;
|
|
110
|
-
}
|
|
111
|
-
else
|
|
110
|
+
}
|
|
111
|
+
else
|
|
112
112
|
{
|
|
113
113
|
let ctx = _self[strExecutionContextKey] = _self[strExecutionContextKey] || {};
|
|
114
114
|
ctx[key] = value;
|
|
@@ -180,9 +180,9 @@ export class PerfManager implements IPerfManager {
|
|
|
180
180
|
}
|
|
181
181
|
|
|
182
182
|
/**
|
|
183
|
-
* Create a new event and start timing, the manager may return null/undefined to indicate that it does not
|
|
183
|
+
* Create a new event and start timing, the manager may return null/undefined to indicate that it does not
|
|
184
184
|
* want to monitor this source event.
|
|
185
|
-
* @param src The source name of the event
|
|
185
|
+
* @param src The source name of the event
|
|
186
186
|
* @param payloadDetails - An optional callback function to fetch the payload details for the event.
|
|
187
187
|
* @param isAsync - Is the event occurring from a async event
|
|
188
188
|
*/
|
|
@@ -225,7 +225,7 @@ const doPerfActiveKey = "CoreUtils.doPerf";
|
|
|
225
225
|
* @param getSource - The callback to create the source name for the event (if perf monitoring is enabled)
|
|
226
226
|
* @param func - The function to call and measure
|
|
227
227
|
* @param details - A function to return the payload details
|
|
228
|
-
* @param isAsync - Is the event / function being call asynchronously or synchronously
|
|
228
|
+
* @param isAsync - Is the event / function being call asynchronously or synchronously
|
|
229
229
|
*/
|
|
230
230
|
export function doPerf<T>(mgrSource: IPerfManagerProvider | IPerfManager, getSource: () => string, func: (perfEvt?: IPerfEvent) => T, details?: () => any, isAsync?: boolean) {
|
|
231
231
|
if (mgrSource) {
|
|
@@ -126,7 +126,7 @@ export class ProcessTelemetryContext implements IProcessTelemetryContext {
|
|
|
126
126
|
/**
|
|
127
127
|
* Call back for telemetry processing before it it is sent
|
|
128
128
|
* @param env - This is the current event being reported
|
|
129
|
-
* @param itemCtx - This is the context for the current request, ITelemetryPlugin instances
|
|
129
|
+
* @param itemCtx - This is the context for the current request, ITelemetryPlugin instances
|
|
130
130
|
* can optionally use this to access the current core instance or define / pass additional information
|
|
131
131
|
* to later plugins (vs appending items to the telemetry item)
|
|
132
132
|
*/
|
|
@@ -49,9 +49,9 @@ export function initializePlugins(processContext:ProcessTelemetryContext, extens
|
|
|
49
49
|
// Now initiatilize the plugins
|
|
50
50
|
arrForEach(initPlugins, thePlugin => {
|
|
51
51
|
thePlugin.initialize(
|
|
52
|
-
processContext.getCfg(),
|
|
53
|
-
processContext.core(),
|
|
54
|
-
extensions,
|
|
52
|
+
processContext.getCfg(),
|
|
53
|
+
processContext.core(),
|
|
54
|
+
extensions,
|
|
55
55
|
processContext.getNext());
|
|
56
56
|
});
|
|
57
57
|
}
|
|
@@ -69,5 +69,5 @@ export function sortPlugins(plugins:IPlugin[]) {
|
|
|
69
69
|
|
|
70
70
|
return result;
|
|
71
71
|
});
|
|
72
|
-
// sort complete
|
|
72
|
+
// sort complete
|
|
73
73
|
}
|
|
@@ -10,6 +10,7 @@ import { _InternalLogMessage } from "./DiagnosticLogger";
|
|
|
10
10
|
import { doPerf } from "./PerfManager";
|
|
11
11
|
import { LoggingSeverity, _InternalMessageId } from '../JavaScriptSDK.Enums/LoggingEnums';
|
|
12
12
|
import { isFunction } from './HelperFuncs';
|
|
13
|
+
import { dumpObj } from './EnvUtils';
|
|
13
14
|
|
|
14
15
|
export class TelemetryPluginChain implements ITelemetryPluginChain {
|
|
15
16
|
|
|
@@ -32,7 +33,7 @@ export class TelemetryPluginChain implements ITelemetryPluginChain {
|
|
|
32
33
|
/**
|
|
33
34
|
* Call back for telemetry processing before it it is sent
|
|
34
35
|
* @param env - This is the current event being reported
|
|
35
|
-
* @param itemCtx - This is the context for the current request, ITelemetryPlugin instances
|
|
36
|
+
* @param itemCtx - This is the context for the current request, ITelemetryPlugin instances
|
|
36
37
|
* can optionally use this to access the current core instance or define / pass additional information
|
|
37
38
|
* to later plugins (vs appending items to the telemetry item)
|
|
38
39
|
*/
|
|
@@ -77,7 +78,7 @@ export class TelemetryPluginChain implements ITelemetryPluginChain {
|
|
|
77
78
|
try {
|
|
78
79
|
|
|
79
80
|
// Ensure that we keep the context in sync (for processNext()), just in case a plugin
|
|
80
|
-
// doesn't calls processTelemetry() instead of itemContext.processNext() or some
|
|
81
|
+
// doesn't calls processTelemetry() instead of itemContext.processNext() or some
|
|
81
82
|
// other form of error occurred
|
|
82
83
|
itemCtx.setNext(_nextProxy);
|
|
83
84
|
if (_hasSetNext) {
|
|
@@ -97,7 +98,7 @@ export class TelemetryPluginChain implements ITelemetryPluginChain {
|
|
|
97
98
|
itemCtx.diagLog().throwInternal(
|
|
98
99
|
LoggingSeverity.CRITICAL,
|
|
99
100
|
_InternalMessageId.PluginException,
|
|
100
|
-
"Plugin [" + plugin.identifier + "] failed during processTelemetry - " + error);
|
|
101
|
+
"Plugin [" + plugin.identifier + "] failed during processTelemetry - " + dumpObj(error));
|
|
101
102
|
}
|
|
102
103
|
|
|
103
104
|
if (_nextProxy && !hasRun) {
|
|
@@ -29,7 +29,7 @@ export interface IAppInsightsCore extends IPerfManagerProvider {
|
|
|
29
29
|
|
|
30
30
|
/*
|
|
31
31
|
* Initialization queue. Contains functions to run when appInsights initializes
|
|
32
|
-
*/
|
|
32
|
+
*/
|
|
33
33
|
initialize(config: IConfiguration, extensions: IPlugin[], logger?: IDiagnosticLogger, notificationManager?: INotificationManager): void;
|
|
34
34
|
|
|
35
35
|
/*
|
|
@@ -74,6 +74,8 @@ export interface IAppInsightsCore extends IPerfManagerProvider {
|
|
|
74
74
|
|
|
75
75
|
pollInternalLogs?(eventName?: string): number;
|
|
76
76
|
|
|
77
|
+
stopPollingInternalLogs?(): void;
|
|
78
|
+
|
|
77
79
|
/**
|
|
78
80
|
* Return a new instance of the IProcessTelemetryContext for processing events
|
|
79
81
|
*/
|
|
@@ -11,7 +11,7 @@ export interface IChannelControls extends ITelemetryPlugin {
|
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Pause sending data
|
|
14
|
-
*/
|
|
14
|
+
*/
|
|
15
15
|
pause(): void;
|
|
16
16
|
|
|
17
17
|
/**
|
|
@@ -27,7 +27,7 @@ export interface IChannelControls extends ITelemetryPlugin {
|
|
|
27
27
|
/**
|
|
28
28
|
* Flush to send data immediately; channel should default to sending data asynchronously
|
|
29
29
|
* @param async: send data asynchronously when true
|
|
30
|
-
* @param callBack: if specified, notify caller when send is complete
|
|
30
|
+
* @param callBack: if specified, notify caller when send is complete
|
|
31
31
|
*/
|
|
32
32
|
flush(async: boolean, callBack?: () => void): void;
|
|
33
33
|
}
|
|
@@ -83,7 +83,7 @@ export interface IConfiguration {
|
|
|
83
83
|
* Channel queues that is setup by caller in desired order.
|
|
84
84
|
* If channels are provided here, core will ignore any channels that are already setup, example if there is a SKU with an initialized channel
|
|
85
85
|
*/
|
|
86
|
-
channels?: IChannelControls[][];
|
|
86
|
+
channels?: IChannelControls[][];
|
|
87
87
|
/**
|
|
88
88
|
* @type {boolean}
|
|
89
89
|
* @memberof IConfiguration
|
|
@@ -102,8 +102,8 @@ export interface IConfiguration {
|
|
|
102
102
|
enablePerfMgr?: boolean;
|
|
103
103
|
|
|
104
104
|
/**
|
|
105
|
-
* [Optional] Callback function that will be called to create a the IPerfManager instance when required and ```enablePerfMgr```
|
|
106
|
-
* is enabled, this enables you to override the default creation of a PerfManager() without needing to ```setPerfMgr()```
|
|
105
|
+
* [Optional] Callback function that will be called to create a the IPerfManager instance when required and ```enablePerfMgr```
|
|
106
|
+
* is enabled, this enables you to override the default creation of a PerfManager() without needing to ```setPerfMgr()```
|
|
107
107
|
* after initialization.
|
|
108
108
|
*/
|
|
109
109
|
createPerfMgr?: (core: IAppInsightsCore, notificationManager: INotificationManager) => IPerfManager;
|
|
@@ -120,7 +120,7 @@ export interface IConfiguration {
|
|
|
120
120
|
idLength?: number;
|
|
121
121
|
|
|
122
122
|
/**
|
|
123
|
-
* @description Custom cookie domain. This is helpful if you want to share Application Insights cookies across subdomains. It
|
|
123
|
+
* @description Custom cookie domain. This is helpful if you want to share Application Insights cookies across subdomains. It
|
|
124
124
|
* can be set here or as part of the cookieCfg.domain, the cookieCfg takes precedence if both are specified.
|
|
125
125
|
* @type {string}
|
|
126
126
|
* @memberof IConfig
|
|
@@ -129,7 +129,7 @@ export interface IConfiguration {
|
|
|
129
129
|
cookieDomain?: string;
|
|
130
130
|
|
|
131
131
|
/**
|
|
132
|
-
* @description Custom cookie path. This is helpful if you want to share Application Insights cookies behind an application
|
|
132
|
+
* @description Custom cookie path. This is helpful if you want to share Application Insights cookies behind an application
|
|
133
133
|
* gateway. It can be set here or as part of the cookieCfg.domain, the cookieCfg takes precedence if both are specified.
|
|
134
134
|
* @type {string}
|
|
135
135
|
* @memberof IConfig
|
|
@@ -144,7 +144,7 @@ export interface IConfiguration {
|
|
|
144
144
|
disableCookiesUsage?: boolean;
|
|
145
145
|
|
|
146
146
|
/**
|
|
147
|
-
* [Optional] A Cookie Manager configuration which includes hooks to allow interception of the get, set and delete cookie
|
|
147
|
+
* [Optional] A Cookie Manager configuration which includes hooks to allow interception of the get, set and delete cookie
|
|
148
148
|
* operations. If this configuration is specified any specified enabled and domain properties will take precedence over the
|
|
149
149
|
* cookieDomain and disableCookiesUsage values.
|
|
150
150
|
*/
|
|
@@ -14,7 +14,7 @@ export interface ICookieMgr {
|
|
|
14
14
|
isEnabled(): boolean;
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
|
-
* Set the named cookie with the value and optional domain and optional
|
|
17
|
+
* Set the named cookie with the value and optional domain and optional
|
|
18
18
|
* @param name - The name of the cookie
|
|
19
19
|
* @param value - The value of the cookie (Must already be encoded)
|
|
20
20
|
* @param maxAgeSec - [optional] The maximum number of SECONDS that this cookie should survive
|
|
@@ -62,9 +62,9 @@ export interface IInstrumentCallDetails {
|
|
|
62
62
|
|
|
63
63
|
/**
|
|
64
64
|
* This returns an object that the hook function can use to store hook specific
|
|
65
|
-
* context, it it not shared with any other hook instances and is unique for the
|
|
65
|
+
* context, it it not shared with any other hook instances and is unique for the
|
|
66
66
|
* current call.
|
|
67
|
-
* A hook implementation can use this to pass / share context between different
|
|
67
|
+
* A hook implementation can use this to pass / share context between different
|
|
68
68
|
* hook callbacks eg. request/response requst/hookErrors etc.
|
|
69
69
|
*/
|
|
70
70
|
ctx: () => any;
|