@microsoft/applicationinsights-core-js 3.1.0-nightly3.2402-09 → 3.1.0-nightly3.2402-12

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 (89) hide show
  1. package/browser/es5/applicationinsights-core-js.cjs.js +1 -1
  2. package/browser/es5/applicationinsights-core-js.cjs.js.map +1 -1
  3. package/browser/es5/applicationinsights-core-js.cjs.min.js +1 -1
  4. package/browser/es5/applicationinsights-core-js.cjs.min.js.map +1 -1
  5. package/browser/es5/applicationinsights-core-js.gbl.js +3 -3
  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 +3 -3
  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 +1 -1
  15. package/dist/es5/applicationinsights-core-js.js.map +1 -1
  16. package/dist/es5/applicationinsights-core-js.min.js +1 -1
  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 +1 -1
  21. package/dist-es5/Config/DynamicProperty.js +1 -1
  22. package/dist-es5/Config/DynamicState.js +1 -1
  23. package/dist-es5/Config/DynamicSupport.js +1 -1
  24. package/dist-es5/Config/IConfigDefaults.js +1 -1
  25. package/dist-es5/Config/IDynamicConfigHandler.js +1 -1
  26. package/dist-es5/Config/IDynamicPropertyHandler.js +1 -1
  27. package/dist-es5/Config/IDynamicWatcher.js +1 -1
  28. package/dist-es5/Config/_IDynamicConfigHandlerState.js +1 -1
  29. package/dist-es5/JavaScriptSDK/AggregationError.js +1 -1
  30. package/dist-es5/JavaScriptSDK/AppInsightsCore.js +1 -1
  31. package/dist-es5/JavaScriptSDK/AsyncUtils.js +1 -1
  32. package/dist-es5/JavaScriptSDK/BaseTelemetryPlugin.js +1 -1
  33. package/dist-es5/JavaScriptSDK/Constants.js +1 -1
  34. package/dist-es5/JavaScriptSDK/CookieMgr.js +1 -1
  35. package/dist-es5/JavaScriptSDK/CoreUtils.js +1 -1
  36. package/dist-es5/JavaScriptSDK/DataCacheHelper.js +1 -1
  37. package/dist-es5/JavaScriptSDK/DbgExtensionUtils.js +1 -1
  38. package/dist-es5/JavaScriptSDK/DiagnosticLogger.js +1 -1
  39. package/dist-es5/JavaScriptSDK/EnvUtils.js +1 -1
  40. package/dist-es5/JavaScriptSDK/EventHelpers.js +1 -1
  41. package/dist-es5/JavaScriptSDK/HelperFuncs.js +1 -1
  42. package/dist-es5/JavaScriptSDK/InstrumentHooks.js +1 -1
  43. package/dist-es5/JavaScriptSDK/InternalConstants.js +1 -1
  44. package/dist-es5/JavaScriptSDK/NotificationManager.js +1 -1
  45. package/dist-es5/JavaScriptSDK/PerfManager.js +1 -1
  46. package/dist-es5/JavaScriptSDK/ProcessTelemetryContext.js +1 -1
  47. package/dist-es5/JavaScriptSDK/RandomHelper.js +1 -1
  48. package/dist-es5/JavaScriptSDK/TelemetryHelpers.js +1 -1
  49. package/dist-es5/JavaScriptSDK/TelemetryInitializerPlugin.js +1 -1
  50. package/dist-es5/JavaScriptSDK/UnloadHandlerContainer.js +1 -1
  51. package/dist-es5/JavaScriptSDK/UnloadHookContainer.js +1 -1
  52. package/dist-es5/JavaScriptSDK/W3cTraceParent.js +1 -1
  53. package/dist-es5/JavaScriptSDK.Enums/EnumHelperFuncs.js +1 -1
  54. package/dist-es5/JavaScriptSDK.Enums/EventsDiscardedReason.js +1 -1
  55. package/dist-es5/JavaScriptSDK.Enums/FeatureOptInEnums.js +1 -1
  56. package/dist-es5/JavaScriptSDK.Enums/LoggingEnums.js +1 -1
  57. package/dist-es5/JavaScriptSDK.Enums/SendRequestReason.js +1 -1
  58. package/dist-es5/JavaScriptSDK.Enums/TelemetryUnloadReason.js +1 -1
  59. package/dist-es5/JavaScriptSDK.Enums/TelemetryUpdateReason.js +1 -1
  60. package/dist-es5/JavaScriptSDK.Interfaces/IAppInsightsCore.js +1 -1
  61. package/dist-es5/JavaScriptSDK.Interfaces/IChannelControls.js +1 -1
  62. package/dist-es5/JavaScriptSDK.Interfaces/IChannelControlsHost.js +1 -1
  63. package/dist-es5/JavaScriptSDK.Interfaces/IConfiguration.js +1 -1
  64. package/dist-es5/JavaScriptSDK.Interfaces/ICookieMgr.js +1 -1
  65. package/dist-es5/JavaScriptSDK.Interfaces/IDbgExtension.js +1 -1
  66. package/dist-es5/JavaScriptSDK.Interfaces/IDiagnosticLogger.js +1 -1
  67. package/dist-es5/JavaScriptSDK.Interfaces/IDistributedTraceContext.js +1 -1
  68. package/dist-es5/JavaScriptSDK.Interfaces/IFeatureOptIn.js +1 -1
  69. package/dist-es5/JavaScriptSDK.Interfaces/IInstrumentHooks.js +1 -1
  70. package/dist-es5/JavaScriptSDK.Interfaces/INotificationListener.js +1 -1
  71. package/dist-es5/JavaScriptSDK.Interfaces/INotificationManager.js +1 -1
  72. package/dist-es5/JavaScriptSDK.Interfaces/IPerfEvent.js +1 -1
  73. package/dist-es5/JavaScriptSDK.Interfaces/IPerfManager.js +1 -1
  74. package/dist-es5/JavaScriptSDK.Interfaces/IProcessTelemetryContext.js +1 -1
  75. package/dist-es5/JavaScriptSDK.Interfaces/ITelemetryInitializers.js +1 -1
  76. package/dist-es5/JavaScriptSDK.Interfaces/ITelemetryItem.js +1 -1
  77. package/dist-es5/JavaScriptSDK.Interfaces/ITelemetryPlugin.js +1 -1
  78. package/dist-es5/JavaScriptSDK.Interfaces/ITelemetryPluginChain.js +1 -1
  79. package/dist-es5/JavaScriptSDK.Interfaces/ITelemetryUnloadState.js +1 -1
  80. package/dist-es5/JavaScriptSDK.Interfaces/ITelemetryUpdateState.js +1 -1
  81. package/dist-es5/JavaScriptSDK.Interfaces/ITraceParent.js +1 -1
  82. package/dist-es5/JavaScriptSDK.Interfaces/IUnloadHook.js +1 -1
  83. package/dist-es5/JavaScriptSDK.Interfaces/IUnloadableComponent.js +1 -1
  84. package/dist-es5/JavaScriptSDK.Interfaces/IXHROverride.js +1 -1
  85. package/dist-es5/__DynamicConstants.js +1 -1
  86. package/dist-es5/applicationinsights-core-js.js +1 -1
  87. package/package.json +3 -3
  88. package/types/applicationinsights-core-js.d.ts +52 -3
  89. package/types/applicationinsights-core-js.namespaced.d.ts +1279 -105
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Microsoft Application Insights Core Javascript SDK, 3.1.0-nightly3.2402-09
2
+ * Microsoft Application Insights Core Javascript SDK, 3.1.0-nightly3.2402-12
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
  */
