@microsoft/1ds-core-js 4.4.0-nightlybeta3.2602-27 → 4.4.1

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 (53) hide show
  1. package/README.md +56 -0
  2. package/bundle/es5/{ms.core-4.4.0-nightlybeta3.2602-27.gbl.js → ms.core-4.4.1.gbl.js} +498 -511
  3. package/bundle/es5/ms.core-4.4.1.gbl.js.map +1 -0
  4. package/bundle/es5/ms.core-4.4.1.gbl.min.js +7 -0
  5. package/bundle/es5/ms.core-4.4.1.gbl.min.js.map +1 -0
  6. package/bundle/es5/ms.core-4.4.1.integrity.json +46 -0
  7. package/bundle/es5/{ms.core-4.4.0-nightlybeta3.2602-27.js → ms.core-4.4.1.js} +498 -511
  8. package/bundle/es5/ms.core-4.4.1.js.map +1 -0
  9. package/bundle/es5/ms.core-4.4.1.min.js +7 -0
  10. package/bundle/es5/ms.core-4.4.1.min.js.map +1 -0
  11. package/bundle/es5/ms.core.gbl.js +497 -510
  12. package/bundle/es5/ms.core.gbl.js.map +1 -1
  13. package/bundle/es5/ms.core.gbl.min.js +2 -2
  14. package/bundle/es5/ms.core.gbl.min.js.map +1 -1
  15. package/bundle/es5/ms.core.integrity.json +17 -17
  16. package/bundle/es5/ms.core.js +497 -510
  17. package/bundle/es5/ms.core.js.map +1 -1
  18. package/bundle/es5/ms.core.min.js +2 -2
  19. package/bundle/es5/ms.core.min.js.map +1 -1
  20. package/dist/es5/ms.core.js +495 -508
  21. package/dist/es5/ms.core.js.map +1 -1
  22. package/dist/es5/ms.core.min.js +2 -2
  23. package/dist/es5/ms.core.min.js.map +1 -1
  24. package/dist-es5/Index.js +9 -22
  25. package/dist-es5/Index.js.map +1 -1
  26. package/package.json +69 -72
  27. package/types/1ds-core-js.d.ts +110 -691
  28. package/types/1ds-core-js.namespaced.d.ts +54 -5
  29. package/bundle/es5/ms.core-4.4.0-nightlybeta3.2602-27.gbl.js.map +0 -1
  30. package/bundle/es5/ms.core-4.4.0-nightlybeta3.2602-27.gbl.min.js +0 -7
  31. package/bundle/es5/ms.core-4.4.0-nightlybeta3.2602-27.gbl.min.js.map +0 -1
  32. package/bundle/es5/ms.core-4.4.0-nightlybeta3.2602-27.integrity.json +0 -46
  33. package/bundle/es5/ms.core-4.4.0-nightlybeta3.2602-27.js.map +0 -1
  34. package/bundle/es5/ms.core-4.4.0-nightlybeta3.2602-27.min.js +0 -7
  35. package/bundle/es5/ms.core-4.4.0-nightlybeta3.2602-27.min.js.map +0 -1
  36. package/dist-es5/AppInsightsCore.js +0 -96
  37. package/dist-es5/AppInsightsCore.js.map +0 -1
  38. package/dist-es5/BaseCore.js +0 -67
  39. package/dist-es5/BaseCore.js.map +0 -1
  40. package/dist-es5/DataModels.js +0 -7
  41. package/dist-es5/DataModels.js.map +0 -1
  42. package/dist-es5/Enums.js +0 -92
  43. package/dist-es5/Enums.js.map +0 -1
  44. package/dist-es5/InternalConstants.js +0 -19
  45. package/dist-es5/InternalConstants.js.map +0 -1
  46. package/dist-es5/Utils.js +0 -397
  47. package/dist-es5/Utils.js.map +0 -1
  48. package/dist-es5/ValueSanitizer.js +0 -262
  49. package/dist-es5/ValueSanitizer.js.map +0 -1
  50. package/dist-es5/__DynamicConstants.js +0 -28
  51. package/dist-es5/__DynamicConstants.js.map +0 -1
  52. package/dist-es5/extSpanUtils.js +0 -308
  53. package/dist-es5/extSpanUtils.js.map +0 -1
