@microsoft/applicationinsights-common 3.1.0-nightly3.2402-09 → 3.1.0

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-common.cjs.js +1 -1
  2. package/browser/es5/applicationinsights-common.cjs.js.map +1 -1
  3. package/browser/es5/applicationinsights-common.cjs.min.js +1 -1
  4. package/browser/es5/applicationinsights-common.cjs.min.js.map +1 -1
  5. package/browser/es5/applicationinsights-common.gbl.js +3 -3
  6. package/browser/es5/applicationinsights-common.gbl.js.map +1 -1
  7. package/browser/es5/applicationinsights-common.gbl.min.js +2 -2
  8. package/browser/es5/applicationinsights-common.gbl.min.js.map +1 -1
  9. package/browser/es5/applicationinsights-common.integrity.json +25 -25
  10. package/browser/es5/applicationinsights-common.js +3 -3
  11. package/browser/es5/applicationinsights-common.js.map +1 -1
  12. package/browser/es5/applicationinsights-common.min.js +2 -2
  13. package/browser/es5/applicationinsights-common.min.js.map +1 -1
  14. package/dist/es5/applicationinsights-common.js +1 -1
  15. package/dist/es5/applicationinsights-common.js.map +1 -1
  16. package/dist/es5/applicationinsights-common.min.js +1 -1
  17. package/dist/es5/applicationinsights-common.min.js.map +1 -1
  18. package/dist-es5/ConnectionStringParser.js +1 -1
  19. package/dist-es5/Constants.js +1 -1
  20. package/dist-es5/DomHelperFuncs.js +1 -1
  21. package/dist-es5/Enums.js +1 -1
  22. package/dist-es5/HelperFuncs.js +1 -1
  23. package/dist-es5/Interfaces/ConnectionString.js +1 -1
  24. package/dist-es5/Interfaces/Context/IApplication.js +1 -1
  25. package/dist-es5/Interfaces/Context/IDevice.js +1 -1
  26. package/dist-es5/Interfaces/Context/IInternal.js +1 -1
  27. package/dist-es5/Interfaces/Context/ILocation.js +1 -1
  28. package/dist-es5/Interfaces/Context/IOperatingSystem.js +1 -1
  29. package/dist-es5/Interfaces/Context/ISample.js +1 -1
  30. package/dist-es5/Interfaces/Context/ISession.js +1 -1
  31. package/dist-es5/Interfaces/Context/ISessionManager.js +1 -1
  32. package/dist-es5/Interfaces/Context/ITelemetryTrace.js +1 -1
  33. package/dist-es5/Interfaces/Context/IUser.js +1 -1
  34. package/dist-es5/Interfaces/Context/IWeb.js +1 -1
  35. package/dist-es5/Interfaces/Contracts/AvailabilityData.js +1 -1
  36. package/dist-es5/Interfaces/Contracts/ContextTagKeys.js +1 -1
  37. package/dist-es5/Interfaces/Contracts/DataPointType.js +1 -1
  38. package/dist-es5/Interfaces/Contracts/DependencyKind.js +1 -1
  39. package/dist-es5/Interfaces/Contracts/DependencySourceType.js +1 -1
  40. package/dist-es5/Interfaces/Contracts/IBase.js +1 -1
  41. package/dist-es5/Interfaces/Contracts/IData.js +1 -1
  42. package/dist-es5/Interfaces/Contracts/IDataPoint.js +1 -1
  43. package/dist-es5/Interfaces/Contracts/IDomain.js +1 -1
  44. package/dist-es5/Interfaces/Contracts/IEnvelope.js +1 -1
  45. package/dist-es5/Interfaces/Contracts/IEventData.js +1 -1
  46. package/dist-es5/Interfaces/Contracts/IExceptionData.js +1 -1
  47. package/dist-es5/Interfaces/Contracts/IExceptionDetails.js +1 -1
  48. package/dist-es5/Interfaces/Contracts/IMessageData.js +1 -1
  49. package/dist-es5/Interfaces/Contracts/IMetricData.js +1 -1
  50. package/dist-es5/Interfaces/Contracts/IPageViewData.js +1 -1
  51. package/dist-es5/Interfaces/Contracts/IPageViewPerfData.js +1 -1
  52. package/dist-es5/Interfaces/Contracts/IRemoteDependencyData.js +1 -1
  53. package/dist-es5/Interfaces/Contracts/IStackFrame.js +1 -1
  54. package/dist-es5/Interfaces/Contracts/RequestData.js +1 -1
  55. package/dist-es5/Interfaces/Contracts/SeverityLevel.js +1 -1
  56. package/dist-es5/Interfaces/IAppInsights.js +1 -1
  57. package/dist-es5/Interfaces/IConfig.js +1 -1
  58. package/dist-es5/Interfaces/ICorrelationConfig.js +1 -1
  59. package/dist-es5/Interfaces/IDependencyTelemetry.js +1 -1
  60. package/dist-es5/Interfaces/IEventTelemetry.js +1 -1
  61. package/dist-es5/Interfaces/IExceptionTelemetry.js +1 -1
  62. package/dist-es5/Interfaces/IMetricTelemetry.js +1 -1
  63. package/dist-es5/Interfaces/IPageViewPerformanceTelemetry.js +1 -1
  64. package/dist-es5/Interfaces/IPageViewTelemetry.js +1 -1
  65. package/dist-es5/Interfaces/IPartC.js +1 -1
  66. package/dist-es5/Interfaces/IPropertiesPlugin.js +1 -1
  67. package/dist-es5/Interfaces/IRequestContext.js +1 -1
  68. package/dist-es5/Interfaces/IStorageBuffer.js +1 -1
  69. package/dist-es5/Interfaces/ITelemetryContext.js +1 -1
  70. package/dist-es5/Interfaces/IThrottleMgr.js +1 -1
  71. package/dist-es5/Interfaces/ITraceTelemetry.js +1 -1
  72. package/dist-es5/Interfaces/PartAExtensions.js +1 -1
  73. package/dist-es5/Interfaces/Telemetry/IEnvelope.js +1 -1
  74. package/dist-es5/Interfaces/Telemetry/ISerializable.js +1 -1
  75. package/dist-es5/Offline.js +1 -1
  76. package/dist-es5/RequestResponseHeaders.js +1 -1
  77. package/dist-es5/StorageHelperFuncs.js +1 -1
  78. package/dist-es5/Telemetry/Common/Data.js +1 -1
  79. package/dist-es5/Telemetry/Common/DataPoint.js +1 -1
  80. package/dist-es5/Telemetry/Common/DataSanitizer.js +1 -1
  81. package/dist-es5/Telemetry/Common/Envelope.js +1 -1
  82. package/dist-es5/Telemetry/Event.js +1 -1
  83. package/dist-es5/Telemetry/Exception.js +1 -1
  84. package/dist-es5/Telemetry/Metric.js +1 -1
  85. package/dist-es5/Telemetry/PageView.js +1 -1
  86. package/dist-es5/Telemetry/PageViewPerformance.js +1 -1
  87. package/dist-es5/Telemetry/RemoteDependencyData.js +1 -1
  88. package/dist-es5/Telemetry/Trace.js +1 -1
  89. package/dist-es5/TelemetryItemCreator.js +1 -1
  90. package/dist-es5/ThrottleMgr.js +1 -1
  91. package/dist-es5/UrlHelperFuncs.js +1 -1
  92. package/dist-es5/Util.js +1 -1
  93. package/dist-es5/__DynamicConstants.js +1 -1
  94. package/dist-es5/applicationinsights-common.js +1 -1
  95. package/package.json +63 -66
  96. package/types/applicationinsights-common.d.ts +22 -4
  97. package/types/applicationinsights-common.namespaced.d.ts +2028 -58
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Microsoft Application Insights Common JavaScript Library, 3.1.0-nightly3.2402-09
2
+ * Microsoft Application Insights Common JavaScript Library, 3.1.0
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  *
5
5
  * Microsoft Application Insights Team
@@ -7,29 +7,6 @@
7
7
  */
8
8
 
9
9
  declare namespace ApplicationInsights {
10
- import { createTraceParent } from '@microsoft/applicationinsights-core-js';
11
- import { _eInternalMessageId } from '@microsoft/applicationinsights-core-js';
12
- import { eLoggingSeverity } from '@microsoft/applicationinsights-core-js';
13
- import { EnumValue } from '@microsoft/applicationinsights-core-js';
14
- import { findW3cTraceParent } from '@microsoft/applicationinsights-core-js';
15
- import { formatTraceParent } from '@microsoft/applicationinsights-core-js';
16
- import { IAppInsightsCore } from '@microsoft/applicationinsights-core-js';
17
- import { IConfiguration } from '@microsoft/applicationinsights-core-js';
18
- import { ICookieMgr } from '@microsoft/applicationinsights-core-js';
19
- import { ICustomProperties } from '@microsoft/applicationinsights-core-js';
20
- import { IDiagnosticLogger } from '@microsoft/applicationinsights-core-js';
21
- import { IDistributedTraceContext } from '@microsoft/applicationinsights-core-js';
22
- import { IPlugin } from '@microsoft/applicationinsights-core-js';
23
- import { isBeaconsSupported as isBeaconApiSupported } from '@microsoft/applicationinsights-core-js';
24
- import { isSampledFlag } from '@microsoft/applicationinsights-core-js';
25
- import { isValidSpanId } from '@microsoft/applicationinsights-core-js';
26
- import { isValidTraceId } from '@microsoft/applicationinsights-core-js';
27
- import { isValidTraceParent } from '@microsoft/applicationinsights-core-js';
28
- import { ITelemetryItem } from '@microsoft/applicationinsights-core-js';
29
- import { ITraceParent } from '@microsoft/applicationinsights-core-js';
30
- import { IUnloadHook } from '@microsoft/applicationinsights-core-js';
31
- import { parseTraceParent } from '@microsoft/applicationinsights-core-js';
32
-
33
10
  /**
34
11
  * Data struct to contain only C section with custom fields.
35
12
  */
@@ -132,7 +109,16 @@ declare namespace ApplicationInsights {
132
109
  [key: string]: any;
133
110
  }): ITelemetryItem;
134
111
 
135
-
112
+ /**
113
+ * Create a new ITraceParent instance using the provided values.
114
+ * @param traceId - The traceId to use, when invalid a new random W3C id will be generated.
115
+ * @param spanId - The parent/span id to use, a new random value will be generated if it is invalid.
116
+ * @param flags - The traceFlags to use, defaults to zero (0) if not supplied or invalid
117
+ * @param version - The version to used, defaults to version "01" if not supplied or invalid.
118
+ * @returns
119
+ */
120
+ function createTraceParent(traceId?: string, spanId?: string, flags?: number, version?: string): ITraceParent;
121
+
136
122
  let CtxTagKeys: ContextTagKeys;
137
123
 
