@microsoft/applicationinsights-common 3.0.0-beta.2208-14 → 3.0.0-beta.2208-19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/README.md +7 -0
  2. package/browser/applicationinsights-common.integrity.json +9 -9
  3. package/browser/applicationinsights-common.js +698 -1416
  4. package/browser/applicationinsights-common.js.map +1 -1
  5. package/browser/applicationinsights-common.min.js +2 -2
  6. package/browser/applicationinsights-common.min.js.map +1 -1
  7. package/dist/applicationinsights-common.api.json +1785 -3953
  8. package/dist/applicationinsights-common.api.md +13 -137
  9. package/dist/applicationinsights-common.d.ts +23 -278
  10. package/dist/applicationinsights-common.js +698 -1416
  11. package/dist/applicationinsights-common.js.map +1 -1
  12. package/dist/applicationinsights-common.min.js +2 -2
  13. package/dist/applicationinsights-common.min.js.map +1 -1
  14. package/dist/applicationinsights-common.rollup.d.ts +23 -278
  15. package/dist-esm/ConnectionStringParser.js +1 -1
  16. package/dist-esm/Constants.js +1 -1
  17. package/dist-esm/DomHelperFuncs.js +1 -1
  18. package/dist-esm/Enums.js +1 -1
  19. package/dist-esm/HelperFuncs.js +1 -1
  20. package/dist-esm/Interfaces/ConnectionString.js +1 -1
  21. package/dist-esm/Interfaces/Context/IApplication.js +1 -1
  22. package/dist-esm/Interfaces/Context/IDevice.js +1 -1
  23. package/dist-esm/Interfaces/Context/IInternal.js +1 -1
  24. package/dist-esm/Interfaces/Context/ILocation.js +1 -1
  25. package/dist-esm/Interfaces/Context/IOperatingSystem.js +1 -1
  26. package/dist-esm/Interfaces/Context/ISample.js +1 -1
  27. package/dist-esm/Interfaces/Context/ISession.js +1 -1
  28. package/dist-esm/Interfaces/Context/ITelemetryTrace.js +1 -1
  29. package/dist-esm/Interfaces/Context/IUser.js +1 -1
  30. package/dist-esm/Interfaces/Context/IWeb.js +1 -1
  31. package/dist-esm/Interfaces/Contracts/AvailabilityData.js +1 -1
  32. package/dist-esm/Interfaces/Contracts/ContextTagKeys.js +1 -1
  33. package/dist-esm/Interfaces/Contracts/DataPointType.js +1 -1
  34. package/dist-esm/Interfaces/Contracts/DependencyKind.js +1 -1
  35. package/dist-esm/Interfaces/Contracts/DependencySourceType.js +1 -1
  36. package/dist-esm/Interfaces/Contracts/IBase.js +1 -1
  37. package/dist-esm/Interfaces/Contracts/IData.js +1 -1
  38. package/dist-esm/Interfaces/Contracts/IDataPoint.js +1 -1
  39. package/dist-esm/Interfaces/Contracts/IDomain.js +1 -1
  40. package/dist-esm/Interfaces/Contracts/IEnvelope.js +1 -1
  41. package/dist-esm/Interfaces/Contracts/IEventData.js +1 -1
  42. package/dist-esm/Interfaces/Contracts/IExceptionData.js +1 -1
  43. package/dist-esm/Interfaces/Contracts/IExceptionDetails.js +1 -1
  44. package/dist-esm/Interfaces/Contracts/IMessageData.js +1 -1
  45. package/dist-esm/Interfaces/Contracts/IMetricData.js +1 -1
  46. package/dist-esm/Interfaces/Contracts/IPageViewData.js +1 -1
  47. package/dist-esm/Interfaces/Contracts/IPageViewPerfData.js +1 -1
  48. package/dist-esm/Interfaces/Contracts/IRemoteDependencyData.js +1 -1
  49. package/dist-esm/Interfaces/Contracts/IStackFrame.js +1 -1
  50. package/dist-esm/Interfaces/Contracts/RequestData.js +1 -1
  51. package/dist-esm/Interfaces/Contracts/SeverityLevel.js +1 -1
  52. package/dist-esm/Interfaces/IAppInsights.js +1 -1
  53. package/dist-esm/Interfaces/IChannelControlsAI.js +1 -1
  54. package/dist-esm/Interfaces/IConfig.js +1 -1
  55. package/dist-esm/Interfaces/ICorrelationConfig.js +1 -1
  56. package/dist-esm/Interfaces/IDependencyTelemetry.js +1 -1
  57. package/dist-esm/Interfaces/IEventTelemetry.js +1 -1
  58. package/dist-esm/Interfaces/IExceptionTelemetry.js +1 -1
  59. package/dist-esm/Interfaces/IMetricTelemetry.js +1 -1
  60. package/dist-esm/Interfaces/IPageViewPerformanceTelemetry.js +1 -1
  61. package/dist-esm/Interfaces/IPageViewTelemetry.js +1 -1
  62. package/dist-esm/Interfaces/IPartC.js +1 -1
  63. package/dist-esm/Interfaces/IPropertiesPlugin.js +1 -1
  64. package/dist-esm/Interfaces/IRequestContext.js +1 -1
  65. package/dist-esm/Interfaces/ITelemetryContext.js +1 -1
  66. package/dist-esm/Interfaces/ITraceTelemetry.js +1 -1
  67. package/dist-esm/Interfaces/PartAExtensions.js +1 -1
  68. package/dist-esm/Interfaces/Telemetry/IEnvelope.js +1 -1
  69. package/dist-esm/Interfaces/Telemetry/ISerializable.js +1 -1
  70. package/dist-esm/RequestResponseHeaders.js +1 -1
  71. package/dist-esm/StorageHelperFuncs.js +1 -1
  72. package/dist-esm/Telemetry/Common/Data.js +1 -1
  73. package/dist-esm/Telemetry/Common/DataPoint.js +1 -1
  74. package/dist-esm/Telemetry/Common/DataSanitizer.js +6 -32
  75. package/dist-esm/Telemetry/Common/DataSanitizer.js.map +1 -1
  76. package/dist-esm/Telemetry/Common/Envelope.js +1 -1
  77. package/dist-esm/Telemetry/Event.js +1 -1
  78. package/dist-esm/Telemetry/Exception.js +1 -1
  79. package/dist-esm/Telemetry/Metric.js +1 -1
  80. package/dist-esm/Telemetry/PageView.js +1 -1
  81. package/dist-esm/Telemetry/PageViewPerformance.js +1 -1
  82. package/dist-esm/Telemetry/RemoteDependencyData.js +1 -1
  83. package/dist-esm/Telemetry/Trace.js +1 -1
  84. package/dist-esm/TelemetryItemCreator.js +1 -1
  85. package/dist-esm/UrlHelperFuncs.js +1 -1
  86. package/dist-esm/Util.js +79 -133
  87. package/dist-esm/Util.js.map +1 -1
  88. package/dist-esm/__DynamicConstants.js +4 -8
  89. package/dist-esm/__DynamicConstants.js.map +1 -1
  90. package/dist-esm/applicationinsights-common.js +3 -3
  91. package/dist-esm/applicationinsights-common.js.map +1 -1
  92. package/package.json +5 -4
  93. package/src/Telemetry/Common/DataSanitizer.ts +5 -95
  94. package/src/Util.ts +79 -395
  95. package/src/__DynamicConstants.ts +3 -7
  96. package/src/applicationinsights-common.ts +3 -4
  97. package/tsconfig.json +1 -1
  98. package/types/Telemetry/Common/DataSanitizer.d.ts +0 -50
  99. package/types/Util.d.ts +19 -212
  100. package/types/__DynamicConstants.d.ts +0 -4
  101. package/types/applicationinsights-common.d.ts +2 -2
  102. 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, IPlugin, arrForEach, arrIndexOf, attachEvent, canUseCookies as coreCanUseCookies, dateNow,