package/dist-es5/Utils.js DELETED
@@ -1,397 +0,0 @@
1
- /*
2
- * 1DS JS SDK Core, 4.4.0-nightlybeta3.2602-27
3
- * Copyright (c) Microsoft and contributors. All rights reserved.
4
- * (Microsoft Internal Only)
5
- */
6
- var _a;
7
- /**
8
- * Utils.ts
9
- * @author Abhilash Panwar (abpanwar) Hector Hernandez (hectorh)
10
- * @copyright Microsoft 2018
11
- * File containing utility functions.
12
- */
13
- import { arrForEach, getGlobalInst, getNavigator, hasDocument, hasWindow, isArray, isBoolean, isNullOrUndefined, isNumber, isObject, isReactNative, isString, isUndefined, newGuid, objForEachKey, perfNow } from "@microsoft/applicationinsights-core-js";
14
- import { ObjProto, strShimObject } from "@microsoft/applicationinsights-shims";
15
- import { strIndexOf, strLeft } from "@nevware21/ts-utils";
16
- import { STR_EMPTY } from "./InternalConstants";
17
- import { _DYN_INDEX_OF, _DYN_KIND, _DYN_LENGTH, _DYN_PROCESS_TELEMETRY_ST0, _DYN_TIMINGS, _DYN_VALUE } from "./__DynamicConstants";
18
- export var Version = '4.4.0-nightlybeta3.2602-27';
19
- export var FullVersionString = "1DS-Web-JS-" + Version;
20
- var ObjHasOwnProperty = ObjProto.hasOwnProperty;
21
- // Defining here so we don't need to take (import) the ApplicationInsights Common module
22
- var strDisabledPropertyName = "Microsoft_ApplicationInsights_BypassAjaxInstrumentation";
23
- var strWithCredentials = "withCredentials";
24
- var strTimeout = "timeout";
25
- // If value is array just get the type for the first element
26
- var _fieldTypeEventPropMap = (_a = {},
27
- _a[0 /* FieldValueSanitizerType.NotSet */] = 0 /* eEventPropertyType.Unspecified */,
28
- _a[2 /* FieldValueSanitizerType.Number */] = 6 /* eEventPropertyType.Double */,
29
- _a[1 /* FieldValueSanitizerType.String */] = 1 /* eEventPropertyType.String */,
30
- _a[3 /* FieldValueSanitizerType.Boolean */] = 7 /* eEventPropertyType.Bool */,
31
- _a[4096 /* FieldValueSanitizerType.Array */ | 2 /* FieldValueSanitizerType.Number */] = 6 /* eEventPropertyType.Double */,
32
- _a[4096 /* FieldValueSanitizerType.Array */ | 1 /* FieldValueSanitizerType.String */] = 1 /* eEventPropertyType.String */,
33
- _a[4096 /* FieldValueSanitizerType.Array */ | 3 /* FieldValueSanitizerType.Boolean */] = 7 /* eEventPropertyType.Bool */,
34
- _a);
35
- /**
36
- * @ignore
37
- */
38
- // let _uaDisallowsSameSiteNone = null;
39
- var uInt8ArraySupported = null;
40
- // var _areCookiesAvailable: boolean | undefined;
41
- /**
42
- * Checks if document object is available
43
- */
44
- export var isDocumentObjectAvailable = hasDocument();
45
- /**
46
- * Checks if window object is available
47
- */
48
- export var isWindowObjectAvailable = hasWindow();
49
- /**
50
- * Checks if value is assigned to the given param.
51
- * @param value - The token from which the tenant id is to be extracted.
52
- * @returns True/false denoting if value is assigned to the param.
53
- */
54
- export function isValueAssigned(value) {
55
- /// <summary> takes a value and checks for undefined, null and empty string </summary>
56
- /// <param type="any"> value to be tested </param>
57
- /// <returns> true if value is null undefined or emptyString </returns>
58
- return !(value === STR_EMPTY || isNullOrUndefined(value));
59
- }
60
- /**
61
- * Gets the tenant id from the tenant token.
62
- * @param apiKey - The token from which the tenant id is to be extracted.
63
- * @returns The tenant id.
64
- */
65
- export function getTenantId(apiKey) {
66
- if (apiKey) {
67
- var indexTenantId = strIndexOf(apiKey, "-");
68
- if (indexTenantId > -1) {
69
- return strLeft(apiKey, indexTenantId);
70
- }
71
- }
72
- return STR_EMPTY;
73
- }
74
- /**
75
- * Checks if Uint8Array are available in the current environment. Safari and Firefox along with
76
- * ReactNative are known to not support Uint8Array properly.
77
- * @returns True if available, false otherwise.
78
- */
79
- export function isUint8ArrayAvailable() {
80
- if (uInt8ArraySupported === null) {
81
- uInt8ArraySupported = !isUndefined(Uint8Array) && !isSafariOrFirefox() && !isReactNative();
82
- }
83
- return uInt8ArraySupported;
84
- }
85
- /**
86
- * Checks if the value is a valid EventLatency.
87
- * @param value - The value that needs to be checked.
88
- * @returns True if the value is in AWTEventLatency, false otherwise.
89
- */
90
- export function isLatency(value) {
91
- if (value && isNumber(value) && value >= 1 /* EventLatencyValue.Normal */ && value <= 4 /* EventLatencyValue.Immediate */) {
92
- return true;
93
- }
94
- return false;
95
- }
96
- /**
97
- * Sanitizes the Property. It checks the that the property name and value are valid. It also
98
- * checks/populates the correct type and pii of the property value.
99
- * @param name - property name - The property name.
100
- * @param property - The property value or an IEventProperty containing value,
101
- * type ,pii and customer content.
102
- * @returns IEventProperty containing valid name, value, pii and type or null if invalid.
103
- */
104
- export function sanitizeProperty(name, property, stringifyObjects) {
105
- // Check that property is valid
106
- if ((!property && !isValueAssigned(property)) || typeof name !== "string") {
107
- return null;
108
- }
109
- // Perf optimization -- only need to get the type once not multiple times
110
- var propType = typeof property;
111
- // If the property isn't IEventProperty (and is either string, number, boolean or array), convert it into one.
112
- if (propType === "string" || propType === "number" || propType === "boolean" || isArray(property)) {
113
- property = { value: property };
114
- }
115
- else if (propType === "object" && !ObjHasOwnProperty.call(property, "value")) {
116
- property = { value: stringifyObjects ? JSON.stringify(property) : property };
117
- }
118
- else if (isNullOrUndefined(property[_DYN_VALUE /* @min:%2evalue */])
119
- || property[_DYN_VALUE /* @min:%2evalue */] === STR_EMPTY || (!isString(property[_DYN_VALUE /* @min:%2evalue */])
120
- && !isNumber(property[_DYN_VALUE /* @min:%2evalue */]) && !isBoolean(property[_DYN_VALUE /* @min:%2evalue */])
121
- && !isArray(property[_DYN_VALUE /* @min:%2evalue */]))) {
122
- // Since property is IEventProperty, we need to validate its value
123
- return null;
124
- }
125
- // We need to check that if the property value is an array, it is valid
126
- if (isArray(property[_DYN_VALUE /* @min:%2evalue */]) &&
127
- !isArrayValid(property[_DYN_VALUE /* @min:%2evalue */])) {
128
- return null;
129
- }
130
- // If either pii or cc is set convert value to string (since only string pii/cc is allowed).
131
- // If the value is a complex type like an array that can't be converted to string we will drop
132
- // the property.
133
- if (!isNullOrUndefined(property[_DYN_KIND /* @min:%2ekind */])) {
134
- if (isArray(property.value) || !isValueKind(property[_DYN_KIND /* @min:%2ekind */])) {
135
- return null;
136
- }
137
- property[_DYN_VALUE /* @min:%2evalue */] = property[_DYN_VALUE /* @min:%2evalue */].toString();
138
- }
139
- return property;
140
- }
141
- export function getCommonSchemaMetaData(value, kind, type) {
142
- var encodedTypeValue = -1;
143
- if (!isUndefined(value)) {
144
- if (kind > 0) {
145
- if (kind === 32 /* eValueKind.CustomerContent_GenericContent */) {
146
- // encode customer content. Value can only be string. bit 13-16 are for cc
147
- encodedTypeValue = (1 << 13);
148
- }
149
- else if (kind <= 13) {
150
- // encode PII. Value can only be string. bits 5-12 are for Pii
151
- encodedTypeValue = (kind << 5);
152
- }
153
- }
154
- // isDataType checks that the "type" is a number so we don't need to check for undefined
155
- if (isDataType(type)) {
156
- // Data Type is provided and valid, so use that
157
- if (encodedTypeValue === -1) {
158
- // Don't return -1
159
- encodedTypeValue = 0;
160
- }
161
- encodedTypeValue |= type;
162
- }
163
- else {
164
- var propType = _fieldTypeEventPropMap[getFieldValueType(value)] || -1;
165
- if (encodedTypeValue !== -1 && propType !== -1) {
166
- // pii exists so we must return correct type
167
- encodedTypeValue |= propType;
168
- }
169
- else if (propType === 6 /* eEventPropertyType.Double */) {
170
- encodedTypeValue = propType;
171
- }
172
- }
173
- }
174
- return encodedTypeValue;
175
- }
176
- /**
177
- * Helper to get and decode the cookie value using decodeURIComponent, this is for historical
178
- * backward compatibility where the document.cookie value was decoded before parsing.
179
- * @param cookieMgr - The cookie manager to use
180
- * @param name - The name of the cookie to get
181
- * @param decode - A flag to indicate whether the cookie value should be decoded
182
- * @returns The decoded cookie value (if available) otherwise an empty string.
183
- */
184
- export function getCookieValue(cookieMgr, name, decode) {
185
- if (decode === void 0) { decode = true; }
186
- var cookieValue;
187
- if (cookieMgr) {
188
- cookieValue = cookieMgr.get(name);
189
- if (decode && cookieValue && decodeURIComponent) {
190
- cookieValue = decodeURIComponent(cookieValue);
191
- }
192
- }
193
- return cookieValue || STR_EMPTY;
194
- }
195
- /**
196
- * Create a new guid.
197
- * @param style - The style of guid to generated, defaults to Digits
198
- * Digits (Default) : 32 digits separated by hyphens: 00000000-0000-0000-0000-000000000000
199
- * Braces - 32 digits separated by hyphens, enclosed in braces: \{00000000-0000-0000-0000-000000000000\}
200
- * Parentheses - 32 digits separated by hyphens, enclosed in parentheses: (00000000-0000-0000-0000-000000000000)
201
- * Numeric - 32 digits: 00000000000000000000000000000000
202
- */
203
- export function createGuid(style) {
204
- if (style === void 0) { style = "D" /* GuidStyle.Digits */; }
205
- var theGuid = newGuid();
206
- if (style === "B" /* GuidStyle.Braces */) {
207
- theGuid = "{" + theGuid + "}";
208
- }
209
- else if (style === "P" /* GuidStyle.Parentheses */) {
210
- theGuid = "(" + theGuid + ")";
211
- }
212
- else if (style === "N" /* GuidStyle.Numeric */) {
213
- theGuid = theGuid.replace(/-/g, STR_EMPTY);
214
- }
215
- return theGuid;
216
- }
217
- /**
218
- * Pass in the objects to merge as arguments.
219
- * @param obj1 - object to merge. Set this argument to 'true' for a deep extend.
220
- * @param obj2 - object to merge.
221
- * @param obj3 - object to merge.
222
- * @param obj4 - object to merge.
223
- * @param obj5 - object to merge.
224
- * @returns The extended object.
225
- */
226
- export function extend(obj, obj2, obj3, obj4, obj5) {
227
- // Variables
228
- var extended = {};
229
- var deep = false;
230
- var i = 0;
231
- var length = arguments[_DYN_LENGTH /* @min:%2elength */];
232
- var theArgs = arguments;
233
- // Check if a deep merge
234
- if (isBoolean(theArgs[0])) {
235
- deep = theArgs[0];
236
- i++;
237
- }
238
- // Loop through each object and conduct a merge
239
- for (; i < length; i++) {
240
- var obj = theArgs[i];
241
- objForEachKey(obj, function (prop, value) {
242
- // If deep merge and property is an object, merge properties
243
- if (deep && value && isObject(value)) {
244
- if (isArray(value)) {
245
- extended[prop] = extended[prop] || [];
246
- arrForEach(value, function (arrayValue, arrayIndex) {
247
- if (arrayValue && isObject(arrayValue)) {
248
- extended[prop][arrayIndex] = extend(true, extended[prop][arrayIndex], arrayValue);
249
- }
250
- else {
251
- extended[prop][arrayIndex] = arrayValue;
252
- }
253
- });
254
- }
255
- else {
256
- extended[prop] = extend(true, extended[prop], value);
257
- }
258
- }
259
- else {
260
- extended[prop] = value;
261
- }
262
- });
263
- }
264
- return extended;
265
- }
266
- export var getTime = perfNow;
267
- export function isValueKind(value) {
268
- // Always assume that it's a number (no type checking) for performance as this is used during the JSON serialization
269
- if (value === 0 /* eValueKind.NotSet */ || ((value > 0 /* eValueKind.NotSet */ && value <= 13 /* eValueKind.Pii_IPV4AddressLegacy */) || value === 32 /* eValueKind.CustomerContent_GenericContent */)) {
270
- return true;
271
- }
272
- return false;
273
- }
274
- function isDataType(value) {
275
- // Remark: 0 returns false, but it doesn't affect encoding anyways
276
- // Always assume that it's a number (no type checking) for performance as this is used during the JSON serialization
277
- if (value >= 0 && value <= 9) {
278
- return true;
279
- }
280
- return false;
281
- }
282
- function isSafariOrFirefox() {
283
- var nav = getNavigator();
284
- // If non-browser navigator will be undefined
285
- if (!isUndefined(nav) && nav.userAgent) {
286
- var ua = nav.userAgent.toLowerCase();
287
- if ((ua[_DYN_INDEX_OF /* @min:%2eindexOf */]("safari") >= 0 || ua[_DYN_INDEX_OF /* @min:%2eindexOf */]("firefox") >= 0) && ua[_DYN_INDEX_OF /* @min:%2eindexOf */]("chrome") < 0) {
288
- return true;
289
- }
290
- }
291
- return false;
292
- }
293
- export function isArrayValid(value) {
294
- return value[_DYN_LENGTH /* @min:%2elength */] > 0;
295
- }
296
- export function setProcessTelemetryTimings(event, identifier) {
297
- var evt = event;
298
- evt[_DYN_TIMINGS /* @min:%2etimings */] = evt[_DYN_TIMINGS /* @min:%2etimings */] || {};
299
- evt[_DYN_TIMINGS /* @min:%2etimings */][_DYN_PROCESS_TELEMETRY_ST0 /* @min:%2eprocessTelemetryStart */] = evt[_DYN_TIMINGS /* @min:%2etimings */][_DYN_PROCESS_TELEMETRY_ST0 /* @min:%2eprocessTelemetryStart */] || {};
300
- evt[_DYN_TIMINGS /* @min:%2etimings */][_DYN_PROCESS_TELEMETRY_ST0 /* @min:%2eprocessTelemetryStart */][identifier] = getTime();
301
- }
302
- /**
303
- * Returns a bitwise value for the FieldValueSanitizerType enum representing the decoded type of the passed value
304
- * @param value - The value to determine the type
305
- */
306
- export function getFieldValueType(value) {
307
- var theType = 0 /* FieldValueSanitizerType.NotSet */;
308
- if (value !== null && value !== undefined) {
309
- var objType = typeof value;
310
- if (objType === "string") {
311
- theType = 1 /* FieldValueSanitizerType.String */;
312
- }
313
- else if (objType === "number") {
314
- theType = 2 /* FieldValueSanitizerType.Number */;
315
- }
316
- else if (objType === "boolean") {
317
- theType = 3 /* FieldValueSanitizerType.Boolean */;
318
- }
319
- else if (objType === strShimObject) {
320
- theType = 4 /* FieldValueSanitizerType.Object */;
321
- if (isArray(value)) {
322
- theType = 4096 /* FieldValueSanitizerType.Array */;
323
- if (value[_DYN_LENGTH /* @min:%2elength */] > 0) {
324
- // Empty arrays are not supported and are considered to be the same as null
325
- theType |= getFieldValueType(value[0]);
326
- }
327
- }
328
- else if (ObjHasOwnProperty.call(value, "value")) {
329
- // Looks like an IEventProperty
330
- theType = 8192 /* FieldValueSanitizerType.EventProperty */ | getFieldValueType(value[_DYN_VALUE /* @min:%2evalue */]);
331
- }
332
- }
333
- }
334
- return theType;
335
- }
336
- /**
337
- * Helper to identify whether we are running in a chromium based browser environment
338
- */
339
- export function isChromium() {
340
- return !!getGlobalInst("chrome");
341
- }
342
- /**
343
- * Create and open an XMLHttpRequest object
344
- * @param method - The request method
345
- * @param urlString - The url
346
- * @param withCredentials - Option flag indicating that credentials should be sent
347
- * @param disabled - Optional flag indicating that the XHR object should be marked as disabled and not tracked (default is false)
348
- * @param isSync - Optional flag indicating if the instance should be a synchronous request (defaults to false)
349
- * @param timeout - Optional value identifying the timeout value that should be assigned to the XHR request
350
- * @returns A new opened XHR request
351
- */
352
- export function openXhr(method, urlString, withCredentials, disabled, isSync, timeout) {
353
- if (disabled === void 0) { disabled = false; }
354
- if (isSync === void 0) { isSync = false; }
355
- function _wrapSetXhrProp(xhr, prop, value) {
356
- try {
357
- xhr[prop] = value;
358
- }
359
- catch (e) {
360
- // - Wrapping as depending on the environment setting the property may fail (non-terminally)
361
- }
362
- }
363
- var xhr = new XMLHttpRequest();
364
- if (disabled) {
365
- // Tag the instance so it's not tracked (trackDependency)
366
- // If the environment has locked down the XMLHttpRequest (preventExtensions and/or freeze), this would
367
- // cause the request to fail and we no telemetry would be sent
368
- _wrapSetXhrProp(xhr, strDisabledPropertyName, disabled);
369
- }
370
- if (withCredentials) {
371
- // Some libraries require that the withCredentials flag is set "before" open and
372
- // - Wrapping as IE 10 has started throwing when setting before open
373
- _wrapSetXhrProp(xhr, strWithCredentials, withCredentials);
374
- }
375
- xhr.open(method, urlString, !isSync);
376
- if (withCredentials) {
377
- // withCredentials should be set AFTER open (https://xhr.spec.whatwg.org/#the-withcredentials-attribute)
378
- // And older firefox instances from 11+ will throw for sync events (current versions don't) which happens during unload processing
379
- _wrapSetXhrProp(xhr, strWithCredentials, withCredentials);
380
- }
381
- // Only set the timeout for asynchronous requests as
382
- // "Timeout shouldn't be used for synchronous XMLHttpRequests requests used in a document environment or it will throw an InvalidAccessError exception.""
383
- // https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/timeout
384
- if (!isSync && timeout) {
385
- _wrapSetXhrProp(xhr, strTimeout, timeout);
386
- }
387
- return xhr;
388
- }
389
- /**
390
- * Check to see if the value is \> 0
391
- * @param value - The value to check
392
- * @returns true if \> 0 otherwise false
393
- */
394
- export function isGreaterThanZero(value) {
395
- return value > 0;
396
- }
397
- //# sourceMappingURL=Utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Utils.js.map","sources":["Utils.js"],"sourcesContent":["var _a;\r\n/**\r\n* Utils.ts\r\n* @author Abhilash Panwar (abpanwar) Hector Hernandez (hectorh)\r\n* @copyright Microsoft 2018\r\n* File containing utility functions.\r\n*/\r\nimport { arrForEach, getGlobalInst, getNavigator, hasDocument, hasWindow, isArray, isBoolean, isNullOrUndefined, isNumber, isObject, isReactNative, isString, isUndefined, newGuid, objForEachKey, perfNow } from \"@microsoft/applicationinsights-core-js\";\r\nimport { ObjProto, strShimObject } from \"@microsoft/applicationinsights-shims\";\r\nimport { strIndexOf, strLeft } from \"@nevware21/ts-utils\";\r\nimport { STR_EMPTY } from \"./InternalConstants\";\r\nimport { _DYN_INDEX_OF, _DYN_KIND, _DYN_LENGTH, _DYN_PROCESS_TELEMETRY_ST0, _DYN_TIMINGS, _DYN_VALUE } from \"./__DynamicConstants\";\r\nexport var Version = '4.4.0-nightlybeta3.2602-27';\r\nexport var FullVersionString = \"1DS-Web-JS-\" + Version;\r\nvar ObjHasOwnProperty = ObjProto.hasOwnProperty;\r\n// Defining here so we don't need to take (import) the ApplicationInsights Common module\r\nvar strDisabledPropertyName = \"Microsoft_ApplicationInsights_BypassAjaxInstrumentation\";\r\nvar strWithCredentials = \"withCredentials\";\r\nvar strTimeout = \"timeout\";\r\n// If value is array just get the type for the first element\r\nvar _fieldTypeEventPropMap = (_a = {},\r\n _a[0 /* FieldValueSanitizerType.NotSet */] = 0 /* eEventPropertyType.Unspecified */,\r\n _a[2 /* FieldValueSanitizerType.Number */] = 6 /* eEventPropertyType.Double */,\r\n _a[1 /* FieldValueSanitizerType.String */] = 1 /* eEventPropertyType.String */,\r\n _a[3 /* FieldValueSanitizerType.Boolean */] = 7 /* eEventPropertyType.Bool */,\r\n _a[4096 /* FieldValueSanitizerType.Array */ | 2 /* FieldValueSanitizerType.Number */] = 6 /* eEventPropertyType.Double */,\r\n _a[4096 /* FieldValueSanitizerType.Array */ | 1 /* FieldValueSanitizerType.String */] = 1 /* eEventPropertyType.String */,\r\n _a[4096 /* FieldValueSanitizerType.Array */ | 3 /* FieldValueSanitizerType.Boolean */] = 7 /* eEventPropertyType.Bool */,\r\n _a);\r\n/**\r\n * @ignore\r\n */\r\n// let _uaDisallowsSameSiteNone = null;\r\nvar uInt8ArraySupported = null;\r\n// var _areCookiesAvailable: boolean | undefined;\r\n/**\r\n * Checks if document object is available\r\n */\r\nexport var isDocumentObjectAvailable = hasDocument();\r\n/**\r\n * Checks if window object is available\r\n */\r\nexport var isWindowObjectAvailable = hasWindow();\r\n/**\r\n * Checks if value is assigned to the given param.\r\n * @param value - The token from which the tenant id is to be extracted.\r\n * @returns True/false denoting if value is assigned to the param.\r\n */\r\nexport function isValueAssigned(value) {\r\n /// <summary> takes a value and checks for undefined, null and empty string </summary>\r\n /// <param type=\"any\"> value to be tested </param>\r\n /// <returns> true if value is null undefined or emptyString </returns>\r\n return !(value === STR_EMPTY || isNullOrUndefined(value));\r\n}\r\n/**\r\n * Gets the tenant id from the tenant token.\r\n * @param apiKey - The token from which the tenant id is to be extracted.\r\n * @returns The tenant id.\r\n */\r\nexport function getTenantId(apiKey) {\r\n if (apiKey) {\r\n var indexTenantId = strIndexOf(apiKey, \"-\");\r\n if (indexTenantId > -1) {\r\n return strLeft(apiKey, indexTenantId);\r\n }\r\n }\r\n return STR_EMPTY;\r\n}\r\n/**\r\n * Checks if Uint8Array are available in the current environment. Safari and Firefox along with\r\n * ReactNative are known to not support Uint8Array properly.\r\n * @returns True if available, false otherwise.\r\n */\r\nexport function isUint8ArrayAvailable() {\r\n if (uInt8ArraySupported === null) {\r\n uInt8ArraySupported = !isUndefined(Uint8Array) && !isSafariOrFirefox() && !isReactNative();\r\n }\r\n return uInt8ArraySupported;\r\n}\r\n/**\r\n * Checks if the value is a valid EventLatency.\r\n * @param value - The value that needs to be checked.\r\n * @returns True if the value is in AWTEventLatency, false otherwise.\r\n */\r\nexport function isLatency(value) {\r\n if (value && isNumber(value) && value >= 1 /* EventLatencyValue.Normal */ && value <= 4 /* EventLatencyValue.Immediate */) {\r\n return true;\r\n }\r\n return false;\r\n}\r\n/**\r\n * Sanitizes the Property. It checks the that the property name and value are valid. It also\r\n * checks/populates the correct type and pii of the property value.\r\n * @param name - property name - The property name.\r\n * @param property - The property value or an IEventProperty containing value,\r\n * type ,pii and customer content.\r\n * @returns IEventProperty containing valid name, value, pii and type or null if invalid.\r\n */\r\nexport function sanitizeProperty(name, property, stringifyObjects) {\r\n // Check that property is valid\r\n if ((!property && !isValueAssigned(property)) || typeof name !== \"string\") {\r\n return null;\r\n }\r\n // Perf optimization -- only need to get the type once not multiple times\r\n var propType = typeof property;\r\n // If the property isn't IEventProperty (and is either string, number, boolean or array), convert it into one.\r\n if (propType === \"string\" || propType === \"number\" || propType === \"boolean\" || isArray(property)) {\r\n property = { value: property };\r\n }\r\n else if (propType === \"object\" && !ObjHasOwnProperty.call(property, \"value\")) {\r\n property = { value: stringifyObjects ? JSON.stringify(property) : property };\r\n }\r\n else if (isNullOrUndefined(property[_DYN_VALUE /* @min:%2evalue */])\r\n || property[_DYN_VALUE /* @min:%2evalue */] === STR_EMPTY || (!isString(property[_DYN_VALUE /* @min:%2evalue */])\r\n && !isNumber(property[_DYN_VALUE /* @min:%2evalue */]) && !isBoolean(property[_DYN_VALUE /* @min:%2evalue */])\r\n && !isArray(property[_DYN_VALUE /* @min:%2evalue */]))) {\r\n // Since property is IEventProperty, we need to validate its value\r\n return null;\r\n }\r\n // We need to check that if the property value is an array, it is valid\r\n if (isArray(property[_DYN_VALUE /* @min:%2evalue */]) &&\r\n !isArrayValid(property[_DYN_VALUE /* @min:%2evalue */])) {\r\n return null;\r\n }\r\n // If either pii or cc is set convert value to string (since only string pii/cc is allowed).\r\n // If the value is a complex type like an array that can't be converted to string we will drop\r\n // the property.\r\n if (!isNullOrUndefined(property[_DYN_KIND /* @min:%2ekind */])) {\r\n if (isArray(property.value) || !isValueKind(property[_DYN_KIND /* @min:%2ekind */])) {\r\n return null;\r\n }\r\n property[_DYN_VALUE /* @min:%2evalue */] = property[_DYN_VALUE /* @min:%2evalue */].toString();\r\n }\r\n return property;\r\n}\r\nexport function getCommonSchemaMetaData(value, kind, type) {\r\n var encodedTypeValue = -1;\r\n if (!isUndefined(value)) {\r\n if (kind > 0) {\r\n if (kind === 32 /* eValueKind.CustomerContent_GenericContent */) {\r\n // encode customer content. Value can only be string. bit 13-16 are for cc\r\n encodedTypeValue = (1 << 13);\r\n }\r\n else if (kind <= 13) {\r\n // encode PII. Value can only be string. bits 5-12 are for Pii\r\n encodedTypeValue = (kind << 5);\r\n }\r\n }\r\n // isDataType checks that the \"type\" is a number so we don't need to check for undefined\r\n if (isDataType(type)) {\r\n // Data Type is provided and valid, so use that\r\n if (encodedTypeValue === -1) {\r\n // Don't return -1\r\n encodedTypeValue = 0;\r\n }\r\n encodedTypeValue |= type;\r\n }\r\n else {\r\n var propType = _fieldTypeEventPropMap[getFieldValueType(value)] || -1;\r\n if (encodedTypeValue !== -1 && propType !== -1) {\r\n // pii exists so we must return correct type\r\n encodedTypeValue |= propType;\r\n }\r\n else if (propType === 6 /* eEventPropertyType.Double */) {\r\n encodedTypeValue = propType;\r\n }\r\n }\r\n }\r\n return encodedTypeValue;\r\n}\r\n/**\r\n * Helper to get and decode the cookie value using decodeURIComponent, this is for historical\r\n * backward compatibility where the document.cookie value was decoded before parsing.\r\n * @param cookieMgr - The cookie manager to use\r\n * @param name - The name of the cookie to get\r\n * @param decode - A flag to indicate whether the cookie value should be decoded\r\n * @returns The decoded cookie value (if available) otherwise an empty string.\r\n */\r\nexport function getCookieValue(cookieMgr, name, decode) {\r\n if (decode === void 0) { decode = true; }\r\n var cookieValue;\r\n if (cookieMgr) {\r\n cookieValue = cookieMgr.get(name);\r\n if (decode && cookieValue && decodeURIComponent) {\r\n cookieValue = decodeURIComponent(cookieValue);\r\n }\r\n }\r\n return cookieValue || STR_EMPTY;\r\n}\r\n/**\r\n * Create a new guid.\r\n * @param style - The style of guid to generated, defaults to Digits\r\n * Digits (Default) : 32 digits separated by hyphens: 00000000-0000-0000-0000-000000000000\r\n * Braces - 32 digits separated by hyphens, enclosed in braces: \\{00000000-0000-0000-0000-000000000000\\}\r\n * Parentheses - 32 digits separated by hyphens, enclosed in parentheses: (00000000-0000-0000-0000-000000000000)\r\n * Numeric - 32 digits: 00000000000000000000000000000000\r\n */\r\nexport function createGuid(style) {\r\n if (style === void 0) { style = \"D\" /* GuidStyle.Digits */; }\r\n var theGuid = newGuid();\r\n if (style === \"B\" /* GuidStyle.Braces */) {\r\n theGuid = \"{\" + theGuid + \"}\";\r\n }\r\n else if (style === \"P\" /* GuidStyle.Parentheses */) {\r\n theGuid = \"(\" + theGuid + \")\";\r\n }\r\n else if (style === \"N\" /* GuidStyle.Numeric */) {\r\n theGuid = theGuid.replace(/-/g, STR_EMPTY);\r\n }\r\n return theGuid;\r\n}\r\n/**\r\n * Pass in the objects to merge as arguments.\r\n * @param obj1 - object to merge. Set this argument to 'true' for a deep extend.\r\n * @param obj2 - object to merge.\r\n * @param obj3 - object to merge.\r\n * @param obj4 - object to merge.\r\n * @param obj5 - object to merge.\r\n * @returns The extended object.\r\n */\r\nexport function extend(obj, obj2, obj3, obj4, obj5) {\r\n // Variables\r\n var extended = {};\r\n var deep = false;\r\n var i = 0;\r\n var length = arguments[_DYN_LENGTH /* @min:%2elength */];\r\n var theArgs = arguments;\r\n // Check if a deep merge\r\n if (isBoolean(theArgs[0])) {\r\n deep = theArgs[0];\r\n i++;\r\n }\r\n // Loop through each object and conduct a merge\r\n for (; i < length; i++) {\r\n var obj = theArgs[i];\r\n objForEachKey(obj, function (prop, value) {\r\n // If deep merge and property is an object, merge properties\r\n if (deep && value && isObject(value)) {\r\n if (isArray(value)) {\r\n extended[prop] = extended[prop] || [];\r\n arrForEach(value, function (arrayValue, arrayIndex) {\r\n if (arrayValue && isObject(arrayValue)) {\r\n extended[prop][arrayIndex] = extend(true, extended[prop][arrayIndex], arrayValue);\r\n }\r\n else {\r\n extended[prop][arrayIndex] = arrayValue;\r\n }\r\n });\r\n }\r\n else {\r\n extended[prop] = extend(true, extended[prop], value);\r\n }\r\n }\r\n else {\r\n extended[prop] = value;\r\n }\r\n });\r\n }\r\n return extended;\r\n}\r\nexport var getTime = perfNow;\r\nexport function isValueKind(value) {\r\n // Always assume that it's a number (no type checking) for performance as this is used during the JSON serialization\r\n if (value === 0 /* eValueKind.NotSet */ || ((value > 0 /* eValueKind.NotSet */ && value <= 13 /* eValueKind.Pii_IPV4AddressLegacy */) || value === 32 /* eValueKind.CustomerContent_GenericContent */)) {\r\n return true;\r\n }\r\n return false;\r\n}\r\nfunction isDataType(value) {\r\n // Remark: 0 returns false, but it doesn't affect encoding anyways\r\n // Always assume that it's a number (no type checking) for performance as this is used during the JSON serialization\r\n if (value >= 0 && value <= 9) {\r\n return true;\r\n }\r\n return false;\r\n}\r\nfunction isSafariOrFirefox() {\r\n var nav = getNavigator();\r\n // If non-browser navigator will be undefined\r\n if (!isUndefined(nav) && nav.userAgent) {\r\n var ua = nav.userAgent.toLowerCase();\r\n if ((ua[_DYN_INDEX_OF /* @min:%2eindexOf */](\"safari\") >= 0 || ua[_DYN_INDEX_OF /* @min:%2eindexOf */](\"firefox\") >= 0) && ua[_DYN_INDEX_OF /* @min:%2eindexOf */](\"chrome\") < 0) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n}\r\nexport function isArrayValid(value) {\r\n return value[_DYN_LENGTH /* @min:%2elength */] > 0;\r\n}\r\nexport function setProcessTelemetryTimings(event, identifier) {\r\n var evt = event;\r\n evt[_DYN_TIMINGS /* @min:%2etimings */] = evt[_DYN_TIMINGS /* @min:%2etimings */] || {};\r\n evt[_DYN_TIMINGS /* @min:%2etimings */][_DYN_PROCESS_TELEMETRY_ST0 /* @min:%2eprocessTelemetryStart */] = evt[_DYN_TIMINGS /* @min:%2etimings */][_DYN_PROCESS_TELEMETRY_ST0 /* @min:%2eprocessTelemetryStart */] || {};\r\n evt[_DYN_TIMINGS /* @min:%2etimings */][_DYN_PROCESS_TELEMETRY_ST0 /* @min:%2eprocessTelemetryStart */][identifier] = getTime();\r\n}\r\n/**\r\n * Returns a bitwise value for the FieldValueSanitizerType enum representing the decoded type of the passed value\r\n * @param value - The value to determine the type\r\n */\r\nexport function getFieldValueType(value) {\r\n var theType = 0 /* FieldValueSanitizerType.NotSet */;\r\n if (value !== null && value !== undefined) {\r\n var objType = typeof value;\r\n if (objType === \"string\") {\r\n theType = 1 /* FieldValueSanitizerType.String */;\r\n }\r\n else if (objType === \"number\") {\r\n theType = 2 /* FieldValueSanitizerType.Number */;\r\n }\r\n else if (objType === \"boolean\") {\r\n theType = 3 /* FieldValueSanitizerType.Boolean */;\r\n }\r\n else if (objType === strShimObject) {\r\n theType = 4 /* FieldValueSanitizerType.Object */;\r\n if (isArray(value)) {\r\n theType = 4096 /* FieldValueSanitizerType.Array */;\r\n if (value[_DYN_LENGTH /* @min:%2elength */] > 0) {\r\n // Empty arrays are not supported and are considered to be the same as null\r\n theType |= getFieldValueType(value[0]);\r\n }\r\n }\r\n else if (ObjHasOwnProperty.call(value, \"value\")) {\r\n // Looks like an IEventProperty\r\n theType = 8192 /* FieldValueSanitizerType.EventProperty */ | getFieldValueType(value[_DYN_VALUE /* @min:%2evalue */]);\r\n }\r\n }\r\n }\r\n return theType;\r\n}\r\n/**\r\n * Helper to identify whether we are running in a chromium based browser environment\r\n */\r\nexport function isChromium() {\r\n return !!getGlobalInst(\"chrome\");\r\n}\r\n/**\r\n * Create and open an XMLHttpRequest object\r\n * @param method - The request method\r\n * @param urlString - The url\r\n * @param withCredentials - Option flag indicating that credentials should be sent\r\n * @param disabled - Optional flag indicating that the XHR object should be marked as disabled and not tracked (default is false)\r\n * @param isSync - Optional flag indicating if the instance should be a synchronous request (defaults to false)\r\n * @param timeout - Optional value identifying the timeout value that should be assigned to the XHR request\r\n * @returns A new opened XHR request\r\n */\r\nexport function openXhr(method, urlString, withCredentials, disabled, isSync, timeout) {\r\n if (disabled === void 0) { disabled = false; }\r\n if (isSync === void 0) { isSync = false; }\r\n function _wrapSetXhrProp(xhr, prop, value) {\r\n try {\r\n xhr[prop] = value;\r\n }\r\n catch (e) {\r\n // - Wrapping as depending on the environment setting the property may fail (non-terminally)\r\n }\r\n }\r\n var xhr = new XMLHttpRequest();\r\n if (disabled) {\r\n // Tag the instance so it's not tracked (trackDependency)\r\n // If the environment has locked down the XMLHttpRequest (preventExtensions and/or freeze), this would\r\n // cause the request to fail and we no telemetry would be sent\r\n _wrapSetXhrProp(xhr, strDisabledPropertyName, disabled);\r\n }\r\n if (withCredentials) {\r\n // Some libraries require that the withCredentials flag is set \"before\" open and\r\n // - Wrapping as IE 10 has started throwing when setting before open\r\n _wrapSetXhrProp(xhr, strWithCredentials, withCredentials);\r\n }\r\n xhr.open(method, urlString, !isSync);\r\n if (withCredentials) {\r\n // withCredentials should be set AFTER open (https://xhr.spec.whatwg.org/#the-withcredentials-attribute)\r\n // And older firefox instances from 11+ will throw for sync events (current versions don't) which happens during unload processing\r\n _wrapSetXhrProp(xhr, strWithCredentials, withCredentials);\r\n }\r\n // Only set the timeout for asynchronous requests as\r\n // \"Timeout shouldn't be used for synchronous XMLHttpRequests requests used in a document environment or it will throw an InvalidAccessError exception.\"\"\r\n // https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/timeout\r\n if (!isSync && timeout) {\r\n _wrapSetXhrProp(xhr, strTimeout, timeout);\r\n }\r\n return xhr;\r\n}\r\n/**\r\n * Check to see if the value is \\> 0\r\n * @param value - The value to check\r\n * @returns true if \\> 0 otherwise false\r\n */\r\nexport function isGreaterThanZero(value) {\r\n return value > 0;\r\n}\r\n//# sourceMappingURL=Utils.js.map"],"names":[],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}