138
124
  class Data<TDomain> implements AIData<TDomain>, ISerializable {
@@ -297,6 +283,132 @@ declare namespace ApplicationInsights {
297
283
  W3C = 2
298
284
  }
299
285
 
286
+ const enum _eInternalMessageId {
287
+ BrowserDoesNotSupportLocalStorage = 0,
288
+ BrowserCannotReadLocalStorage = 1,
289
+ BrowserCannotReadSessionStorage = 2,
290
+ BrowserCannotWriteLocalStorage = 3,
291
+ BrowserCannotWriteSessionStorage = 4,
292
+ BrowserFailedRemovalFromLocalStorage = 5,
293
+ BrowserFailedRemovalFromSessionStorage = 6,
294
+ CannotSendEmptyTelemetry = 7,
295
+ ClientPerformanceMathError = 8,
296
+ ErrorParsingAISessionCookie = 9,
297
+ ErrorPVCalc = 10,
298
+ ExceptionWhileLoggingError = 11,
299
+ FailedAddingTelemetryToBuffer = 12,
300
+ FailedMonitorAjaxAbort = 13,
301
+ FailedMonitorAjaxDur = 14,
302
+ FailedMonitorAjaxOpen = 15,
303
+ FailedMonitorAjaxRSC = 16,
304
+ FailedMonitorAjaxSend = 17,
305
+ FailedMonitorAjaxGetCorrelationHeader = 18,
306
+ FailedToAddHandlerForOnBeforeUnload = 19,
307
+ FailedToSendQueuedTelemetry = 20,
308
+ FailedToReportDataLoss = 21,
309
+ FlushFailed = 22,
310
+ MessageLimitPerPVExceeded = 23,
311
+ MissingRequiredFieldSpecification = 24,
312
+ NavigationTimingNotSupported = 25,
313
+ OnError = 26,
314
+ SessionRenewalDateIsZero = 27,
315
+ SenderNotInitialized = 28,
316
+ StartTrackEventFailed = 29,
317
+ StopTrackEventFailed = 30,
318
+ StartTrackFailed = 31,
319
+ StopTrackFailed = 32,
320
+ TelemetrySampledAndNotSent = 33,
321
+ TrackEventFailed = 34,
322
+ TrackExceptionFailed = 35,
323
+ TrackMetricFailed = 36,
324
+ TrackPVFailed = 37,
325
+ TrackPVFailedCalc = 38,
326
+ TrackTraceFailed = 39,
327
+ TransmissionFailed = 40,
328
+ FailedToSetStorageBuffer = 41,
329
+ FailedToRestoreStorageBuffer = 42,
330
+ InvalidBackendResponse = 43,
331
+ FailedToFixDepricatedValues = 44,
332
+ InvalidDurationValue = 45,
333
+ TelemetryEnvelopeInvalid = 46,
334
+ CreateEnvelopeError = 47,
335
+ CannotSerializeObject = 48,
336
+ CannotSerializeObjectNonSerializable = 49,
337
+ CircularReferenceDetected = 50,
338
+ ClearAuthContextFailed = 51,
339
+ ExceptionTruncated = 52,
340
+ IllegalCharsInName = 53,
341
+ ItemNotInArray = 54,
342
+ MaxAjaxPerPVExceeded = 55,
343
+ MessageTruncated = 56,
344
+ NameTooLong = 57,
345
+ SampleRateOutOfRange = 58,
346
+ SetAuthContextFailed = 59,
347
+ SetAuthContextFailedAccountName = 60,
348
+ StringValueTooLong = 61,
349
+ StartCalledMoreThanOnce = 62,
350
+ StopCalledWithoutStart = 63,
351
+ TelemetryInitializerFailed = 64,
352
+ TrackArgumentsNotSpecified = 65,
353
+ UrlTooLong = 66,
354
+ SessionStorageBufferFull = 67,
355
+ CannotAccessCookie = 68,
356
+ IdTooLong = 69,
357
+ InvalidEvent = 70,
358
+ FailedMonitorAjaxSetRequestHeader = 71,
359
+ SendBrowserInfoOnUserInit = 72,
360
+ PluginException = 73,
361
+ NotificationException = 74,
362
+ SnippetScriptLoadFailure = 99,
363
+ InvalidInstrumentationKey = 100,
364
+ CannotParseAiBlobValue = 101,
365
+ InvalidContentBlob = 102,
366
+ TrackPageActionEventFailed = 103,
367
+ FailedAddingCustomDefinedRequestContext = 104,
368
+ InMemoryStorageBufferFull = 105,
369
+ InstrumentationKeyDeprecation = 106,
370
+ ConfigWatcherException = 107,
371
+ DynamicConfigException = 108,
372
+ DefaultThrottleMsgKey = 109,
373
+ CdnDeprecation = 110,
374
+ SdkLdrUpdate = 111
375
+ }
376
+
377
+ const enum eLoggingSeverity {
378
+ /**
379
+ * No Logging will be enabled
380
+ */
381
+ DISABLED = 0,
382
+ /**
383
+ * Error will be sent as internal telemetry
384
+ */
385
+ CRITICAL = 1,
386
+ /**
387
+ * Error will NOT be sent as internal telemetry, and will only be shown in browser console
388
+ */
389
+ WARNING = 2,
390
+ /**
391
+ * The Error will NOT be sent as an internal telemetry, and will only be shown in the browser
392
+ * console if the logging level allows it.
393
+ */
394
+ DEBUG = 3
395
+ }
396
+
397
+ /**
398
+ * A type that identifies an enum class generated from a constant enum.
399
+ * @group Enum
400
+ * @typeParam E - The constant enum type
401
+ *
402
+ * Returned from {@link createEnum}
403
+ */
404
+ type EnumCls<E = any> = {
405
+ readonly [key in keyof E extends string | number | symbol ? keyof E : never]: key extends string ? E[key] : key;
406
+ } & {
407
+ readonly [key in keyof E]: E[key];
408
+ };
409
+
410
+ type EnumValue<E = any> = EnumCls<E>;
411
+
300
412
  class Envelope implements IEnvelope {
301
413
  /**
302
414
  * The data contract for serializing this object.
@@ -489,6 +601,21 @@ declare namespace ApplicationInsights {
489
601
  SDKExt: string;
490
602
  };
491
603
 
604
+ const enum FeatureOptInMode {
605
+ /**
606
+ * not set, completely depends on cdn cfg
607
+ */
608
+ none = 1,
609
+ /**
610
+ * try to not apply config from cdn
611
+ */
612
+ disable = 2,
613
+ /**
614
+ * try to apply config from cdn
615
+ */
616
+ enable = 3
617
+ }
618
+
492
619
  /**
493
620
  * Enum is used in aiDataContract to describe how fields are serialized.
494
621
  * For instance: (Fieldtype.Required | FieldType.Array) will mark the field as required and indicate it's an array
@@ -500,14 +627,34 @@ declare namespace ApplicationInsights {
500
627
  Hidden = 4
501
628
  }
502
629
 
503
-
630
+ /**
631
+ * This defines the handler function that is called via the finally when the promise is resolved or rejected
632
+ */
633
+ type FinallyPromiseHandler = (() => void) | undefined | null;
634
+
635
+ /**
636
+ * Helper function to fetch the passed traceparent from the page, looking for it as a meta-tag or a Server-Timing header.
637
+ * @param selectIdx - If the found value is comma separated which is the preferred entry to select, defaults to the first
638
+ * @returns
639
+ */
640
+ function findW3cTraceParent(selectIdx?: number): ITraceParent;
641
+
504
642
  /**
505
643
  * Formats the provided errorObj for display and reporting, it may be a String, Object, integer or undefined depending on the browser.
506
644
  * @param errorObj - The supplied errorObj
507
645
  */
508
646
  function _formatErrorCode(errorObj: any): any;
509
647
 
510
-
648
+ /**
649
+ * Format the ITraceParent value as a string using the supported and know version formats.
650
+ * So even if the passed traceParent is a later version the string value returned from this
651
+ * function will convert it to only the known version formats.
652
+ * This currently only supports version "00" and invalid "ff"
653
+ * @param value - The parsed traceParent value
654
+ * @returns
655
+ */
656
+ function formatTraceParent(value: ITraceParent): string;
657
+
511
658
  function getExtensionByName(extensions: IPlugin[], identifier: string): IPlugin | null;
512
659
 
513
660
  const HttpMethod = "http.method";
@@ -534,15 +681,167 @@ declare namespace ApplicationInsights {
534
681
  [key: string]: any;
535
682
  }): void;
536
683
  startTrackPage(name?: string): void;
537
- stopTrackPage(name?: string, url?: string, customProperties?: Object): void;
684
+ stopTrackPage(name?: string, url?: string, properties?: {
685
+ [key: string]: string;
686
+ }, measurements?: {
687
+ [key: string]: number;
688
+ }): void;
538
689
  startTrackEvent(name: string): void;
539
- stopTrackEvent(name: string, properties?: Object, measurements?: Object): void;
690
+ stopTrackEvent(name: string, properties?: {
691
+ [key: string]: string;
692
+ }, measurements?: {
693
+ [key: string]: number;
694
+ }): void;
540
695
  addTelemetryInitializer(telemetryInitializer: (item: ITelemetryItem) => boolean | void): void;
541
696
  trackPageViewPerformance(pageViewPerformance: IPageViewPerformanceTelemetry, customProperties?: {
542
697
  [key: string]: any;
543
698
  }): void;
544
699
  }
545
700
 