@@ -831,6 +1116,19 @@ declare namespace ApplicationInsights {
831
1116
  DEBUG = 3
832
1117
  }
833
1118
 
1119
+ /**
1120
+ * A type that identifies an enum class generated from a constant enum.
1121
+ * @group Enum
1122
+ * @typeParam E - The constant enum type
1123
+ *
1124
+ * Returned from {@link createEnum}
1125
+ */
1126
+ type EnumCls<E = any> = {
1127
+ readonly [key in keyof E extends string | number | symbol ? keyof E : never]: key extends string ? E[key] : key;
1128
+ } & {
1129
+ readonly [key in keyof E]: E[key];
1130
+ };
1131
+
834
1132
  type EnumValue<E = any> = EnumCls<E>;
835
1133
 
836
1134
  /**
@@ -882,6 +1180,11 @@ declare namespace ApplicationInsights {
882
1180
  enable = 3
883
1181
  }
884
1182
 
1183
+ /**
1184
+ * This defines the handler function that is called via the finally when the promise is resolved or rejected
1185
+ */
1186
+ type FinallyPromiseHandler = (() => void) | undefined | null;
1187
+
885
1188
  /**
886
1189
  * Helper function to fetch the named meta-tag from the page.
887
1190
  * @param name
@@ -949,7 +1252,13 @@ declare namespace ApplicationInsights {
949
1252
 
950
1253
  function getDebugListener(config: IConfiguration): INotificationListener;
951
1254
 
952
-
1255
+ /**
1256
+ * Return the global `document` instance.
1257
+ * @group Environment
1258
+ * @returns
1259
+ */
1260
+ function getDocument(): Document;
1261
+
953
1262
  /**
954
1263
  * @internal
955
1264
  * Get the dynamic config handler if the value is already dynamic
@@ -969,9 +1278,54 @@ declare namespace ApplicationInsights {
969
1278
  */
970
1279
  function getGblPerfMgr(): IPerfManager;
971
1280
 
972
-
973
-
974
-
1281
+ /**
1282
+ * Returns the current global scope object, for a normal web page this will be the current
1283
+ * window, for a Web Worker this will be current worker global scope via "self". The internal
1284
+ * implementation returns the first available instance object in the following order
1285
+ * - globalThis (New standard)
1286
+ * - self (Will return the current window instance for supported browsers)
1287
+ * - window (fallback for older browser implementations)
1288
+ * - global (NodeJS standard)
1289
+ * - <null> (When all else fails)
1290
+ * While the return type is a Window for the normal case, not all environments will support all
1291
+ * of the properties or functions. And this caches the lookup of the global as in some environments
1292
+ * this can be an expensive operation.
1293
+ * @group Environment
1294
+ * @param useCached - [Optional] used for testing to bypass the cached lookup, when `true` this will
1295
+ * cause the cached global to be reset.
1296
+ */
1297
+ function getGlobal(useCached?: boolean): Window;
1298
+
1299
+ /**
1300
+ * Return the named global object if available, will return null if the object is not available.
1301
+ * @group Environment
1302
+ * @param name The globally named object, may be any valid property key (string, number or symbol)
1303
+ * @param useCached - [Optional] used for testing to bypass the cached lookup, when `true` this will
1304
+ * cause the cached global to be reset.
1305
+ * @example
1306
+ * ```ts
1307
+ * // This does not cause the evaluation to occur
1308
+ * window.myGlobal = "Hello";
1309
+ * let cachedValue = getInst("myGlobal");
1310
+ * // cachedValue === "Hello"
1311
+ *
1312
+ * window.myGlobal = "Darkness";
1313
+ * // getInst("myGlobal") === "Darkness"
1314
+ *
1315
+ * let promiseCls = getInst("Promise");
1316
+ * // May throw if the global is not supported by the runtime
1317
+ * // otherwise the Promise class.
1318
+ * ```
1319
+ */
1320
+ function getGlobalInst<T>(name: string | number | symbol, useCached?: boolean): T | null;
1321
+
1322
+ /**
1323
+ * Returns the global `history` instance
1324
+ * @group Environment
1325
+ * @returns
1326
+ */
1327
+ function getHistory(): History | null;
1328
+
975
1329
  /**
976
1330
  * Gets IE version returning the document emulation mode if we are running on IE, or null otherwise
977
1331
  */
