@microsoft/applicationinsights-core-js 3.0.7 → 3.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/browser/es5/applicationinsights-core-js.cjs.js +406 -324
  2. package/browser/es5/applicationinsights-core-js.cjs.js.map +1 -1
  3. package/browser/es5/applicationinsights-core-js.cjs.min.js +2 -2
  4. package/browser/es5/applicationinsights-core-js.cjs.min.js.map +1 -1
  5. package/browser/es5/applicationinsights-core-js.gbl.js +408 -326
  6. package/browser/es5/applicationinsights-core-js.gbl.js.map +1 -1
  7. package/browser/es5/applicationinsights-core-js.gbl.min.js +2 -2
  8. package/browser/es5/applicationinsights-core-js.gbl.min.js.map +1 -1
  9. package/browser/es5/applicationinsights-core-js.integrity.json +25 -25
  10. package/browser/es5/applicationinsights-core-js.js +408 -326
  11. package/browser/es5/applicationinsights-core-js.js.map +1 -1
  12. package/browser/es5/applicationinsights-core-js.min.js +2 -2
  13. package/browser/es5/applicationinsights-core-js.min.js.map +1 -1
  14. package/dist/es5/applicationinsights-core-js.js +406 -324
  15. package/dist/es5/applicationinsights-core-js.js.map +1 -1
  16. package/dist/es5/applicationinsights-core-js.min.js +2 -2
  17. package/dist/es5/applicationinsights-core-js.min.js.map +1 -1
  18. package/dist-es5/Config/ConfigDefaultHelpers.js +1 -1
  19. package/dist-es5/Config/ConfigDefaults.js +1 -1
  20. package/dist-es5/Config/DynamicConfig.js +2 -1
  21. package/dist-es5/Config/DynamicConfig.js.map +1 -1
  22. package/dist-es5/Config/DynamicProperty.js +1 -1
  23. package/dist-es5/Config/DynamicState.js +1 -1
  24. package/dist-es5/Config/DynamicSupport.js +1 -1
  25. package/dist-es5/Config/IConfigDefaults.js +1 -1
  26. package/dist-es5/Config/IDynamicConfigHandler.js +1 -1
  27. package/dist-es5/Config/IDynamicPropertyHandler.js +1 -1
  28. package/dist-es5/Config/IDynamicWatcher.js +1 -1
  29. package/dist-es5/Config/_IDynamicConfigHandlerState.js +1 -1
  30. package/dist-es5/JavaScriptSDK/AggregationError.js +1 -1
  31. package/dist-es5/JavaScriptSDK/AppInsightsCore.js +59 -44
  32. package/dist-es5/JavaScriptSDK/AppInsightsCore.js.map +1 -1
  33. package/dist-es5/JavaScriptSDK/AsyncUtils.js +1 -1
  34. package/dist-es5/JavaScriptSDK/BaseTelemetryPlugin.js +3 -3
  35. package/dist-es5/JavaScriptSDK/BaseTelemetryPlugin.js.map +1 -1
  36. package/dist-es5/JavaScriptSDK/Constants.js +1 -1
  37. package/dist-es5/JavaScriptSDK/CookieMgr.js +1 -1
  38. package/dist-es5/JavaScriptSDK/CoreUtils.js +1 -1
  39. package/dist-es5/JavaScriptSDK/DataCacheHelper.js +2 -2
  40. package/dist-es5/JavaScriptSDK/DataCacheHelper.js.map +1 -1
  41. package/dist-es5/JavaScriptSDK/DbgExtensionUtils.js +1 -1
  42. package/dist-es5/JavaScriptSDK/DiagnosticLogger.js +1 -1
  43. package/dist-es5/JavaScriptSDK/EnvUtils.js +1 -1
  44. package/dist-es5/JavaScriptSDK/EventHelpers.js +1 -1
  45. package/dist-es5/JavaScriptSDK/HelperFuncs.js +1 -1
  46. package/dist-es5/JavaScriptSDK/InstrumentHooks.js +1 -1
  47. package/dist-es5/JavaScriptSDK/InternalConstants.js +1 -1
  48. package/dist-es5/JavaScriptSDK/NotificationManager.js +38 -18
  49. package/dist-es5/JavaScriptSDK/NotificationManager.js.map +1 -1
  50. package/dist-es5/JavaScriptSDK/PerfManager.js +1 -1
  51. package/dist-es5/JavaScriptSDK/ProcessTelemetryContext.js +1 -1
  52. package/dist-es5/JavaScriptSDK/RandomHelper.js +1 -1
  53. package/dist-es5/JavaScriptSDK/TelemetryHelpers.js +1 -1
  54. package/dist-es5/JavaScriptSDK/TelemetryInitializerPlugin.js +1 -1
  55. package/dist-es5/JavaScriptSDK/UnloadHandlerContainer.js +1 -1
  56. package/dist-es5/JavaScriptSDK/UnloadHookContainer.js +20 -1
  57. package/dist-es5/JavaScriptSDK/UnloadHookContainer.js.map +1 -1
  58. package/dist-es5/JavaScriptSDK/W3cTraceParent.js +1 -1
  59. package/dist-es5/JavaScriptSDK.Enums/EnumHelperFuncs.js +1 -1
  60. package/dist-es5/JavaScriptSDK.Enums/EventsDiscardedReason.js +1 -1
  61. package/dist-es5/JavaScriptSDK.Enums/FeatureOptInEnums.js +1 -1
  62. package/dist-es5/JavaScriptSDK.Enums/LoggingEnums.js +1 -1
  63. package/dist-es5/JavaScriptSDK.Enums/SendRequestReason.js +1 -1
  64. package/dist-es5/JavaScriptSDK.Enums/TelemetryUnloadReason.js +1 -1
  65. package/dist-es5/JavaScriptSDK.Enums/TelemetryUpdateReason.js +1 -1
  66. package/dist-es5/JavaScriptSDK.Interfaces/IAppInsightsCore.js +1 -1
  67. package/dist-es5/JavaScriptSDK.Interfaces/IChannelControls.js +1 -1
  68. package/dist-es5/JavaScriptSDK.Interfaces/IChannelControlsHost.js +1 -1
  69. package/dist-es5/JavaScriptSDK.Interfaces/IConfiguration.js +1 -1
  70. package/dist-es5/JavaScriptSDK.Interfaces/ICookieMgr.js +1 -1
  71. package/dist-es5/JavaScriptSDK.Interfaces/IDbgExtension.js +1 -1
  72. package/dist-es5/JavaScriptSDK.Interfaces/IDiagnosticLogger.js +1 -1
  73. package/dist-es5/JavaScriptSDK.Interfaces/IDistributedTraceContext.js +1 -1
  74. package/dist-es5/JavaScriptSDK.Interfaces/IFeatureOptIn.js +1 -1
  75. package/dist-es5/JavaScriptSDK.Interfaces/IInstrumentHooks.js +1 -1
  76. package/dist-es5/JavaScriptSDK.Interfaces/INotificationListener.js +1 -1
  77. package/dist-es5/JavaScriptSDK.Interfaces/INotificationManager.js +1 -1
  78. package/dist-es5/JavaScriptSDK.Interfaces/IPerfEvent.js +1 -1
  79. package/dist-es5/JavaScriptSDK.Interfaces/IPerfManager.js +1 -1
  80. package/dist-es5/JavaScriptSDK.Interfaces/IProcessTelemetryContext.js +1 -1
  81. package/dist-es5/JavaScriptSDK.Interfaces/ITelemetryInitializers.js +1 -1
  82. package/dist-es5/JavaScriptSDK.Interfaces/ITelemetryItem.js +1 -1
  83. package/dist-es5/JavaScriptSDK.Interfaces/ITelemetryPlugin.js +1 -1
  84. package/dist-es5/JavaScriptSDK.Interfaces/ITelemetryPluginChain.js +1 -1
  85. package/dist-es5/JavaScriptSDK.Interfaces/ITelemetryUnloadState.js +1 -1
  86. package/dist-es5/JavaScriptSDK.Interfaces/ITelemetryUpdateState.js +1 -1
  87. package/dist-es5/JavaScriptSDK.Interfaces/ITraceParent.js +1 -1
  88. package/dist-es5/JavaScriptSDK.Interfaces/IUnloadHook.js +1 -1
  89. package/dist-es5/JavaScriptSDK.Interfaces/IUnloadableComponent.js +1 -1
  90. package/dist-es5/JavaScriptSDK.Interfaces/IXHROverride.js +1 -1
  91. package/dist-es5/__DynamicConstants.js +9 -9
  92. package/dist-es5/__DynamicConstants.js.map +1 -1
  93. package/dist-es5/applicationinsights-core-js.js +2 -2
  94. package/dist-es5/applicationinsights-core-js.js.map +1 -1
  95. package/package.json +78 -75
  96. package/types/applicationinsights-core-js.d.ts +60 -2
  97. package/types/applicationinsights-core-js.namespaced.d.ts +1287 -104
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Microsoft Application Insights Core Javascript SDK, 3.0.7
2
+ * Microsoft Application Insights Core Javascript SDK, 3.0.9
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  *
5
5
  * Microsoft Application Insights Team
@@ -7,59 +7,6 @@
7
7
  */
8
8
 
