@microsoft/applicationinsights-common 3.0.0-beta.2208-14 → 3.0.0-beta.2208-16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -0
- package/browser/applicationinsights-common.integrity.json +9 -9
- package/browser/applicationinsights-common.js +698 -1416
- 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 +1785 -3953
- package/dist/applicationinsights-common.api.md +13 -137
- package/dist/applicationinsights-common.d.ts +23 -278
- package/dist/applicationinsights-common.js +698 -1416
- 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 +23 -278
- 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/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 +6 -32
- package/dist-esm/Telemetry/Common/DataSanitizer.js.map +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 +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/UrlHelperFuncs.js +1 -1
- package/dist-esm/Util.js +79 -133
- package/dist-esm/Util.js.map +1 -1
- package/dist-esm/__DynamicConstants.js +4 -8
- package/dist-esm/__DynamicConstants.js.map +1 -1
- package/dist-esm/applicationinsights-common.js +3 -3
- package/dist-esm/applicationinsights-common.js.map +1 -1
- package/package.json +5 -4
- package/src/Telemetry/Common/DataSanitizer.ts +5 -95
- package/src/Util.ts +79 -395
- package/src/__DynamicConstants.ts +3 -7
- package/src/applicationinsights-common.ts +3 -4
- package/tsconfig.json +1 -1
- package/types/Telemetry/Common/DataSanitizer.d.ts +0 -50
- package/types/Util.d.ts +19 -212
- package/types/__DynamicConstants.d.ts +0 -4
- package/types/applicationinsights-common.d.ts +2 -2
- package/types/tsdoc-metadata.json +1 -1
package/src/Util.ts
CHANGED
|
@@ -2,23 +2,15 @@
|
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
|
-
IDiagnosticLogger, IDistributedTraceContext,
|
|
6
|
-
|
|
7
|
-
getExceptionName as coreGetExceptionName, getIEVersion, getPerformance, isArray, isBeaconsSupported, isDate, isError, isNullOrUndefined,
|
|
8
|
-
isValidSpanId, isValidTraceId, newId, random32, setCookie as coreSetCookie, strTrim, toISOString, uaDisallowsSameSiteNone
|
|
5
|
+
IDiagnosticLogger, IDistributedTraceContext, arrForEach, arrIndexOf, dateNow, getPerformance, isNullOrUndefined, isValidSpanId,
|
|
6
|
+
isValidTraceId
|
|
9
7
|
} from "@microsoft/applicationinsights-core-js";
|
|
10
|
-
import { DEFAULT_BREEZE_ENDPOINT, DEFAULT_BREEZE_PATH
|
|
11
|
-
import { createDomEvent } from "./DomHelperFuncs";
|
|
12
|
-
import { getExtensionByName, isCrossOriginError, msToTimeSpan, stringToBoolOrDefault } from "./HelperFuncs";
|
|
8
|
+
import { DEFAULT_BREEZE_ENDPOINT, DEFAULT_BREEZE_PATH } from "./Constants";
|
|
13
9
|
import { ITelemetryTrace } from "./Interfaces/Context/ITelemetryTrace";
|
|
14
10
|
import { ICorrelationConfig } from "./Interfaces/ICorrelationConfig";
|
|
15
11
|
import { RequestHeaders, eRequestHeaders } from "./RequestResponseHeaders";
|
|
16
|
-
import {
|
|
17
|
-
utlCanUseLocalStorage, utlCanUseSessionStorage, utlDisableStorage, utlGetLocalStorage, utlGetSessionStorage, utlGetSessionStorageKeys,
|
|
18
|
-
utlRemoveSessionStorage, utlRemoveStorage, utlSetLocalStorage, utlSetSessionStorage
|
|
19
|
-
} from "./StorageHelperFuncs";
|
|
20
12
|
import { dataSanitizeString } from "./Telemetry/Common/DataSanitizer";
|
|
21
|
-
import {
|
|
13
|
+
import { urlParseFullHost, urlParseUrl } from "./UrlHelperFuncs";
|
|
22
14
|
|
|
23
15
|
// listing only non-geo specific locations
|
|
24
16
|
const _internalEndpoints: string[] = [
|
|
@@ -27,394 +19,107 @@ const _internalEndpoints: string[] = [
|
|
|
27
19
|
"https://dc-int.services.visualstudio.com" + DEFAULT_BREEZE_PATH
|
|
28
20
|
];
|
|
29
21
|
|
|
22
|
+
let _correlationIdPrefix: string = "cid-v1:";
|
|
23
|
+
|
|
30
24
|
export function isInternalApplicationInsightsEndpoint(endpointUrl: string): boolean {
|
|
31
25
|
return arrIndexOf(_internalEndpoints, endpointUrl.toLowerCase()) !== -1;
|
|
32
26
|
}
|
|
33
27
|
|
|
34
|
-
export
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
createDomEvent: (eventName: string) => Event,
|
|
38
|
-
|
|
39
|
-
/*
|
|
40
|
-
* Force the SDK not to use local and session storage
|
|
41
|
-
*/
|
|
42
|
-
disableStorage: () => void,
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Checks if endpoint URL is application insights internal injestion service URL.
|
|
46
|
-
*
|
|
47
|
-
* @param endpointUrl Endpoint URL to check.
|
|
48
|
-
* @returns {boolean} True if if endpoint URL is application insights internal injestion service URL.
|
|
49
|
-
*/
|
|
50
|
-
isInternalApplicationInsightsEndpoint: (endpointUrl: string) => boolean,
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Check if the browser supports local storage.
|
|
54
|
-
*
|
|
55
|
-
* @returns {boolean} True if local storage is supported.
|
|
56
|
-
*/
|
|
57
|
-
canUseLocalStorage: () => boolean,
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Get an object from the browser's local storage
|
|
61
|
-
*
|
|
62
|
-
* @param {string} name - the name of the object to get from storage
|
|
63
|
-
* @returns {string} The contents of the storage object with the given name. Null if storage is not supported.
|
|
64
|
-
*/
|
|
65
|
-
getStorage: (logger: IDiagnosticLogger, name: string) => string,
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Set the contents of an object in the browser's local storage
|
|
69
|
-
*
|
|
70
|
-
* @param {string} name - the name of the object to set in storage
|
|
71
|
-
* @param {string} data - the contents of the object to set in storage
|
|
72
|
-
* @returns {boolean} True if the storage object could be written.
|
|
73
|
-
*/
|
|
74
|
-
setStorage: (logger: IDiagnosticLogger, name: string, data: string) => boolean,
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Remove an object from the browser's local storage
|
|
78
|
-
*
|
|
79
|
-
* @param {string} name - the name of the object to remove from storage
|
|
80
|
-
* @returns {boolean} True if the storage object could be removed.
|
|
81
|
-
*/
|
|
82
|
-
removeStorage: (logger: IDiagnosticLogger, name: string) => boolean,
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Check if the browser supports session storage.
|
|
86
|
-
*
|
|
87
|
-
* @returns {boolean} True if session storage is supported.
|
|
88
|
-
*/
|
|
89
|
-
canUseSessionStorage: () => boolean,
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Gets the list of session storage keys
|
|
93
|
-
*
|
|
94
|
-
* @returns {string[]} List of session storage keys
|
|
95
|
-
*/
|
|
96
|
-
getSessionStorageKeys: () => string[],
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Get an object from the browser's session storage
|
|
100
|
-
*
|
|
101
|
-
* @param {string} name - the name of the object to get from storage
|
|
102
|
-
* @returns {string} The contents of the storage object with the given name. Null if storage is not supported.
|
|
103
|
-
*/
|
|
104
|
-
getSessionStorage: (logger: IDiagnosticLogger, name: string) => string,
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Set the contents of an object in the browser's session storage
|
|
108
|
-
*
|
|
109
|
-
* @param {string} name - the name of the object to set in storage
|
|
110
|
-
* @param {string} data - the contents of the object to set in storage
|
|
111
|
-
* @returns {boolean} True if the storage object could be written.
|
|
112
|
-
*/
|
|
113
|
-
setSessionStorage: (logger: IDiagnosticLogger, name: string, data: string) => boolean,
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Remove an object from the browser's session storage
|
|
117
|
-
*
|
|
118
|
-
* @param {string} name - the name of the object to remove from storage
|
|
119
|
-
* @returns {boolean} True if the storage object could be removed.
|
|
120
|
-
*/
|
|
121
|
-
removeSessionStorage: (logger: IDiagnosticLogger, name: string) => boolean,
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* @deprecated - Use the core.getCookieMgr().disable()
|
|
125
|
-
* Force the SDK not to store and read any data from cookies.
|
|
126
|
-
*/
|
|
127
|
-
disableCookies: () => void,
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* @deprecated - Use the core.getCookieMgr().isEnabled()
|
|
131
|
-
* Helper method to tell if document.cookie object is available and whether it can be used.
|
|
132
|
-
*/
|
|
133
|
-
canUseCookies: (logger: IDiagnosticLogger) => any,
|
|
134
|
-
|
|
135
|
-
disallowsSameSiteNone: (userAgent: string) => boolean,
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* @deprecated - Use the core.getCookieMgr().set()
|
|
139
|
-
* helper method to set userId and sessionId cookie
|
|
140
|
-
*/
|
|
141
|
-
setCookie: (logger: IDiagnosticLogger, name: string, value: string, domain?: string) => void,
|
|
142
|
-
|
|
143
|
-
stringToBoolOrDefault: (str: any, defaultValue?: boolean) => boolean,
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* @deprecated - Use the core.getCookieMgr().get()
|
|
147
|
-
* helper method to access userId and sessionId cookie
|
|
148
|
-
*/
|
|
149
|
-
getCookie: (logger: IDiagnosticLogger, name: string) => string,
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* @deprecated - Use the core.getCookieMgr().del()
|
|
153
|
-
* Deletes a cookie by setting it's expiration time in the past.
|
|
154
|
-
* @param name - The name of the cookie to delete.
|
|
155
|
-
*/
|
|
156
|
-
deleteCookie: (logger: IDiagnosticLogger, name: string) => void,
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* helper method to trim strings (IE8 does not implement String.prototype.trim)
|
|
160
|
-
*/
|
|
161
|
-
trim: (str: any) => string,
|
|
162
|
-
|
|
163
|
-
/**
|
|
164
|
-
* generate random id string
|
|
165
|
-
*/
|
|
166
|
-
newId: () => string,
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* generate a random 32bit number (-0x80000000..0x7FFFFFFF).
|
|
170
|
-
*/
|
|
171
|
-
random32: () => number,
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* generate W3C trace id
|
|
175
|
-
*/
|
|
176
|
-
generateW3CId: () => string,
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* Check if an object is of type Array
|
|
180
|
-
*/
|
|
181
|
-
isArray: (obj: any) => boolean,
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* Check if an object is of type Error
|
|
185
|
-
*/
|
|
186
|
-
isError: (obj: any) => obj is Error,
|
|
187
|
-
|
|
188
|
-
/**
|
|
189
|
-
* Check if an object is of type Date
|
|
190
|
-
*/
|
|
191
|
-
isDate: (obj: any) => obj is Date,
|
|
192
|
-
|
|
193
|
-
// Keeping this name for backward compatibility (for now)
|
|
194
|
-
toISOStringForIE8: (date: Date) => string,
|
|
195
|
-
|
|
196
|
-
/**
|
|
197
|
-
* Gets IE version returning the document emulation mode if we are running on IE, or null otherwise
|
|
198
|
-
*/
|
|
199
|
-
getIEVersion: (userAgentStr?: string) => number,
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* Convert ms to c# time span format
|
|
203
|
-
*/
|
|
204
|
-
msToTimeSpan: (totalms: number) => string,
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* Checks if error has no meaningful data inside. Ususally such errors are received by window.onerror when error
|
|
208
|
-
* happens in a script from other domain (cross origin, CORS).
|
|
209
|
-
*/
|
|
210
|
-
isCrossOriginError: (message: string|Event, url: string, lineNumber: number, columnNumber: number, error: Error) => boolean,
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
* Returns string representation of an object suitable for diagnostics logging.
|
|
214
|
-
*/
|
|
215
|
-
dump: (object: any) => string,
|
|
216
|
-
|
|
217
|
-
/**
|
|
218
|
-
* Returns the name of object if it's an Error. Otherwise, returns empty string.
|
|
219
|
-
*/
|
|
220
|
-
getExceptionName: (object: any) => string,
|
|
221
|
-
|
|
222
|
-
/**
|
|
223
|
-
* Adds an event handler for the specified event to the window
|
|
224
|
-
* @param eventName {string} - The name of the event
|
|
225
|
-
* @param callback {any} - The callback function that needs to be executed for the given event
|
|
226
|
-
* @return {boolean} - true if the handler was successfully added
|
|
227
|
-
*/
|
|
228
|
-
addEventHandler: (obj: any, eventNameWithoutOn: string, handlerRef: any, useCapture: boolean) => boolean,
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
* Tells if a browser supports a Beacon API
|
|
232
|
-
*/
|
|
233
|
-
IsBeaconApiSupported: () => boolean,
|
|
234
|
-
|
|
235
|
-
getExtension: (extensions: IPlugin[], identifier: string) => IPlugin | null
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
export const Util: IUtil = {
|
|
239
|
-
NotSpecified: strNotSpecified,
|
|
240
|
-
createDomEvent,
|
|
241
|
-
disableStorage: utlDisableStorage,
|
|
242
|
-
isInternalApplicationInsightsEndpoint,
|
|
243
|
-
canUseLocalStorage: utlCanUseLocalStorage,
|
|
244
|
-
getStorage: utlGetLocalStorage,
|
|
245
|
-
setStorage: utlSetLocalStorage,
|
|
246
|
-
removeStorage: utlRemoveStorage,
|
|
247
|
-
canUseSessionStorage: utlCanUseSessionStorage,
|
|
248
|
-
getSessionStorageKeys: utlGetSessionStorageKeys,
|
|
249
|
-
getSessionStorage: utlGetSessionStorage,
|
|
250
|
-
setSessionStorage: utlSetSessionStorage,
|
|
251
|
-
removeSessionStorage: utlRemoveSessionStorage,
|
|
252
|
-
disableCookies: coreDisableCookies,
|
|
253
|
-
canUseCookies: coreCanUseCookies,
|
|
254
|
-
disallowsSameSiteNone: uaDisallowsSameSiteNone,
|
|
255
|
-
setCookie: coreSetCookie,
|
|
256
|
-
stringToBoolOrDefault,
|
|
257
|
-
getCookie: coreGetCookie,
|
|
258
|
-
deleteCookie: coreDeleteCookie,
|
|
259
|
-
trim: strTrim,
|
|
260
|
-
newId,
|
|
261
|
-
random32() {
|
|
262
|
-
return random32(true);
|
|
263
|
-
},
|
|
264
|
-
generateW3CId,
|
|
265
|
-
isArray,
|
|
266
|
-
isError,
|
|
267
|
-
isDate,
|
|
268
|
-
toISOStringForIE8: toISOString,
|
|
269
|
-
getIEVersion,
|
|
270
|
-
msToTimeSpan,
|
|
271
|
-
isCrossOriginError,
|
|
272
|
-
dump: dumpObj,
|
|
273
|
-
getExceptionName: coreGetExceptionName,
|
|
274
|
-
addEventHandler: attachEvent,
|
|
275
|
-
IsBeaconApiSupported: isBeaconsSupported,
|
|
276
|
-
getExtension: getExtensionByName
|
|
277
|
-
};
|
|
278
|
-
|
|
279
|
-
export interface IUrlHelper {
|
|
280
|
-
|
|
281
|
-
parseUrl: (url: string) => HTMLAnchorElement,
|
|
282
|
-
getAbsoluteUrl: (url: string) => string,
|
|
283
|
-
getPathName: (url: string) => string,
|
|
284
|
-
getCompleteUrl: (method: string, absoluteUrl: string) => string,
|
|
285
|
-
|
|
286
|
-
// Fallback method to grab host from url if document.createElement method is not available
|
|
287
|
-
parseHost: (url: string, inclPort?: boolean) => string,
|
|
288
|
-
|
|
289
|
-
/**
|
|
290
|
-
* Get the full host from the url, optionally including the port
|
|
291
|
-
*/
|
|
292
|
-
parseFullHost: (url: string, inclPort?: boolean) => string
|
|
28
|
+
export function correlationIdSetPrefix(prefix: string) {
|
|
29
|
+
_correlationIdPrefix = prefix;
|
|
293
30
|
}
|
|
294
31
|
|
|
295
|
-
export
|
|
296
|
-
|
|
297
|
-
getAbsoluteUrl: urlGetAbsoluteUrl,
|
|
298
|
-
getPathName: urlGetPathName,
|
|
299
|
-
getCompleteUrl: urlGetCompleteUrl,
|
|
300
|
-
parseHost: urlParseHost,
|
|
301
|
-
parseFullHost: urlParseFullHost
|
|
302
|
-
};
|
|
303
|
-
|
|
304
|
-
export interface ICorrelationIdHelper {
|
|
305
|
-
correlationIdPrefix: string;
|
|
306
|
-
|
|
307
|
-
/**
|
|
308
|
-
* Checks if a request url is not on a excluded domain list and if it is safe to add correlation headers.
|
|
309
|
-
* Headers are always included if the current domain matches the request domain. If they do not match (CORS),
|
|
310
|
-
* they are regex-ed across correlationHeaderDomains and correlationHeaderExcludedDomains to determine if headers are included.
|
|
311
|
-
* Some environments don't give information on currentHost via window.location.host (e.g. Cordova). In these cases, the user must
|
|
312
|
-
* manually supply domains to include correlation headers on. Else, no headers will be included at all.
|
|
313
|
-
*/
|
|
314
|
-
canIncludeCorrelationHeader(config: ICorrelationConfig, requestUrl: string, currentHost?: string): boolean;
|
|
315
|
-
|
|
316
|
-
/**
|
|
317
|
-
* Combines target appId and target role name from response header.
|
|
318
|
-
*/
|
|
319
|
-
getCorrelationContext(responseHeader: string): string | undefined;
|
|
320
|
-
|
|
321
|
-
/**
|
|
322
|
-
* Gets key from correlation response header
|
|
323
|
-
*/
|
|
324
|
-
getCorrelationContextValue(responseHeader: string, key: string): string | undefined;
|
|
32
|
+
export function correlationIdGetPrefix() {
|
|
33
|
+
return _correlationIdPrefix;
|
|
325
34
|
}
|
|
326
35
|
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
if (!requestUrl || (config && config.disableCorrelationHeaders)) {
|
|
339
|
-
return false;
|
|
340
|
-
}
|
|
36
|
+
/**
|
|
37
|
+
* Checks if a request url is not on a excluded domain list and if it is safe to add correlation headers.
|
|
38
|
+
* Headers are always included if the current domain matches the request domain. If they do not match (CORS),
|
|
39
|
+
* they are regex-ed across correlationHeaderDomains and correlationHeaderExcludedDomains to determine if headers are included.
|
|
40
|
+
* Some environments don't give information on currentHost via window.location.host (e.g. Cordova). In these cases, the user must
|
|
41
|
+
* manually supply domains to include correlation headers on. Else, no headers will be included at all.
|
|
42
|
+
*/
|
|
43
|
+
export function correlationIdCanIncludeCorrelationHeader(config: ICorrelationConfig, requestUrl: string, currentHost?: string) {
|
|
44
|
+
if (!requestUrl || (config && config.disableCorrelationHeaders)) {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
341
47
|
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
}
|
|
48
|
+
if (config && config.correlationHeaderExcludePatterns) {
|
|
49
|
+
for (let i = 0; i < config.correlationHeaderExcludePatterns.length; i++) {
|
|
50
|
+
if (config.correlationHeaderExcludePatterns[i].test(requestUrl)) {
|
|
51
|
+
return false;
|
|
347
52
|
}
|
|
348
53
|
}
|
|
54
|
+
}
|
|
349
55
|
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
56
|
+
let requestHost = urlParseUrl(requestUrl).host.toLowerCase();
|
|
57
|
+
if (requestHost && (requestHost.indexOf(":443") !== -1 || requestHost.indexOf(":80") !== -1)) {
|
|
58
|
+
// [Bug #1260] IE can include the port even for http and https URLs so if present
|
|
59
|
+
// try and parse it to remove if it matches the default protocol port
|
|
60
|
+
requestHost = (urlParseFullHost(requestUrl, true) || "").toLowerCase();
|
|
61
|
+
}
|
|
356
62
|
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
63
|
+
if ((!config || !config.enableCorsCorrelation) && (requestHost && requestHost !== currentHost)) {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
360
66
|
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
67
|
+
const includedDomains = config && config.correlationHeaderDomains;
|
|
68
|
+
if (includedDomains) {
|
|
69
|
+
let matchExists: boolean;
|
|
70
|
+
arrForEach(includedDomains, (domain) => {
|
|
71
|
+
const regex = new RegExp(domain.toLowerCase().replace(/\\/g, "\\\\").replace(/\./g, "\\.").replace(/\*/g, ".*"));
|
|
72
|
+
matchExists = matchExists || regex.test(requestHost);
|
|
73
|
+
});
|
|
368
74
|
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
}
|
|
75
|
+
if (!matchExists) {
|
|
76
|
+
return false;
|
|
372
77
|
}
|
|
78
|
+
}
|
|
373
79
|
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
80
|
+
const excludedDomains = config && config.correlationHeaderExcludedDomains;
|
|
81
|
+
if (!excludedDomains || excludedDomains.length === 0) {
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
378
84
|
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
}
|
|
85
|
+
for (let i = 0; i < excludedDomains.length; i++) {
|
|
86
|
+
const regex = new RegExp(excludedDomains[i].toLowerCase().replace(/\\/g, "\\\\").replace(/\./g, "\\.").replace(/\*/g, ".*"));
|
|
87
|
+
if (regex.test(requestHost)) {
|
|
88
|
+
return false;
|
|
384
89
|
}
|
|
90
|
+
}
|
|
385
91
|
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
92
|
+
// if we don't know anything about the requestHost, require the user to use included/excludedDomains.
|
|
93
|
+
// Previously we always returned false for a falsy requestHost
|
|
94
|
+
return requestHost && requestHost.length > 0;
|
|
95
|
+
}
|
|
390
96
|
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
}
|
|
97
|
+
/**
|
|
98
|
+
* Combines target appId and target role name from response header.
|
|
99
|
+
*/
|
|
100
|
+
export function correlationIdGetCorrelationContext(responseHeader: string) {
|
|
101
|
+
if (responseHeader) {
|
|
102
|
+
const correlationId = correlationIdGetCorrelationContextValue(responseHeader, RequestHeaders[eRequestHeaders.requestContextTargetKey]);
|
|
103
|
+
if (correlationId && correlationId !== _correlationIdPrefix) {
|
|
104
|
+
return correlationId;
|
|
400
105
|
}
|
|
401
|
-
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
402
108
|
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
}
|
|
109
|
+
/**
|
|
110
|
+
* Gets key from correlation response header
|
|
111
|
+
*/
|
|
112
|
+
export function correlationIdGetCorrelationContextValue(responseHeader: string, key: string) {
|
|
113
|
+
if (responseHeader) {
|
|
114
|
+
const keyValues = responseHeader.split(",");
|
|
115
|
+
for (let i = 0; i < keyValues.length; ++i) {
|
|
116
|
+
const keyValue = keyValues[i].split("=");
|
|
117
|
+
if (keyValue.length === 2 && keyValue[0] === key) {
|
|
118
|
+
return keyValue[1];
|
|
414
119
|
}
|
|
415
120
|
}
|
|
416
121
|
}
|
|
417
|
-
}
|
|
122
|
+
}
|
|
418
123
|
|
|
419
124
|
export function AjaxHelperParseDependencyPath(logger: IDiagnosticLogger, absoluteUrl: string, method: string, commandName: string) {
|
|
420
125
|
let target, name = commandName, data = commandName;
|
|
@@ -469,27 +174,6 @@ export function dateTimeUtilsDuration(start: number, end: number): number {
|
|
|
469
174
|
return result;
|
|
470
175
|
}
|
|
471
176
|
|
|
472
|
-
export interface IDateTimeUtils {
|
|
473
|
-
/**
|
|
474
|
-
* Get the number of milliseconds since 1970/01/01 in local timezone
|
|
475
|
-
*/
|
|
476
|
-
Now: () => number;
|
|
477
|
-
|
|
478
|
-
/**
|
|
479
|
-
* Gets duration between two timestamps
|
|
480
|
-
*/
|
|
481
|
-
GetDuration: (start: number, end: number) => number;
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
/**
|
|
485
|
-
* A utility class that helps getting time related parameters
|
|
486
|
-
*/
|
|
487
|
-
export const DateTimeUtils: IDateTimeUtils = {
|
|
488
|
-
Now: dateTimeUtilsNow,
|
|
489
|
-
GetDuration: dateTimeUtilsDuration
|
|
490
|
-
};
|
|
491
|
-
|
|
492
|
-
|
|
493
177
|
/**
|
|
494
178
|
* Creates a IDistributedTraceContext from an optional telemetryTrace
|
|
495
179
|
* @param telemetryTrace - The telemetryTrace instance that is being wrapped
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
// AUTO GENERATED FILE: This file is Auto Generated during build.
|
|
7
7
|
// ##############################################################
|
|
8
8
|
|
|
9
|
-
//
|
|
10
|
-
// Note: DON'T Export these const from the package as we are still targeting
|
|
11
|
-
//
|
|
9
|
+
// ###########################################################################################################################################
|
|
10
|
+
// Note: DON'T Export these const from the package as we are still targeting IE this will export a mutable variables that someone could change
|
|
11
|
+
// ###########################################################################################################################################
|
|
12
12
|
|
|
13
13
|
export const _DYN_SPLIT = "split"; // Count: 6
|
|
14
14
|
export const _DYN_LENGTH = "length"; // Count: 40
|
|
@@ -42,7 +42,3 @@ export const _DYN_LINE = "line"; // Count: 6
|
|
|
42
42
|
export const _DYN_DURATION = "duration"; // Count: 4
|
|
43
43
|
export const _DYN_RECEIVED_RESPONSE = "receivedResponse"; // Count: 2
|
|
44
44
|
export const _DYN_SUBSTRING = "substring"; // Count: 6
|
|
45
|
-
export const _DYN_SANITIZE_KEY_AND_ADD2 = "sanitizeKeyAndAddUniqueness"; // Count: 2
|
|
46
|
-
export const _DYN_SANITIZE_EXCEPTION = "sanitizeException"; // Count: 2
|
|
47
|
-
export const _DYN_SANITIZE_PROPERTIES = "sanitizeProperties"; // Count: 2
|
|
48
|
-
export const _DYN_SANITIZE_MEASUREMENT3 = "sanitizeMeasurements"; // Count: 2
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
2
|
// Licensed under the
|
|
3
3
|
export {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
IUrlHelper, UrlHelper, isInternalApplicationInsightsEndpoint,
|
|
4
|
+
correlationIdSetPrefix, correlationIdGetPrefix, correlationIdCanIncludeCorrelationHeader, correlationIdGetCorrelationContext,
|
|
5
|
+
correlationIdGetCorrelationContextValue, dateTimeUtilsNow, dateTimeUtilsDuration, isInternalApplicationInsightsEndpoint,
|
|
7
6
|
createDistributedTraceContextFromTrace
|
|
8
7
|
} from "./Util";
|
|
9
8
|
export { parseConnectionString, ConnectionStringParser } from "./ConnectionStringParser";
|
|
@@ -36,7 +35,7 @@ export { IConfig, ConfigurationManager } from "./Interfaces/IConfig";
|
|
|
36
35
|
export { IChannelControlsAI } from "./Interfaces/IChannelControlsAI";
|
|
37
36
|
export { IContextTagKeys, ContextTagKeys } from "./Interfaces/Contracts/ContextTagKeys";
|
|
38
37
|
export {
|
|
39
|
-
DataSanitizerValues,
|
|
38
|
+
DataSanitizerValues,
|
|
40
39
|
dataSanitizeKeyAndAddUniqueness, dataSanitizeKey, dataSanitizeString, dataSanitizeUrl, dataSanitizeMessage,
|
|
41
40
|
dataSanitizeException, dataSanitizeProperties, dataSanitizeMeasurements, dataSanitizeId, dataSanitizeInput,
|
|
42
41
|
dsPadNumber
|
package/tsconfig.json
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { IDiagnosticLogger, _eInternalMessageId } from "@microsoft/applicationinsights-core-js";
|
|
2
|
-
import { _DYN_SANITIZE_EXCEPTION, _DYN_SANITIZE_KEY_AND_ADD2, _DYN_SANITIZE_MEASUREMENT3, _DYN_SANITIZE_PROPERTIES } from "../../__DynamicConstants";
|
|
3
2
|
export declare const enum DataSanitizerValues {
|
|
4
3
|
/**
|
|
5
4
|
* Max length allowed for custom names.
|
|
@@ -41,52 +40,3 @@ export declare function dataSanitizeMeasurements(logger: IDiagnosticLogger, meas
|
|
|
41
40
|
export declare function dataSanitizeId(logger: IDiagnosticLogger, id: string): string;
|
|
42
41
|
export declare function dataSanitizeInput(logger: IDiagnosticLogger, input: any, maxLength: number, _msgId: _eInternalMessageId): any;
|
|
43
42
|
export declare function dsPadNumber(num: number): string;
|
|
44
|
-
export interface IDataSanitizer {
|
|
45
|
-
/**
|
|
46
|
-
* Max length allowed for custom names.
|
|
47
|
-
*/
|
|
48
|
-
MAX_NAME_LENGTH: number;
|
|
49
|
-
/**
|
|
50
|
-
* Max length allowed for Id field in page views.
|
|
51
|
-
*/
|
|
52
|
-
MAX_ID_LENGTH: number;
|
|
53
|
-
/**
|
|
54
|
-
* Max length allowed for custom values.
|
|
55
|
-
*/
|
|
56
|
-
MAX_PROPERTY_LENGTH: number;
|
|
57
|
-
/**
|
|
58
|
-
* Max length allowed for names
|
|
59
|
-
*/
|
|
60
|
-
MAX_STRING_LENGTH: number;
|
|
61
|
-
/**
|
|
62
|
-
* Max length allowed for url.
|
|
63
|
-
*/
|
|
64
|
-
MAX_URL_LENGTH: number;
|
|
65
|
-
/**
|
|
66
|
-
* Max length allowed for messages.
|
|
67
|
-
*/
|
|
68
|
-
MAX_MESSAGE_LENGTH: number;
|
|
69
|
-
/**
|
|
70
|
-
* Max length allowed for exceptions.
|
|
71
|
-
*/
|
|
72
|
-
MAX_EXCEPTION_LENGTH: number;
|
|
73
|
-
[_DYN_SANITIZE_KEY_AND_ADD2]: (logger: IDiagnosticLogger, key: any, map: any) => string;
|
|
74
|
-
sanitizeKey: (logger: IDiagnosticLogger, name: any) => string;
|
|
75
|
-
sanitizeString: (logger: IDiagnosticLogger, value: any, maxLength?: number) => string;
|
|
76
|
-
sanitizeUrl: (logger: IDiagnosticLogger, url: any) => string;
|
|
77
|
-
sanitizeMessage: (logger: IDiagnosticLogger, message: any) => string;
|
|
78
|
-
[_DYN_SANITIZE_EXCEPTION]: (logger: IDiagnosticLogger, exception: any) => string;
|
|
79
|
-
[_DYN_SANITIZE_PROPERTIES]: (logger: IDiagnosticLogger, properties: any) => any;
|
|
80
|
-
[_DYN_SANITIZE_MEASUREMENT3]: (logger: IDiagnosticLogger, measurements: any) => any;
|
|
81
|
-
sanitizeId: (logger: IDiagnosticLogger, id: string) => string;
|
|
82
|
-
sanitizeInput: (logger: IDiagnosticLogger, input: any, maxLength: number, _msgId: _eInternalMessageId) => any;
|
|
83
|
-
padNumber: (num: number) => string;
|
|
84
|
-
/**
|
|
85
|
-
* helper method to trim strings (IE8 does not implement String.prototype.trim)
|
|
86
|
-
*/
|
|
87
|
-
trim: (str: any) => string;
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Provides the DataSanitizer functions within the previous namespace.
|
|
91
|
-
*/
|
|
92
|
-
export declare const DataSanitizer: IDataSanitizer;
|