@@ -998,8 +1352,25 @@ declare namespace ApplicationInsights {
998
1352
  */
999
1353
  function getMsCrypto(): Crypto | null;
1000
1354
 
1001
-
1002
-
1355
+ /**
1356
+ * Returns the global `navigator` instance
1357
+ * @group Environment
1358
+ * @returns
1359
+ */
1360
+ function getNavigator(): Navigator;
1361
+
1362
+ /**
1363
+ * Returns the global `performance` Object if available, which can be used to
1364
+ * gather performance information about the current document. It serves as the
1365
+ * point of exposure for the Performance Timeline API, the High Resolution Time
1366
+ * API, the Navigation Timing API, the User Timing API, and the Resource Timing API.
1367
+ *
1368
+ * @since 0.4.4
1369
+ * @group Environment
1370
+ * @returns The global performance object if available.
1371
+ */
1372
+ function getPerformance(): Performance;
1373
+
1003
1374
  /**
1004
1375
  * Returns the current value from the target object if not null or undefined otherwise sets the new value and returns it
1005
1376
  * @param target - The target object to return or set the default value
@@ -1008,9 +1379,27 @@ declare namespace ApplicationInsights {
1008
1379
  */
1009
1380
  function getSetValue<T, K extends keyof T>(target: T, field: K, defValue?: T[K]): T[K];
1010
1381
 
1011
-
1012
-
1013
-
1382
+ /**
1383
+ * Return the global `window` instance.
1384
+ * @group Environment
1385
+ * @returns
1386
+ */
1387
+ function getWindow(): Window;
1388
+
1389
+ /**
1390
+ * Identify whether the runtime contains a `document` object
1391
+ * @group Environment
1392
+ * @returns - True if a `document` exists
1393
+ */
1394
+ function hasDocument(): boolean;
1395
+
1396
+ /**
1397
+ * Identifies whether the runtime contains a `history` object
1398
+ * @group Environment
1399
+ * @returns
1400
+ */
1401
+ function hasHistory(): boolean;
1402
+
1014
1403
  /**
1015
1404
  * Checks if JSON object is available, this is required as we support the API running without a
1016
1405
  * window /document (eg. Node server, electron webworkers) and if we attempt to assign a history
@@ -1020,9 +1409,54 @@ declare namespace ApplicationInsights {
1020
1409
  */
1021
1410
  function hasJSON(): boolean;
1022
1411
 
1023
-
1024
-
1025
-
1412
+ /**
1413
+ * Identify whether the runtimne contains a `navigator` object
1414
+ * @group Environment
1415
+ * @returns
1416
+ */
1417
+ function hasNavigator(): boolean;
1418
+
1419
+ /**
1420
+ * The objHasOwnProperty() method returns a boolean indicating whether the object
1421
+ * has the specified property as its own property (as opposed to inheriting it).
1422
+ *
1423
+ * The objHasOwnProperty() method returns true if the specified property is a direct
1424
+ * property of the object — even if the value is null or undefined. The method returns
1425
+ * false if the property is inherited, or has not been declared at all. Unlike the in
1426
+ * operator, this method does not check for the specified property in the object's
1427
+ * prototype chain.
1428
+ *
1429
+ * The method can be called on most JavaScript objects, because most objects descend
1430
+ * from Object, and hence inherit its methods. For example Array is an Object, so you
1431
+ * can use objHasOwnProperty() method to check whether an index exists:
1432
+ * @group Object
1433
+ * @param obj - The object being evaluated
1434
+ * @param prop - The String or Symbol of the property to test
1435
+ * @returns `true` if the object has the specified property as own property; otherwise `false`
1436
+ * @example
1437
+ * ```ts
1438
+ * let example = {};
1439
+ * objHasOwnProperty(example, 'prop'); // false
1440
+ *
1441
+ * example.prop = 'exists';
1442
+ * objHasOwnProperty(example, 'prop'); // true - 'prop' has been defined
1443
+ *
1444
+ * example.prop = null;
1445
+ * objHasOwnProperty(example, 'prop'); // true - own property exists with value of null
1446
+ *
1447
+ * example.prop = undefined;
1448
+ * objHasOwnProperty(example, 'prop'); // true - own property exists with value of undefined
1449
+ * ```
1450
+ */
1451
+ function hasOwnProperty<T = any>(obj: T, prop: PropertyKey): boolean;
1452
+
1453
+ /**
1454
+ * Identify whether the runtime contains a `window` object
1455
+ * @group Environment
1456
+ * @returns
1457
+ */
1458
+ function hasWindow(): boolean;
1459
+
1026
1460
  interface IAppInsightsCore<CfgType extends IConfiguration = IConfiguration> extends IPerfManagerProvider {
1027
1461
  readonly config: CfgType;
1028
1462
  /**
@@ -2388,12 +2822,241 @@ declare namespace ApplicationInsights {
2388
2822
  createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryUpdateContext;
2389
2823
  }
2390
2824
 
2825
+ /**
2826
+ * Create a Promise object that represents the eventual completion (or failure) of an asynchronous operation and its resulting value.
2827
+ * This interface definition, closely mirrors the typescript / javascript PromiseLike<T> and Promise<T> definitions as well as providing
2828
+ * simular functions as that provided by jQuery deferred objects.
2829
+ *
2830
+ * The returned Promise is a proxy for a value not necessarily known when the promise is created. It allows you to associate handlers
2831
+ * with an asynchronous action's eventual success value or failure reason. This lets asynchronous methods return values like synchronous
2832
+ * methods: instead of immediately returning the final value, the asynchronous method returns a promise to supply the value at some point
2833
+ * in the future.
2834
+ *
2835
+ * A Promise is in one of these states:
2836
+ * <ul>
2837
+ * <li> pending: initial state, neither fulfilled nor rejected.
2838
+ * <li> fulfilled: meaning that the operation was completed successfully.
2839
+ * <li> rejected: meaning that the operation failed.
2840
+ * </ul>
2841
+ *
2842
+ * A pending promise can either be fulfilled with a value or rejected with a reason (error). When either of these options happens, the
2843
+ * associated handlers queued up by a promise's then method are called synchronously. If the promise has already been fulfilled or rejected
2844
+ * when a corresponding handler is attached, the handler will be called synchronously, so there is no race condition between an asynchronous
2845
+ * operation completing and its handlers being attached.
2846
+ *
2847
+ * As the `then()` and `catch()` methods return promises, they can be chained.
2848
+ * @typeParam T - Identifies the expected return type from the promise
2849
+ */
2850
+ interface IPromise<T> extends PromiseLike<T>, Promise<T> {
2851
+ /**
2852
+ * Returns a string representation of the current state of the promise. The promise can be in one of four states.
2853
+ * <ul>
2854
+ * <li> <b>"pending"</b>: The promise is not yet in a completed state (neither "rejected"; or "resolved").</li>
2855
+ * <li> <b>"resolved"</b>: The promise is in the resolved state.</li>
2856
+ * <li> <b>"rejected"</b>: The promise is in the rejected state.</li>
2857
+ * </ul>
2858
+ * @example
2859
+ * ```ts
2860
+ * let doResolve;
2861
+ * let promise: IPromise<any> = createSyncPromise((resolve) => {
2862
+ * doResolve = resolve;
2863
+ * });
2864
+ *
2865
+ * let state: string = promise.state();
2866
+ * console.log("State: " + state); // State: pending
2867
+ * doResolve(true); // Promise will resolve synchronously as it's a synchronous promise
2868
+ * console.log("State: " + state); // State: resolved
2869
+ * ```
2870
+ */
2871
+ state?: string;
2872
+ /**
2873
+ * Attaches callbacks for the resolution and/or rejection of the Promise.
2874
+ * @param onResolved The callback to execute when the Promise is resolved.
2875
+ * @param onRejected The callback to execute when the Promise is rejected.
2876
+ * @returns A Promise for the completion of which ever callback is executed.
2877
+ * @example
2878
+ * ```ts
2879
+ * const promise1 = createPromise((resolve, reject) => {
2880
+ * resolve('Success!');
2881
+ * });
2882
+ *
2883
+ * promise1.then((value) => {
2884
+ * console.log(value);
2885
+ * // expected output: "Success!"
2886
+ * });
2887
+ * ```
2888
+ */
2889
+ then<TResult1 = T, TResult2 = never>(onResolved?: ResolvedPromiseHandler<T, TResult1>, onRejected?: RejectedPromiseHandler<TResult2>): IPromise<TResult1 | TResult2>;
2890
+ /**
2891
+ * Attaches callbacks for the resolution and/or rejection of the Promise.
2892
+ * @param onResolved The callback to execute when the Promise is resolved.
2893
+ * @param onRejected The callback to execute when the Promise is rejected.
2894
+ * @returns A Promise for the completion of which ever callback is executed.
2895
+ * @example
2896
+ * ```ts
2897
+ * const promise1 = createPromise((resolve, reject) => {
2898
+ * resolve('Success!');
2899
+ * });
2900
+ *
2901
+ * promise1.then((value) => {
2902
+ * console.log(value);
2903
+ * // expected output: "Success!"
2904
+ * });
2905
+ * ```
2906
+ */
2907
+ then<TResult1 = T, TResult2 = never>(onResolved?: ResolvedPromiseHandler<T, TResult1>, onRejected?: RejectedPromiseHandler<TResult2>): PromiseLike<TResult1 | TResult2>;
2908
+ /**
2909
+ * Attaches callbacks for the resolution and/or rejection of the Promise.
2910
+ * @param onResolved The callback to execute when the Promise is resolved.
2911
+ * @param onRejected The callback to execute when the Promise is rejected.
2912
+ * @returns A Promise for the completion of which ever callback is executed.
2913
+ * @example
2914
+ * ```ts
2915
+ * const promise1 = createPromise((resolve, reject) => {
2916
+ * resolve('Success!');
2917
+ * });
2918
+ *
2919
+ * promise1.then((value) => {
2920
+ * console.log(value);
2921
+ * // expected output: "Success!"
2922
+ * });
2923
+ * ```
2924
+ */
2925
+ then<TResult1 = T, TResult2 = never>(onResolved?: ResolvedPromiseHandler<T, TResult1>, onRejected?: RejectedPromiseHandler<TResult2>): Promise<TResult1 | TResult2>;
2926
+ /**
2927
+ * Attaches a callback for only the rejection of the Promise.
2928
+ * @param onRejected The callback to execute when the Promise is rejected.
2929
+ * @returns A Promise for the completion of the callback.
2930
+ * @example
2931
+ * ```ts
2932
+ * const promise1 = createPromise((resolve, reject) => {
2933
+ * throw 'Uh-oh!';
2934
+ * });
2935
+ *
2936
+ * promise1.catch((error) => {
2937
+ * console.error(error);
2938
+ * });
2939
+ * // expected output: Uh-oh!
2940
+ * ```
2941
+ */
2942
+ catch<TResult = never>(onRejected?: ((reason: any) => TResult | IPromise<TResult>) | undefined | null): IPromise<T | TResult>;
2943
+ /**
2944
+ * Attaches a callback for only the rejection of the Promise.
2945
+ * @param onRejected The callback to execute when the Promise is rejected.
2946
+ * @returns A Promise for the completion of the callback.
2947
+ * @example
2948
+ * ```ts
2949
+ * const promise1 = createPromise((resolve, reject) => {
2950
+ * throw 'Uh-oh!';
2951
+ * });
2952
+ *
2953
+ * promise1.catch((error) => {
2954
+ * console.error(error);
2955
+ * });
2956
+ * // expected output: Uh-oh!
2957
+ * ```
2958
+ */
2959
+ catch<TResult = never>(onRejected?: ((reason: any) => TResult | IPromise<TResult>) | undefined | null): PromiseLike<T | TResult>;
2960
+ /**
2961
+ * Attaches a callback for only the rejection of the Promise.
2962
+ * @param onRejected The callback to execute when the Promise is rejected.
2963
+ * @returns A Promise for the completion of the callback.
2964
+ * @example
2965
+ * ```ts
2966
+ * const promise1 = createPromise((resolve, reject) => {
2967
+ * throw 'Uh-oh!';
2968
+ * });
2969
+ *
2970
+ * promise1.catch((error) => {
2971
+ * console.error(error);
2972
+ * });
2973
+ * // expected output: Uh-oh!
2974
+ * ```
2975
+ */
2976
+ catch<TResult = never>(onRejected?: ((reason: any) => TResult | IPromise<TResult>) | undefined | null): Promise<T | TResult>;
2977
+ /**
2978
+ * Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The
2979
+ * resolved value cannot be modified from the callback.
2980
+ * @param onfinally The callback to execute when the Promise is settled (fulfilled or rejected).
2981
+ * @returns A Promise for the completion of the callback.
2982
+ * @example
2983
+ * ```ts
2984
+ * function doFunction() {
2985
+ * return createPromise((resolve, reject) => {
2986
+ * if (Math.random() > 0.5) {
2987
+ * resolve('Function has completed');
2988
+ * } else {
2989
+ * reject(new Error('Function failed to process'));
2990
+ * }
2991
+ * });
2992
+ * }
2993
+ *
2994
+ * doFunction().then((data) => {
2995
+ * console.log(data);
2996
+ * }).catch((err) => {
2997
+ * console.error(err);
2998
+ * }).finally(() => {
2999
+ * console.log('Function processing completed');
3000
+ * });
3001
+ * ```
3002
+ */
3003
+ finally(onfinally?: FinallyPromiseHandler): IPromise<T>;
3004
+ /**
3005
+ * Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The
3006
+ * resolved value cannot be modified from the callback.
3007
+ * @param onfinally The callback to execute when the Promise is settled (fulfilled or rejected).
3008
+ * @returns A Promise for the completion of the callback.
3009
+ * @example
3010
+ * ```ts
3011
+ * function doFunction() {
3012
+ * return createPromise((resolve, reject) => {
3013
+ * if (Math.random() > 0.5) {
3014
+ * resolve('Function has completed');
3015
+ * } else {
3016
+ * reject(new Error('Function failed to process'));
3017
+ * }
3018
+ * });
3019
+ * }
3020
+ *
3021
+ * doFunction().then((data) => {
3022
+ * console.log(data);
3023
+ * }).catch((err) => {
3024
+ * console.error(err);
3025
+ * }).finally(() => {
3026
+ * console.log('Function processing completed');
3027
+ * });
3028
+ * ```
3029
+ */
3030
+ finally(onFinally?: FinallyPromiseHandler): Promise<T>;
3031
+ }
3032
+
2391
3033
  interface _IRegisteredEvents {
2392
3034
  name: string;
2393
3035
  handler: any;
2394
3036
  }
2395
3037
 
2396
-
3038
+ /**
3039
+ * Checks if the type of value is an Array.
3040
+ *
3041
+ * @group Type Identity
3042
+ * @group Array
3043
+ * @param {any} value - Value to be checked.
3044
+ * @return {boolean} True if the value is a Array, false otherwise.
3045
+ * @example
3046
+ * ```ts
3047
+ * import { isArray, isObject } from "@nevware21/ts-utils";
3048
+ *
3049
+ * function performAction(value: any) {
3050
+ * if (isArray(value) || isObject(value)) {
3051
+ * // Do something
3052
+ * } else {
3053
+ * // Do something else
3054
+ * }
3055
+ * }
3056
+ * ```
3057
+ */
3058
+ const isArray: <T = any>(arg: any) => arg is Array<T>;
3059
+
2397
3060
  /**
2398
3061
  * Checks if HTML5 Beacons are supported in the current environment.
2399
3062
  * @param useCached - [Optional] used for testing to bypass the cached lookup, when `true` this will
@@ -2402,9 +3065,41 @@ declare namespace ApplicationInsights {
2402
3065
  */
2403
3066
  function isBeaconsSupported(useCached?: boolean): boolean;
2404
3067
 
2405
-
2406
-
2407
-
3068
+ /**
3069
+ * Checks if the type of value is a boolean.
3070
+ * @group Type Identity
3071
+ * @param {any} value - Value to be checked.
3072
+ * @return {boolean} True if the value is a boolean, false otherwise.
3073
+ */
3074
+ const isBoolean: (value: any) => value is boolean;
3075
+
3076
+ /**
3077
+ * Check if an object is of type Date
3078
+ * @group Type Identity
3079
+ * @example
3080
+ * ```ts
3081
+ * import { isDate } from "@nevware21/ts-utils";
3082
+ *
3083
+ * let _theDate = null;
3084
+ *
3085
+ * function getSetDate(newDate?: any) {
3086
+ * _theDate = isDate(newDate) ? newDate : new Date();
3087
+ *
3088
+ * return _theDate;
3089
+ * }
3090
+ * ```
3091
+ */
3092
+ const isDate: (value: any) => value is Date;
3093
+
3094
+ /**
3095
+ * Checks if the type of value is a Error object.
3096
+ * @group Type Identity
3097
+ * @group Error
3098
+ * @param {any} value - Value to be checked.
3099
+ * @return {boolean} True if the value is a Error, false otherwise.
3100
+ */
3101
+ const isError: (value: any) => value is Error;
3102
+
2408
3103
  function isFeatureEnabled<T extends IConfiguration = IConfiguration>(feature?: string, cfg?: T): boolean;
2409
3104
 
2410
3105
  /**
@@ -2414,7 +3109,30 @@ declare namespace ApplicationInsights {
2414
3109
  */
2415
3110
  function isFetchSupported(withKeepAlive?: boolean): boolean;
2416
3111
 
2417
-
3112
+ /**
3113
+ * Checks to see if the past value is a function value
3114
+ * @group Type Identity
3115
+ * @param value - The value to check
3116
+ * @returns
3117
+ * @example
3118
+ * ```ts
3119
+ * function myFunction() { }
3120
+ * isFunction(null); // false
3121
+ * isFunction(undefined); // false
3122
+ * isFunction("null"); // false
3123
+ * isFunction("undefined"); // false
3124
+ * isFunction("1"); // false
3125
+ * isFunction("aa"); // false
3126
+ * isFunction(new Date()); // false
3127
+ * isFunction(1); // false
3128
+ * isFunction(""); // false
3129
+ * isFunction(myFunction); // true
3130
+ * isFunction([]); // false
3131
+ * isFunction(new Array(1)); // false
3132
+ * ```
3133
+ */
3134
+ const isFunction: (value: any) => value is Function;
3135
+
2418
3136
  /**
2419
3137
  * Identifies whether the current environment appears to be IE
2420
3138
  */
@@ -2422,12 +3140,61 @@ declare namespace ApplicationInsights {
2422
3140
 
2423
3141
  function isNotNullOrUndefined<T>(value: T): value is T;
2424
3142
 
2425
-
3143
+ /**
3144
+ * Checks if the type of value does not evaluate to true value, handling some special
3145
+ * case usages of Boolean(true/false) and new Boolean(true/false).
3146
+ * @group Value Check
3147
+ * @param {any} value - Value to be checked.
3148
+ * @return {boolean} True if the value is not truthy, false otherwise.
3149
+ */
3150
+ function isNotTruthy(value: any): boolean;
3151
+
2426
3152
  function isNotUndefined<T>(value: T): value is T;
2427
3153
 
2428
-
2429
-
2430
-
3154
+ /**
3155
+ * Checks if the provided value is null, undefined or contains the string value of "undefined".
3156
+ * @group Type Identity
3157
+ * @group Value Check
3158
+ * @param value - The value to check
3159
+ * @returns `true` if the value is `null` or `undefined`
3160
+ * @example
3161
+ * ```ts
3162
+ * isNullOrUndefined(null); // true
3163
+ * isNullOrUndefined(undefined); // true
3164
+ * isNullOrUndefined("undefined"); // true
3165
+ *
3166
+ * let value = null;
3167
+ * isNullOrUndefined(value); // true
3168
+ * let value = undefined;
3169
+ * isNullOrUndefined(value); // true
3170
+ *
3171
+ * isNullOrUndefined(""); // false
3172
+ * isNullOrUndefined(0); // false
3173
+ * isNullOrUndefined(new Date()); // false
3174
+ * isNullOrUndefined(true); // false
3175
+ * isNullOrUndefined(false); // false
3176
+ * ```
3177
+ */
3178
+ function isNullOrUndefined(value: any): boolean;
3179
+
3180
+ /**
3181
+ * Checks if the type of value is a number.
3182
+ * @group Type Identity
3183
+ * @param {any} value - Value to be checked.
3184
+ * @return {boolean} True if the value is a number, false otherwise.
3185
+ */
3186
+ const isNumber: (value: any) => value is number;
3187
+
3188
+ /**
3189
+ * Checks to see if the past value is an object value
3190
+ * @group Type Identity
3191
+ * @group Object
3192
+ * @typeParam T - The object type, defaults to any
3193
+ * @param value - The value to check
3194
+ * @returns
3195
+ */
3196
+ function isObject<T>(value: T): value is T;
3197
+
2431
3198
  /**
2432
3199
  * Returns whether the environment is reporting that we are running in a React Native Environment
2433
3200
  */
@@ -2442,11 +3209,103 @@ declare namespace ApplicationInsights {
2442
3209
  */
2443
3210
  function isSampledFlag(value: ITraceParent): boolean;
2444
3211
 
2445
-
2446
-
2447
-
2448
-
2449
-
3212
+ /**
3213
+ * Checks to see if the past value is a string value
3214
+ * @group Type Identity
3215
+ * @group String
3216
+ * @param value - The value to check
3217
+ * @returns
3218
+ * @example
3219
+ * ```ts
3220
+ * isString(""); // true
3221
+ * isString("null"); // true
3222
+ * isString("undefined"); // true
3223
+ * isString(String("")); // true
3224
+ *
3225
+ * isString(null); // false
3226
+ * isString(undefined); // false
3227
+ * isString(0); // false
3228
+ * ```
3229
+ */
3230
+ const isString: (value: any) => value is string;
3231
+
3232
+ /**
3233
+ * Checks if the type of value is a symbol.
3234
+ * @group Symbol
3235
+ * @param {any} value - Value to be checked.
3236
+ * @return {boolean} True if the value is a symbol, false otherwise.
3237
+ */
3238
+ const isSymbol: (value: any) => value is symbol;
3239
+
3240
+ /**
3241
+ * Checks if the type of value evaluates to true value, handling some special
3242
+ * case usages of Boolean(true/false) and new Boolean(true/false).
3243
+ * @group Value Check
3244
+ * @param {any} value - Value to be checked.
3245
+ * @return {boolean} True if the value is not truthy, false otherwise.
3246
+ */
3247
+ function isTruthy(value: any): boolean;
3248
+
3249
+ /**
3250
+ * Validate if the provided value object is of the expected type
3251
+ * @group Type Identity
3252
+ * @param value - The value to check
3253
+ * @param theType - The expected type name as a string
3254
+ * @returns `true` if the value matches the provided type
3255
+ */
3256
+ function isTypeof(value: any, theType: string): boolean;
3257
+
3258
+ /**
3259
+ * Checks if the provided value is undefined or contains the string value "undefined",
3260
+ * if you want to consider the string value as undefined see {@link isStrictUndefined}
3261
+ * @group Type Identity
3262
+ * @group Value Check
3263
+ * @param value - The value to check
3264
+ * @returns true if the value is undefined or "undefined", otherwise false
3265
+ * @example
3266
+ * ```ts
3267
+ * isUndefined(undefined); // true
3268
+ * isUndefined("undefined"); // true
3269
+ *
3270
+ * isUndefined(null); // false
3271
+ * isUndefined("null"); // false
3272
+ * isUndefined("1"); // false
3273
+ * isUndefined("aa"); // false
3274
+ * isUndefined(new Date()); // false
3275
+ * isUndefined(1); // false
3276
+ * isUndefined(""); // false
3277
+ * isUndefined(_dummyFunction); // false
3278
+ * isUndefined([]); // false
3279
+ * isUndefined(new Array(1)); // false
3280
+ * isUndefined(true); // false
3281
+ * isUndefined(false); // false
3282
+ * isUndefined("true"); // false
3283
+ * isUndefined("false"); // false
3284
+ * isUndefined(new Boolean(true)); // false
3285
+ * isUndefined(new Boolean(false)); // false
3286
+ * isUndefined(new Boolean("true")); // false
3287
+ * isUndefined(new Boolean("false")); // false
3288
+ * isUndefined(Boolean(true)); // false
3289
+ * isUndefined(Boolean(false)); // false
3290
+ * isUndefined(Boolean("true")); // false
3291
+ * isUndefined(Boolean("false")); // false
3292
+ * isUndefined(new RegExp("")); // false
3293
+ * isUndefined(new ArrayBuffer(0)); // false
3294
+ * isUndefined(new Error("Test Error"));// false
3295
+ * isUndefined(new TypeError("Test TypeError")); // false
3296
+ * isUndefined(new TestError("Test TestError")); // false
3297
+ * isUndefined(_dummyError()); // false
3298
+ * isUndefined(Promise.reject()); // false
3299
+ * isUndefined(Promise.resolve()); // false
3300
+ * isUndefined(new Promise(() => {})); // false
3301
+ * isUndefined(_simplePromise()); // false
3302
+ * isUndefined(_simplePromiseLike()); // false
3303
+ * isUndefined(Object.create(null)); // false
3304
+ * isUndefined(polyObjCreate(null)); // false
3305
+ * ```
3306
+ */
3307
+ function isUndefined(value: any): boolean;
3308
+
2450
3309
  /**
2451
3310
  * Is the provided W3c span id (aka. parent id) a valid string representation, it must be a 16-character
2452
3311
  * string of lowercase hexadecimal characters, for example, 00f067aa0ba902b7.
@@ -2520,7 +3379,7 @@ declare namespace ApplicationInsights {
2520
3379
  /**
2521
3380
  * System context property extensions that are not global (not in ctx)
2522
3381
  */
2523
- tags?: Tags & Tags[];
3382
+ tags?: Tags;
2524
3383
  /**
2525
3384
  * Custom data
2526
3385
  */
@@ -2631,6 +3490,120 @@ declare namespace ApplicationInsights {
2631
3490
  removed?: IPlugin[];
2632
3491
  }
2633
3492
 
3493
+ /**
3494
+ * A Timer handler which is returned from {@link scheduleTimeout} which contains functions to
3495
+ * cancel or restart (refresh) the timeout function.
3496
+ *
3497
+ * @since 0.4.4
3498
+ * @group Timer
3499
+ */
3500
+ interface ITimerHandler {
3501
+ /**
3502
+ * Cancels a timeout that was previously scheduled, after calling this function any previously
3503
+ * scheduled timer will not execute.
3504
+ * @example
3505
+ * ```ts
3506
+ * let theTimer = scheduleTimeout(...);
3507
+ * theTimer.cancel();
3508
+ * ```
3509
+ */
3510
+ cancel(): void;
3511
+ /**
3512
+ * Reschedules the timer to call its callback at the previously specified duration
3513
+ * adjusted to the current time. This is useful for refreshing a timer without allocating
3514
+ * a new JavaScript object.
3515
+ *
3516
+ * Using this on a timer that has already called its callback will reactivate the timer.
3517
+ * Calling on a timer that has not yet executed will just reschedule the current timer.
3518
+ * @example
3519
+ * ```ts
3520
+ * let theTimer = scheduleTimeout(...);
3521
+ * // The timer will be restarted (if already executed) or rescheduled (if it has not yet executed)
3522
+ * theTimer.refresh();
3523
+ * ```
3524
+ */
3525
+ refresh(): ITimerHandler;
3526
+ /**
3527
+ * When called, requests that the event loop not exit so long when the ITimerHandler is active.
3528
+ * Calling timer.ref() multiple times will have no effect. By default, all ITimerHandler objects
3529
+ * will create "ref'ed" instances, making it normally unnecessary to call timer.ref() unless
3530
+ * timer.unref() had been called previously.
3531
+ * @since 0.7.0
3532
+ * @returns the ITimerHandler instance
3533
+ * @example
3534
+ * ```ts
3535
+ * let theTimer = createTimeout(...);
3536
+ *
3537
+ * // Make sure the timer is referenced (the default) so that the runtime (Node) does not terminate
3538
+ * // if there is a waiting referenced timer.
3539
+ * theTimer.ref();
3540
+ * ```
3541
+ */
3542
+ ref(): this;
3543
+ /**
3544
+ * When called, the any active ITimerHandler instance will not require the event loop to remain
3545
+ * active (Node.js). If there is no other activity keeping the event loop running, the process may
3546
+ * exit before the ITimerHandler instance callback is invoked. Calling timer.unref() multiple times
3547
+ * will have no effect.
3548
+ * @since 0.7.0
3549
+ * @returns the ITimerHandler instance
3550
+ * @example
3551
+ * ```ts
3552
+ * let theTimer = createTimeout(...);
3553
+ *
3554
+ * // Unreference the timer so that the runtime (Node) may terminate if nothing else is running.
3555
+ * theTimer.unref();
3556
+ * ```
3557
+ */
3558
+ unref(): this;
3559
+ /**
3560
+ * If true, any running referenced `ITimerHandler` instance will keep the Node.js event loop active.
3561
+ * @since 0.7.0
3562
+ * @example
3563
+ * ```ts
3564
+ * let theTimer = createTimeout(...);
3565
+ *
3566
+ * // Unreference the timer so that the runtime (Node) may terminate if nothing else is running.
3567
+ * theTimer.unref();
3568
+ * let hasRef = theTimer.hasRef(); // false
3569
+ *
3570
+ * theTimer.ref();
3571
+ * hasRef = theTimer.hasRef(); // true
3572
+ * ```
3573
+ */
3574
+ hasRef(): boolean;
3575
+ /**
3576
+ * Gets or Sets a flag indicating if the underlying timer is currently enabled and running.
3577
+ * Setting the enabled flag to the same as it's current value has no effect, setting to `true`
3578
+ * when already `true` will not {@link ITimerHandler.refresh | refresh}() the timer.
3579
+ * And setting to 'false` will {@link ITimerHandler.cancel | cancel}() the timer.
3580
+ * @since 0.8.1
3581
+ * @example
3582
+ * ```ts
3583
+ * let theTimer = createTimeout(...);
3584
+ *
3585
+ * // Check if enabled
3586
+ * theTimer.enabled; // false
3587
+ *
3588
+ * // Start the timer
3589
+ * theTimer.enabled = true; // Same as calling refresh()
3590
+ * theTimer.enabled; //true
3591
+ *
3592
+ * // Has no effect as it's already running
3593
+ * theTimer.enabled = true;
3594
+ *
3595
+ * // Will refresh / restart the time
3596
+ * theTimer.refresh()
3597
+ *
3598
+ * let theTimer = scheduleTimeout(...);
3599
+ *
3600
+ * // Check if enabled
3601
+ * theTimer.enabled; // true
3602
+ * ```
3603
+ */
3604
+ enabled: boolean;
3605
+ }
3606
+
2634
3607
  /**
2635
3608
  * This interface represents the components of a W3C traceparent header
2636
3609
  */
@@ -2845,7 +3818,24 @@ declare namespace ApplicationInsights {
2845
3818
  unload?(isAsync?: boolean): void | IPromise<void>;
2846
3819
  }
2847
3820
 
2848
-
3821
+ /**
3822
+ * Try to define get/set object property accessors for the target object/prototype, this will provide compatibility with
3823
+ * existing API definition when run within an ES5+ container that supports accessors but still enable the code to be loaded
3824
+ * and executed in an ES3 container, providing basic IE8 compatibility.
3825
+ * @deprecated It is recommended that you use {@link objDefine} instead {@link objDefineAccessors} as this internally creates
3826
+ * the {@link ObjDefinePropDescriptor} definition based on your provided arguments. And only using a minimum set of functions
3827
+ * reduces your overall bundle size.
3828
+ * @group Object
3829
+ * @param target - The object on which to define the property.
3830
+ * @param prop - The name of the property to be defined or modified.
3831
+ * @param getProp - The getter function to wire against the getter.
3832
+ * @param setProp - The setter function to wire against the setter.
3833
+ * @param configurable - Can the value be changed, defaults to true
3834
+ * @param enumerable - Should this get property be enumerable, defaults to true.
3835
+ * @returns The object that was passed to the function
3836
+ */
3837
+ function objDefineAccessors<T, V = any>(target: T, prop: PropertyKey, getProp?: (() => V) | null, setProp?: ((v: V) => void) | null, configurable?: boolean, enumerable?: boolean): T;
3838
+
2849
3839
  /**
2850
3840
  * Pass in the objects to merge as arguments, this will only "merge" (extend) properties that are owned by the object.
2851
3841
  * It will NOT merge inherited or non-enumerable properties.
@@ -2860,11 +3850,125 @@ declare namespace ApplicationInsights {
2860
3850
 
2861
3851
  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;
2862
3852
 
2863
-
2864
-
2865
-
2866
-
2867
-
3853
+ /**
3854
+ * Calls the provided `callbackFn` function once for each key in an object. This is equivelent to `arrForEach(Object.keys(theObject), callbackFn)` or
3855
+ * if not using the array helper `Object.keys(theObject).forEach(callbackFn)` except that this helper avoid creating a temporary of the object
3856
+ * keys before iterating over them and like the `arrForEach` helper you CAN stop or break the iteration by returning -1 from the `callbackFn` function.
3857
+ * @group Object
3858
+ * @typeParam T - The object type
3859
+ * @param callbackfn A function that accepts up to two arguments, the key name and the current value of the property represented by the key.
3860
+ * @param thisArg [Optional] An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, null or undefined
3861
+ * the object will be used as the this value.
3862
+ * @example
3863
+ * ```ts
3864
+ * function performAction<T>(target: T, source: any) {
3865
+ * if (!isNullOrUndefined(source)) {
3866
+ * objForEachKey(source, (key, value) => {
3867
+ * // Set the target with a reference to the same value with the same name
3868
+ * target[key] = value;
3869
+ * });
3870
+ * }
3871
+ *
3872
+ * return target;
3873
+ * }
3874
+ * ```
3875
+ */
3876
+ function objForEachKey<T>(theObject: T, callbackfn: (key: string, value: T[keyof T]) => void | number, thisArg?: any): void;
3877
+
3878
+ /**
3879
+ * The `objFreeze()` method freezes an object. A frozen object can no longer be changed; freezing an object
3880
+ * prevents new properties from being added to it, existing properties from being removed, prevents changing the
3881
+ * enumerability, configurability, or writability of existing properties, and prevents the values of existing
3882
+ * properties from being changed. In addition, freezing an object also prevents its prototype from being changed.
3883
+ * `objFreeze()` returns the same object that was passed in.
3884
+ *
3885
+ * Nothing can be added to or removed from the properties set of a frozen object. Any attempt to do so will fail,
3886
+ * either silently or by throwing a TypeError exception (most commonly, but not exclusively, when in strict mode).
3887
+ *
3888
+ * For data properties of a frozen object, values cannot be changed, the writable and configurable attributes are
3889
+ * set to false. Accessor properties (getters and setters) work the same (and still give the illusion that you are
3890
+ * changing the value). Note that values that are objects can still be modified, unless they are also frozen. As
3891
+ * an object, an array can be frozen; after doing so, its elements cannot be altered and no elements can be added
3892
+ * to or removed from the array.
3893
+ *
3894
+ * `objFreeze()` returns the same object that was passed into the function. It does not create a frozen copy.
3895
+ * @group Object
3896
+ * @param value - The object to freeze.
3897
+ * @returns The object that was passed to the function.
3898
+ */
3899
+ const objFreeze: <T>(value: T) => T;
3900
+
3901
+ /**
3902
+ * The `objKeys()` method returns an array of a given object's own enumerable property names, iterated in
3903
+ * the same order that a normal loop would.
3904
+ *
3905
+ * objKeys() returns an array whose elements are strings corresponding to the enumerable properties found
3906
+ * directly upon object. The ordering of the properties is the same as that given by looping over the
3907
+ * properties of the object manually.
3908
+ * @group Object
3909
+ * @param value - The object to obtain a copy of the keys from
3910
+ * @returns An array of the properties names for the value object.
3911
+ * @example
3912
+ * ```ts
3913
+ * // simple array
3914
+ * const arr = ['a', 'b', 'c'];
3915
+ * console.log(objKeys(arr)); // console: ['0', '1', '2']
3916
+ *
3917
+ * // array-like object
3918
+ * const obj = { 0: 'a', 1: 'b', 2: 'c' };
3919
+ * console.log(objKeys(obj)); // console: ['0', '1', '2']
3920
+ *
3921
+ * // array-like object with random key ordering
3922
+ * const anObj = { 100: 'a', 2: 'b', 7: 'c' };
3923
+ * console.log(objKeys(anObj)); // console: ['2', '7', '100']
3924
+ *
3925
+ * // getFoo is a property which isn't enumerable
3926
+ * const myObj = objCreate({}, {
3927
+ * getFoo: {
3928
+ * value() { return this.foo; }
3929
+ * }
3930
+ * });
3931
+ * myObj.foo = 1;
3932
+ * console.log(objKeys(myObj)); // console: ['foo']
3933
+ * ```
3934
+ */
3935
+ const objKeys: (value: any) => string[];
3936
+
3937
+ /**
3938
+ * The `objSeal()` method seals an object, preventing new properties from being added to it and marking all
3939
+ * existing properties as non-configurable. Values of present properties can still be changed as long as they
3940
+ * are writable.
3941
+ * @group Object
3942
+ * @param value - The object which should be sealed.
3943
+ * @returns The object being sealed.
3944
+ */
3945
+ const objSeal: <T>(value: T) => T;
3946
+
3947
+ /**
3948
+ * The `objToString()` method returns a string representing the object. This explicitly
3949
+ * always calls the `Object.prototype.toString()` method.
3950
+ *
3951
+ * An object's toString() method is most commonly invoked when that object undergoes:
3952
+ * - explicit type conversion to a string (for example, String(myObject))
3953
+ * - implicit type coercion into a string (for example, myObject + "hello world")
3954
+ *
3955
+ * @group Object
3956
+ * @param value - The object to be converted into a string
3957
+ * @returns A string representation of the object
3958
+ * @example
3959
+ * ```ts
3960
+ * objToString(new Date()); // [object Date]
3961
+ * objToString(new String()); // [object String]
3962
+ *
3963
+ * // Math has its Symbol.toStringTag
3964
+ * objToString(Math); // [object Math]
3965
+ *
3966
+ * objToString(undefined); // [object Undefined]
3967
+ * objToString(null); // [object Null]
3968
+ * ```
3969
+ */
3970
+ function objToString(value: any): string;
3971
+
2868
3972
  type OnCompleteCallback = (status: number, headers: {
2869
3973
  [headerName: string]: string;
2870
3974
  }, response?: string) => void;
@@ -2971,7 +4075,23 @@ declare namespace ApplicationInsights {
2971
4075
  getCtx(key: string): any;
2972
4076
  }
2973
4077
 
2974
-
4078
+ /**
4079
+ * Returns the number of milliseconds that has elapsed since the time origin, if
4080
+ * the runtime does not support the `performance` API it will fallback to return
4081
+ * the number of milliseconds since the unix epoch.
4082
+ *
4083
+ * @since 0.4.4
4084
+ * @group Timer
4085
+ *
4086
+ * @returns The number of milliseconds as a `DOMHighResTimeStamp` double value or
4087
+ * an integer depending on the runtime.
4088
+ * @example
4089
+ * ```ts
4090
+ * let now = perfNow();
4091
+ * ```
4092
+ */
4093
+ function perfNow(): number;
4094
+
2975
4095
  /**
2976
4096
  * This class will be removed!
2977
4097
  * @deprecated use createProcessTelemetryContext() instead
@@ -3091,6 +4211,13 @@ declare namespace ApplicationInsights {
3091
4211
  */
3092
4212
  function randomValue(maxValue: number): number;
3093
4213
 
4214
+ /**
4215
+ * This defines the handler function for when a promise is rejected.
4216
+ * @param value This is the value passed as part of resolving the Promise
4217
+ * @return This may return a value, another Promise or void. @see {@link IPromise.then} for how the value is handled.
4218
+ */
4219
+ type RejectedPromiseHandler<T = never> = (((reason: any) => T | IPromise<T> | PromiseLike<T>) | undefined | null);
4220
+
3094
4221
  /**
3095
4222
  * Trys to remove event handler(s) for the specified event/namespace to the window, body and document
3096
4223
  * @param eventName - {string} - The name of the event, with optional namespaces or just the namespaces,
@@ -3137,6 +4264,13 @@ declare namespace ApplicationInsights {
3137
4264
  */
3138
4265
  function removePageUnloadEventListener(listener: any, evtNamespace?: string | string[]): void;
3139
4266
 
4267
+ /**
4268
+ * This defines the handler function for when a promise is resolved.
4269
+ * @param value This is the value passed as part of resolving the Promise
4270
+ * @return This may return a value, another Promise or void. @see {@link IPromise.then} for how the value is handled.
4271
+ */
4272
+ type ResolvedPromiseHandler<T, TResult1 = T> = (((value: T) => TResult1 | IPromise<TResult1> | PromiseLike<TResult1>) | undefined | null);
4273
+
3140
4274
  /**
3141
4275
  * Run the unload function of the target object if it exists
3142
4276
  * @param target - The target object that contains the unload function
@@ -3249,13 +4383,48 @@ declare namespace ApplicationInsights {
3249
4383
  */
3250
4384
  function strContains(value: string, search: string): boolean;
3251
4385
 
3252
-
3253
-
3254
-
3255
-
3256
-
3257
-
3258
-
4386
+ /**
4387
+ * This method lets you determine whether or not a string ends with another string. This method is case-sensitive.
4388
+ * @group String
4389
+ * @param value - The value to be checked
4390
+ * @param searchString - The characters to be searched for at the end of `value` string.
4391
+ * @param length - If provided, it is used as the length of `value`. Defaults to value.length.
4392
+ */
4393
+ const strEndsWith: (value: string, searchString: string, length?: number) => boolean;
4394
+
4395
+ const strFunction = "function";
4396
+
4397
+ const strObject = "object";
4398
+
4399
+ const strPrototype = "prototype";
4400
+
4401
+ /**
4402
+ * This method lets you determine whether or not a string begins with another string. This method is case-sensitive.
4403
+ * @group String
4404
+ * @param value - The value to be checked
4405
+ * @param searchString - The characters to be searched for at the start of the string
4406
+ * @param position - [Optional] The position in this string at which to begin searching for `searchString`.
4407
+ * Defaults to 0
4408
+ * @returns `true` if the given characters are found at the beginning of the string; otherwise, `false`.
4409
+ */
4410
+ const strStartsWith: (value: string, searchString: string, length?: number) => boolean;
4411
+
4412
+ /**
4413
+ * The trim() method removes whitespace from both ends of a string and returns a new string,
4414
+ * without modifying the original string. Whitespace in this context is all the whitespace
4415
+ * characters (space, tab, no-break space, etc.) and all the line terminator characters
4416
+ * (LF, CR, etc.).
4417
+ * @group String
4418
+ * @param value - The string value to be trimmed.
4419
+ * @returns A new string representing str stripped of whitespace from both its beginning and end.
4420
+ * If neither the beginning or end of str has any whitespace, a new string is still returned (essentially
4421
+ * a copy of str), with no exception being thrown.
4422
+ * To return a new string with whitespace trimmed from just one end, use `strTrimStart()` or `strTrimEnd()`.
4423
+ */
4424
+ const strTrim: (value: string) => string;
4425
+
4426
+ const strUndefined = "undefined";
4427
+
3259
4428
  interface Tags {
3260
4429
  [key: string]: any;
3261
4430
  }
@@ -3313,7 +4482,13 @@ declare namespace ApplicationInsights {
3313
4482
  */
3314
4483
  function throwAggregationError(message: string, sourceErrors: any[]): never;
3315
4484
 
3316
-
4485
+ /**
4486
+ * Throw an error exception with the specified optional message
4487
+ * @group Error
4488
+ * @param message
4489
+ */
4490
+ function throwError(message?: string): never;
4491
+
3317
4492
  /**
3318
4493
  * This is a helper method which will call throwInternal on the passed logger, will throw exceptions in
3319
4494
  * debug mode or attempt to log the error as a console warning. This helper is provided mostly to better
@@ -3377,5 +4552,4 @@ declare namespace ApplicationInsights {
3377
4552
 
3378
4553
  type WatcherFunction<T = IConfiguration> = (details: IWatchDetails<T>) => void;
3379
4554
 
3380
-
3381
4555
  }