6
- deleteCookie as coreDeleteCookie, disableCookies as coreDisableCookies, dumpObj, generateW3CId, getCookie as coreGetCookie,
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, strNotSpecified } from "./Constants";
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 { urlGetAbsoluteUrl, urlGetCompleteUrl, urlGetPathName, urlParseFullHost, urlParseHost, urlParseUrl } from "./UrlHelperFuncs";
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 interface IUtil {
35
- NotSpecified: string,
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 const UrlHelper: IUrlHelper = {
296
- parseUrl: urlParseUrl,
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
- export const CorrelationIdHelper: ICorrelationIdHelper = {
328
- correlationIdPrefix: "cid-v1:",
329
-
330
- /**
331
- * Checks if a request url is not on a excluded domain list and if it is safe to add correlation headers.
332
- * Headers are always included if the current domain matches the request domain. If they do not match (CORS),
333
- * they are regex-ed across correlationHeaderDomains and correlationHeaderExcludedDomains to determine if headers are included.
334
- * Some environments don't give information on currentHost via window.location.host (e.g. Cordova). In these cases, the user must
335
- * manually supply domains to include correlation headers on. Else, no headers will be included at all.
336
- */
337
- canIncludeCorrelationHeader(config: ICorrelationConfig, requestUrl: string, currentHost?: string) {
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
- if (config && config.correlationHeaderExcludePatterns) {
343
- for (let i = 0; i < config.correlationHeaderExcludePatterns.length; i++) {
344
- if (config.correlationHeaderExcludePatterns[i].test(requestUrl)) {
345
- return false;
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
- let requestHost = urlParseUrl(requestUrl).host.toLowerCase();
351
- if (requestHost && (requestHost.indexOf(":443") !== -1 || requestHost.indexOf(":80") !== -1)) {
352
- // [Bug #1260] IE can include the port even for http and https URLs so if present
353
- // try and parse it to remove if it matches the default protocol port
354
- requestHost = (urlParseFullHost(requestUrl, true) || "").toLowerCase();
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
- if ((!config || !config.enableCorsCorrelation) && (requestHost && requestHost !== currentHost)) {
358
- return false;
359
- }
63
+ if ((!config || !config.enableCorsCorrelation) && (requestHost && requestHost !== currentHost)) {
64
+ return false;
65
+ }
360
66
 
361
- const includedDomains = config && config.correlationHeaderDomains;
362
- if (includedDomains) {
363
- let matchExists: boolean;
364
- arrForEach(includedDomains, (domain) => {
365
- const regex = new RegExp(domain.toLowerCase().replace(/\\/g, "\\\\").replace(/\./g, "\\.").replace(/\*/g, ".*"));
366
- matchExists = matchExists || regex.test(requestHost);
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
- if (!matchExists) {
370
- return false;
371
- }
75
+ if (!matchExists) {
76
+ return false;
372
77
  }
78
+ }
373
79
 
374
- const excludedDomains = config && config.correlationHeaderExcludedDomains;
375
- if (!excludedDomains || excludedDomains.length === 0) {
376
- return true;
377
- }
80
+ const excludedDomains = config && config.correlationHeaderExcludedDomains;
81
+ if (!excludedDomains || excludedDomains.length === 0) {
82
+ return true;
83
+ }
378
84
 
379
- for (let i = 0; i < excludedDomains.length; i++) {
380
- const regex = new RegExp(excludedDomains[i].toLowerCase().replace(/\\/g, "\\\\").replace(/\./g, "\\.").replace(/\*/g, ".*"));
381
- if (regex.test(requestHost)) {
382
- return false;
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
- // if we don't know anything about the requestHost, require the user to use included/excludedDomains.
387
- // Previously we always returned false for a falsy requestHost
388
- return requestHost && requestHost.length > 0;
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
- * Combines target appId and target role name from response header.
393
- */
394
- getCorrelationContext(responseHeader: string) {
395
- if (responseHeader) {
396
- const correlationId = CorrelationIdHelper.getCorrelationContextValue(responseHeader, RequestHeaders[eRequestHeaders.requestContextTargetKey]);
397
- if (correlationId && correlationId !== CorrelationIdHelper.correlationIdPrefix) {
398
- return correlationId;
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
- * Gets key from correlation response header
405
- */
406
- getCorrelationContextValue(responseHeader: string, key: string) {
407
- if (responseHeader) {
408
- const keyValues = responseHeader.split(",");
409
- for (let i = 0; i < keyValues.length; ++i) {
410
- const keyValue = keyValues[i].split("=");
411
- if (keyValue.length === 2 && keyValue[0] === key) {
412
- return keyValue[1];
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 ES3 this will export a mutable variables that someone could change!!!
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
- IUtil, Util, ICorrelationIdHelper, CorrelationIdHelper,
5
- IDateTimeUtils, DateTimeUtils, dateTimeUtilsNow, dateTimeUtilsDuration,
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, IDataSanitizer, DataSanitizer,
38
+ DataSanitizerValues,
40
39
  dataSanitizeKeyAndAddUniqueness, dataSanitizeKey, dataSanitizeString, dataSanitizeUrl, dataSanitizeMessage,
41
40
  dataSanitizeException, dataSanitizeProperties, dataSanitizeMeasurements, dataSanitizeId, dataSanitizeInput,
42
41
  dsPadNumber
package/tsconfig.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "noImplicitAny": true,
6
6
  "module": "es6",
7
7
  "moduleResolution": "Node",
8
- "target": "es3",
8
+ "target": "es5",
9
9
  "alwaysStrict": true,
10
10
  "suppressImplicitAnyIndexErrors": true,
11
11
  "allowSyntheticDefaultImports": true,
@@ -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;