9
9
  declare namespace ApplicationInsights {
10
- import { arrForEach } from '@nevware21/ts-utils';
11
- import { arrIndexOf } from '@nevware21/ts-utils';
12
- import { arrMap } from '@nevware21/ts-utils';
13
- import { arrReduce } from '@nevware21/ts-utils';
14
- import { asString } from '@nevware21/ts-utils';
15
- import { utcNow as dateNow } from '@nevware21/ts-utils';
16
- import { objDeepFreeze as deepFreeze } from '@nevware21/ts-utils';
17
- import { dumpObj } from '@nevware21/ts-utils';
18
- import { EnumCls } from '@nevware21/ts-utils';
19
- import { getDocument } from '@nevware21/ts-utils';
20
- import { getGlobal } from '@microsoft/applicationinsights-shims';
21
- import { getInst as getGlobalInst } from '@nevware21/ts-utils';
22
- import { getHistory } from '@nevware21/ts-utils';
23
- import { getNavigator } from '@nevware21/ts-utils';
24
- import { getPerformance } from '@nevware21/ts-utils';
25
- import { getWindow } from '@nevware21/ts-utils';
26
- import { hasDocument } from '@nevware21/ts-utils';
27
- import { hasHistory } from '@nevware21/ts-utils';
28
- import { hasNavigator } from '@nevware21/ts-utils';
29
- import { objHasOwnProperty as hasOwnProperty } from '@nevware21/ts-utils';
30
- import { hasWindow } from '@nevware21/ts-utils';
31
- import { IPromise } from '@nevware21/ts-async';
32
- import { isArray } from '@nevware21/ts-utils';
33
- import { isBoolean } from '@nevware21/ts-utils';
34
- import { isDate } from '@nevware21/ts-utils';
35
- import { isError } from '@nevware21/ts-utils';
36
- import { isFunction } from '@nevware21/ts-utils';
37
- import { isNotTruthy } from '@nevware21/ts-utils';
38
- import { isNullOrUndefined } from '@nevware21/ts-utils';
39
- import { isNumber } from '@nevware21/ts-utils';
40
- import { isObject } from '@nevware21/ts-utils';
41
- import { isString } from '@nevware21/ts-utils';
42
- import { isSymbol } from '@nevware21/ts-utils';
43
- import { isTruthy } from '@nevware21/ts-utils';
44
- import { isTypeof } from '@nevware21/ts-utils';
45
- import { isUndefined } from '@nevware21/ts-utils';
46
- import { ITimerHandler } from '@nevware21/ts-utils';
47
- import { objDefineAccessors } from '@nevware21/ts-utils';
48
- import { objForEachKey } from '@nevware21/ts-utils';
49
- import { objFreeze } from '@nevware21/ts-utils';
50
- import { objKeys } from '@nevware21/ts-utils';
51
- import { objSeal } from '@nevware21/ts-utils';
52
- import { objToString } from '@nevware21/ts-utils';
53
- import { perfNow } from '@nevware21/ts-utils';
54
- import { strEndsWith } from '@nevware21/ts-utils';
55
- import { strShimFunction as strFunction } from '@microsoft/applicationinsights-shims';
56
- import { strShimObject as strObject } from '@microsoft/applicationinsights-shims';
57
- import { strShimPrototype as strPrototype } from '@microsoft/applicationinsights-shims';
58
- import { strStartsWith } from '@nevware21/ts-utils';
59
- import { strTrim } from '@nevware21/ts-utils';
60
- import { strShimUndefined as strUndefined } from '@microsoft/applicationinsights-shims';
61
- import { throwError } from '@nevware21/ts-utils';
62
-
63
10
  /**
64
11
  * Get all of the registered events on the target object, this is primarily used for testing cleanup but may also be used by
65
12
  * applications to remove their own events
@@ -284,11 +231,269 @@ declare namespace ApplicationInsights {
284
231
 
285
232
  function areCookiesSupported(logger?: IDiagnosticLogger): any;
286
233
 
287
-
288
-
289
-
290
-
291
-
234
+ /**
235
+ * Calls the provided `callbackFn` function once for each element in an array in ascending index order. It is not invoked for index properties
236
+ * that have been deleted or are uninitialized. And unlike the ES6 forEach() you CAN stop or break the iteration by returning -1 from the
237
+ * `callbackFn` function.
238
+ *
239
+ * The range (number of elements) processed by arrForEach() is set before the first call to the `callbackFn`. Any elements added beyond the range
240
+ * or elements which as assigned to indexes already processed will not be visited by the `callbackFn`.
241
+ * @group Array
242
+ * @group ArrayLike
243
+ * @typeParam T - Identifies the element type of the array
244
+ * @param theArray - The array or array like object of elements to be searched.
245
+ * @param callbackfn A `synchronous` function that accepts up to three arguments. arrForEach calls the callbackfn function one time for each element in the array.
246
+ * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, null or undefined
247
+ * the array will be used as the this value.
248
+ * @remarks
249
+ * arrForEach expects a `synchronous` function.
250
+ * arrForEach does not wait for promises. Make sure you are aware of the implications while using promises (or async functions) as forEach callback.
251
+ * @example
252
+ * ```ts
253
+ * const items = ['item1', 'item2', 'item3'];
254
+ * const copyItems = [];
255
+ *
256
+ * // before using for loop
257
+ * for (let i = 0; i < items.length; i++) {
258
+ * copyItems.push(items[i]);
259
+ * }
260
+ *
261
+ * // before using forEach()
262
+ * items.forEach((item) => {
263
+ * copyItems.push(item);
264
+ * });
265
+ *
266
+ * // after
267
+ * arrForEach(items, (item) => {
268
+ * copyItems.push(item);
269
+ * // May return -1 to abort the iteration
270
+ * });
271
+ *
272
+ * // Also supports input as an array like object
273
+ * const items = { length: 3, 0: 'item1', 1: 'item2', 2: 'item3' };
274
+ * ```
275
+ */
276
+ function arrForEach<T = any>(theArray: ArrayLike<T>, callbackfn: (value: T, index: number, array: T[]) => void | number, thisArg?: any): void;
277
+
278
+ /**
279
+ * The arrIndexOf() method returns the first index at which a given element can be found in the array,
280
+ * or -1 if it is not present.
281
+ * `arrIndexOf()` compares searchElement to elements of the Array using strict equality (the same
282
+ * method used by the === or triple-equals operator).
283
+ * @group Array
284
+ * @group ArrayLike
285
+ * @typeParam T - Identifies the type of array elements
286
+ * @param theArray - The array or array like object of elements to be searched.
287
+ * @param searchElement - The element to locate in the array.
288
+ * @param fromIndex - The index to start the search at. If the index is greater than or equal to
289
+ * the array's length, -1 is returned, which means the array will not be searched. If the provided
290
+ * index value is a negative number, it is taken as the offset from the end of the array.
291
+ * Note: if the provided index is negative, the array is still searched from front to back. If the
292
+ * provided index is 0, then the whole array will be searched. Default: 0 (entire array is searched).
293
+ * @return The first index of the element in the array; -1 if not found.
294
+ * @example
295
+ * ```ts
296
+ * const array = [2, 9, 9];
297
+ * arrIndexOf(array, 2); // 0
298
+ * arrIndexOf(array, 7); // -1
299
+ * arrIndexOf(array, 9, 2); // 2
300
+ * arrIndexOf(array, 2, -1); // -1
301
+ * arrIndexOf(array, 2, -3); // 0
302
+ *
303
+ * let indices: number[] = [];
304
+ * const array = ['a', 'b', 'a', 'c', 'a', 'd'];
305
+ * const element = 'a';
306
+ * let idx = arrIndexOf(array, element);
307
+ * while (idx !== -1) {
308
+ * indices.push(idx);
309
+ * idx = arrIndexOf(array, element, idx + 1);
310
+ * }
311
+ * console.log(indices);
312
+ * // [0, 2, 4]
313
+ *
314
+ * function updateVegetablesCollection (veggies, veggie) {
315
+ * if (arrIndexOf(veggies, veggie) === -1) {
316
+ * veggies.push(veggie);
317
+ * console.log('New veggies collection is : ' + veggies);
318
+ * } else {
319
+ * console.log(veggie + ' already exists in the veggies collection.');
320
+ * }
321
+ * }
322
+ *
323
+ * let veggies = ['potato', 'tomato', 'chillies', 'green-pepper'];
324
+ *
325
+ * updateVegetablesCollection(veggies, 'spinach');
326
+ * // New veggies collection is : potato,tomato,chillies,green-pepper,spinach
327
+ * updateVegetablesCollection(veggies, 'spinach');
328
+ * // spinach already exists in the veggies collection.
329
+ *
330
+ * // Array Like
331
+ * let arrayLike = {
332
+ * length: 3,
333
+ * 0: "potato",
334
+ * 1: "tomato",
335
+ * 2: "chillies",
336
+ * 3: "green-pepper" // Not checked as index is > length
337
+ * };
338
+ *
339
+ * arrIndexOf(arrayLike, "potato"); // 0
340
+ * arrIndexOf(arrayLike, "tomato"); // 1
341
+ * arrIndexOf(arrayLike, "chillies"); 2
342
+ * arrIndexOf(arrayLike, "green-pepper"); // -1
343
+ * ```
344
+ */
345
+ const arrIndexOf: <T>(theArray: ArrayLike<T>, searchElement: T, fromIndex?: number) => number;
346
+
347
+ /**
348
+ * The arrMap() method creates a new array populated with the results of calling a provided function on every
349
+ * element in the calling array.
350
+ *
351
+ * `arrMap` calls a provided callbackFn function once for each element in an array, in order, and constructs
352
+ * a new array from the results. callbackFn is invoked only for indexes of the array which have assigned
353
+ * values (including undefined).
354
+ *
355
+ * It is not called for missing elements of the array; that is:
356
+ * - indexes that have never been set;
357
+ * - indexes which have been deleted.
358
+ *
359
+ * @since 0.3.3
360
+ * @group Array
361
+ * @group ArrayLike
362
+ * @typeParam T - Identifies the type of the array elements
363
+ * @typeParam R - Identifies the type of the elements returned by the callback function, defaults to T.
364
+ * @param theArray - The array or array like object of elements to be searched.
365
+ * @param callbackFn - The function that is called for evetn element of `theArray`.
366
+ * @param thisArg - The value to use as the `this` when executing the `callbackFn`.
367
+ * @example
368
+ * ```ts
369
+ * const numbers = [1, 4, 9];
370
+ * const roots = arrMap(numbers, (num) => Math.sqrt(num));
371
+ *
372
+ * // roots is now [1, 2, 3]
373
+ * // numbers is still [1, 4, 9]
374
+ *
375
+ * const kvArray = [{ key: 1, value: 10 },
376
+ * { key: 2, value: 20 },
377
+ * { key: 3, value: 30 }];
378
+ *
379
+ * const reformattedArray = arrMap(kvArray, ({ key, value}) => ({ [key]: value }));
380
+ *
381
+ * // reformattedArray is now [{1: 10}, {2: 20}, {3: 30}],
382
+ *
383
+ * // kvArray is still:
384
+ * // [{key: 1, value: 10},
385
+ * // {key: 2, value: 20},
386
+ * // {key: 3, value: 30}]
387
+ *
388
+ * // Also supports Array Like objects with same output
389
+ * const kvArray = {
390
+ * length: 3,
391
+ * 0: { key: 1, value: 10 },
392
+ * 1: { key: 2, value: 20 },
393
+ * 2: { key: 3, value: 30 }
394
+ * };
395
+ * ```
396
+ */
397
+ const arrMap: <T, R = T>(theArray: ArrayLike<T>, callbackFn: ArrMapCallbackFn<T, R>, thisArg?: any) => R[];
398
+
399
+ /**
400
+ * Callback signature for {@link arrMap} that is called for every element of array. Each time callbackFn
401
+ * executes, the returned value is added to newArray.
402
+ *
403
+ * @since 0.3.3
404
+ * @group Array
405
+ * @group ArrayLike
406
+ * @typeParam T - Identifies the type of the array elements
407
+ * @typeParam R - Identifies the type of the elements returned by the callback function, defaults to T.
408
+ * @param value - The current element being processed in the array.
409
+ * @param index - The index of the current element being processed in the array.
410
+ * @param array - The array that the `map` function was called on.
411
+ */
412
+ type ArrMapCallbackFn<T, R = T> = (value: T, index?: number, array?: T[]) => R;
413
+
414
+ /**
415
+ * The arrReduce() method executes a user-supplied "reducer" callback function on each element of the array,
416
+ * in order, passing in the return value from the calculation on the preceding element. The final result of
417
+ * running the reducer across all elements of the array is a single value.
418
+ *
419
+ * The first time that the callback is run there is no "return value of the previous calculation". If supplied,
420
+ * an initial value may be used in its place. Otherwise the array element at index 0 is used as the initial
421
+ * value and iteration starts from the next element (index 1 instead of index 0).
422
+ * @group Array
423
+ * @group ArrayLike
424
+ * @typeParam T - Identifies the type of array elements
425
+ * @param theArray - The array or array like object of elements to be searched.
426
+ * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array.
427
+ * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.
428
+ * @returns The value that results from running the "reducer" callback function to completion over the entire array.
429
+ * @example
430
+ * ```ts
431
+ * const getMax = (a: number, b: number) => Math.max(a, b);
432
+ *
433
+ * // callback is invoked for each element in the array starting at index 0
434
+ * arrReduce([1, 100], getMax, 50); // 100
435
+ * arrReduce([ 50], getMax, 10); // 50
436
+ *
437
+ * // callback is invoked once for element at index 1
438
+ * arrReduce([1, 100], getMax); // 100
439
+ *
440
+ * // callback is not invoked
441
+ * arrReduce([ 50], getMax); // 50
442
+ * arrReduce([ ], getMax, 1); // 1
443
+ *
444
+ * arrReduce([ ], getMax); // throws TypeError
445
+ *
446
+ * // Also supports Array like objects
447
+ * arrReduce({ length: 2, 0: 1, 1: 100 }, getMax, 50); // 100
448
+ * arrReduce({ length: 1, 0: 50 }, getMax, 10); // 50
449
+ *
450
+ * // callback is invoked once for element at index 1
451
+ * arrReduce({ length: 2, 0: 1, 1: 100 }, getMax); // 100
452
+ *
453
+ * // callback is not invoked
454
+ * arrReduce({ length: 1, 0: 50 }, getMax); // 50
455
+ * arrReduce({ length: 0 }, getMax, 1); // 1
456
+ * ```
457
+ */
458
+ const arrReduce: <T, R = T>(theArray: ArrayLike<T>, callbackfn: ArrReduceCallbackFn<T, R>, initialValue?: T | R) => R;
459
+
460
+ /**
461
+ * The `reducer` function called for {@link arrReduce}.
462
+ * @group Array
463
+ * @group ArrayLike
464
+ * @typeParam T - Identifies the type of array elements
465
+ * @typeParam R - Identifies the type of the return array elements (defaults to T)
466
+ * @param previousValue - The value resulting from the previous call to callbackFn. On first call, initialValue if
467
+ * specified, otherwise the value of array[0].
468
+ * @param currentValue - The value of the current element. On first call, the value of array[0] if an initialValue
469
+ * was specified, otherwise the value of array[1].
470
+ * @param currentIndex - The index position of currentValue in the array. On first call, 0 if initialValue was
471
+ * specified, otherwise 1.
472
+ * @param array -The array being traversed.
473
+ */
474
+ type ArrReduceCallbackFn<T, R = T> = (previousValue: T | R, currentValue: T, currentIndex: number, array: T[]) => R;
475
+
476
+ /**
477
+ * The asString() method returns a string representing the value by
478
+ * explicitly using `String(`value`)`.
479
+ *
480
+ * @since 0.4.3
481
+ * @group String
482
+ * @group Conversion
483
+ * @group Value
484
+ * @param value - The value to get a string representation of
485
+ * @example
486
+ * ```ts
487
+ * const arr = [ 1, 2, 3];
488
+ * asString(arr); // "1,2,3"
489
+ * asString(null); // "null"
490
+ * asString(undefined); // "undefined"
491
+ * asString(42); // "42"
492
+ * asString(Symbol.for("Hello")); // "Symbol(Hello)"
493
+ * ```
494
+ */
495
+ const asString: (value: any) => string;
496
+
292
497
  /**
293
498
  * Binds the specified function to an event, so that the function gets called whenever the event fires on the object
294
499
  * @param obj - Object to add the event too.
@@ -594,8 +799,33 @@ declare namespace ApplicationInsights {
594
799
  [key in keyof E]: [E[keyof E], V[keyof V]];
595
800
  }) => V;
596
801
 
597
-
598
-
802
+ /**
803
+ * Return the number of milliseconds that have elapsed since January 1, 1970 00:00:00 UTC.
804
+ *
805
+ * To offer protection against timing attacks and fingerprinting, the precision of utcNow()
806
+ * might get rounded depending on browser settings. In Firefox, the privacy.reduceTimerPrecision
807
+ * preference is enabled by default and defaults to 20µs in Firefox 59; in 60 it will be 2ms.
808
+ *
809
+ * @since 0.4.4
810
+ * @group Timer
811
+ *
812
+ * @returns A Number representing the milliseconds elapsed since the UNIX epoch.
813
+ * @example
814
+ * ```ts
815
+ * let now = utcNow();
816
+ * ```
817
+ */
818
+ function dateNow(): number;
819
+
820
+ /**
821
+ * Perform a deep freeze on the object and all of it's contained values / properties by recursively calling
822
+ * `objFreeze()` on all enumerable properties of the object and on each property returned.
823
+ * @group Object
824
+ * @param value - the object to be completly frozen.
825
+ * @returns The originally passed in object.
826
+ */
827
+ function deepFreeze<T>(value: T): T;
828
+
599
829
  /**
600
830
  * Removes an event handler for the specified event
601
831
  * @param Object - to remove the event from
@@ -689,7 +919,62 @@ declare namespace ApplicationInsights {
689
919
  unload?: (isAsync?: boolean) => T | IPromise<T>;
690
920
  }>, isAsync?: boolean, done?: () => void): void | IPromise<void>;
691
921
 
692
-
922
+ /**
923
+ * Returns string representation of an object suitable for diagnostics logging.
924
+ * @group Error
925
+ * @group Diagnostic
926
+ * @param object - The object to be converted to a diagnostic string value
927
+ * @param format - Identifies whether the JSON value should be formated
928
+ * - `true` - Format with 4 spaces
929
+ * - 'number' - The number of spaces to format with
930
+ * - `false` (or not Truthy) - Do not format
931
+ * @returns A string representation of the object suitable for diagnostics logging
932
+ * @example
933
+ * ```ts
934
+ * let obj = { a: 1, b: "Hello", c: { d: 2, e: "Darkness" } };
935
+ *
936
+ * let objStr = dumpObj(obj);
937
+ * // objStr === "[object Object]: { a: 1, b: "Hello", c: { d: 2, e: "Darkness" } }"
938
+ *
939
+ * let objStrFmt = dumpObj(obj, true);
940
+ * // objStrFmt === "[object Object]: {\n a: 1,\n b: "Hello",\n c: {\n d: 2,\n e: "Darkness"\n }\n}"
941
+ *
942
+ * let objStrFmt2 = dumpObj(obj, 2);
943
+ * // objStrFmt2 === "[object Object]: {\n a: 1,\n b: "Hello",\n c: {\n d: 2,\n e: "Darkness"\n }\n}"
944
+ *
945
+ * let objStrFmt3 = dumpObj(obj, 0);
946
+ * // objStrFmt3 === "[object Object]: { a: 1, b: "Hello", c: { d: 2, e: "Darkness" } }"
947
+ *
948
+ * let objStrFmt4 = dumpObj(obj, false);
949
+ * // objStrFmt4 === "[object Object]: { a: 1, b: "Hello", c: { d: 2, e: "Darkness" } }"
950
+ *
951
+ * let objStrFmt5 = dumpObj(obj, null);
952
+ * // objStrFmt5 === "[object Object]: { a: 1, b: "Hello", c: { d: 2, e: "Darkness" } }"
953
+ *
954
+ * let objStrFmt6 = dumpObj(obj, undefined);
955
+ * // objStrFmt6 === "[object Object]: { a: 1, b: "Hello", c: { d: 2, e: "Darkness" } }"
956
+ *
957
+ * let objStrFmt7 = dumpObj(obj, "");
958
+ * // objStrFmt7 === "[object Object]: { a: 1, b: "Hello", c: { d: 2, e: "Darkness" } }"
959
+ *
960
+ * let err = new Error("Hello Darkness");
961
+ * let errStr = dumpObj(err);
962
+ * // errStr === "[object Error]: { stack: 'Error: Hello Darkness\n at <anonymous>:1:13', message: 'Hello Darkness', name: 'Error'"
963
+ *
964
+ * let errStrFmt = dumpObj(err, true);
965
+ * // errStrFmt === "[object Error]: {\n stack: "Error: Hello Darkness\n at <anonymous>:1:13",\n message: "Hello Darkness",\n name: "Error"\n}"
966
+ *
967
+ * let errStrFmt2 = dumpObj(err, 2);
968
+ * // errStrFmt2 === "[object Error]: {\n stack: "Error: Hello Darkness\n at <anonymous>:1:13",\n message: "Hello Darkness",\n name: "Error"\n}"
969
+ *
970
+ * let errStrFmt3 = dumpObj(err, 0);
971
+ * // errStrFmt3 === "[object Error]: { stack: "Error: Hello Darkness\n at <anonymous>:1:13", message: "Hello Darkness", name: "Error" }"
972
+ *
973
+ * ```
974
+ * @see {@link dumpObj}
975
+ */
976
+ function dumpObj(object: any, format?: boolean | number): string;
977
+
693
978
  /**
694
979
  * The eEventsDiscardedReason enumeration contains a set of values that specify the reason for discarding an event.
695
980
  */
@@ -769,6 +1054,7 @@ declare namespace ApplicationInsights {
769
1054
  InvalidDurationValue = 45,
770
1055
  TelemetryEnvelopeInvalid = 46,
771
1056
  CreateEnvelopeError = 47,
1057
+ MaxUnloadHookExceeded = 48,
772
1058
  CannotSerializeObject = 48,
773
1059
  CannotSerializeObjectNonSerializable = 49,
774
1060
  CircularReferenceDetected = 50,
@@ -831,6 +1117,19 @@ declare namespace ApplicationInsights {
831
1117
  DEBUG = 3
832
1118
  }
833
1119
 
1120
+ /**
1121
+ * A type that identifies an enum class generated from a constant enum.
1122
+ * @group Enum
1123
+ * @typeParam E - The constant enum type
1124
+ *
1125
+ * Returned from {@link createEnum}
1126
+ */
1127
+ type EnumCls<E = any> = {
1128
+ readonly [key in keyof E extends string | number | symbol ? keyof E : never]: key extends string ? E[key] : key;
1129
+ } & {
1130
+ readonly [key in keyof E]: E[key];
1131
+ };
1132
+
834
1133
  type EnumValue<E = any> = EnumCls<E>;
835
1134
 
836
1135
  /**
@@ -882,6 +1181,11 @@ declare namespace ApplicationInsights {
882
1181
  enable = 3
883
1182
  }
884
1183
 
1184
+ /**
1185
+ * This defines the handler function that is called via the finally when the promise is resolved or rejected
1186
+ */
1187
+ type FinallyPromiseHandler = (() => void) | undefined | null;
1188
+
885
1189
  /**
886
1190
  * Helper function to fetch the named meta-tag from the page.
887
1191
  * @param name
@@ -949,7 +1253,13 @@ declare namespace ApplicationInsights {
949
1253
 
950
1254
  function getDebugListener(config: IConfiguration): INotificationListener;
951
1255
 
952
-
1256
+ /**
1257
+ * Return the global `document` instance.
1258
+ * @group Environment
1259
+ * @returns
1260
+ */
1261
+ const getDocument: () => Document;
1262
+
953
1263
  /**
954
1264
  * @internal
955
1265
  * Get the dynamic config handler if the value is already dynamic
@@ -969,9 +1279,54 @@ declare namespace ApplicationInsights {
969
1279
  */
970
1280
  function getGblPerfMgr(): IPerfManager;
971
1281
 
972
-
973
-
974
-
1282
+ /**
1283
+ * Returns the current global scope object, for a normal web page this will be the current
1284
+ * window, for a Web Worker this will be current worker global scope via "self". The internal
1285
+ * implementation returns the first available instance object in the following order
1286
+ * - globalThis (New standard)
1287
+ * - self (Will return the current window instance for supported browsers)
1288
+ * - window (fallback for older browser implementations)
1289
+ * - global (NodeJS standard)
1290
+ * - <null> (When all else fails)
1291
+ * While the return type is a Window for the normal case, not all environments will support all
1292
+ * of the properties or functions. And this caches the lookup of the global as in some environments
1293
+ * this can be an expensive operation.
1294
+ * @group Environment
1295
+ * @param useCached - [Optional] used for testing to bypass the cached lookup, when `true` this will
1296
+ * cause the cached global to be reset.
1297
+ */
1298
+ function getGlobal(useCached?: boolean): Window;
1299
+
1300
+ /**
1301
+ * Return the named global object if available, will return null if the object is not available.
1302
+ * @group Environment
1303
+ * @param name The globally named object, may be any valid property key (string, number or symbol)
1304
+ * @param useCached - [Optional] used for testing to bypass the cached lookup, when `true` this will
1305
+ * cause the cached global to be reset.
1306
+ * @example
1307
+ * ```ts
1308
+ * // This does not cause the evaluation to occur
1309
+ * window.myGlobal = "Hello";
1310
+ * let cachedValue = getInst("myGlobal");
1311
+ * // cachedValue === "Hello"
1312
+ *
1313
+ * window.myGlobal = "Darkness";
1314
+ * // getInst("myGlobal") === "Darkness"
1315
+ *
1316
+ * let promiseCls = getInst("Promise");
1317
+ * // May throw if the global is not supported by the runtime
1318
+ * // otherwise the Promise class.
1319
+ * ```
1320
+ */
1321
+ function getGlobalInst<T>(name: string | number | symbol, useCached?: boolean): T | null;
1322
+
1323
+ /**
1324
+ * Returns the global `history` instance
1325
+ * @group Environment
1326
+ * @returns
1327
+ */
1328
+ const getHistory: () => History;
1329
+
975
1330
  /**
976
1331
  * Gets IE version returning the document emulation mode if we are running on IE, or null otherwise
977
1332
  */
@@ -998,8 +1353,25 @@ declare namespace ApplicationInsights {
998
1353
  */
999
1354
  function getMsCrypto(): Crypto | null;
1000
1355
 
1001
-
1002
-
1356
+ /**
1357
+ * Returns the global `navigator` instance
1358
+ * @group Environment
1359
+ * @returns
1360
+ */
1361
+ const getNavigator: () => Navigator;
1362
+
1363
+ /**
1364
+ * Returns the global `performance` Object if available, which can be used to
1365
+ * gather performance information about the current document. It serves as the
1366
+ * point of exposure for the Performance Timeline API, the High Resolution Time
1367
+ * API, the Navigation Timing API, the User Timing API, and the Resource Timing API.
1368
+ *
1369
+ * @since 0.4.4
1370
+ * @group Environment
1371
+ * @returns The global performance object if available.
1372
+ */
1373
+ function getPerformance(): Performance;
1374
+
1003
1375
  /**
1004
1376
  * Returns the current value from the target object if not null or undefined otherwise sets the new value and returns it
1005
1377
  * @param target - The target object to return or set the default value
@@ -1008,9 +1380,27 @@ declare namespace ApplicationInsights {
1008
1380
  */
1009
1381
  function getSetValue<T, K extends keyof T>(target: T, field: K, defValue?: T[K]): T[K];
1010
1382
 
1011
-
1012
-
1013
-
1383
+ /**
1384
+ * Return the global `window` instance.
1385
+ * @group Environment
1386
+ * @returns
1387
+ */
1388
+ const getWindow: () => Window;
1389
+
1390
+ /**
1391
+ * Identify whether the runtime contains a `document` object
1392
+ * @group Environment
1393
+ * @returns - True if a `document` exists
1394
+ */
1395
+ function hasDocument(): boolean;
1396
+
1397
+ /**
1398
+ * Identifies whether the runtime contains a `history` object
1399
+ * @group Environment
1400
+ * @returns
1401
+ */
1402
+ function hasHistory(): boolean;
1403
+
1014
1404
  /**
1015
1405
  * Checks if JSON object is available, this is required as we support the API running without a
1016
1406
  * window /document (eg. Node server, electron webworkers) and if we attempt to assign a history
@@ -1020,9 +1410,54 @@ declare namespace ApplicationInsights {
1020
1410
  */
1021
1411
  function hasJSON(): boolean;
1022
1412
 
1023
-
1024
-
1025
-
1413
+ /**
1414
+ * Identify whether the runtimne contains a `navigator` object
1415
+ * @group Environment
1416
+ * @returns
1417
+ */
1418
+ function hasNavigator(): boolean;
1419
+
1420
+ /**
1421
+ * The objHasOwnProperty() method returns a boolean indicating whether the object
1422
+ * has the specified property as its own property (as opposed to inheriting it).
1423
+ *
1424
+ * The objHasOwnProperty() method returns true if the specified property is a direct
1425
+ * property of the object — even if the value is null or undefined. The method returns
1426
+ * false if the property is inherited, or has not been declared at all. Unlike the in
1427
+ * operator, this method does not check for the specified property in the object's
1428
+ * prototype chain.
1429
+ *
1430
+ * The method can be called on most JavaScript objects, because most objects descend
1431
+ * from Object, and hence inherit its methods. For example Array is an Object, so you
1432
+ * can use objHasOwnProperty() method to check whether an index exists:
1433
+ * @group Object
1434
+ * @param obj - The object being evaluated
1435
+ * @param prop - The String or Symbol of the property to test
1436
+ * @returns `true` if the object has the specified property as own property; otherwise `false`
1437
+ * @example
1438
+ * ```ts
1439
+ * let example = {};
1440
+ * objHasOwnProperty(example, 'prop'); // false
1441
+ *
1442
+ * example.prop = 'exists';
1443
+ * objHasOwnProperty(example, 'prop'); // true - 'prop' has been defined
1444
+ *
1445
+ * example.prop = null;
1446
+ * objHasOwnProperty(example, 'prop'); // true - own property exists with value of null
1447
+ *
1448
+ * example.prop = undefined;
1449
+ * objHasOwnProperty(example, 'prop'); // true - own property exists with value of undefined
1450
+ * ```
1451
+ */
1452
+ function hasOwnProperty<T = any>(obj: T, prop: PropertyKey): boolean;
1453
+
1454
+ /**
1455
+ * Identify whether the runtime contains a `window` object
1456
+ * @group Environment
1457
+ * @returns
1458
+ */
1459
+ function hasWindow(): boolean;
1460
+
1026
1461
  interface IAppInsightsCore<CfgType extends IConfiguration = IConfiguration> extends IPerfManagerProvider {
1027
1462
  readonly config: CfgType;
1028
1463
  /**
@@ -2347,12 +2782,241 @@ declare namespace ApplicationInsights {
2347
2782
  createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryUpdateContext;
2348
2783
  }
2349
2784
 
2785
+ /**
2786
+ * Create a Promise object that represents the eventual completion (or failure) of an asynchronous operation and its resulting value.
2787
+ * This interface definition, closely mirrors the typescript / javascript PromiseLike<T> and Promise<T> definitions as well as providing
2788
+ * simular functions as that provided by jQuery deferred objects.
2789
+ *
2790
+ * The returned Promise is a proxy for a value not necessarily known when the promise is created. It allows you to associate handlers
2791
+ * with an asynchronous action's eventual success value or failure reason. This lets asynchronous methods return values like synchronous
2792
+ * methods: instead of immediately returning the final value, the asynchronous method returns a promise to supply the value at some point
2793
+ * in the future.
2794
+ *
2795
+ * A Promise is in one of these states:
2796
+ * <ul>
2797
+ * <li> pending: initial state, neither fulfilled nor rejected.
2798
+ * <li> fulfilled: meaning that the operation was completed successfully.
2799
+ * <li> rejected: meaning that the operation failed.
2800
+ * </ul>
2801
+ *
2802
+ * A pending promise can either be fulfilled with a value or rejected with a reason (error). When either of these options happens, the
2803
+ * associated handlers queued up by a promise's then method are called synchronously. If the promise has already been fulfilled or rejected
2804
+ * when a corresponding handler is attached, the handler will be called synchronously, so there is no race condition between an asynchronous
2805
+ * operation completing and its handlers being attached.
2806
+ *
2807
+ * As the `then()` and `catch()` methods return promises, they can be chained.
2808
+ * @typeParam T - Identifies the expected return type from the promise
2809
+ */
2810
+ interface IPromise<T> extends PromiseLike<T>, Promise<T> {
2811
+ /**
2812
+ * Returns a string representation of the current state of the promise. The promise can be in one of four states.
2813
+ * <ul>
2814
+ * <li> <b>"pending"</b>: The promise is not yet in a completed state (neither "rejected"; or "resolved").</li>
2815
+ * <li> <b>"resolved"</b>: The promise is in the resolved state.</li>
2816
+ * <li> <b>"rejected"</b>: The promise is in the rejected state.</li>
2817
+ * </ul>
2818
+ * @example
2819
+ * ```ts
2820
+ * let doResolve;
2821
+ * let promise: IPromise<any> = createSyncPromise((resolve) => {
2822
+ * doResolve = resolve;
2823
+ * });
2824
+ *
2825
+ * let state: string = promise.state();
2826
+ * console.log("State: " + state); // State: pending
2827
+ * doResolve(true); // Promise will resolve synchronously as it's a synchronous promise
2828
+ * console.log("State: " + state); // State: resolved
2829
+ * ```
2830
+ */
2831
+ state?: string;
2832
+ /**
2833
+ * Attaches callbacks for the resolution and/or rejection of the Promise.
2834
+ * @param onResolved The callback to execute when the Promise is resolved.
2835
+ * @param onRejected The callback to execute when the Promise is rejected.
2836
+ * @returns A Promise for the completion of which ever callback is executed.
2837
+ * @example
2838
+ * ```ts
2839
+ * const promise1 = createPromise((resolve, reject) => {
2840
+ * resolve('Success!');
2841
+ * });
2842
+ *
2843
+ * promise1.then((value) => {
2844
+ * console.log(value);
2845
+ * // expected output: "Success!"
2846
+ * });
2847
+ * ```
2848
+ */
2849
+ then<TResult1 = T, TResult2 = never>(onResolved?: ResolvedPromiseHandler<T, TResult1>, onRejected?: RejectedPromiseHandler<TResult2>): IPromise<TResult1 | TResult2>;
2850
+ /**
2851
+ * Attaches callbacks for the resolution and/or rejection of the Promise.
2852
+ * @param onResolved The callback to execute when the Promise is resolved.
2853
+ * @param onRejected The callback to execute when the Promise is rejected.
2854
+ * @returns A Promise for the completion of which ever callback is executed.
2855
+ * @example
2856
+ * ```ts
2857
+ * const promise1 = createPromise((resolve, reject) => {
2858
+ * resolve('Success!');
2859
+ * });
2860
+ *
2861
+ * promise1.then((value) => {
2862
+ * console.log(value);
2863
+ * // expected output: "Success!"
2864
+ * });
2865
+ * ```
2866
+ */
2867
+ then<TResult1 = T, TResult2 = never>(onResolved?: ResolvedPromiseHandler<T, TResult1>, onRejected?: RejectedPromiseHandler<TResult2>): PromiseLike<TResult1 | TResult2>;
2868
+ /**
2869
+ * Attaches callbacks for the resolution and/or rejection of the Promise.
2870
+ * @param onResolved The callback to execute when the Promise is resolved.
2871
+ * @param onRejected The callback to execute when the Promise is rejected.
2872
+ * @returns A Promise for the completion of which ever callback is executed.
2873
+ * @example
2874
+ * ```ts
2875
+ * const promise1 = createPromise((resolve, reject) => {
2876
+ * resolve('Success!');
2877
+ * });
2878
+ *
2879
+ * promise1.then((value) => {
2880
+ * console.log(value);
2881
+ * // expected output: "Success!"
2882
+ * });
2883
+ * ```
2884
+ */
2885
+ then<TResult1 = T, TResult2 = never>(onResolved?: ResolvedPromiseHandler<T, TResult1>, onRejected?: RejectedPromiseHandler<TResult2>): Promise<TResult1 | TResult2>;
2886
+ /**
2887
+ * Attaches a callback for only the rejection of the Promise.
2888
+ * @param onRejected The callback to execute when the Promise is rejected.
2889
+ * @returns A Promise for the completion of the callback.
2890
+ * @example
2891
+ * ```ts
2892
+ * const promise1 = createPromise((resolve, reject) => {
2893
+ * throw 'Uh-oh!';
2894
+ * });
2895
+ *
2896
+ * promise1.catch((error) => {
2897
+ * console.error(error);
2898
+ * });
2899
+ * // expected output: Uh-oh!
2900
+ * ```
2901
+ */
2902
+ catch<TResult = never>(onRejected?: ((reason: any) => TResult | IPromise<TResult>) | undefined | null): IPromise<T | TResult>;
2903
+ /**
2904
+ * Attaches a callback for only the rejection of the Promise.
2905
+ * @param onRejected The callback to execute when the Promise is rejected.
2906
+ * @returns A Promise for the completion of the callback.
2907
+ * @example
2908
+ * ```ts
2909
+ * const promise1 = createPromise((resolve, reject) => {
2910
+ * throw 'Uh-oh!';
2911
+ * });
2912
+ *
2913
+ * promise1.catch((error) => {
2914
+ * console.error(error);
2915
+ * });
2916
+ * // expected output: Uh-oh!
2917
+ * ```
2918
+ */
2919
+ catch<TResult = never>(onRejected?: ((reason: any) => TResult | IPromise<TResult>) | undefined | null): PromiseLike<T | TResult>;
2920
+ /**
2921
+ * Attaches a callback for only the rejection of the Promise.
2922
+ * @param onRejected The callback to execute when the Promise is rejected.
2923
+ * @returns A Promise for the completion of the callback.
2924
+ * @example
2925
+ * ```ts
2926
+ * const promise1 = createPromise((resolve, reject) => {
2927
+ * throw 'Uh-oh!';
2928
+ * });
2929
+ *
2930
+ * promise1.catch((error) => {
2931
+ * console.error(error);
2932
+ * });
2933
+ * // expected output: Uh-oh!
2934
+ * ```
2935
+ */
2936
+ catch<TResult = never>(onRejected?: ((reason: any) => TResult | IPromise<TResult>) | undefined | null): Promise<T | TResult>;
2937
+ /**
2938
+ * Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The
2939
+ * resolved value cannot be modified from the callback.
2940
+ * @param onfinally The callback to execute when the Promise is settled (fulfilled or rejected).
2941
+ * @returns A Promise for the completion of the callback.
2942
+ * @example
2943
+ * ```ts
2944
+ * function doFunction() {
2945
+ * return createPromise((resolve, reject) => {
2946
+ * if (Math.random() > 0.5) {
2947
+ * resolve('Function has completed');
2948
+ * } else {
2949
+ * reject(new Error('Function failed to process'));
2950
+ * }
2951
+ * });
2952
+ * }
2953
+ *
2954
+ * doFunction().then((data) => {
2955
+ * console.log(data);
2956
+ * }).catch((err) => {
2957
+ * console.error(err);
2958
+ * }).finally(() => {
2959
+ * console.log('Function processing completed');
2960
+ * });
2961
+ * ```
2962
+ */
2963
+ finally(onfinally?: FinallyPromiseHandler): IPromise<T>;
2964
+ /**
2965
+ * Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The
2966
+ * resolved value cannot be modified from the callback.
2967
+ * @param onfinally The callback to execute when the Promise is settled (fulfilled or rejected).
2968
+ * @returns A Promise for the completion of the callback.
2969
+ * @example
2970
+ * ```ts
2971
+ * function doFunction() {
2972
+ * return createPromise((resolve, reject) => {
2973
+ * if (Math.random() > 0.5) {
2974
+ * resolve('Function has completed');
2975
+ * } else {
2976
+ * reject(new Error('Function failed to process'));
2977
+ * }
2978
+ * });
2979
+ * }
2980
+ *
2981
+ * doFunction().then((data) => {
2982
+ * console.log(data);
2983
+ * }).catch((err) => {
2984
+ * console.error(err);
2985
+ * }).finally(() => {
2986
+ * console.log('Function processing completed');
2987
+ * });
2988
+ * ```
2989
+ */
2990
+ finally(onFinally?: FinallyPromiseHandler): Promise<T>;
2991
+ }
2992
+
2350
2993
  interface _IRegisteredEvents {
2351
2994
  name: string;
2352
2995
  handler: any;
2353
2996
  }
2354
2997
 
2355
-
2998
+ /**
2999
+ * Checks if the type of value is an Array.
3000
+ *
3001
+ * @group Type Identity
3002
+ * @group Array
3003
+ * @param {any} value - Value to be checked.
3004
+ * @return {boolean} True if the value is a Array, false otherwise.
3005
+ * @example
3006
+ * ```ts
3007
+ * import { isArray, isObject } from "@nevware21/ts-utils";
3008
+ *
3009
+ * function performAction(value: any) {
3010
+ * if (isArray(value) || isObject(value)) {
3011
+ * // Do something
3012
+ * } else {
3013
+ * // Do something else
3014
+ * }
3015
+ * }
3016
+ * ```
3017
+ */
3018
+ const isArray: <T = any>(arg: any) => arg is Array<T>;
3019
+
2356
3020
  /**
2357
3021
  * Checks if HTML5 Beacons are supported in the current environment.
2358
3022
  * @param useCached - [Optional] used for testing to bypass the cached lookup, when `true` this will
@@ -2361,9 +3025,41 @@ declare namespace ApplicationInsights {
2361
3025
  */
2362
3026
  function isBeaconsSupported(useCached?: boolean): boolean;
2363
3027
 
2364
-
2365
-
2366
-
3028
+ /**
3029
+ * Checks if the type of value is a boolean.
3030
+ * @group Type Identity
3031
+ * @param {any} value - Value to be checked.
3032
+ * @return {boolean} True if the value is a boolean, false otherwise.
3033
+ */
3034
+ const isBoolean: (value: any) => value is boolean;
3035
+
3036
+ /**
3037
+ * Check if an object is of type Date
3038
+ * @group Type Identity
3039
+ * @example
3040
+ * ```ts
3041
+ * import { isDate } from "@nevware21/ts-utils";
3042
+ *
3043
+ * let _theDate = null;
3044
+ *
3045
+ * function getSetDate(newDate?: any) {
3046
+ * _theDate = isDate(newDate) ? newDate : new Date();
3047
+ *
3048
+ * return _theDate;
3049
+ * }
3050
+ * ```
3051
+ */
3052
+ const isDate: (value: any) => value is Date;
3053
+
3054
+ /**
3055
+ * Checks if the type of value is a Error object.
3056
+ * @group Type Identity
3057
+ * @group Error
3058
+ * @param {any} value - Value to be checked.
3059
+ * @return {boolean} True if the value is a Error, false otherwise.
3060
+ */
3061
+ const isError: (value: any) => value is Error;
3062
+
2367
3063
  function isFeatureEnabled<T extends IConfiguration = IConfiguration>(feature?: string, cfg?: T): boolean;
2368
3064
 
2369
3065
  /**
@@ -2373,7 +3069,30 @@ declare namespace ApplicationInsights {
2373
3069
  */
2374
3070
  function isFetchSupported(withKeepAlive?: boolean): boolean;
2375
3071
 
2376
-
3072
+ /**
3073
+ * Checks to see if the past value is a function value
3074
+ * @group Type Identity
3075
+ * @param value - The value to check
3076
+ * @returns
3077
+ * @example
3078
+ * ```ts
3079
+ * function myFunction() { }
3080
+ * isFunction(null); // false
3081
+ * isFunction(undefined); // false
3082
+ * isFunction("null"); // false
3083
+ * isFunction("undefined"); // false
3084
+ * isFunction("1"); // false
3085
+ * isFunction("aa"); // false
3086
+ * isFunction(new Date()); // false
3087
+ * isFunction(1); // false
3088
+ * isFunction(""); // false
3089
+ * isFunction(myFunction); // true
3090
+ * isFunction([]); // false
3091
+ * isFunction(new Array(1)); // false
3092
+ * ```
3093
+ */
3094
+ const isFunction: (value: any) => value is Function;
3095
+
2377
3096
  /**
2378
3097
  * Identifies whether the current environment appears to be IE
2379
3098
  */
@@ -2381,12 +3100,61 @@ declare namespace ApplicationInsights {
2381
3100
 
2382
3101
  function isNotNullOrUndefined<T>(value: T): value is T;
2383
3102
 
2384
-
3103
+ /**
3104
+ * Checks if the type of value does not evaluate to true value, handling some special
3105
+ * case usages of Boolean(true/false) and new Boolean(true/false).
3106
+ * @group Value Check
3107
+ * @param {any} value - Value to be checked.
3108
+ * @return {boolean} True if the value is not truthy, false otherwise.
3109
+ */
3110
+ function isNotTruthy(value: any): boolean;
3111
+
2385
3112
  function isNotUndefined<T>(value: T): value is T;
2386
3113
 
2387
-
2388
-
2389
-
3114
+ /**
3115
+ * Checks if the provided value is null, undefined or contains the string value of "undefined".
3116
+ * @group Type Identity
3117
+ * @group Value Check
3118
+ * @param value - The value to check
3119
+ * @returns `true` if the value is `null` or `undefined`
3120
+ * @example
3121
+ * ```ts
3122
+ * isNullOrUndefined(null); // true
3123
+ * isNullOrUndefined(undefined); // true
3124
+ * isNullOrUndefined("undefined"); // true
3125
+ *
3126
+ * let value = null;
3127
+ * isNullOrUndefined(value); // true
3128
+ * let value = undefined;
3129
+ * isNullOrUndefined(value); // true
3130
+ *
3131
+ * isNullOrUndefined(""); // false
3132
+ * isNullOrUndefined(0); // false
3133
+ * isNullOrUndefined(new Date()); // false
3134
+ * isNullOrUndefined(true); // false
3135
+ * isNullOrUndefined(false); // false
3136
+ * ```
3137
+ */
3138
+ function isNullOrUndefined(value: any): boolean;
3139
+
3140
+ /**
3141
+ * Checks if the type of value is a number.
3142
+ * @group Type Identity
3143
+ * @param {any} value - Value to be checked.
3144
+ * @return {boolean} True if the value is a number, false otherwise.
3145
+ */
3146
+ const isNumber: (value: any) => value is number;
3147
+
3148
+ /**
3149
+ * Checks to see if the past value is an object value
3150
+ * @group Type Identity
3151
+ * @group Object
3152
+ * @typeParam T - The object type, defaults to any
3153
+ * @param value - The value to check
3154
+ * @returns
3155
+ */
3156
+ function isObject<T>(value: T): value is T;
3157
+
2390
3158
  /**
2391
3159
  * Returns whether the environment is reporting that we are running in a React Native Environment
2392
3160
  */
@@ -2401,11 +3169,103 @@ declare namespace ApplicationInsights {
2401
3169
  */
2402
3170
  function isSampledFlag(value: ITraceParent): boolean;
2403
3171
 
2404
-
2405
-
2406
-
2407
-
2408
-
3172
+ /**
3173
+ * Checks to see if the past value is a string value
3174
+ * @group Type Identity
3175
+ * @group String
3176
+ * @param value - The value to check
3177
+ * @returns
3178
+ * @example
3179
+ * ```ts
3180
+ * isString(""); // true
3181
+ * isString("null"); // true
3182
+ * isString("undefined"); // true
3183
+ * isString(String("")); // true
3184
+ *
3185
+ * isString(null); // false
3186
+ * isString(undefined); // false
3187
+ * isString(0); // false
3188
+ * ```
3189
+ */
3190
+ const isString: (value: any) => value is string;
3191
+
3192
+ /**
3193
+ * Checks if the type of value is a symbol.
3194
+ * @group Symbol
3195
+ * @param {any} value - Value to be checked.
3196
+ * @return {boolean} True if the value is a symbol, false otherwise.
3197
+ */
3198
+ const isSymbol: (value: any) => value is symbol;
3199
+
3200
+ /**
3201
+ * Checks if the type of value evaluates to true value, handling some special
3202
+ * case usages of Boolean(true/false) and new Boolean(true/false).
3203
+ * @group Value Check
3204
+ * @param {any} value - Value to be checked.
3205
+ * @return {boolean} True if the value is not truthy, false otherwise.
3206
+ */
3207
+ function isTruthy(value: any): boolean;
3208
+
3209
+ /**
3210
+ * Validate if the provided value object is of the expected type
3211
+ * @group Type Identity
3212
+ * @param value - The value to check
3213
+ * @param theType - The expected type name as a string
3214
+ * @returns `true` if the value matches the provided type
3215
+ */
3216
+ function isTypeof(value: any, theType: string): boolean;
3217
+
3218
+ /**
3219
+ * Checks if the provided value is undefined or contains the string value "undefined",
3220
+ * if you want to consider the string value as undefined see {@link isStrictUndefined}
3221
+ * @group Type Identity
3222
+ * @group Value Check
3223
+ * @param value - The value to check
3224
+ * @returns true if the value is undefined or "undefined", otherwise false
3225
+ * @example
3226
+ * ```ts
3227
+ * isUndefined(undefined); // true
3228
+ * isUndefined("undefined"); // true
3229
+ *
3230
+ * isUndefined(null); // false
3231
+ * isUndefined("null"); // false
3232
+ * isUndefined("1"); // false
3233
+ * isUndefined("aa"); // false
3234
+ * isUndefined(new Date()); // false
3235
+ * isUndefined(1); // false
3236
+ * isUndefined(""); // false
3237
+ * isUndefined(_dummyFunction); // false
3238
+ * isUndefined([]); // false
3239
+ * isUndefined(new Array(1)); // false
3240
+ * isUndefined(true); // false
3241
+ * isUndefined(false); // false
3242
+ * isUndefined("true"); // false
3243
+ * isUndefined("false"); // false
3244
+ * isUndefined(new Boolean(true)); // false
3245
+ * isUndefined(new Boolean(false)); // false
3246
+ * isUndefined(new Boolean("true")); // false
3247
+ * isUndefined(new Boolean("false")); // false
3248
+ * isUndefined(Boolean(true)); // false
3249
+ * isUndefined(Boolean(false)); // false
3250
+ * isUndefined(Boolean("true")); // false
3251
+ * isUndefined(Boolean("false")); // false
3252
+ * isUndefined(new RegExp("")); // false
3253
+ * isUndefined(new ArrayBuffer(0)); // false
3254
+ * isUndefined(new Error("Test Error"));// false
3255
+ * isUndefined(new TypeError("Test TypeError")); // false
3256
+ * isUndefined(new TestError("Test TestError")); // false
3257
+ * isUndefined(_dummyError()); // false
3258
+ * isUndefined(Promise.reject()); // false
3259
+ * isUndefined(Promise.resolve()); // false
3260
+ * isUndefined(new Promise(() => {})); // false
3261
+ * isUndefined(_simplePromise()); // false
3262
+ * isUndefined(_simplePromiseLike()); // false
3263
+ * isUndefined(Object.create(null)); // false
3264
+ * isUndefined(polyObjCreate(null)); // false
3265
+ * ```
3266
+ */
3267
+ function isUndefined(value: any): boolean;
3268
+
2409
3269
  /**
2410
3270
  * Is the provided W3c span id (aka. parent id) a valid string representation, it must be a 16-character
2411
3271
  * string of lowercase hexadecimal characters, for example, 00f067aa0ba902b7.
@@ -2590,6 +3450,120 @@ declare namespace ApplicationInsights {
2590
3450
  removed?: IPlugin[];
2591
3451
  }
2592
3452
 
3453
+ /**
3454
+ * A Timer handler which is returned from {@link scheduleTimeout} which contains functions to
3455
+ * cancel or restart (refresh) the timeout function.
3456
+ *
3457
+ * @since 0.4.4
3458
+ * @group Timer
3459
+ */
3460
+ interface ITimerHandler {
3461
+ /**
3462
+ * Cancels a timeout that was previously scheduled, after calling this function any previously
3463
+ * scheduled timer will not execute.
3464
+ * @example
3465
+ * ```ts
3466
+ * let theTimer = scheduleTimeout(...);
3467
+ * theTimer.cancel();
3468
+ * ```
3469
+ */
3470
+ cancel(): void;
3471
+ /**
3472
+ * Reschedules the timer to call its callback at the previously specified duration
3473
+ * adjusted to the current time. This is useful for refreshing a timer without allocating
3474
+ * a new JavaScript object.
3475
+ *
3476
+ * Using this on a timer that has already called its callback will reactivate the timer.
3477
+ * Calling on a timer that has not yet executed will just reschedule the current timer.
3478
+ * @example
3479
+ * ```ts
3480
+ * let theTimer = scheduleTimeout(...);
3481
+ * // The timer will be restarted (if already executed) or rescheduled (if it has not yet executed)
3482
+ * theTimer.refresh();
3483
+ * ```
3484
+ */
3485
+ refresh(): ITimerHandler;
3486
+ /**
3487
+ * When called, requests that the event loop not exit so long when the ITimerHandler is active.
3488
+ * Calling timer.ref() multiple times will have no effect. By default, all ITimerHandler objects
3489
+ * will create "ref'ed" instances, making it normally unnecessary to call timer.ref() unless
3490
+ * timer.unref() had been called previously.
3491
+ * @since 0.7.0
3492
+ * @returns the ITimerHandler instance
3493
+ * @example
3494
+ * ```ts
3495
+ * let theTimer = createTimeout(...);
3496
+ *
3497
+ * // Make sure the timer is referenced (the default) so that the runtime (Node) does not terminate
3498
+ * // if there is a waiting referenced timer.
3499
+ * theTimer.ref();
3500
+ * ```
3501
+ */
3502
+ ref(): this;
3503
+ /**
3504
+ * When called, the any active ITimerHandler instance will not require the event loop to remain
3505
+ * active (Node.js). If there is no other activity keeping the event loop running, the process may
3506
+ * exit before the ITimerHandler instance callback is invoked. Calling timer.unref() multiple times
3507
+ * will have no effect.
3508
+ * @since 0.7.0
3509
+ * @returns the ITimerHandler instance
3510
+ * @example
3511
+ * ```ts
3512
+ * let theTimer = createTimeout(...);
3513
+ *
3514
+ * // Unreference the timer so that the runtime (Node) may terminate if nothing else is running.
3515
+ * theTimer.unref();
3516
+ * ```
3517
+ */
3518
+ unref(): this;
3519
+ /**
3520
+ * If true, any running referenced `ITimerHandler` instance will keep the Node.js event loop active.
3521
+ * @since 0.7.0
3522
+ * @example
3523
+ * ```ts
3524
+ * let theTimer = createTimeout(...);
3525
+ *
3526
+ * // Unreference the timer so that the runtime (Node) may terminate if nothing else is running.
3527
+ * theTimer.unref();
3528
+ * let hasRef = theTimer.hasRef(); // false
3529
+ *
3530
+ * theTimer.ref();
3531
+ * hasRef = theTimer.hasRef(); // true
3532
+ * ```
3533
+ */
3534
+ hasRef(): boolean;
3535
+ /**
3536
+ * Gets or Sets a flag indicating if the underlying timer is currently enabled and running.
3537
+ * Setting the enabled flag to the same as it's current value has no effect, setting to `true`
3538
+ * when already `true` will not {@link ITimerHandler.refresh | refresh}() the timer.
3539
+ * And setting to 'false` will {@link ITimerHandler.cancel | cancel}() the timer.
3540
+ * @since 0.8.1
3541
+ * @example
3542
+ * ```ts
3543
+ * let theTimer = createTimeout(...);
3544
+ *
3545
+ * // Check if enabled
3546
+ * theTimer.enabled; // false
3547
+ *
3548
+ * // Start the timer
3549
+ * theTimer.enabled = true; // Same as calling refresh()
3550
+ * theTimer.enabled; //true
3551
+ *
3552
+ * // Has no effect as it's already running
3553
+ * theTimer.enabled = true;
3554
+ *
3555
+ * // Will refresh / restart the time
3556
+ * theTimer.refresh()
3557
+ *
3558
+ * let theTimer = scheduleTimeout(...);
3559
+ *
3560
+ * // Check if enabled
3561
+ * theTimer.enabled; // true
3562
+ * ```
3563
+ */
3564
+ enabled: boolean;
3565
+ }
3566
+
2593
3567
  /**
2594
3568
  * This interface represents the components of a W3C traceparent header
2595
3569
  */
@@ -2804,7 +3778,24 @@ declare namespace ApplicationInsights {
2804
3778
  unload?(isAsync?: boolean): void | IPromise<void>;
2805
3779
  }
2806
3780
 
2807
-
3781
+ /**
3782
+ * Try to define get/set object property accessors for the target object/prototype, this will provide compatibility with
3783
+ * existing API definition when run within an ES5+ container that supports accessors but still enable the code to be loaded
3784
+ * and executed in an ES3 container, providing basic IE8 compatibility.
3785
+ * @deprecated It is recommended that you use {@link objDefine} instead {@link objDefineAccessors} as this internally creates
3786
+ * the {@link ObjDefinePropDescriptor} definition based on your provided arguments. And only using a minimum set of functions
3787
+ * reduces your overall bundle size.
3788
+ * @group Object
3789
+ * @param target - The object on which to define the property.
3790
+ * @param prop - The name of the property to be defined or modified.
3791
+ * @param getProp - The getter function to wire against the getter.
3792
+ * @param setProp - The setter function to wire against the setter.
3793
+ * @param configurable - Can the value be changed, defaults to true
3794
+ * @param enumerable - Should this get property be enumerable, defaults to true.
3795
+ * @returns The object that was passed to the function
3796
+ */
3797
+ function objDefineAccessors<T, V = any>(target: T, prop: PropertyKey, getProp?: (() => V) | null, setProp?: ((v: V) => void) | null, configurable?: boolean, enumerable?: boolean): T;
3798
+
2808
3799
  /**
2809
3800
  * Pass in the objects to merge as arguments, this will only "merge" (extend) properties that are owned by the object.
2810
3801
  * It will NOT merge inherited or non-enumerable properties.
@@ -2819,11 +3810,125 @@ declare namespace ApplicationInsights {
2819
3810
 
2820
3811
  function objExtend<T1, T2, T3, T4, T5, T6>(obj1?: T1, obj2?: T2, obj3?: T3, obj4?: T4, obj5?: T5, obj6?: T6): T1 & T2 & T3 & T4 & T5 & T6;
2821
3812
 
2822
-
2823
-
2824
-
2825
-
2826
-
3813
+ /**
3814
+ * Calls the provided `callbackFn` function once for each key in an object. This is equivelent to `arrForEach(Object.keys(theObject), callbackFn)` or
3815
+ * if not using the array helper `Object.keys(theObject).forEach(callbackFn)` except that this helper avoid creating a temporary of the object
3816
+ * keys before iterating over them and like the `arrForEach` helper you CAN stop or break the iteration by returning -1 from the `callbackFn` function.
3817
+ * @group Object
3818
+ * @typeParam T - The object type
3819
+ * @param callbackfn A function that accepts up to two arguments, the key name and the current value of the property represented by the key.
3820
+ * @param thisArg [Optional] An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, null or undefined
3821
+ * the object will be used as the this value.
3822
+ * @example
3823
+ * ```ts
3824
+ * function performAction<T>(target: T, source: any) {
3825
+ * if (!isNullOrUndefined(source)) {
3826
+ * objForEachKey(source, (key, value) => {
3827
+ * // Set the target with a reference to the same value with the same name
3828
+ * target[key] = value;
3829
+ * });
3830
+ * }
3831
+ *
3832
+ * return target;
3833
+ * }
3834
+ * ```
3835
+ */
3836
+ function objForEachKey<T>(theObject: T, callbackfn: (key: string, value: T[keyof T]) => void | number, thisArg?: any): void;
3837
+
3838
+ /**
3839
+ * The `objFreeze()` method freezes an object. A frozen object can no longer be changed; freezing an object
3840
+ * prevents new properties from being added to it, existing properties from being removed, prevents changing the
3841
+ * enumerability, configurability, or writability of existing properties, and prevents the values of existing
3842
+ * properties from being changed. In addition, freezing an object also prevents its prototype from being changed.
3843
+ * `objFreeze()` returns the same object that was passed in.
3844
+ *
3845
+ * Nothing can be added to or removed from the properties set of a frozen object. Any attempt to do so will fail,
3846
+ * either silently or by throwing a TypeError exception (most commonly, but not exclusively, when in strict mode).
3847
+ *
3848
+ * For data properties of a frozen object, values cannot be changed, the writable and configurable attributes are
3849
+ * set to false. Accessor properties (getters and setters) work the same (and still give the illusion that you are
3850
+ * changing the value). Note that values that are objects can still be modified, unless they are also frozen. As
3851
+ * an object, an array can be frozen; after doing so, its elements cannot be altered and no elements can be added
3852
+ * to or removed from the array.
3853
+ *
3854
+ * `objFreeze()` returns the same object that was passed into the function. It does not create a frozen copy.
3855
+ * @group Object
3856
+ * @param value - The object to freeze.
3857
+ * @returns The object that was passed to the function.
3858
+ */
3859
+ const objFreeze: <T>(value: T) => T;
3860
+
3861
+ /**
3862
+ * The `objKeys()` method returns an array of a given object's own enumerable property names, iterated in
3863
+ * the same order that a normal loop would.
3864
+ *
3865
+ * objKeys() returns an array whose elements are strings corresponding to the enumerable properties found
3866
+ * directly upon object. The ordering of the properties is the same as that given by looping over the
3867
+ * properties of the object manually.
3868
+ * @group Object
3869
+ * @param value - The object to obtain a copy of the keys from
3870
+ * @returns An array of the properties names for the value object.
3871
+ * @example
3872
+ * ```ts
3873
+ * // simple array
3874
+ * const arr = ['a', 'b', 'c'];
3875
+ * console.log(objKeys(arr)); // console: ['0', '1', '2']
3876
+ *
3877
+ * // array-like object
3878
+ * const obj = { 0: 'a', 1: 'b', 2: 'c' };
3879
+ * console.log(objKeys(obj)); // console: ['0', '1', '2']
3880
+ *
3881
+ * // array-like object with random key ordering
3882
+ * const anObj = { 100: 'a', 2: 'b', 7: 'c' };
3883
+ * console.log(objKeys(anObj)); // console: ['2', '7', '100']
3884
+ *
3885
+ * // getFoo is a property which isn't enumerable
3886
+ * const myObj = objCreate({}, {
3887
+ * getFoo: {
3888
+ * value() { return this.foo; }
3889
+ * }
3890
+ * });
3891
+ * myObj.foo = 1;
3892
+ * console.log(objKeys(myObj)); // console: ['foo']
3893
+ * ```
3894
+ */
3895
+ const objKeys: (value: any) => string[];
3896
+
3897
+ /**
3898
+ * The `objSeal()` method seals an object, preventing new properties from being added to it and marking all
3899
+ * existing properties as non-configurable. Values of present properties can still be changed as long as they
3900
+ * are writable.
3901
+ * @group Object
3902
+ * @param value - The object which should be sealed.
3903
+ * @returns The object being sealed.
3904
+ */
3905
+ const objSeal: <T>(value: T) => T;
3906
+
3907
+ /**
3908
+ * The `objToString()` method returns a string representing the object. This explicitly
3909
+ * always calls the `Object.prototype.toString()` method.
3910
+ *
3911
+ * An object's toString() method is most commonly invoked when that object undergoes:
3912
+ * - explicit type conversion to a string (for example, String(myObject))
3913
+ * - implicit type coercion into a string (for example, myObject + "hello world")
3914
+ *
3915
+ * @group Object
3916
+ * @param value - The object to be converted into a string
3917
+ * @returns A string representation of the object
3918
+ * @example
3919
+ * ```ts
3920
+ * objToString(new Date()); // [object Date]
3921
+ * objToString(new String()); // [object String]
3922
+ *
3923
+ * // Math has its Symbol.toStringTag
3924
+ * objToString(Math); // [object Math]
3925
+ *
3926
+ * objToString(undefined); // [object Undefined]
3927
+ * objToString(null); // [object Null]
3928
+ * ```
3929
+ */
3930
+ function objToString(value: any): string;
3931
+
2827
3932
  type OnCompleteCallback = (status: number, headers: {
2828
3933
  [headerName: string]: string;
2829
3934
  }, response?: string) => void;
@@ -2930,7 +4035,23 @@ declare namespace ApplicationInsights {
2930
4035
  getCtx(key: string): any;
2931
4036
  }
2932
4037
 
2933
-
4038
+ /**
4039
+ * Returns the number of milliseconds that has elapsed since the time origin, if
4040
+ * the runtime does not support the `performance` API it will fallback to return
4041
+ * the number of milliseconds since the unix epoch.
4042
+ *
4043
+ * @since 0.4.4
4044
+ * @group Timer
4045
+ *
4046
+ * @returns The number of milliseconds as a `DOMHighResTimeStamp` double value or
4047
+ * an integer depending on the runtime.
4048
+ * @example
4049
+ * ```ts
4050
+ * let now = perfNow();
4051
+ * ```
4052
+ */
4053
+ function perfNow(): number;
4054
+
2934
4055
  /**
2935
4056
  * This class will be removed!
2936
4057
  * @deprecated use createProcessTelemetryContext() instead
@@ -3050,6 +4171,13 @@ declare namespace ApplicationInsights {
3050
4171
  */
3051
4172
  function randomValue(maxValue: number): number;
3052
4173
 
4174
+ /**
4175
+ * This defines the handler function for when a promise is rejected.
4176
+ * @param value This is the value passed as part of resolving the Promise
4177
+ * @return This may return a value, another Promise or void. @see {@link IPromise.then} for how the value is handled.
4178
+ */
4179
+ type RejectedPromiseHandler<T = never> = (((reason: any) => T | IPromise<T> | PromiseLike<T>) | undefined | null);
4180
+
3053
4181
  /**
3054
4182
  * Trys to remove event handler(s) for the specified event/namespace to the window, body and document
3055
4183
  * @param eventName - {string} - The name of the event, with optional namespaces or just the namespaces,
@@ -3096,6 +4224,13 @@ declare namespace ApplicationInsights {
3096
4224
  */
3097
4225
  function removePageUnloadEventListener(listener: any, evtNamespace?: string | string[]): void;
3098
4226
 
4227
+ /**
4228
+ * This defines the handler function for when a promise is resolved.
4229
+ * @param value This is the value passed as part of resolving the Promise
4230
+ * @return This may return a value, another Promise or void. @see {@link IPromise.then} for how the value is handled.
4231
+ */
4232
+ type ResolvedPromiseHandler<T, TResult1 = T> = (((value: T) => TResult1 | IPromise<TResult1> | PromiseLike<TResult1>) | undefined | null);
4233
+
3099
4234
  /**
3100
4235
  * Run the unload function of the target object if it exists
3101
4236
  * @param target - The target object that contains the unload function
@@ -3208,13 +4343,48 @@ declare namespace ApplicationInsights {
3208
4343
  */
3209
4344
  function strContains(value: string, search: string): boolean;
3210
4345
 
3211
-
3212
-
3213
-
3214
-
3215
-
3216
-
3217
-
4346
+ /**
4347
+ * This method lets you determine whether or not a string ends with another string. This method is case-sensitive.
4348
+ * @group String
4349
+ * @param value - The value to be checked
4350
+ * @param searchString - The characters to be searched for at the end of `value` string.
4351
+ * @param length - If provided, it is used as the length of `value`. Defaults to value.length.
4352
+ */
4353
+ const strEndsWith: (value: string, searchString: string, length?: number) => boolean;
4354
+
4355
+ const strFunction = "function";
4356
+
4357
+ const strObject = "object";
4358
+
4359
+ const strPrototype = "prototype";
4360
+
4361
+ /**
4362
+ * This method lets you determine whether or not a string begins with another string. This method is case-sensitive.
4363
+ * @group String
4364
+ * @param value - The value to be checked
4365
+ * @param searchString - The characters to be searched for at the start of the string
4366
+ * @param position - [Optional] The position in this string at which to begin searching for `searchString`.
4367
+ * Defaults to 0
4368
+ * @returns `true` if the given characters are found at the beginning of the string; otherwise, `false`.
4369
+ */
4370
+ const strStartsWith: (value: string, searchString: string, length?: number) => boolean;
4371
+
4372
+ /**
4373
+ * The trim() method removes whitespace from both ends of a string and returns a new string,
4374
+ * without modifying the original string. Whitespace in this context is all the whitespace
4375
+ * characters (space, tab, no-break space, etc.) and all the line terminator characters
4376
+ * (LF, CR, etc.).
4377
+ * @group String
4378
+ * @param value - The string value to be trimmed.
4379
+ * @returns A new string representing str stripped of whitespace from both its beginning and end.
4380
+ * If neither the beginning or end of str has any whitespace, a new string is still returned (essentially
4381
+ * a copy of str), with no exception being thrown.
4382
+ * To return a new string with whitespace trimmed from just one end, use `strTrimStart()` or `strTrimEnd()`.
4383
+ */
4384
+ const strTrim: (value: string) => string;
4385
+
4386
+ const strUndefined = "undefined";
4387
+
3218
4388
  interface Tags {
3219
4389
  [key: string]: any;
3220
4390
  }
@@ -3265,6 +4435,14 @@ declare namespace ApplicationInsights {
3265
4435
  PluginRemoved = 32
3266
4436
  }
3267
4437
 
4438
+ /**
4439
+ * Test hook for setting the maximum number of unload hooks and calling a monitor function when the hooks are added or removed
4440
+ * This allows for automatic test failure when the maximum number of unload hooks is exceeded
4441
+ * @param maxHooks - The maximum number of unload hooks
4442
+ * @param addMonitor - The monitor function to call when hooks are added or removed
4443
+ */
4444
+ function _testHookMaxUnloadHooksCb(maxHooks?: number, addMonitor?: (state: string, hooks: Array<ILegacyUnloadHook | IUnloadHook>) => void): void;
4445
+
3268
4446
  /**
3269
4447
  * Throws an Aggregation Error which includes all of the errors that led to this error occurring
3270
4448
  * @param message - The message describing the aggregation error (the sourceError details are added to this)
@@ -3272,7 +4450,13 @@ declare namespace ApplicationInsights {
3272
4450
  */
3273
4451
  function throwAggregationError(message: string, sourceErrors: any[]): never;
3274
4452
 
3275
-
4453
+ /**
4454
+ * Throw an error exception with the specified optional message
4455
+ * @group Error
4456
+ * @param message
4457
+ */
4458
+ function throwError(message?: string): never;
4459
+
3276
4460
  /**
3277
4461
  * This is a helper method which will call throwInternal on the passed logger, will throw exceptions in
3278
4462
  * debug mode or attempt to log the error as a console warning. This helper is provided mostly to better
@@ -3336,5 +4520,4 @@ declare namespace ApplicationInsights {
3336
4520
 
3337
4521
  type WatcherFunction<T = IConfiguration> = (details: IWatchDetails<T>) => void;
3338
4522
 
3339
-
3340
4523
  }