701
+ interface IAppInsightsCore<CfgType extends IConfiguration = IConfiguration> extends IPerfManagerProvider {
702
+ readonly config: CfgType;
703
+ /**
704
+ * The current logger instance for this instance.
705
+ */
706
+ readonly logger: IDiagnosticLogger;
707
+ /**
708
+ * An array of the installed plugins that provide a version
709
+ */
710
+ readonly pluginVersionStringArr: string[];
711
+ /**
712
+ * The formatted string of the installed plugins that contain a version number
713
+ */
714
+ readonly pluginVersionString: string;
715
+ /**
716
+ * Returns a value that indicates whether the instance has already been previously initialized.
717
+ */
718
+ isInitialized?: () => boolean;
719
+ initialize(config: CfgType, extensions: IPlugin[], logger?: IDiagnosticLogger, notificationManager?: INotificationManager): void;
720
+ getChannels(): IChannelControls[];
721
+ track(telemetryItem: ITelemetryItem): void;
722
+ /**
723
+ * Get the current notification manager
724
+ */
725
+ getNotifyMgr(): INotificationManager;
726
+ /**
727
+ * Get the current cookie manager for this instance
728
+ */
729
+ getCookieMgr(): ICookieMgr;
730
+ /**
731
+ * Set the current cookie manager for this instance
732
+ * @param cookieMgr - The manager, if set to null/undefined will cause the default to be created
733
+ */
734
+ setCookieMgr(cookieMgr: ICookieMgr): void;
735
+ /**
736
+ * Adds a notification listener. The SDK calls methods on the listener when an appropriate notification is raised.
737
+ * The added plugins must raise notifications. If the plugins do not implement the notifications, then no methods will be
738
+ * called.
739
+ * @param listener - An INotificationListener object.
740
+ */
741
+ addNotificationListener?(listener: INotificationListener): void;
742
+ /**
743
+ * Removes all instances of the listener.
744
+ * @param listener - INotificationListener to remove.
745
+ */
746
+ removeNotificationListener?(listener: INotificationListener): void;
747
+ /**
748
+ * Add a telemetry processor to decorate or drop telemetry events.
749
+ * @param telemetryInitializer - The Telemetry Initializer function
750
+ * @returns - A ITelemetryInitializerHandler to enable the initializer to be removed
751
+ */
752
+ addTelemetryInitializer(telemetryInitializer: TelemetryInitializerFunction): ITelemetryInitializerHandler;
753
+ pollInternalLogs?(eventName?: string): ITimerHandler;
754
+ stopPollingInternalLogs?(): void;
755
+ /**
756
+ * Return a new instance of the IProcessTelemetryContext for processing events
757
+ */
758
+ getProcessTelContext(): IProcessTelemetryContext;
759
+ /**
760
+ * Unload and Tear down the SDK and any initialized plugins, after calling this the SDK will be considered
761
+ * to be un-initialized and non-operational, re-initializing the SDK should only be attempted if the previous
762
+ * unload call return `true` stating that all plugins reported that they also unloaded, the recommended
763
+ * approach is to create a new instance and initialize that instance.
764
+ * This is due to possible unexpected side effects caused by plugins not supporting unload / teardown, unable
765
+ * to successfully remove any global references or they may just be completing the unload process asynchronously.
766
+ * If you pass isAsync as `true` (also the default) and DO NOT pass a callback function then an [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html)
767
+ * will be returned which will resolve once the unload is complete. The actual implementation of the `IPromise`
768
+ * will be a native Promise (if supported) or the default as supplied by [ts-async library](https://github.com/nevware21/ts-async)
769
+ * @param isAsync - Can the unload be performed asynchronously (default)
770
+ * @param unloadComplete - An optional callback that will be called once the unload has completed
771
+ * @param cbTimeout - An optional timeout to wait for any flush operations to complete before proceeding with the
772
+ * unload. Defaults to 5 seconds.
773
+ * @return Nothing or if occurring asynchronously a [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html)
774
+ * which will be resolved once the unload is complete, the [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html)
775
+ * will only be returned when no callback is provided and isAsync is true
776
+ */
777
+ unload(isAsync?: boolean, unloadComplete?: (unloadState: ITelemetryUnloadState) => void, cbTimeout?: number): void | IPromise<ITelemetryUnloadState>;
778
+ /**
779
+ * Find and return the (first) plugin with the specified identifier if present
780
+ * @param pluginIdentifier
781
+ */
782
+ getPlugin<T extends IPlugin = IPlugin>(pluginIdentifier: string): ILoadedPlugin<T>;
783
+ /**
784
+ * Add a new plugin to the installation
785
+ * @param plugin - The new plugin to add
786
+ * @param replaceExisting - should any existing plugin be replaced, default is false
787
+ * @param doAsync - Should the add be performed asynchronously
788
+ * @param addCb - [Optional] callback to call after the plugin has been added
789
+ */
790
+ addPlugin<T extends IPlugin = ITelemetryPlugin>(plugin: T, replaceExisting?: boolean, doAsync?: boolean, addCb?: (added?: boolean) => void): void;
791
+ /**
792
+ * Update the configuration used and broadcast the changes to all loaded plugins, this does NOT support updating, adding or removing
793
+ * any the plugins (extensions or channels). It will notify each plugin (if supported) that the configuration has changed but it will
794
+ * not remove or add any new plugins, you need to call addPlugin or getPlugin(identifier).remove();
795
+ * @param newConfig - The new configuration is apply
796
+ * @param mergeExisting - Should the new configuration merge with the existing or just replace it. Default is to merge.
797
+ */
798
+ updateCfg(newConfig: CfgType, mergeExisting?: boolean): void;
799
+ /**
800
+ * Returns the unique event namespace that should be used when registering events
801
+ */
802
+ evtNamespace(): string;
803
+ /**
804
+ * Add a handler that will be called when the SDK is being unloaded
805
+ * @param handler - the handler
806
+ */
807
+ addUnloadCb(handler: UnloadHandler): void;
808
+ /**
809
+ * Add this hook so that it is automatically removed during unloading
810
+ * @param hooks - The single hook or an array of IInstrumentHook objects
811
+ */
812
+ addUnloadHook(hooks: IUnloadHook | IUnloadHook[] | Iterator<IUnloadHook> | ILegacyUnloadHook | ILegacyUnloadHook[] | Iterator<ILegacyUnloadHook>): void;
813
+ /**
814
+ * Flush and send any batched / cached data immediately
815
+ * @param async - send data asynchronously when true (defaults to true)
816
+ * @param callBack - if specified, notify caller when send is complete, the channel should return true to indicate to the caller that it will be called.
817
+ * If the caller doesn't return true the caller should assume that it may never be called.
818
+ * @param sendReason - specify the reason that you are calling "flush" defaults to ManualFlush (1) if not specified
819
+ * @param cbTimeout - An optional timeout to wait for any flush operations to complete before proceeding with the unload. Defaults to 5 seconds.
820
+ * @returns - true if the callback will be return after the flush is complete otherwise the caller should assume that any provided callback will never be called
821
+ */
822
+ flush(isAsync?: boolean, callBack?: (flushComplete?: boolean) => void, sendReason?: SendRequestReason, cbTimeout?: number): boolean | void;
823
+ /**
824
+ * Gets the current distributed trace context for this instance if available
825
+ * @param createNew - Optional flag to create a new instance if one doesn't currently exist, defaults to true
826
+ */
827
+ getTraceCtx(createNew?: boolean): IDistributedTraceContext | null;
828
+ /**
829
+ * Sets the current distributed trace context for this instance if available
830
+ */
831
+ setTraceCtx(newTraceCtx: IDistributedTraceContext | null | undefined): void;
832
+ /**
833
+ * Watches and tracks changes for accesses to the current config, and if the accessed config changes the
834
+ * handler will be recalled.
835
+ * @param handler
836
+ * @returns A watcher handler instance that can be used to remove itself when being unloaded
837
+ */
838
+ onCfgChange(handler: WatcherFunction<CfgType>): IUnloadHook;
839
+ /**
840
+ * Function used to identify the get w parameter used to identify status bit to some channels
841
+ */
842
+ getWParam: () => number;
843
+ }
844
+
546
845
  interface IApplication {
547
846
  /**
548
847
  * The application version.
@@ -616,6 +915,111 @@ declare namespace ApplicationInsights {
616
915
  errorSrc?: string;
617
916
  }
618
917
 
918
+ interface IBaseProcessingContext {
919
+ /**
920
+ * The current core instance for the request
921
+ */
922
+ core: () => IAppInsightsCore;
923
+ /**
924
+ * THe current diagnostic logger for the request
925
+ */
926
+ diagLog: () => IDiagnosticLogger;
927
+ /**
928
+ * Gets the current core config instance
929
+ */
930
+ getCfg: () => IConfiguration;
931
+ /**
932
+ * Gets the named extension config
933
+ */
934
+ getExtCfg: <T>(identifier: string, defaultValue?: IConfigDefaults<T>) => T;
935
+ /**
936
+ * Gets the named config from either the named identifier extension or core config if neither exist then the
937
+ * default value is returned
938
+ * @param identifier - The named extension identifier
939
+ * @param field - The config field name
940
+ * @param defaultValue - The default value to return if no defined config exists
941
+ */
942
+ getConfig: (identifier: string, field: string, defaultValue?: number | string | boolean | string[] | RegExp[] | Function) => number | string | boolean | string[] | RegExp[] | Function;
943
+ /**
944
+ * Helper to allow plugins to check and possibly shortcut executing code only
945
+ * required if there is a nextPlugin
946
+ */
947
+ hasNext: () => boolean;
948
+ /**
949
+ * Returns the next configured plugin proxy
950
+ */
951
+ getNext: () => ITelemetryPluginChain;
952
+ /**
953
+ * Helper to set the next plugin proxy
954
+ */
955
+ setNext: (nextCtx: ITelemetryPluginChain) => void;
956
+ /**
957
+ * Synchronously iterate over the context chain running the callback for each plugin, once
958
+ * every plugin has been executed via the callback, any associated onComplete will be called.
959
+ * @param callback - The function call for each plugin in the context chain
960
+ */
961
+ iterate: <T extends ITelemetryPlugin = ITelemetryPlugin>(callback: (plugin: T) => void) => void;
962
+ /**
963
+ * Set the function to call when the current chain has executed all processNext or unloadNext items.
964
+ * @param onComplete - The onComplete to call
965
+ * @param that - The "this" value to use for the onComplete call, if not provided or undefined defaults to the current context
966
+ * @param args - Any additional arguments to pass to the onComplete function
967
+ */
968
+ onComplete: (onComplete: () => void, that?: any, ...args: any[]) => void;
969
+ /**
970
+ * Create a new context using the core and config from the current instance, returns a new instance of the same type
971
+ * @param plugins - The execution order to process the plugins, if null or not supplied
972
+ * then the current execution order will be copied.
973
+ * @param startAt - The plugin to start processing from, if missing from the execution
974
+ * order then the next plugin will be NOT set.
975
+ */
976
+ createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IBaseProcessingContext;
977
+ }
978
+
979
+ /**
980
+ * Provides data transmission capabilities
981
+ */
982
+ interface IChannelControls extends ITelemetryPlugin {
983
+ /**
984
+ * Pause sending data
985
+ */
986
+ pause?(): void;
987
+ /**
988
+ * Resume sending data
989
+ */
990
+ resume?(): void;
991
+ /**
992
+ * Tear down the plugin and remove any hooked value, the plugin should be removed so that it is no longer initialized and
993
+ * therefore could be re-initialized after being torn down. The plugin should ensure that once this has been called any further
994
+ * processTelemetry calls are ignored and it just calls the processNext() with the provided context.
995
+ * @param unloadCtx - This is the context that should be used during unloading.
996
+ * @param unloadState - The details / state of the unload process, it holds details like whether it should be unloaded synchronously or asynchronously and the reason for the unload.
997
+ * @returns boolean - true if the plugin has or will call processNext(), this for backward compatibility as previously teardown was synchronous and returned nothing.
998
+ */
999
+ teardown?: (unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState) => void | boolean;
1000
+ /**
1001
+ * Flush to send data immediately; channel should default to sending data asynchronously. If executing asynchronously and
1002
+ * you DO NOT pass a callback function then a [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html)
1003
+ * will be returned which will resolve once the flush is complete. The actual implementation of the `IPromise`
1004
+ * will be a native Promise (if supported) or the default as supplied by [ts-async library](https://github.com/nevware21/ts-async)
1005
+ * @param async - send data asynchronously when true
1006
+ * @param callBack - if specified, notify caller when send is complete, the channel should return true to indicate to the caller that it will be called.
1007
+ * If the caller doesn't return true the caller should assume that it may never be called.
1008
+ * @param sendReason - specify the reason that you are calling "flush" defaults to ManualFlush (1) if not specified
1009
+ * @returns - If a callback is provided `true` to indicate that callback will be called after the flush is complete otherwise the caller
1010
+ * should assume that any provided callback will never be called, Nothing or if occurring asynchronously a
1011
+ * [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html) which will be resolved once the unload is complete,
1012
+ * the [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html) will only be returned when no callback is provided
1013
+ * and async is true.
1014
+ */
1015
+ flush?(async: boolean, callBack?: (flushComplete?: boolean) => void, sendReason?: SendRequestReason): boolean | void | IPromise<boolean>;
1016
+ /**
1017
+ * Get offline support
1018
+ * @returns IInternalOfflineSupport
1019
+ */
1020
+ getOfflineSupport?: () => IInternalOfflineSupport;
1021
+ }
1022
+
619
1023
  /**
620
1024
  * Configuration settings for how telemetry is sent
621
1025
  * @export
@@ -936,6 +1340,237 @@ declare namespace ApplicationInsights {
936
1340
  };
937
1341
  }
938
1342
 
1343
+ /**
1344
+ * The type to identify whether the default value should be applied in preference to the provided value.
1345
+ */
1346
+ type IConfigCheckFn<V> = (value: V) => boolean;
1347
+
1348
+ /**
1349
+ * The default values with a check function
1350
+ */
1351
+ interface IConfigDefaultCheck<T, V, C = IConfiguration> {
1352
+ /**
1353
+ * Callback function to check if the user-supplied value is valid, if not the default will be applied
1354
+ */
1355
+ isVal?: IConfigCheckFn<V>;
1356
+ /**
1357
+ * Optional function to allow converting and setting of the default value
1358
+ */
1359
+ set?: IConfigSetFn<T, V>;
1360
+ /**
1361
+ * The default value to apply if the user-supplied value is not valid
1362
+ */
1363
+ v?: V | IConfigDefaults<V, T>;
1364
+ /**
1365
+ * The default fallback key if the main key is not present, this is the key value from the config
1366
+ */
1367
+ fb?: keyof T | keyof C | Array<keyof T | keyof C>;
1368
+ /**
1369
+ * Use this check to determine the default fallback, default only checked whether the property isDefined,
1370
+ * therefore `null`; `""` are considered to be valid values.
1371
+ */
1372
+ dfVal?: (value: any) => boolean;
1373
+ /**
1374
+ * Specify that any provided value should have the default value(s) merged into the value rather than
1375
+ * just using either the default of user provided values. Mergeed objects will automatically be marked
1376
+ * as referenced.
1377
+ */
1378
+ mrg?: boolean;
1379
+ /**
1380
+ * Set this field of the target as referenced, which will cause any object or array instance
1381
+ * to be updated in-place rather than being entirely replaced. All other values will continue to be replaced.
1382
+ * This is required for nested default objects to avoid multiple repetitive updates to listeners
1383
+ * @returns The referenced properties current value
1384
+ */
1385
+ ref?: boolean;
1386
+ /**
1387
+ * Set this field of the target as read-only, which will block this single named property from
1388
+ * ever being changed for the target instance.
1389
+ * This does NOT freeze or seal the instance, it just stops the direct re-assignment of the named property,
1390
+ * if the value is a non-primitive (ie. an object or array) it's properties will still be mutable.
1391
+ * @returns The referenced properties current value
1392
+ */
1393
+ rdOnly?: boolean;
1394
+ /**
1395
+ * Block the value associated with this property from having it's properties / values converted into
1396
+ * dynamic properties, this is generally used to block objects or arrays provided by external libraries
1397
+ * which may be a plain object with readonly (non-configurable) or const properties.
1398
+ */
1399
+ blkVal?: boolean;
1400
+ }
1401
+
1402
+ /**
1403
+ * The Type definition to define default values to be applied to the config
1404
+ * The value may be either the direct value or a ConfigDefaultCheck definition
1405
+ */
1406
+ type IConfigDefaults<T, C = IConfiguration> = {
1407
+ [key in keyof T]: T[key] | IConfigDefaultCheck<T, T[key], C>;
1408
+ };
1409
+
1410
+ /**
1411
+ * The type which identifies the function use to validate the user supplied value
1412
+ */
1413
+ type IConfigSetFn<T, V> = (value: any, defValue: V, theConfig: T) => V;
1414
+
1415
+ /**
1416
+ * Configuration provided to SDK core
1417
+ */
1418
+ interface IConfiguration {
1419
+ /**
1420
+ * Instrumentation key of resource. Either this or connectionString must be specified.
1421
+ */
1422
+ instrumentationKey?: string;
1423
+ /**
1424
+ * Connection string of resource. Either this or instrumentationKey must be specified.
1425
+ */
1426
+ connectionString?: string;
1427
+ /**
1428
+ * Set the timer interval (in ms) for internal logging queue, this is the
1429
+ * amount of time to wait after logger.queue messages are detected to be sent.
1430
+ * Note: since 3.0.1 and 2.8.13 the diagnostic logger timer is a normal timeout timer
1431
+ * and not an interval timer. So this now represents the timer "delay" and not
1432
+ * the frequency at which the events are sent.
1433
+ */
1434
+ diagnosticLogInterval?: number;
1435
+ /**
1436
+ * Maximum number of iKey transmitted logging telemetry per page view
1437
+ */
1438
+ maxMessageLimit?: number;
1439
+ /**
1440
+ * Console logging level. All logs with a severity level higher
1441
+ * than the configured level will be printed to console. Otherwise
1442
+ * they are suppressed. ie Level 2 will print both CRITICAL and
1443
+ * WARNING logs to console, level 1 prints only CRITICAL.
1444
+ *
1445
+ * Note: Logs sent as telemetry to instrumentation key will also
1446
+ * be logged to console if their severity meets the configured loggingConsoleLevel
1447
+ *
1448
+ * 0: ALL console logging off
1449
+ * 1: logs to console: severity >= CRITICAL
1450
+ * 2: logs to console: severity >= WARNING
1451
+ */
1452
+ loggingLevelConsole?: number;
1453
+ /**
1454
+ * Telemtry logging level to instrumentation key. All logs with a severity
1455
+ * level higher than the configured level will sent as telemetry data to
1456
+ * the configured instrumentation key.
1457
+ *
1458
+ * 0: ALL iKey logging off
1459
+ * 1: logs to iKey: severity >= CRITICAL
1460
+ * 2: logs to iKey: severity >= WARNING
1461
+ */
1462
+ loggingLevelTelemetry?: number;
1463
+ /**
1464
+ * If enabled, uncaught exceptions will be thrown to help with debugging
1465
+ */
1466
+ enableDebug?: boolean;
1467
+ /**
1468
+ * Endpoint where telemetry data is sent
1469
+ */
1470
+ endpointUrl?: string;
1471
+ /**
1472
+ * Extension configs loaded in SDK
1473
+ */
1474
+ extensionConfig?: {
1475
+ [key: string]: any;
1476
+ };
1477
+ /**
1478
+ * Additional plugins that should be loaded by core at runtime
1479
+ */
1480
+ readonly extensions?: ITelemetryPlugin[];
1481
+ /**
1482
+ * Channel queues that is setup by caller in desired order.
1483
+ * If channels are provided here, core will ignore any channels that are already setup, example if there is a SKU with an initialized channel
1484
+ */
1485
+ readonly channels?: IChannelControls[][];
1486
+ /**
1487
+ * @type {boolean}
1488
+ * Flag that disables the Instrumentation Key validation.
1489
+ */
1490
+ disableInstrumentationKeyValidation?: boolean;
1491
+ /**
1492
+ * [Optional] When enabled this will create local perfEvents based on sections of the code that have been instrumented
1493
+ * to emit perfEvents (via the doPerf()) when this is enabled. This can be used to identify performance issues within
1494
+ * the SDK, the way you are using it or optionally your own instrumented code.
1495
+ * The provided IPerfManager implementation does NOT send any additional telemetry events to the server it will only fire
1496
+ * the new perfEvent() on the INotificationManager which you can listen to.
1497
+ * This also does not use the window.performance API, so it will work in environments where this API is not supported.
1498
+ */
1499
+ enablePerfMgr?: boolean;
1500
+ /**
1501
+ * [Optional] Callback function that will be called to create a the IPerfManager instance when required and ```enablePerfMgr```
1502
+ * is enabled, this enables you to override the default creation of a PerfManager() without needing to ```setPerfMgr()```
1503
+ * after initialization.
1504
+ */
1505
+ createPerfMgr?: (core: IAppInsightsCore, notificationManager: INotificationManager) => IPerfManager;
1506
+ /**
1507
+ * [Optional] Fire every single performance event not just the top level root performance event. Defaults to false.
1508
+ */
1509
+ perfEvtsSendAll?: boolean;
1510
+ /**
1511
+ * [Optional] Identifies the default length used to generate random session and user id's if non currently exists for the user / session.
1512
+ * Defaults to 22, previous default value was 5, if you need to keep the previous maximum length you should set this value to 5.
1513
+ */
1514
+ idLength?: number;
1515
+ /**
1516
+ * @description Custom cookie domain. This is helpful if you want to share Application Insights cookies across subdomains. It
1517
+ * can be set here or as part of the cookieCfg.domain, the cookieCfg takes precedence if both are specified.
1518
+ * @type {string}
1519
+ * @defaultValue ""
1520
+ */
1521
+ cookieDomain?: string;
1522
+ /**
1523
+ * @description Custom cookie path. This is helpful if you want to share Application Insights cookies behind an application
1524
+ * gateway. It can be set here or as part of the cookieCfg.domain, the cookieCfg takes precedence if both are specified.
1525
+ * @type {string}
1526
+ * @defaultValue ""
1527
+ */
1528
+ cookiePath?: string;
1529
+ /**
1530
+ * [Optional] A boolean that indicated whether to disable the use of cookies by the SDK. If true, the SDK will not store or
1531
+ * read any data from cookies. Cookie usage can be re-enabled after initialization via the core.getCookieMgr().enable().
1532
+ */
1533
+ disableCookiesUsage?: boolean;
1534
+ /**
1535
+ * [Optional] A Cookie Manager configuration which includes hooks to allow interception of the get, set and delete cookie
1536
+ * operations. If this configuration is specified any specified enabled and domain properties will take precedence over the
1537
+ * cookieDomain and disableCookiesUsage values.
1538
+ */
1539
+ cookieCfg?: ICookieMgrConfig;
1540
+ /**
1541
+ * [Optional] An array of the page unload events that you would like to be ignored, special note there must be at least one valid unload
1542
+ * event hooked, if you list all or the runtime environment only supports a listed "disabled" event it will still be hooked, if required by the SDK.
1543
+ * Unload events include "beforeunload", "unload", "visibilitychange" (with 'hidden' state) and "pagehide"
1544
+ */
1545
+ disablePageUnloadEvents?: string[];
1546
+ /**
1547
+ * [Optional] An array of page show events that you would like to be ignored, special note there must be at lease one valid show event
1548
+ * hooked, if you list all or the runtime environment only supports a listed (disabled) event it will STILL be hooked, if required by the SDK.
1549
+ * Page Show events include "pageshow" and "visibilitychange" (with 'visible' state)
1550
+ */
1551
+ disablePageShowEvents?: string[];
1552
+ /**
1553
+ * [Optional] A flag for performance optimization to disable attempting to use the Chrome Debug Extension, if disabled and the extension is installed
1554
+ * this will not send any notifications.
1555
+ */
1556
+ disableDbgExt?: boolean;
1557
+ /**
1558
+ * Add "&w=0" parameter to support UA Parsing when web-workers don't have access to Document.
1559
+ * Default is false
1560
+ */
1561
+ enableWParam?: boolean;
1562
+ /**
1563
+ * Custom optional value that will be added as a prefix for storage name.
1564
+ * @defaultValue undefined
1565
+ */
1566
+ storagePrefix?: string;
1567
+ /**
1568
+ * Custom optional value to opt in features
1569
+ * @defaultValue undefined
1570
+ */
1571
+ featureOptIn?: IFeatureOptIn;
1572
+ }
1573
+
939
1574
  interface IContextTagKeys {
940
1575
  /**
941
1576
  * Application version. Information in the application context fields is always about the application that is sending the telemetry.
@@ -1107,30 +1742,138 @@ declare namespace ApplicationInsights {
1107
1742
  readonly internalSdkSrc: string;
1108
1743
  }
1109
1744
 
1110
- interface ICorrelationConfig {
1111
- enableCorsCorrelation: boolean;
1112
- correlationHeaderExcludedDomains: string[];
1113
- correlationHeaderExcludePatterns?: RegExp[];
1114
- disableCorrelationHeaders: boolean;
1115
- distributedTracingMode: DistributedTracingModes;
1116
- maxAjaxCallsPerView: number;
1117
- disableAjaxTracking: boolean;
1118
- disableFetchTracking: boolean;
1119
- appId?: string;
1120
- enableRequestHeaderTracking?: boolean;
1121
- enableResponseHeaderTracking?: boolean;
1122
- enableAjaxErrorStatusText?: boolean;
1745
+ interface ICookieMgr {
1123
1746
  /**
1124
- * Flag to enable looking up and including additional browser window.performance timings
1125
- * in the reported ajax (XHR and fetch) reported metrics.
1126
- * Defaults to false.
1747
+ * Enable or Disable the usage of cookies
1127
1748
  */
1128
- enableAjaxPerfTracking?: boolean;
1749
+ setEnabled(value: boolean): void;
1129
1750
  /**
1130
- * The maximum number of times to look for the window.performance timings (if available), this
1131
- * is required as not all browsers populate the window.performance before reporting the
1132
- * end of the XHR request and for fetch requests this is added after its complete
1133
- * Defaults to 3
1751
+ * Can the system use cookies, if this returns false then all cookie setting and access functions will return nothing
1752
+ */
1753
+ isEnabled(): boolean;
1754
+ /**
1755
+ * Set the named cookie with the value and optional domain and optional
1756
+ * @param name - The name of the cookie
1757
+ * @param value - The value of the cookie (Must already be encoded)
1758
+ * @param maxAgeSec - [optional] The maximum number of SECONDS that this cookie should survive
1759
+ * @param domain - [optional] The domain to set for the cookie
1760
+ * @param path - [optional] Path to set for the cookie, if not supplied will default to "/"
1761
+ * @returns - True if the cookie was set otherwise false (Because cookie usage is not enabled or available)
1762
+ */
1763
+ set(name: string, value: string, maxAgeSec?: number, domain?: string, path?: string): boolean;
1764
+ /**
1765
+ * Get the value of the named cookie
1766
+ * @param name - The name of the cookie
1767
+ */
1768
+ get(name: string): string;
1769
+ /**
1770
+ * Delete/Remove the named cookie if cookie support is available and enabled.
1771
+ * Note: Not using "delete" as the name because it's a reserved word which would cause issues on older browsers
1772
+ * @param name - The name of the cookie
1773
+ * @param path - [optional] Path to set for the cookie, if not supplied will default to "/"
1774
+ * @returns - True if the cookie was marked for deletion otherwise false (Because cookie usage is not enabled or available)
1775
+ */
1776
+ del(name: string, path?: string): boolean;
1777
+ /**
1778
+ * Purge the cookie from the system if cookie support is available, this function ignores the enabled setting of the manager
1779
+ * so any cookie will be removed.
1780
+ * Note: Not using "delete" as the name because it's a reserved word which would cause issues on older browsers
1781
+ * @param name - The name of the cookie
1782
+ * @param path - [optional] Path to set for the cookie, if not supplied will default to "/"
1783
+ * @returns - True if the cookie was marked for deletion otherwise false (Because cookie usage is not available)
1784
+ */
1785
+ purge(name: string, path?: string): boolean;
1786
+ /**
1787
+ * Optional Callback hook to allow the cookie manager to update it's configuration, not generally implemented now that
1788
+ * dynamic configuration is supported
1789
+ * @param updateState
1790
+ */
1791
+ update?(updateState: ITelemetryUpdateState): void;
1792
+ /**
1793
+ * Unload and remove any state that this ICookieMgr may be holding, this is generally called when the
1794
+ * owning SDK is being unloaded.
1795
+ * @param isAsync - Can the unload be performed asynchronously (default)
1796
+ * @return If the unload occurs synchronously then nothing should be returned, if happening asynchronously then
1797
+ * the function should return an [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html)
1798
+ * / Promise to allow any listeners to wait for the operation to complete.
1799
+ */
1800
+ unload?(isAsync?: boolean): void | IPromise<void>;
1801
+ }
1802
+
1803
+ /**
1804
+ * Configuration definition for instance based cookie management configuration
1805
+ */
1806
+ interface ICookieMgrConfig {
1807
+ /**
1808
+ * Defaults to true, A boolean that indicates whether the use of cookies by the SDK is enabled by the current instance.
1809
+ * If false, the instance of the SDK initialized by this configuration will not store or read any data from cookies
1810
+ */
1811
+ enabled?: boolean;
1812
+ /**
1813
+ * Custom cookie domain. This is helpful if you want to share Application Insights cookies across subdomains.
1814
+ */
1815
+ domain?: string;
1816
+ /**
1817
+ * Specifies the path to use for the cookie, defaults to '/'
1818
+ */
1819
+ path?: string;
1820
+ /**
1821
+ * Specify the cookie name(s) to be ignored, this will cause any matching cookie name to never be read or written.
1822
+ * They may still be explicitly purged or deleted. You do not need to repeat the name in the `blockedCookies`
1823
+ * configuration.(Since v2.8.8)
1824
+ */
1825
+ ignoreCookies?: string[];
1826
+ /**
1827
+ * Specify the cookie name(s) to never be written, this will cause any cookie name to never be created or updated,
1828
+ * they will still be read unless also included in the ignoreCookies and may still be explicitly purged or deleted.
1829
+ * If not provided defaults to the same list provided in ignoreCookies. (Since v2.8.8)
1830
+ */
1831
+ blockedCookies?: string[];
1832
+ /**
1833
+ * Hook function to fetch the named cookie value.
1834
+ * @param name - The name of the cookie
1835
+ */
1836
+ getCookie?: (name: string) => string;
1837
+ /**
1838
+ * Hook function to set the named cookie with the specified value.
1839
+ * @param name - The name of the cookie
1840
+ * @param value - The value to set for the cookie
1841
+ */
1842
+ setCookie?: (name: string, value: string) => void;
1843
+ /**
1844
+ * Hook function to delete the named cookie with the specified value, separated from
1845
+ * setCookie to avoid the need to parse the value to determine whether the cookie is being
1846
+ * added or removed.
1847
+ * @param name - The name of the cookie
1848
+ * @param cookieValue - The value to set to expire the cookie
1849
+ */
1850
+ delCookie?: (name: string, cookieValue: string) => void;
1851
+ }
1852
+
1853
+ interface ICorrelationConfig {
1854
+ enableCorsCorrelation: boolean;
1855
+ correlationHeaderExcludedDomains: string[];
1856
+ correlationHeaderExcludePatterns?: RegExp[];
1857
+ disableCorrelationHeaders: boolean;
1858
+ distributedTracingMode: DistributedTracingModes;
1859
+ maxAjaxCallsPerView: number;
1860
+ disableAjaxTracking: boolean;
1861
+ disableFetchTracking: boolean;
1862
+ appId?: string;
1863
+ enableRequestHeaderTracking?: boolean;
1864
+ enableResponseHeaderTracking?: boolean;
1865
+ enableAjaxErrorStatusText?: boolean;
1866
+ /**
1867
+ * Flag to enable looking up and including additional browser window.performance timings
1868
+ * in the reported ajax (XHR and fetch) reported metrics.
1869
+ * Defaults to false.
1870
+ */
1871
+ enableAjaxPerfTracking?: boolean;
1872
+ /**
1873
+ * The maximum number of times to look for the window.performance timings (if available), this
1874
+ * is required as not all browsers populate the window.performance before reporting the
1875
+ * end of the XHR request and for fetch requests this is added after its complete
1876
+ * Defaults to 3
1134
1877
  */
1135
1878
  maxAjaxPerfLookupAttempts?: number;
1136
1879
  /**
@@ -1164,6 +1907,10 @@ declare namespace ApplicationInsights {
1164
1907
  addIntEndpoints?: boolean;
1165
1908
  }
1166
1909
 
1910
+ interface ICustomProperties {
1911
+ [key: string]: any;
1912
+ }
1913
+
1167
1914
  /**
1168
1915
  * Metric data single measurement.
1169
1916
  */
@@ -1238,6 +1985,110 @@ declare namespace ApplicationInsights {
1238
1985
  ip: string;
1239
1986
  }
1240
1987
 
1988
+ interface IDiagnosticLogger {
1989
+ /**
1990
+ * 0: OFF
1991
+ * 1: only critical (default)
1992
+ * 2: critical + info
1993
+ */
1994
+ consoleLoggingLevel: () => number;
1995
+ /**
1996
+ * The internal logging queue
1997
+ */
1998
+ queue: _InternalLogMessage[];
1999
+ /**
2000
+ * This method will throw exceptions in debug mode or attempt to log the error as a console warning.
2001
+ * @param severity - The severity of the log message
2002
+ * @param message - The log message.
2003
+ */
2004
+ throwInternal(severity: LoggingSeverity, msgId: _InternalMessageId, msg: string, properties?: Object, isUserAct?: boolean): void;
2005
+ /**
2006
+ * This will write a debug message to the console if possible
2007
+ * @param message - {string} - The debug message
2008
+ */
2009
+ debugToConsole?(message: string): void;
2010
+ /**
2011
+ * This will write a warning to the console if possible
2012
+ * @param message - The warning message
2013
+ */
2014
+ warnToConsole(message: string): void;
2015
+ /**
2016
+ * This will write an error to the console if possible.
2017
+ * Provided by the default DiagnosticLogger instance, and internally the SDK will fall back to warnToConsole, however,
2018
+ * direct callers MUST check for its existence on the logger as you can provide your own IDiagnosticLogger instance.
2019
+ * @param message - The error message
2020
+ */
2021
+ errorToConsole?(message: string): void;
2022
+ /**
2023
+ * Resets the internal message count
2024
+ */
2025
+ resetInternalMessageCount(): void;
2026
+ /**
2027
+ * Logs a message to the internal queue.
2028
+ * @param severity - The severity of the log message
2029
+ * @param message - The message to log.
2030
+ */
2031
+ logInternalMessage?(severity: LoggingSeverity, message: _InternalLogMessage): void;
2032
+ /**
2033
+ * Optional Callback hook to allow the diagnostic logger to update it's configuration
2034
+ * @param updateState
2035
+ */
2036
+ update?(updateState: ITelemetryUpdateState): void;
2037
+ /**
2038
+ * Unload and remove any state that this IDiagnosticLogger may be holding, this is generally called when the
2039
+ * owning SDK is being unloaded.
2040
+ * @param isAsync - Can the unload be performed asynchronously (default)
2041
+ * @return If the unload occurs synchronously then nothing should be returned, if happening asynchronously then
2042
+ * the function should return an [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html)
2043
+ * / Promise to allow any listeners to wait for the operation to complete.
2044
+ */
2045
+ unload?(isAsync?: boolean): void | IPromise<void>;
2046
+ }
2047
+
2048
+ interface IDistributedTraceContext {
2049
+ /**
2050
+ * Returns the current name of the page
2051
+ */
2052
+ getName(): string;
2053
+ /**
2054
+ * Sets the current name of the page
2055
+ * @param pageName
2056
+ */
2057
+ setName(pageName: string): void;
2058
+ /**
2059
+ * Returns the unique identifier for a trace. All requests / spans from the same trace share the same traceId.
2060
+ * Must be read from incoming headers or generated according to the W3C TraceContext specification,
2061
+ * in a hex representation of 16-byte array. A.k.a. trace-id, TraceID or Distributed TraceID
2062
+ */
2063
+ getTraceId(): string;
2064
+ /**
2065
+ * Set the unique identifier for a trace. All requests / spans from the same trace share the same traceId.
2066
+ * Must be conform to the W3C TraceContext specification, in a hex representation of 16-byte array.
2067
+ * A.k.a. trace-id, TraceID or Distributed TraceID https://www.w3.org/TR/trace-context/#trace-id
2068
+ */
2069
+ setTraceId(newValue: string): void;
2070
+ /**
2071
+ * Self-generated 8-bytes identifier of the incoming request. Must be a hex representation of 8-byte array.
2072
+ * Also know as the parentId, used to link requests together
2073
+ */
2074
+ getSpanId(): string;
2075
+ /**
2076
+ * Self-generated 8-bytes identifier of the incoming request. Must be a hex representation of 8-byte array.
2077
+ * Also know as the parentId, used to link requests together
2078
+ * https://www.w3.org/TR/trace-context/#parent-id
2079
+ */
2080
+ setSpanId(newValue: string): void;
2081
+ /**
2082
+ * An integer representation of the W3C TraceContext trace-flags.
2083
+ */
2084
+ getTraceFlags(): number | undefined;
2085
+ /**
2086
+ * https://www.w3.org/TR/trace-context/#trace-flags
2087
+ * @param newValue
2088
+ */
2089
+ setTraceFlags(newValue?: number): void;
2090
+ }
2091
+
1241
2092
  /**
1242
2093
  * The abstract common base of all domains.
1243
2094
  */
@@ -1438,6 +2289,41 @@ declare namespace ApplicationInsights {
1438
2289
  severityLevel?: SeverityLevel | number;
1439
2290
  }
1440
2291
 
2292
+ interface IFeatureOptIn {
2293
+ [feature: string]: IFeatureOptInDetails;
2294
+ }
2295
+
2296
+ interface IFeatureOptInDetails {
2297
+ /**
2298
+ * sets feature opt-in mode
2299
+ * @default undefined
2300
+ */
2301
+ mode?: FeatureOptInMode;
2302
+ /**
2303
+ * Identifies configuration override values when given feature is enabled
2304
+ * NOTE: should use flat string for fields, for example, if you want to set value for extensionConfig.Ananlytics.disableAjaxTrackig in configurations,
2305
+ * you should use "extensionConfig.Ananlytics.disableAjaxTrackig" as field name: {["extensionConfig.Analytics.disableAjaxTrackig"]:1}
2306
+ * Default: undefined
2307
+ */
2308
+ onCfg?: {
2309
+ [field: string]: any;
2310
+ };
2311
+ /**
2312
+ * Identifies configuration override values when given feature is disabled
2313
+ * NOTE: should use flat string for fields, for example, if you want to set value for extensionConfig.Ananlytics.disableAjaxTrackig in configurations,
2314
+ * you should use "extensionConfig.Ananlytics.disableAjaxTrackig" as field name: {["extensionConfig.Analytics.disableAjaxTrackig"]:1}
2315
+ * Default: undefined
2316
+ */
2317
+ offCfg?: {
2318
+ [field: string]: any;
2319
+ };
2320
+ /**
2321
+ * define if should block any changes from cdn cfg, if set to true, cfgValue will be applied under all scenarios
2322
+ * @default false
2323
+ */
2324
+ blockCdnCfg?: boolean;
2325
+ }
2326
+
1441
2327
  interface IInternal {
1442
2328
  /**
1443
2329
  * The SDK version used to create this telemetry item.
@@ -1462,6 +2348,70 @@ declare namespace ApplicationInsights {
1462
2348
  sdkSrc: string;
1463
2349
  }
1464
2350
 
2351
+ /**
2352
+ * Internal Interface
2353
+ */
2354
+ interface IInternalOfflineSupport {
2355
+ /**
2356
+ * Get current endpoint url
2357
+ * @returns endpoint
2358
+ */
2359
+ getUrl: () => string;
2360
+ /**
2361
+ * Create payload data
2362
+ * @param data data
2363
+ * @returns IPayloadData
2364
+ */
2365
+ createPayload: (data: string | Uint8Array) => IPayloadData;
2366
+ /**
2367
+ * Serialize an item into a string
2368
+ * @param input telemetry item
2369
+ * @param convertUndefined convert undefined to a custom-defined object
2370
+ * @returns Serialized string
2371
+ */
2372
+ serialize?: (input: ITelemetryItem, convertUndefined?: any) => string;
2373
+ /**
2374
+ * Batch an array of strings into one string
2375
+ * @param arr array of strings
2376
+ * @returns a string represent all items in the given array
2377
+ */
2378
+ batch?: (arr: string[]) => string;
2379
+ /**
2380
+ * If the item should be processed by offline channel
2381
+ * @param evt telemetry item
2382
+ * @returns should process or not
2383
+ */
2384
+ shouldProcess?: (evt: ITelemetryItem) => boolean;
2385
+ }
2386
+
2387
+ /**
2388
+ * An alternate interface which provides automatic removal during unloading of the component
2389
+ */
2390
+ interface ILegacyUnloadHook {
2391
+ /**
2392
+ * Legacy Self remove the referenced component
2393
+ */
2394
+ remove: () => void;
2395
+ }
2396
+
2397
+ interface ILoadedPlugin<T extends IPlugin> {
2398
+ plugin: T;
2399
+ /**
2400
+ * Identifies whether the plugin is enabled and can process events. This is slightly different from isInitialized as the plugin may be initialized but disabled
2401
+ * via the setEnabled() or it may be a shared plugin which has had it's teardown function called from another instance..
2402
+ * @returns boolean = true if the plugin is in a state where it is operational.
2403
+ */
2404
+ isEnabled: () => boolean;
2405
+ /**
2406
+ * You can optionally enable / disable a plugin from processing events.
2407
+ * Setting enabled to true will not necessarily cause the `isEnabled()` to also return true
2408
+ * as the plugin must also have been successfully initialized and not had it's `teardown` method called
2409
+ * (unless it's also been re-initialized)
2410
+ */
2411
+ setEnabled: (isEnabled: boolean) => void;
2412
+ remove: (isAsync?: boolean, removeCb?: (removed?: boolean) => void) => void;
2413
+ }
2414
+
1465
2415
  interface ILocation {
1466
2416
  /**
1467
2417
  * Client IP address for reverse lookup
@@ -1563,6 +2513,105 @@ declare namespace ApplicationInsights {
1563
2513
  iKey?: string;
1564
2514
  }
1565
2515
 
2516
+ /**
2517
+ * An interface used for the notification listener.
2518
+ * @interface
2519
+ */
2520
+ interface INotificationListener {
2521
+ /**
2522
+ * [Optional] A function called when events are sent.
2523
+ * @param events - The array of events that have been sent.
2524
+ */
2525
+ eventsSent?: (events: ITelemetryItem[]) => void;
2526
+ /**
2527
+ * [Optional] A function called when events are discarded.
2528
+ * @param events - The array of events that have been discarded.
2529
+ * @param reason - The reason for discarding the events. The EventsDiscardedReason
2530
+ * constant should be used to check the different values.
2531
+ */
2532
+ eventsDiscarded?: (events: ITelemetryItem[], reason: number) => void;
2533
+ /**
2534
+ * [Optional] A function called when the events have been requested to be sent to the sever.
2535
+ * @param sendReason - The reason why the event batch is being sent.
2536
+ * @param isAsync - A flag which identifies whether the requests are being sent in an async or sync manner.
2537
+ */
2538
+ eventsSendRequest?: (sendReason: number, isAsync?: boolean) => void;
2539
+ /**
2540
+ * [Optional] This event is sent if you have enabled perf events, they are primarily used to track internal performance testing and debugging
2541
+ * the event can be displayed via the debug plugin extension.
2542
+ * @param perfEvent
2543
+ */
2544
+ perfEvent?: (perfEvent: IPerfEvent) => void;
2545
+ /**
2546
+ * Unload and remove any state that this INotificationListener may be holding, this is generally called when the
2547
+ * owning Manager is being unloaded.
2548
+ * @param isAsync - Can the unload be performed asynchronously (default)
2549
+ * @return If the unload occurs synchronously then nothing should be returned, if happening asynchronously then
2550
+ * the function should return an [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html)
2551
+ * / Promise to allow any listeners to wait for the operation to complete.
2552
+ */
2553
+ unload?(isAsync?: boolean): void | IPromise<void>;
2554
+ }
2555
+
2556
+ /**
2557
+ * Class to manage sending notifications to all the listeners.
2558
+ */
2559
+ interface INotificationManager {
2560
+ listeners: INotificationListener[];
2561
+ /**
2562
+ * Adds a notification listener.
2563
+ * @param listener - The notification listener to be added.
2564
+ */
2565
+ addNotificationListener(listener: INotificationListener): void;
2566
+ /**
2567
+ * Removes all instances of the listener.
2568
+ * @param listener - AWTNotificationListener to remove.
2569
+ */
2570
+ removeNotificationListener(listener: INotificationListener): void;
2571
+ /**
2572
+ * Notification for events sent.
2573
+ * @param events - The array of events that have been sent.
2574
+ */
2575
+ eventsSent(events: ITelemetryItem[]): void;
2576
+ /**
2577
+ * Notification for events being discarded.
2578
+ * @param events - The array of events that have been discarded by the SDK.
2579
+ * @param reason - The reason for which the SDK discarded the events. The EventsDiscardedReason
2580
+ * constant should be used to check the different values.
2581
+ */
2582
+ eventsDiscarded(events: ITelemetryItem[], reason: number): void;
2583
+ /**
2584
+ * [Optional] A function called when the events have been requested to be sent to the sever.
2585
+ * @param sendReason - The reason why the event batch is being sent.
2586
+ * @param isAsync - A flag which identifies whether the requests are being sent in an async or sync manner.
2587
+ */
2588
+ eventsSendRequest?(sendReason: number, isAsync: boolean): void;
2589
+ /**
2590
+ * [Optional] This event is sent if you have enabled perf events, they are primarily used to track internal performance testing and debugging
2591
+ * the event can be displayed via the debug plugin extension.
2592
+ * @param perfEvent - The perf event details
2593
+ */
2594
+ perfEvent?(perfEvent: IPerfEvent): void;
2595
+ /**
2596
+ * Unload and remove any state that this INotificationManager may be holding, this is generally called when the
2597
+ * owning SDK is being unloaded.
2598
+ * @param isAsync - Can the unload be performed asynchronously (default)
2599
+ * @return If the unload occurs synchronously then nothing should be returned, if happening asynchronously then
2600
+ * the function should return an [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html)
2601
+ * / Promise to allow any listeners to wait for the operation to complete.
2602
+ */
2603
+ unload?(isAsync?: boolean): void | IPromise<void>;
2604
+ }
2605
+
2606
+ class _InternalLogMessage {
2607
+ static dataType: string;
2608
+ message: string;
2609
+ messageId: _InternalMessageId;
2610
+ constructor(msgId: _InternalMessageId, msg: string, isUserAct?: boolean, properties?: Object);
2611
+ }
2612
+
2613
+ type _InternalMessageId = number | _eInternalMessageId;
2614
+
1566
2615
  interface IOfflineListener {
1567
2616
  isOnline: () => boolean;
1568
2617
  isListening: () => boolean;
@@ -1762,6 +2811,433 @@ declare namespace ApplicationInsights {
1762
2811
  };
1763
2812
  }
1764
2813
 
2814
+ /** IPayloadData describes interface of payload sent via POST channel */
2815
+ interface IPayloadData {
2816
+ urlString: string;
2817
+ data: Uint8Array | string;
2818
+ headers?: {
2819
+ [name: string]: string;
2820
+ };
2821
+ timeout?: number;
2822
+ disableXhrSync?: boolean;
2823
+ disableFetchKeepAlive?: boolean;
2824
+ sendReason?: SendRequestReason;
2825
+ }
2826
+
2827
+ /**
2828
+ * This interface identifies the details of an internal performance event - it does not represent an outgoing reported event
2829
+ */
2830
+ interface IPerfEvent {
2831
+ /**
2832
+ * The name of the performance event
2833
+ */
2834
+ name: string;
2835
+ /**
2836
+ * The start time of the performance event
2837
+ */
2838
+ start: number;
2839
+ /**
2840
+ * The payload (contents) of the perfEvent, may be null or only set after the event has completed depending on
2841
+ * the runtime environment.
2842
+ */
2843
+ payload: any;
2844
+ /**
2845
+ * Is this occurring from an asynchronous event
2846
+ */
2847
+ isAsync: boolean;
2848
+ /**
2849
+ * Identifies the total inclusive time spent for this event, including the time spent for child events,
2850
+ * this will be undefined until the event is completed
2851
+ */
2852
+ time?: number;
2853
+ /**
2854
+ * Identifies the exclusive time spent in for this event (not including child events),
2855
+ * this will be undefined until the event is completed.
2856
+ */
2857
+ exTime?: number;
2858
+ /**
2859
+ * The Parent event that was started before this event was created
2860
+ */
2861
+ parent?: IPerfEvent;
2862
+ /**
2863
+ * The child perf events that are contained within the total time of this event.
2864
+ */
2865
+ childEvts?: IPerfEvent[];
2866
+ /**
2867
+ * Identifies whether this event is a child event of a parent
2868
+ */
2869
+ isChildEvt: () => boolean;
2870
+ /**
2871
+ * Get the names additional context associated with this perf event
2872
+ */
2873
+ getCtx?: (key: string) => any;
2874
+ /**
2875
+ * Set the named additional context to be associated with this perf event, this will replace any existing value
2876
+ */
2877
+ setCtx?: (key: string, value: any) => void;
2878
+ /**
2879
+ * Mark this event as completed, calculating the total execution time.
2880
+ */
2881
+ complete: () => void;
2882
+ }
2883
+
2884
+ /**
2885
+ * This defines an internal performance manager for tracking and reporting the internal performance of the SDK -- It does
2886
+ * not represent or report any event to the server.
2887
+ */
2888
+ interface IPerfManager {
2889
+ /**
2890
+ * Create a new event and start timing, the manager may return null/undefined to indicate that it does not
2891
+ * want to monitor this source event.
2892
+ * @param src - The source name of the event
2893
+ * @param payloadDetails - An optional callback function to fetch the payload details for the event.
2894
+ * @param isAsync - Is the event occurring from a async event
2895
+ */
2896
+ create(src: string, payloadDetails?: () => any, isAsync?: boolean): IPerfEvent | null | undefined;
2897
+ /**
2898
+ * Complete the perfEvent and fire any notifications.
2899
+ * @param perfEvent - Fire the event which will also complete the passed event
2900
+ */
2901
+ fire(perfEvent: IPerfEvent): void;
2902
+ /**
2903
+ * Set an execution context value
2904
+ * @param key - The context key name
2905
+ * @param value - The value
2906
+ */
2907
+ setCtx(key: string, value: any): void;
2908
+ /**
2909
+ * Get the execution context value
2910
+ * @param key - The context key
2911
+ */
2912
+ getCtx(key: string): any;
2913
+ }
2914
+
2915
+ /**
2916
+ * Identifies an interface to a host that can provide an IPerfManager implementation
2917
+ */
2918
+ interface IPerfManagerProvider {
2919
+ /**
2920
+ * Get the current performance manager
2921
+ */
2922
+ getPerfMgr(): IPerfManager;
2923
+ /**
2924
+ * Set the current performance manager
2925
+ * @param perfMgr - The performance manager
2926
+ */
2927
+ setPerfMgr(perfMgr: IPerfManager): void;
2928
+ }
2929
+
2930
+ interface IPlugin {
2931
+ /**
2932
+ * Initialize plugin loaded by SDK
2933
+ * @param config - The config for the plugin to use
2934
+ * @param core - The current App Insights core to use for initializing this plugin instance
2935
+ * @param extensions - The complete set of extensions to be used for initializing the plugin
2936
+ * @param pluginChain - [Optional] specifies the current plugin chain which identifies the
2937
+ * set of plugins and the order they should be executed for the current request.
2938
+ */
2939
+ initialize: (config: IConfiguration, core: IAppInsightsCore, extensions: IPlugin[], pluginChain?: ITelemetryPluginChain) => void;
2940
+ /**
2941
+ * Returns a value that indicates whether the plugin has already been previously initialized.
2942
+ * New plugins should implement this method to avoid being initialized more than once.
2943
+ */
2944
+ isInitialized?: () => boolean;
2945
+ /**
2946
+ * Tear down the plugin and remove any hooked value, the plugin should be removed so that it is no longer initialized and
2947
+ * therefore could be re-initialized after being torn down. The plugin should ensure that once this has been called any further
2948
+ * processTelemetry calls are ignored and it just calls the processNext() with the provided context.
2949
+ * @param unloadCtx - This is the context that should be used during unloading.
2950
+ * @param unloadState - The details / state of the unload process, it holds details like whether it should be unloaded synchronously or asynchronously and the reason for the unload.
2951
+ * @returns boolean - true if the plugin has or will call processNext(), this for backward compatibility as previously teardown was synchronous and returned nothing.
2952
+ */
2953
+ teardown?: (unloadCtx: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState) => void | boolean;
2954
+ /**
2955
+ * Extension name
2956
+ */
2957
+ readonly identifier: string;
2958
+ /**
2959
+ * Plugin version (available in data.properties.version in common schema)
2960
+ */
2961
+ readonly version?: string;
2962
+ /**
2963
+ * The App Insights core to use for backward compatibility.
2964
+ * Therefore the interface will be able to access the core without needing to cast to "any".
2965
+ * [optional] any 3rd party plugins which are already implementing this interface don't fail to compile.
2966
+ */
2967
+ core?: IAppInsightsCore;
2968
+ }
2969
+
2970
+ /**
2971
+ * The current context for the current call to processTelemetry(), used to support sharing the same plugin instance
2972
+ * between multiple AppInsights instances
2973
+ */
2974
+ interface IProcessTelemetryContext extends IBaseProcessingContext {
2975
+ /**
2976
+ * Call back for telemetry processing before it it is sent
2977
+ * @param env - This is the current event being reported
2978
+ * @returns boolean (true) if there is no more plugins to process otherwise false or undefined (void)
2979
+ */
2980
+ processNext: (env: ITelemetryItem) => boolean | void;
2981
+ /**
2982
+ * Create a new context using the core and config from the current instance, returns a new instance of the same type
2983
+ * @param plugins - The execution order to process the plugins, if null or not supplied
2984
+ * then the current execution order will be copied.
2985
+ * @param startAt - The plugin to start processing from, if missing from the execution
2986
+ * order then the next plugin will be NOT set.
2987
+ */
2988
+ createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryContext;
2989
+ }
2990
+
2991
+ /**
2992
+ * The current context for the current call to teardown() implementations, used to support when plugins are being removed
2993
+ * or the SDK is being unloaded.
2994
+ */
2995
+ interface IProcessTelemetryUnloadContext extends IBaseProcessingContext {
2996
+ /**
2997
+ * This Plugin has finished unloading, so unload the next one
2998
+ * @param uploadState - The state of the unload process
2999
+ * @returns boolean (true) if there is no more plugins to process otherwise false or undefined (void)
3000
+ */
3001
+ processNext: (unloadState: ITelemetryUnloadState) => boolean | void;
3002
+ /**
3003
+ * Create a new context using the core and config from the current instance, returns a new instance of the same type
3004
+ * @param plugins - The execution order to process the plugins, if null or not supplied
3005
+ * then the current execution order will be copied.
3006
+ * @param startAt - The plugin to start processing from, if missing from the execution
3007
+ * order then the next plugin will be NOT set.
3008
+ */
3009
+ createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryUnloadContext;
3010
+ }
3011
+
3012
+ /**
3013
+ * The current context for the current call to the plugin update() implementations, used to support the notifications
3014
+ * for when plugins are added, removed or the configuration was changed.
3015
+ */
3016
+ interface IProcessTelemetryUpdateContext extends IBaseProcessingContext {
3017
+ /**
3018
+ * This Plugin has finished unloading, so unload the next one
3019
+ * @param updateState - The update State
3020
+ * @returns boolean (true) if there is no more plugins to process otherwise false or undefined (void)
3021
+ */
3022
+ processNext: (updateState: ITelemetryUpdateState) => boolean | void;
3023
+ /**
3024
+ * Create a new context using the core and config from the current instance, returns a new instance of the same type
3025
+ * @param plugins - The execution order to process the plugins, if null or not supplied
3026
+ * then the current execution order will be copied.
3027
+ * @param startAt - The plugin to start processing from, if missing from the execution
3028
+ * order then the next plugin will be NOT set.
3029
+ */
3030
+ createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryUpdateContext;
3031
+ }
3032
+
3033
+ /**
3034
+ * Create a Promise object that represents the eventual completion (or failure) of an asynchronous operation and its resulting value.
3035
+ * This interface definition, closely mirrors the typescript / javascript PromiseLike<T> and Promise<T> definitions as well as providing
3036
+ * simular functions as that provided by jQuery deferred objects.
3037
+ *
3038
+ * The returned Promise is a proxy for a value not necessarily known when the promise is created. It allows you to associate handlers
3039
+ * with an asynchronous action's eventual success value or failure reason. This lets asynchronous methods return values like synchronous
3040
+ * methods: instead of immediately returning the final value, the asynchronous method returns a promise to supply the value at some point
3041
+ * in the future.
3042
+ *
3043
+ * A Promise is in one of these states:
3044
+ * <ul>
3045
+ * <li> pending: initial state, neither fulfilled nor rejected.
3046
+ * <li> fulfilled: meaning that the operation was completed successfully.
3047
+ * <li> rejected: meaning that the operation failed.
3048
+ * </ul>
3049
+ *
3050
+ * A pending promise can either be fulfilled with a value or rejected with a reason (error). When either of these options happens, the
3051
+ * associated handlers queued up by a promise's then method are called synchronously. If the promise has already been fulfilled or rejected
3052
+ * when a corresponding handler is attached, the handler will be called synchronously, so there is no race condition between an asynchronous
3053
+ * operation completing and its handlers being attached.
3054
+ *
3055
+ * As the `then()` and `catch()` methods return promises, they can be chained.
3056
+ * @typeParam T - Identifies the expected return type from the promise
3057
+ */
3058
+ interface IPromise<T> extends PromiseLike<T>, Promise<T> {
3059
+ /**
3060
+ * Returns a string representation of the current state of the promise. The promise can be in one of four states.
3061
+ * <ul>
3062
+ * <li> <b>"pending"</b>: The promise is not yet in a completed state (neither "rejected"; or "resolved").</li>
3063
+ * <li> <b>"resolved"</b>: The promise is in the resolved state.</li>
3064
+ * <li> <b>"rejected"</b>: The promise is in the rejected state.</li>
3065
+ * </ul>
3066
+ * @example
3067
+ * ```ts
3068
+ * let doResolve;
3069
+ * let promise: IPromise<any> = createSyncPromise((resolve) => {
3070
+ * doResolve = resolve;
3071
+ * });
3072
+ *
3073
+ * let state: string = promise.state();
3074
+ * console.log("State: " + state); // State: pending
3075
+ * doResolve(true); // Promise will resolve synchronously as it's a synchronous promise
3076
+ * console.log("State: " + state); // State: resolved
3077
+ * ```
3078
+ */
3079
+ state?: string;
3080
+ /**
3081
+ * Attaches callbacks for the resolution and/or rejection of the Promise.
3082
+ * @param onResolved The callback to execute when the Promise is resolved.
3083
+ * @param onRejected The callback to execute when the Promise is rejected.
3084
+ * @returns A Promise for the completion of which ever callback is executed.
3085
+ * @example
3086
+ * ```ts
3087
+ * const promise1 = createPromise((resolve, reject) => {
3088
+ * resolve('Success!');
3089
+ * });
3090
+ *
3091
+ * promise1.then((value) => {
3092
+ * console.log(value);
3093
+ * // expected output: "Success!"
3094
+ * });
3095
+ * ```
3096
+ */
3097
+ then<TResult1 = T, TResult2 = never>(onResolved?: ResolvedPromiseHandler<T, TResult1>, onRejected?: RejectedPromiseHandler<TResult2>): IPromise<TResult1 | TResult2>;
3098
+ /**
3099
+ * Attaches callbacks for the resolution and/or rejection of the Promise.
3100
+ * @param onResolved The callback to execute when the Promise is resolved.
3101
+ * @param onRejected The callback to execute when the Promise is rejected.
3102
+ * @returns A Promise for the completion of which ever callback is executed.
3103
+ * @example
3104
+ * ```ts
3105
+ * const promise1 = createPromise((resolve, reject) => {
3106
+ * resolve('Success!');
3107
+ * });
3108
+ *
3109
+ * promise1.then((value) => {
3110
+ * console.log(value);
3111
+ * // expected output: "Success!"
3112
+ * });
3113
+ * ```
3114
+ */
3115
+ then<TResult1 = T, TResult2 = never>(onResolved?: ResolvedPromiseHandler<T, TResult1>, onRejected?: RejectedPromiseHandler<TResult2>): PromiseLike<TResult1 | TResult2>;
3116
+ /**
3117
+ * Attaches callbacks for the resolution and/or rejection of the Promise.
3118
+ * @param onResolved The callback to execute when the Promise is resolved.
3119
+ * @param onRejected The callback to execute when the Promise is rejected.
3120
+ * @returns A Promise for the completion of which ever callback is executed.
3121
+ * @example
3122
+ * ```ts
3123
+ * const promise1 = createPromise((resolve, reject) => {
3124
+ * resolve('Success!');
3125
+ * });
3126
+ *
3127
+ * promise1.then((value) => {
3128
+ * console.log(value);
3129
+ * // expected output: "Success!"
3130
+ * });
3131
+ * ```
3132
+ */
3133
+ then<TResult1 = T, TResult2 = never>(onResolved?: ResolvedPromiseHandler<T, TResult1>, onRejected?: RejectedPromiseHandler<TResult2>): Promise<TResult1 | TResult2>;
3134
+ /**
3135
+ * Attaches a callback for only the rejection of the Promise.
3136
+ * @param onRejected The callback to execute when the Promise is rejected.
3137
+ * @returns A Promise for the completion of the callback.
3138
+ * @example
3139
+ * ```ts
3140
+ * const promise1 = createPromise((resolve, reject) => {
3141
+ * throw 'Uh-oh!';
3142
+ * });
3143
+ *
3144
+ * promise1.catch((error) => {
3145
+ * console.error(error);
3146
+ * });
3147
+ * // expected output: Uh-oh!
3148
+ * ```
3149
+ */
3150
+ catch<TResult = never>(onRejected?: ((reason: any) => TResult | IPromise<TResult>) | undefined | null): IPromise<T | TResult>;
3151
+ /**
3152
+ * Attaches a callback for only the rejection of the Promise.
3153
+ * @param onRejected The callback to execute when the Promise is rejected.
3154
+ * @returns A Promise for the completion of the callback.
3155
+ * @example
3156
+ * ```ts
3157
+ * const promise1 = createPromise((resolve, reject) => {
3158
+ * throw 'Uh-oh!';
3159
+ * });
3160
+ *
3161
+ * promise1.catch((error) => {
3162
+ * console.error(error);
3163
+ * });
3164
+ * // expected output: Uh-oh!
3165
+ * ```
3166
+ */
3167
+ catch<TResult = never>(onRejected?: ((reason: any) => TResult | IPromise<TResult>) | undefined | null): PromiseLike<T | TResult>;
3168
+ /**
3169
+ * Attaches a callback for only the rejection of the Promise.
3170
+ * @param onRejected The callback to execute when the Promise is rejected.
3171
+ * @returns A Promise for the completion of the callback.
3172
+ * @example
3173
+ * ```ts
3174
+ * const promise1 = createPromise((resolve, reject) => {
3175
+ * throw 'Uh-oh!';
3176
+ * });
3177
+ *
3178
+ * promise1.catch((error) => {
3179
+ * console.error(error);
3180
+ * });
3181
+ * // expected output: Uh-oh!
3182
+ * ```
3183
+ */
3184
+ catch<TResult = never>(onRejected?: ((reason: any) => TResult | IPromise<TResult>) | undefined | null): Promise<T | TResult>;
3185
+ /**
3186
+ * Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The
3187
+ * resolved value cannot be modified from the callback.
3188
+ * @param onfinally The callback to execute when the Promise is settled (fulfilled or rejected).
3189
+ * @returns A Promise for the completion of the callback.
3190
+ * @example
3191
+ * ```ts
3192
+ * function doFunction() {
3193
+ * return createPromise((resolve, reject) => {
3194
+ * if (Math.random() > 0.5) {
3195
+ * resolve('Function has completed');
3196
+ * } else {
3197
+ * reject(new Error('Function failed to process'));
3198
+ * }
3199
+ * });
3200
+ * }
3201
+ *
3202
+ * doFunction().then((data) => {
3203
+ * console.log(data);
3204
+ * }).catch((err) => {
3205
+ * console.error(err);
3206
+ * }).finally(() => {
3207
+ * console.log('Function processing completed');
3208
+ * });
3209
+ * ```
3210
+ */
3211
+ finally(onfinally?: FinallyPromiseHandler): IPromise<T>;
3212
+ /**
3213
+ * Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The
3214
+ * resolved value cannot be modified from the callback.
3215
+ * @param onfinally The callback to execute when the Promise is settled (fulfilled or rejected).
3216
+ * @returns A Promise for the completion of the callback.
3217
+ * @example
3218
+ * ```ts
3219
+ * function doFunction() {
3220
+ * return createPromise((resolve, reject) => {
3221
+ * if (Math.random() > 0.5) {
3222
+ * resolve('Function has completed');
3223
+ * } else {
3224
+ * reject(new Error('Function failed to process'));
3225
+ * }
3226
+ * });
3227
+ * }
3228
+ *
3229
+ * doFunction().then((data) => {
3230
+ * console.log(data);
3231
+ * }).catch((err) => {
3232
+ * console.error(err);
3233
+ * }).finally(() => {
3234
+ * console.log('Function processing completed');
3235
+ * });
3236
+ * ```
3237
+ */
3238
+ finally(onFinally?: FinallyPromiseHandler): Promise<T>;
3239
+ }
3240
+
1765
3241
  interface IPropertiesPlugin {
1766
3242
  readonly context: ITelemetryContext;
1767
3243
  }
@@ -1869,7 +3345,14 @@ declare namespace ApplicationInsights {
1869
3345
  isSampledIn(envelope: ITelemetryItem): boolean;
1870
3346
  }
1871
3347
 
1872
-
3348
+ /**
3349
+ * Checks if HTML5 Beacons are supported in the current environment.
3350
+ * @param useCached - [Optional] used for testing to bypass the cached lookup, when `true` this will
3351
+ * cause the cached global to be reset.
3352
+ * @returns True if supported, false otherwise.
3353
+ */
3354
+ function isBeaconApiSupported(useCached?: boolean): boolean;
3355
+
1873
3356
  function isCrossOriginError(message: string | Event, url: string, lineNumber: number, columnNumber: number, error: Error | Event): boolean;
1874
3357
 
1875
3358
  interface ISerializable {
@@ -1923,7 +3406,13 @@ declare namespace ApplicationInsights {
1923
3406
 
1924
3407
  function isInternalApplicationInsightsEndpoint(endpointUrl: string): boolean;
1925
3408
 
1926
-
3409
+ /**
3410
+ * Is the parsed traceParent indicating that the trace is currently sampled.
3411
+ * @param value - The parsed traceParent value
3412
+ * @returns
3413
+ */
3414
+ function isSampledFlag(value: ITraceParent): boolean;
3415
+
1927
3416
  interface IStackDetails {
1928
3417
  src: string;
1929
3418
  obj: string[];
@@ -1972,9 +3461,31 @@ declare namespace ApplicationInsights {
1972
3461
  setItem(logger: IDiagnosticLogger, name: string, data: string): boolean;
1973
3462
  }
1974
3463
 
1975
-
1976
-
1977
-
3464
+ /**
3465
+ * Is the provided W3c span id (aka. parent id) a valid string representation, it must be a 16-character
3466
+ * string of lowercase hexadecimal characters, for example, 00f067aa0ba902b7.
3467
+ * If all characters are zero (0000000000000000) this is considered an invalid value.
3468
+ * @param value - The W3c span id to be validated
3469
+ * @returns true if valid otherwise false
3470
+ */
3471
+ function isValidSpanId(value: string): boolean;
3472
+
3473
+ /**
3474
+ * Is the provided W3c Trace Id a valid string representation, it must be a 32-character string
3475
+ * of lowercase hexadecimal characters for example, 4bf92f3577b34da6a3ce929d0e0e4736.
3476
+ * If all characters as zero (00000000000000000000000000000000) it will be considered an invalid value.
3477
+ * @param value - The W3c trace Id to be validated
3478
+ * @returns true if valid otherwise false
3479
+ */
3480
+ function isValidTraceId(value: string): boolean;
3481
+
3482
+ /**
3483
+ * Validates that the provided ITraceParent instance conforms to the currently supported specifications
3484
+ * @param value
3485
+ * @returns
3486
+ */
3487
+ function isValidTraceParent(value: ITraceParent): boolean;
3488
+
1978
3489
  interface ITelemetryContext {
1979
3490
  /**
1980
3491
  * The object describing a component tracked by this object.
@@ -2026,6 +3537,113 @@ declare namespace ApplicationInsights {
2026
3537
  getSessionId: () => string;
2027
3538
  }
2028
3539
 
3540
+ interface ITelemetryInitializerHandler extends ILegacyUnloadHook {
3541
+ remove(): void;
3542
+ }
3543
+
3544
+ /**
3545
+ * Telemety item supported in Core
3546
+ */
3547
+ interface ITelemetryItem {
3548
+ /**
3549
+ * CommonSchema Version of this SDK
3550
+ */
3551
+ ver?: string;
3552
+ /**
3553
+ * Unique name of the telemetry item
3554
+ */
3555
+ name: string;
3556
+ /**
3557
+ * Timestamp when item was sent
3558
+ */
3559
+ time?: string;
3560
+ /**
3561
+ * Identifier of the resource that uniquely identifies which resource data is sent to
3562
+ */
3563
+ iKey?: string;
3564
+ /**
3565
+ * System context properties of the telemetry item, example: ip address, city etc
3566
+ */
3567
+ ext?: {
3568
+ [key: string]: any;
3569
+ };
3570
+ /**
3571
+ * System context property extensions that are not global (not in ctx)
3572
+ */
3573
+ tags?: Tags;
3574
+ /**
3575
+ * Custom data
3576
+ */
3577
+ data?: ICustomProperties;
3578
+ /**
3579
+ * Telemetry type used for part B
3580
+ */
3581
+ baseType?: string;
3582
+ /**
3583
+ * Based on schema for part B
3584
+ */
3585
+ baseData?: {
3586
+ [key: string]: any;
3587
+ };
3588
+ }
3589
+
3590
+ /**
3591
+ * Configuration provided to SDK core
3592
+ */
3593
+ interface ITelemetryPlugin extends ITelemetryProcessor, IPlugin {
3594
+ /**
3595
+ * Set next extension for telemetry processing, this is not optional as plugins should use the
3596
+ * processNext() function of the passed IProcessTelemetryContext instead. It is being kept for
3597
+ * now for backward compatibility only.
3598
+ */
3599
+ setNextPlugin?: (next: ITelemetryPlugin | ITelemetryPluginChain) => void;
3600
+ /**
3601
+ * Priority of the extension
3602
+ */
3603
+ readonly priority: number;
3604
+ }
3605
+
3606
+ /**
3607
+ * Configuration provided to SDK core
3608
+ */
3609
+ interface ITelemetryPluginChain extends ITelemetryProcessor {
3610
+ /**
3611
+ * Returns the underlying plugin that is being proxied for the processTelemetry call
3612
+ */
3613
+ getPlugin: () => ITelemetryPlugin;
3614
+ /**
3615
+ * Returns the next plugin
3616
+ */
3617
+ getNext: () => ITelemetryPluginChain;
3618
+ /**
3619
+ * This plugin is being unloaded and should remove any hooked events and cleanup any global/scoped values, after this
3620
+ * call the plugin will be removed from the telemetry processing chain and will no longer receive any events..
3621
+ * @param unloadCtx - The unload context to use for this call.
3622
+ * @param unloadState - The details of the unload operation
3623
+ */
3624
+ unload?: (unloadCtx: IProcessTelemetryUnloadContext, unloadState: ITelemetryUnloadState) => void;
3625
+ }
3626
+
3627
+ interface ITelemetryProcessor {
3628
+ /**
3629
+ * Call back for telemetry processing before it it is sent
3630
+ * @param env - This is the current event being reported
3631
+ * @param itemCtx - This is the context for the current request, ITelemetryPlugin instances
3632
+ * can optionally use this to access the current core instance or define / pass additional information
3633
+ * to later plugins (vs appending items to the telemetry item)
3634
+ */
3635
+ processTelemetry: (env: ITelemetryItem, itemCtx?: IProcessTelemetryContext) => void;
3636
+ /**
3637
+ * The the plugin should re-evaluate configuration and update any cached configuration settings or
3638
+ * plugins. If implemented this method will be called whenever a plugin is added or removed and if
3639
+ * the configuration has bee updated.
3640
+ * @param updateCtx - This is the context that should be used during updating.
3641
+ * @param updateState - The details / state of the update process, it holds details like the current and previous configuration.
3642
+ * @returns boolean - true if the plugin has or will call updateCtx.processNext(), this allows the plugin to perform any asynchronous operations.
3643
+ */
3644
+ update?: (updateCtx: IProcessTelemetryUpdateContext, updateState: ITelemetryUpdateState) => void | boolean;
3645
+ }
3646
+
2029
3647
  interface ITelemetryTrace {
2030
3648
  /**
2031
3649
  * Trace id
@@ -2050,6 +3668,43 @@ declare namespace ApplicationInsights {
2050
3668
  name?: string;
2051
3669
  }
2052
3670
 
3671
+ interface ITelemetryUnloadState {
3672
+ reason: TelemetryUnloadReason;
3673
+ isAsync: boolean;
3674
+ flushComplete?: boolean;
3675
+ }
3676
+
3677
+ interface ITelemetryUpdateState {
3678
+ /**
3679
+ * Identifies the reason for the update notification, this is a bitwise numeric value
3680
+ */
3681
+ reason: TelemetryUpdateReason;
3682
+ /**
3683
+ * This is a new active configuration that should be used
3684
+ */
3685
+ cfg?: IConfiguration;
3686
+ /**
3687
+ * The detected changes
3688
+ */
3689
+ oldCfg?: IConfiguration;
3690
+ /**
3691
+ * If this is a configuration update this was the previous configuration that was used
3692
+ */
3693
+ newConfig?: IConfiguration;
3694
+ /**
3695
+ * Was the new config requested to be merged with the existing config
3696
+ */
3697
+ merge?: boolean;
3698
+ /**
3699
+ * This holds a collection of plugins that have been added (if the reason identifies that one or more plugins have been added)
3700
+ */
3701
+ added?: IPlugin[];
3702
+ /**
3703
+ * This holds a collection of plugins that have been removed (if the reason identifies that one or more plugins have been removed)
3704
+ */
3705
+ removed?: IPlugin[];
3706
+ }
3707
+
2053
3708
  /**
2054
3709
  * Identifies frequency of items sent
2055
3710
  * Default: send data on 28th every 3 month each year
@@ -2145,7 +3800,153 @@ declare namespace ApplicationInsights {
2145
3800
  throttleNum: number;
2146
3801
  }
2147
3802
 
2148
-
3803
+ /**
3804
+ * A Timer handler which is returned from {@link scheduleTimeout} which contains functions to
3805
+ * cancel or restart (refresh) the timeout function.
3806
+ *
3807
+ * @since 0.4.4
3808
+ * @group Timer
3809
+ */
3810
+ interface ITimerHandler {
3811
+ /**
3812
+ * Cancels a timeout that was previously scheduled, after calling this function any previously
3813
+ * scheduled timer will not execute.
3814
+ * @example
3815
+ * ```ts
3816
+ * let theTimer = scheduleTimeout(...);
3817
+ * theTimer.cancel();
3818
+ * ```
3819
+ */
3820
+ cancel(): void;
3821
+ /**
3822
+ * Reschedules the timer to call its callback at the previously specified duration
3823
+ * adjusted to the current time. This is useful for refreshing a timer without allocating
3824
+ * a new JavaScript object.
3825
+ *
3826
+ * Using this on a timer that has already called its callback will reactivate the timer.
3827
+ * Calling on a timer that has not yet executed will just reschedule the current timer.
3828
+ * @example
3829
+ * ```ts
3830
+ * let theTimer = scheduleTimeout(...);
3831
+ * // The timer will be restarted (if already executed) or rescheduled (if it has not yet executed)
3832
+ * theTimer.refresh();
3833
+ * ```
3834
+ */
3835
+ refresh(): ITimerHandler;
3836
+ /**
3837
+ * When called, requests that the event loop not exit so long when the ITimerHandler is active.
3838
+ * Calling timer.ref() multiple times will have no effect. By default, all ITimerHandler objects
3839
+ * will create "ref'ed" instances, making it normally unnecessary to call timer.ref() unless
3840
+ * timer.unref() had been called previously.
3841
+ * @since 0.7.0
3842
+ * @returns the ITimerHandler instance
3843
+ * @example
3844
+ * ```ts
3845
+ * let theTimer = createTimeout(...);
3846
+ *
3847
+ * // Make sure the timer is referenced (the default) so that the runtime (Node) does not terminate
3848
+ * // if there is a waiting referenced timer.
3849
+ * theTimer.ref();
3850
+ * ```
3851
+ */
3852
+ ref(): this;
3853
+ /**
3854
+ * When called, the any active ITimerHandler instance will not require the event loop to remain
3855
+ * active (Node.js). If there is no other activity keeping the event loop running, the process may
3856
+ * exit before the ITimerHandler instance callback is invoked. Calling timer.unref() multiple times
3857
+ * will have no effect.
3858
+ * @since 0.7.0
3859
+ * @returns the ITimerHandler instance
3860
+ * @example
3861
+ * ```ts
3862
+ * let theTimer = createTimeout(...);
3863
+ *
3864
+ * // Unreference the timer so that the runtime (Node) may terminate if nothing else is running.
3865
+ * theTimer.unref();
3866
+ * ```
3867
+ */
3868
+ unref(): this;
3869
+ /**
3870
+ * If true, any running referenced `ITimerHandler` instance will keep the Node.js event loop active.
3871
+ * @since 0.7.0
3872
+ * @example
3873
+ * ```ts
3874
+ * let theTimer = createTimeout(...);
3875
+ *
3876
+ * // Unreference the timer so that the runtime (Node) may terminate if nothing else is running.
3877
+ * theTimer.unref();
3878
+ * let hasRef = theTimer.hasRef(); // false
3879
+ *
3880
+ * theTimer.ref();
3881
+ * hasRef = theTimer.hasRef(); // true
3882
+ * ```
3883
+ */
3884
+ hasRef(): boolean;
3885
+ /**
3886
+ * Gets or Sets a flag indicating if the underlying timer is currently enabled and running.
3887
+ * Setting the enabled flag to the same as it's current value has no effect, setting to `true`
3888
+ * when already `true` will not {@link ITimerHandler.refresh | refresh}() the timer.
3889
+ * And setting to 'false` will {@link ITimerHandler.cancel | cancel}() the timer.
3890
+ * @since 0.8.1
3891
+ * @example
3892
+ * ```ts
3893
+ * let theTimer = createTimeout(...);
3894
+ *
3895
+ * // Check if enabled
3896
+ * theTimer.enabled; // false
3897
+ *
3898
+ * // Start the timer
3899
+ * theTimer.enabled = true; // Same as calling refresh()
3900
+ * theTimer.enabled; //true
3901
+ *
3902
+ * // Has no effect as it's already running
3903
+ * theTimer.enabled = true;
3904
+ *
3905
+ * // Will refresh / restart the time
3906
+ * theTimer.refresh()
3907
+ *
3908
+ * let theTimer = scheduleTimeout(...);
3909
+ *
3910
+ * // Check if enabled
3911
+ * theTimer.enabled; // true
3912
+ * ```
3913
+ */
3914
+ enabled: boolean;
3915
+ }
3916
+
3917
+ /**
3918
+ * This interface represents the components of a W3C traceparent header
3919
+ */
3920
+ interface ITraceParent {
3921
+ /**
3922
+ * The version of the definition, this MUST be a string with a length of 2 and only contain lowercase
3923
+ * hexadecimal characters. A value of 'ff' is considered to be an invalid version.
3924
+ */
3925
+ version: string;
3926
+ /**
3927
+ * This is the ID of the whole trace forest and is used to uniquely identify a distributed trace
3928
+ * through a system. It is represented as a 32-character string of lowercase hexadecimal characters,
3929
+ * for example, 4bf92f3577b34da6a3ce929d0e0e4736.
3930
+ * All characters as zero (00000000000000000000000000000000) is considered an invalid value.
3931
+ */
3932
+ traceId: string;
3933
+ /**
3934
+ * This is the ID of the current request as known by the caller (in some tracing systems, this is also
3935
+ * known as the parent-id, where a span is the execution of a client request). It is represented as an
3936
+ * 16-character string of lowercase hexadecimal characters, for example, 00f067aa0ba902b7.
3937
+ * All bytes as zero (0000000000000000) is considered an invalid value.
3938
+ */
3939
+ spanId: string;
3940
+ /**
3941
+ * An 8-bit value of flags that controls tracing such as sampling, trace level, etc. These flags are
3942
+ * recommendations given by the caller rather than strict rules to follow.
3943
+ * As this is a bit field, you cannot interpret flags by decoding the hex value and looking at the resulting
3944
+ * number. For example, a flag 00000001 could be encoded as 01 in hex, or 09 in hex if present with the flag
3945
+ * 00001000. A common mistake in bit fields is forgetting to mask when interpreting flags.
3946
+ */
3947
+ traceFlags: number;
3948
+ }
3949
+
2149
3950
  interface ITraceState {
2150
3951
  }
2151
3952
 
@@ -2170,6 +3971,16 @@ declare namespace ApplicationInsights {
2170
3971
  iKey?: string;
2171
3972
  }
2172
3973
 
3974
+ /**
3975
+ * An interface which provides automatic removal during unloading of the component
3976
+ */
3977
+ interface IUnloadHook {
3978
+ /**
3979
+ * Self remove the referenced component
3980
+ */
3981
+ rm: () => void;
3982
+ }
3983
+
2173
3984
  interface IUser {
2174
3985
  /**
2175
3986
  * The telemetry configuration.
@@ -2211,6 +4022,40 @@ declare namespace ApplicationInsights {
2211
4022
  update(userId?: string): void;
2212
4023
  }
2213
4024
 
4025
+ interface IWatchDetails<T = IConfiguration> {
4026
+ /**
4027
+ * The current config object
4028
+ */
4029
+ cfg: T;
4030
+ /**
4031
+ * Set the value against the provided config/name with the value, the property
4032
+ * will be converted to be dynamic (if not already) as long as the provided config
4033
+ * is already a tracked dynamic object.
4034
+ * @throws TypeError if the provided config is not a monitored dynamic config
4035
+ */
4036
+ set: <C, V>(theConfig: C, name: string, value: V) => V;
4037
+ /**
4038
+ * Set default values for the config if not present.
4039
+ * @param theConfig - The configuration object to set default on (if missing)
4040
+ * @param defaultValues - The default values to apply to the config
4041
+ */
4042
+ setDf: <C>(theConfig: C, defaultValues: IConfigDefaults<C>) => C;
4043
+ /**
4044
+ * Set this named property of the target as referenced, which will cause any object or array instance
4045
+ * to be updated in-place rather than being entirely replaced. All other values will continue to be replaced.
4046
+ * @returns The referenced properties current value
4047
+ */
4048
+ ref: <C, V = any>(target: C, name: string) => V;
4049
+ /**
4050
+ * Set this named property of the target as read-only, which will block this single named property from
4051
+ * ever being changed for the target instance.
4052
+ * This does NOT freeze or seal the instance, it just stops the direct re-assignment of the named property,
4053
+ * if the value is a non-primitive (ie. an object or array) it's properties will still be mutable.
4054
+ * @returns The referenced properties current value
4055
+ */
4056
+ rdOnly: <C, V = any>(target: C, name: string) => V;
4057
+ }
4058
+
2214
4059
  interface IWeb {
2215
4060
  /**
2216
4061
  * Browser name, set at ingestion
@@ -2242,6 +4087,10 @@ declare namespace ApplicationInsights {
2242
4087
  domain: string;
2243
4088
  }
2244
4089
 
4090
+ const LoggingSeverity: EnumValue<typeof eLoggingSeverity>;
4091
+
4092
+ type LoggingSeverity = number | eLoggingSeverity;
4093
+
2245
4094
  class Metric implements IMetricData, ISerializable {
2246
4095
  static envelopeType: string;
2247
4096
  static dataType: string;
@@ -2411,11 +4260,26 @@ declare namespace ApplicationInsights {
2411
4260
 
2412
4261
  function parseConnectionString(connectionString?: string): ConnectionString;
2413
4262
 
2414
-
4263
+ /**
4264
+ * Attempt to parse the provided string as a W3C TraceParent header value (https://www.w3.org/TR/trace-context/#traceparent-header)
4265
+ *
4266
+ * @param value - The value to be parsed
4267
+ * @param selectIdx - If the found value is comma separated which is the preferred entry to select, defaults to the first
4268
+ * @returns
4269
+ */
4270
+ function parseTraceParent(value: string, selectIdx?: number): ITraceParent;
4271
+
2415
4272
  const ProcessLegacy = "ProcessLegacy";
2416
4273
 
2417
4274
  const PropertiesPluginIdentifier = "AppInsightsPropertiesPlugin";
2418
4275
 
4276
+ /**
4277
+ * This defines the handler function for when a promise is rejected.
4278
+ * @param value This is the value passed as part of resolving the Promise
4279
+ * @return This may return a value, another Promise or void. @see {@link IPromise.then} for how the value is handled.
4280
+ */
4281
+ type RejectedPromiseHandler<T = never> = (((reason: any) => T | IPromise<T> | PromiseLike<T>) | undefined | null);
4282
+
2419
4283
  class RemoteDependencyData implements IRemoteDependencyData, ISerializable {
2420
4284
  static envelopeType: string;
2421
4285
  static dataType: string;
@@ -2513,8 +4377,61 @@ declare namespace ApplicationInsights {
2513
4377
  8: "request-context";
2514
4378
  };
2515
4379
 
4380
+ /**
4381
+ * This defines the handler function for when a promise is resolved.
4382
+ * @param value This is the value passed as part of resolving the Promise
4383
+ * @return This may return a value, another Promise or void. @see {@link IPromise.then} for how the value is handled.
4384
+ */
4385
+ type ResolvedPromiseHandler<T, TResult1 = T> = (((value: T) => TResult1 | IPromise<TResult1> | PromiseLike<TResult1>) | undefined | null);
4386
+
2516
4387
  const SampleRate = "sampleRate";
2517
4388
 
4389
+ /**
4390
+ * The EventsDiscardedReason enumeration contains a set of values that specify the reason for discarding an event.
4391
+ */
4392
+ const enum SendRequestReason {
4393
+ /**
4394
+ * No specific reason was specified
4395
+ */
4396
+ Undefined = 0,
4397
+ /**
4398
+ * Events are being sent based on the normal event schedule / timer.
4399
+ */
4400
+ NormalSchedule = 1,
4401
+ /**
4402
+ * A manual flush request was received
4403
+ */
4404
+ ManualFlush = 1,
4405
+ /**
4406
+ * Unload event is being processed
4407
+ */
4408
+ Unload = 2,
4409
+ /**
4410
+ * The event(s) being sent are sync events
4411
+ */
4412
+ SyncEvent = 3,
4413
+ /**
4414
+ * The Channel was resumed
4415
+ */
4416
+ Resumed = 4,
4417
+ /**
4418
+ * The event(s) being sent as a retry
4419
+ */
4420
+ Retry = 5,
4421
+ /**
4422
+ * The SDK is unloading
4423
+ */
4424
+ SdkUnload = 6,
4425
+ /**
4426
+ * Maximum batch size would be exceeded
4427
+ */
4428
+ MaxBatchSize = 10,
4429
+ /**
4430
+ * The Maximum number of events have already been queued
4431
+ */
4432
+ MaxQueuedEvents = 20
4433
+ }
4434
+
2518
4435
  /**
2519
4436
  * Defines the level of severity for the event.
2520
4437
  */
@@ -2526,6 +4443,12 @@ declare namespace ApplicationInsights {
2526
4443
 
2527
4444
  const strNotSpecified = "not_specified";
2528
4445
 
4446
+ interface Tags {
4447
+ [key: string]: any;
4448
+ }
4449
+
4450
+ type TelemetryInitializerFunction = <T extends ITelemetryItem>(item: T) => boolean | void;
4451
+
2529
4452
  class TelemetryItemCreator {
2530
4453
  /**
2531
4454
  * Create a telemetry item that the 1DS channel understands
@@ -2539,6 +4462,50 @@ declare namespace ApplicationInsights {
2539
4462
  static create: typeof createTelemetryItem;
2540
4463
  }
2541
4464
 
4465
+ /**
4466
+ * The TelemetryUnloadReason enumeration contains the possible reasons for why a plugin is being unloaded / torndown().
4467
+ */
4468
+ const enum TelemetryUnloadReason {
4469
+ /**
4470
+ * Teardown has been called without any context.
4471
+ */
4472
+ ManualTeardown = 0,
4473
+ /**
4474
+ * Just this plugin is being removed
4475
+ */
4476
+ PluginUnload = 1,
4477
+ /**
4478
+ * This instance of the plugin is being removed and replaced
4479
+ */
4480
+ PluginReplace = 2,
4481
+ /**
4482
+ * The entire SDK is being unloaded
4483
+ */
4484
+ SdkUnload = 50
4485
+ }
4486
+
4487
+ /**
4488
+ * The TelemetryUpdateReason enumeration contains a set of bit-wise values that specify the reason for update request.
4489
+ */
4490
+ const enum TelemetryUpdateReason {
4491
+ /**
4492
+ * Unknown.
4493
+ */
4494
+ Unknown = 0,
4495
+ /**
4496
+ * The configuration has ben updated or changed
4497
+ */
4498
+ ConfigurationChanged = 1,
4499
+ /**
4500
+ * One or more plugins have been added
4501
+ */
4502
+ PluginAdded = 16,
4503
+ /**
4504
+ * One or more plugins have been removed
4505
+ */
4506
+ PluginRemoved = 32
4507
+ }
4508
+
2542
4509
  class ThrottleMgr {
2543
4510
  canThrottle: (msgId: _eInternalMessageId | number) => boolean;
2544
4511
  sendMessage: (msgId: _eInternalMessageId, message: string, severity?: eLoggingSeverity) => IThrottleResult | null;
@@ -2589,6 +4556,8 @@ declare namespace ApplicationInsights {
2589
4556
  });
2590
4557
  }
2591
4558
 
4559
+ type UnloadHandler = (itemCtx: IProcessTelemetryUnloadContext, unloadState: ITelemetryUnloadState) => void;
4560
+
2592
4561
  function urlGetAbsoluteUrl(url: string): string;
2593
4562
 
2594
4563
  function urlGetCompleteUrl(method: string, absoluteUrl: string): string;
@@ -2636,5 +4605,6 @@ declare namespace ApplicationInsights {
2636
4605
 
2637
4606
  function utlSetStoragePrefix(storagePrefix: string): void;
2638
4607
 
2639
-
4608
+ type WatcherFunction<T = IConfiguration> = (details: IWatchDetails<T>) => void;
4609
+
2640
4610
  }