@microsoft/applicationinsights-web 2.8.0-beta.2202-06 → 2.8.0-beta.2203-02

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 (51) hide show
  1. package/README.md +1 -0
  2. package/browser/{ai.2.8.0-beta.2202-06.cjs.js → ai.2.8.0-beta.2203-02.cjs.js} +876 -515
  3. package/browser/ai.2.8.0-beta.2203-02.cjs.js.map +1 -0
  4. package/browser/ai.2.8.0-beta.2203-02.cjs.min.js +6 -0
  5. package/browser/ai.2.8.0-beta.2203-02.cjs.min.js.map +1 -0
  6. package/browser/{ai.2.8.0-beta.2202-06.gbl.js → ai.2.8.0-beta.2203-02.gbl.js} +876 -515
  7. package/browser/ai.2.8.0-beta.2203-02.gbl.js.map +1 -0
  8. package/browser/ai.2.8.0-beta.2203-02.gbl.min.js +6 -0
  9. package/browser/ai.2.8.0-beta.2203-02.gbl.min.js.map +1 -0
  10. package/browser/ai.2.8.0-beta.2203-02.integrity.json +66 -0
  11. package/browser/{ai.2.8.0-beta.2202-06.js → ai.2.8.0-beta.2203-02.js} +876 -515
  12. package/browser/ai.2.8.0-beta.2203-02.js.map +1 -0
  13. package/browser/ai.2.8.0-beta.2203-02.min.js +6 -0
  14. package/browser/ai.2.8.0-beta.2203-02.min.js.map +1 -0
  15. package/browser/ai.2.cjs.js +875 -514
  16. package/browser/ai.2.cjs.js.map +1 -1
  17. package/browser/ai.2.cjs.min.js +2 -2
  18. package/browser/ai.2.cjs.min.js.map +1 -1
  19. package/browser/ai.2.gbl.js +875 -514
  20. package/browser/ai.2.gbl.js.map +1 -1
  21. package/browser/ai.2.gbl.min.js +2 -2
  22. package/browser/ai.2.gbl.min.js.map +1 -1
  23. package/browser/ai.2.js +875 -514
  24. package/browser/ai.2.js.map +1 -1
  25. package/browser/ai.2.min.js +2 -2
  26. package/browser/ai.2.min.js.map +1 -1
  27. package/dist/applicationinsights-web.api.json +328 -568
  28. package/dist/applicationinsights-web.api.md +44 -32
  29. package/dist/applicationinsights-web.d.ts +298 -93
  30. package/dist/applicationinsights-web.js +941 -578
  31. package/dist/applicationinsights-web.js.map +1 -1
  32. package/dist/applicationinsights-web.min.js +2 -2
  33. package/dist/applicationinsights-web.min.js.map +1 -1
  34. package/dist/applicationinsights-web.rollup.d.ts +298 -93
  35. package/dist-esm/ApplicationInsightsContainer.js +1 -1
  36. package/dist-esm/ApplicationInsightsDeprecated.js +1 -1
  37. package/dist-esm/Init.js +1 -1
  38. package/dist-esm/Initialization.js +1 -1
  39. package/dist-esm/applicationinsights-web.js +1 -1
  40. package/package.json +7 -7
  41. package/types/Initialization.d.ts +6 -2
  42. package/browser/ai.2.8.0-beta.2202-06.cjs.js.map +0 -1
  43. package/browser/ai.2.8.0-beta.2202-06.cjs.min.js +0 -6
  44. package/browser/ai.2.8.0-beta.2202-06.cjs.min.js.map +0 -1
  45. package/browser/ai.2.8.0-beta.2202-06.gbl.js.map +0 -1
  46. package/browser/ai.2.8.0-beta.2202-06.gbl.min.js +0 -6
  47. package/browser/ai.2.8.0-beta.2202-06.gbl.min.js.map +0 -1
  48. package/browser/ai.2.8.0-beta.2202-06.integrity.json +0 -66
  49. package/browser/ai.2.8.0-beta.2202-06.js.map +0 -1
  50. package/browser/ai.2.8.0-beta.2202-06.min.js +0 -6
  51. package/browser/ai.2.8.0-beta.2202-06.min.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Microsoft.ApplicationInsights, 2.8.0-beta.2202-06
2
+ * Microsoft.ApplicationInsights, 2.8.0-beta.2203-02
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  *
5
5
  * Microsoft Application Insights Team
@@ -418,6 +418,10 @@ declare namespace ApplicationInsights {
418
418
  */
419
419
  addTelemetryInitializer(telemetryInitializer: TelemetryInitializerFunction): ITelemetryInitializerHandler | void;
420
420
  getPlugin<T extends IPlugin = IPlugin>(pluginIdentifier: string): ILoadedPlugin<T>;
421
+ /**
422
+ * Returns the unique event namespace that should be used
423
+ */
424
+ evtNamespace(): string;
421
425
  protected releaseQueue(): void;
422
426
  }
423
427
 
@@ -466,8 +470,26 @@ declare namespace ApplicationInsights {
466
470
  * Internal helper to allow setting of the internal initialized setting for inherited instances and unit testing
467
471
  */
468
472
  protected setInitialized: (isInitialized: boolean) => void;
473
+ /**
474
+ * Teardown / Unload hook to allow implementations to perform some additional unload operations before the BaseTelemetryPlugin
475
+ * finishes it's removal.
476
+ * @param unloadCtx - This is the context that should be used during unloading.
477
+ * @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.
478
+ * @param asyncCallback - An optional callback that the plugin must call if it returns true to inform the caller that it has completed any async unload/teardown operations.
479
+ * @returns boolean - true if the plugin has or will call asyncCallback, this allows the plugin to perform any asynchronous operations.
480
+ */
481
+ protected _doTeardown?: (unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState, asyncCallback?: () => void) => void | boolean;
469
482
  constructor();
470
483
  initialize(config: IConfiguration, core: IAppInsightsCore, extensions: IPlugin[], pluginChain?: ITelemetryPluginChain): void;
484
+ /**
485
+ * Tear down the plugin and remove any hooked value, the plugin should be removed so that it is no longer initialized and
486
+ * therefore could be re-initialized after being torn down. The plugin should ensure that once this has been called any further
487
+ * processTelemetry calls are ignored and it just calls the processNext() with the provided context.
488
+ * @param unloadCtx - This is the context that should be used during unloading.
489
+ * @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.
490
+ * @returns boolean - true if the plugin has or will call processNext(), this for backward compatibility as previously teardown was synchronous and returned nothing.
491
+ */
492
+ teardown(unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState): void | boolean;
471
493
  abstract processTelemetry(env: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
472
494
  /**
473
495
  * Add this hook so that it is automatically removed during unloading
@@ -579,7 +601,6 @@ declare namespace ApplicationInsights {
579
601
  priority: number;
580
602
  constructor();
581
603
  initialize(config: IConfiguration & IConfig, core: IAppInsightsCore, extensions: IPlugin[], pluginChain?: ITelemetryPluginChain): void;
582
- teardown(): void;
583
604
  processTelemetry(item: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
584
605
  /**
585
606
  * Logs dependency call
@@ -602,20 +623,13 @@ declare namespace ApplicationInsights {
602
623
  }): void;
603
624
  }
604
625
 
605
- enum DistributedTracingModes {
606
- /**
607
- * (Default) Send Application Insights correlation headers
608
- */
609
- AI = 0,
610
- /**
611
- * Send both W3C Trace Context headers and back-compatibility Application Insights headers
612
- */
613
- AI_AND_W3C = 1,
614
- /**
615
- * Send W3C Trace Context headers
616
- */
617
- W3C = 2
618
- }
626
+ const DistributedTracingModes: {
627
+ AI: number;
628
+ AI_AND_W3C: number;
629
+ W3C: number;
630
+ };
631
+
632
+ type DistributedTracingModes = number | eDistributedTracingModes;
619
633
 
620
634
  /**
621
635
  * The abstract common base of all domains.
@@ -633,6 +647,117 @@ declare namespace ApplicationInsights {
633
647
  */
634
648
  function doPerf<T>(mgrSource: IPerfManagerProvider | IPerfManager, getSource: () => string, func: (perfEvt?: IPerfEvent) => T, details?: () => any, isAsync?: boolean): T;
635
649
 
650
+ const enum eDistributedTracingModes {
651
+ /**
652
+ * (Default) Send Application Insights correlation headers
653
+ */
654
+ AI = 0,
655
+ /**
656
+ * Send both W3C Trace Context headers and back-compatibility Application Insights headers
657
+ */
658
+ AI_AND_W3C = 1,
659
+ /**
660
+ * Send W3C Trace Context headers
661
+ */
662
+ W3C = 2
663
+ }
664
+
665
+ const enum _eInternalMessageId {
666
+ BrowserDoesNotSupportLocalStorage = 0,
667
+ BrowserCannotReadLocalStorage = 1,
668
+ BrowserCannotReadSessionStorage = 2,
669
+ BrowserCannotWriteLocalStorage = 3,
670
+ BrowserCannotWriteSessionStorage = 4,
671
+ BrowserFailedRemovalFromLocalStorage = 5,
672
+ BrowserFailedRemovalFromSessionStorage = 6,
673
+ CannotSendEmptyTelemetry = 7,
674
+ ClientPerformanceMathError = 8,
675
+ ErrorParsingAISessionCookie = 9,
676
+ ErrorPVCalc = 10,
677
+ ExceptionWhileLoggingError = 11,
678
+ FailedAddingTelemetryToBuffer = 12,
679
+ FailedMonitorAjaxAbort = 13,
680
+ FailedMonitorAjaxDur = 14,
681
+ FailedMonitorAjaxOpen = 15,
682
+ FailedMonitorAjaxRSC = 16,
683
+ FailedMonitorAjaxSend = 17,
684
+ FailedMonitorAjaxGetCorrelationHeader = 18,
685
+ FailedToAddHandlerForOnBeforeUnload = 19,
686
+ FailedToSendQueuedTelemetry = 20,
687
+ FailedToReportDataLoss = 21,
688
+ FlushFailed = 22,
689
+ MessageLimitPerPVExceeded = 23,
690
+ MissingRequiredFieldSpecification = 24,
691
+ NavigationTimingNotSupported = 25,
692
+ OnError = 26,
693
+ SessionRenewalDateIsZero = 27,
694
+ SenderNotInitialized = 28,
695
+ StartTrackEventFailed = 29,
696
+ StopTrackEventFailed = 30,
697
+ StartTrackFailed = 31,
698
+ StopTrackFailed = 32,
699
+ TelemetrySampledAndNotSent = 33,
700
+ TrackEventFailed = 34,
701
+ TrackExceptionFailed = 35,
702
+ TrackMetricFailed = 36,
703
+ TrackPVFailed = 37,
704
+ TrackPVFailedCalc = 38,
705
+ TrackTraceFailed = 39,
706
+ TransmissionFailed = 40,
707
+ FailedToSetStorageBuffer = 41,
708
+ FailedToRestoreStorageBuffer = 42,
709
+ InvalidBackendResponse = 43,
710
+ FailedToFixDepricatedValues = 44,
711
+ InvalidDurationValue = 45,
712
+ TelemetryEnvelopeInvalid = 46,
713
+ CreateEnvelopeError = 47,
714
+ CannotSerializeObject = 48,
715
+ CannotSerializeObjectNonSerializable = 49,
716
+ CircularReferenceDetected = 50,
717
+ ClearAuthContextFailed = 51,
718
+ ExceptionTruncated = 52,
719
+ IllegalCharsInName = 53,
720
+ ItemNotInArray = 54,
721
+ MaxAjaxPerPVExceeded = 55,
722
+ MessageTruncated = 56,
723
+ NameTooLong = 57,
724
+ SampleRateOutOfRange = 58,
725
+ SetAuthContextFailed = 59,
726
+ SetAuthContextFailedAccountName = 60,
727
+ StringValueTooLong = 61,
728
+ StartCalledMoreThanOnce = 62,
729
+ StopCalledWithoutStart = 63,
730
+ TelemetryInitializerFailed = 64,
731
+ TrackArgumentsNotSpecified = 65,
732
+ UrlTooLong = 66,
733
+ SessionStorageBufferFull = 67,
734
+ CannotAccessCookie = 68,
735
+ IdTooLong = 69,
736
+ InvalidEvent = 70,
737
+ FailedMonitorAjaxSetRequestHeader = 71,
738
+ SendBrowserInfoOnUserInit = 72,
739
+ PluginException = 73,
740
+ NotificationException = 74,
741
+ SnippetScriptLoadFailure = 99,
742
+ InvalidInstrumentationKey = 100,
743
+ CannotParseAiBlobValue = 101,
744
+ InvalidContentBlob = 102,
745
+ TrackPageActionEventFailed = 103,
746
+ FailedAddingCustomDefinedRequestContext = 104,
747
+ InMemoryStorageBufferFull = 105
748
+ }
749
+
750
+ const enum eLoggingSeverity {
751
+ /**
752
+ * Error will be sent as internal telemetry
753
+ */
754
+ CRITICAL = 1,
755
+ /**
756
+ * Error will NOT be sent as internal telemetry, and will only be shown in browser console
757
+ */
758
+ WARNING = 2
759
+ }
760
+
636
761
  class Envelope extends Envelope_2 implements IEnvelope {
637
762
  /**
638
763
  * The data contract for serializing this object.
@@ -930,6 +1055,10 @@ declare namespace ApplicationInsights {
930
1055
  * @param pluginIdentifier
931
1056
  */
932
1057
  getPlugin<T extends IPlugin = IPlugin>(pluginIdentifier: string): ILoadedPlugin<T>;
1058
+ /**
1059
+ * Returns the unique event namespace that should be used when registering events
1060
+ */
1061
+ evtNamespace(): string;
933
1062
  }
934
1063
 
935
1064
  interface IAppInsightsDeprecated {
@@ -1183,6 +1312,67 @@ declare namespace ApplicationInsights {
1183
1312
  readonly appId?: string;
1184
1313
  }
1185
1314
 
1315
+ interface IBaseProcessingContext {
1316
+ /**
1317
+ * The current core instance for the request
1318
+ */
1319
+ core: () => IAppInsightsCore;
1320
+ /**
1321
+ * THe current diagnostic logger for the request
1322
+ */
1323
+ diagLog: () => IDiagnosticLogger;
1324
+ /**
1325
+ * Gets the current core config instance
1326
+ */
1327
+ getCfg: () => IConfiguration;
1328
+ /**
1329
+ * Gets the named extension config
1330
+ */
1331
+ getExtCfg: <T>(identifier: string, defaultValue?: T | any, mergeDefault?: GetExtCfgMergeType) => T;
1332
+ /**
1333
+ * Gets the named config from either the named identifier extension or core config if neither exist then the
1334
+ * default value is returned
1335
+ * @param identifier The named extension identifier
1336
+ * @param field The config field name
1337
+ * @param defaultValue The default value to return if no defined config exists
1338
+ */
1339
+ getConfig: (identifier: string, field: string, defaultValue?: number | string | boolean | string[] | RegExp[] | Function) => number | string | boolean | string[] | RegExp[] | Function;
1340
+ /**
1341
+ * Helper to allow plugins to check and possibly shortcut executing code only
1342
+ * required if there is a nextPlugin
1343
+ */
1344
+ hasNext: () => boolean;
1345
+ /**
1346
+ * Returns the next configured plugin proxy
1347
+ */
1348
+ getNext: () => ITelemetryPluginChain;
1349
+ /**
1350
+ * Helper to set the next plugin proxy
1351
+ */
1352
+ setNext: (nextCtx: ITelemetryPluginChain) => void;
1353
+ /**
1354
+ * Synchronously iterate over the context chain running the callback for each plugin, once
1355
+ * every plugin has been executed via the callback, any associated onComplete will be called.
1356
+ * @param callback - The function call for each plugin in the context chain
1357
+ */
1358
+ iterate: <T extends ITelemetryPlugin = ITelemetryPlugin>(callback: (plugin: T) => void) => void;
1359
+ /**
1360
+ * Set the function to call when the current chain has executed all processNext or unloadNext items.
1361
+ * @param onComplete - The onComplete to call
1362
+ * @param that - The "this" value to use for the onComplete call, if not provided or undefined defaults to the current context
1363
+ * @param args - Any additional arguments to pass to the onComplete function
1364
+ */
1365
+ onComplete: (onComplete: Function, that?: any, ...args: any[]) => void;
1366
+ /**
1367
+ * Create a new context using the core and config from the current instance, returns a new instance of the same type
1368
+ * @param plugins - The execution order to process the plugins, if null or not supplied
1369
+ * then the current execution order will be copied.
1370
+ * @param startAt - The plugin to start processing from, if missing from the execution
1371
+ * order then the next plugin will be NOT set.
1372
+ */
1373
+ createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IBaseProcessingContext;
1374
+ }
1375
+
1186
1376
  /**
1187
1377
  * Provides data transmission capabilities
1188
1378
  */
@@ -1196,9 +1386,14 @@ declare namespace ApplicationInsights {
1196
1386
  */
1197
1387
  resume(): void;
1198
1388
  /**
1199
- * Tear down transmission pipeline
1389
+ * Tear down the plugin and remove any hooked value, the plugin should be removed so that it is no longer initialized and
1390
+ * therefore could be re-initialized after being torn down. The plugin should ensure that once this has been called any further
1391
+ * processTelemetry calls are ignored and it just calls the processNext() with the provided context.
1392
+ * @param unloadCtx - This is the context that should be used during unloading.
1393
+ * @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.
1394
+ * @returns boolean - true if the plugin has or will call processNext(), this for backward compatibility as previously teardown was synchronous and returned nothing.
1200
1395
  */
1201
- teardown(): void;
1396
+ teardown: (unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState) => void | boolean;
1202
1397
  /**
1203
1398
  * Flush to send data immediately; channel should default to sending data asynchronously
1204
1399
  * @param async - send data asynchronously when true
@@ -2053,7 +2248,7 @@ declare namespace ApplicationInsights {
2053
2248
  * @param callback {any} - The callback function that needs to be executed for the given event
2054
2249
  * @return {boolean} - true if the handler was successfully added
2055
2250
  */
2056
- addEventHandler: (eventName: string, callback: any) => boolean;
2251
+ addEventHandler: (eventName: string, callback: any, evtNamespace?: string | string[]) => boolean;
2057
2252
  /**
2058
2253
  * Return the current time via the Date now() function (if available) and falls back to (new Date()).getTime() if now() is unavailable (IE8 or less)
2059
2254
  * https://caniuse.com/#search=Date.now
@@ -2528,6 +2723,19 @@ declare namespace ApplicationInsights {
2528
2723
 
2529
2724
  interface ILoadedPlugin<T extends IPlugin> {
2530
2725
  plugin: T;
2726
+ /**
2727
+ * Identifies whether the plugin is enabled and can process events. This is slightly different from isInitialized as the plugin may be initialized but disabled
2728
+ * via the setEnabled() or it may be a shared plugin which has had it's teardown function called from another instance..
2729
+ * @returns boolean = true if the plugin is in a state where it is operational.
2730
+ */
2731
+ isEnabled: () => boolean;
2732
+ /**
2733
+ * You can optionally enable / disable a plugin from processing events.
2734
+ * Setting enabled to true will not necessarily cause the `isEnabled()` to also return true
2735
+ * as the plugin must also have been successfully initialized and not had it's `teardown` method called
2736
+ * (unless it's also been re-initialized)
2737
+ */
2738
+ setEnabled: (isEnabled: boolean) => void;
2531
2739
  }
2532
2740
 
2533
2741
  interface ILocation {
@@ -2756,7 +2964,7 @@ declare namespace ApplicationInsights {
2756
2964
  InMemoryStorageBufferFull: number;
2757
2965
  };
2758
2966
 
2759
- type _InternalMessageId = number | typeof _InternalMessageId;
2967
+ type _InternalMessageId = number | _eInternalMessageId;
2760
2968
 
2761
2969
  interface IOperatingSystem {
2762
2970
  name: string;
@@ -3009,10 +3217,14 @@ declare namespace ApplicationInsights {
3009
3217
  */
3010
3218
  isInitialized?: () => boolean;
3011
3219
  /**
3012
- * Tear down the plugin and remove any hooked value, the plugin should remove that it is no longer initialized and
3013
- * therefore can be re-initialized after being torn down.
3220
+ * Tear down the plugin and remove any hooked value, the plugin should be removed so that it is no longer initialized and
3221
+ * therefore could be re-initialized after being torn down. The plugin should ensure that once this has been called any further
3222
+ * processTelemetry calls are ignored and it just calls the processNext() with the provided context.
3223
+ * @param unloadCtx - This is the context that should be used during unloading.
3224
+ * @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.
3225
+ * @returns boolean - true if the plugin has or will call processNext(), this for backward compatibility as previously teardown was synchronous and returned nothing.
3014
3226
  */
3015
- teardown?: () => void;
3227
+ teardown?: (unloadCtx: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState) => void | boolean;
3016
3228
  /**
3017
3229
  * Extension name
3018
3230
  */
@@ -3027,67 +3239,42 @@ declare namespace ApplicationInsights {
3027
3239
  * The current context for the current call to processTelemetry(), used to support sharing the same plugin instance
3028
3240
  * between multiple AppInsights instances
3029
3241
  */
3030
- interface IProcessTelemetryContext {
3031
- /**
3032
- * The current core instance for the request
3033
- */
3034
- core: () => IAppInsightsCore;
3035
- /**
3036
- * THe current diagnostic logger for the request
3037
- */
3038
- diagLog: () => IDiagnosticLogger;
3039
- /**
3040
- * Gets the current core config instance
3041
- */
3042
- getCfg: () => IConfiguration;
3043
- /**
3044
- * Gets the named extension config
3045
- */
3046
- getExtCfg: <T>(identifier: string, defaultValue?: T | any, mergeDefault?: GetExtCfgMergeType) => T;
3047
- /**
3048
- * Gets the named config from either the named identifier extension or core config if neither exist then the
3049
- * default value is returned
3050
- * @param identifier The named extension identifier
3051
- * @param field The config field name
3052
- * @param defaultValue The default value to return if no defined config exists
3053
- */
3054
- getConfig: (identifier: string, field: string, defaultValue?: number | string | boolean | string[] | RegExp[] | Function) => number | string | boolean | string[] | RegExp[] | Function;
3055
- /**
3056
- * Helper to allow plugins to check and possibly shortcut executing code only
3057
- * required if there is a nextPlugin
3058
- */
3059
- hasNext: () => boolean;
3060
- /**
3061
- * Returns the next configured plugin proxy
3062
- */
3063
- getNext: () => ITelemetryPluginChain;
3064
- /**
3065
- * Helper to set the next plugin proxy
3066
- */
3067
- setNext: (nextCtx: ITelemetryPluginChain) => void;
3242
+ interface IProcessTelemetryContext extends IBaseProcessingContext {
3068
3243
  /**
3069
3244
  * Call back for telemetry processing before it it is sent
3070
3245
  * @param env - This is the current event being reported
3246
+ * @returns boolean (true) if there is no more plugins to process otherwise false or undefined (void)
3071
3247
  */
3072
- processNext: (env: ITelemetryItem) => void;
3073
- /**
3074
- * Synchronously iterate over the context chain running the callback for each plugin, once
3075
- * every plugin has been executed via the callback, any associated onComplete will be called.
3076
- * @param callback - The function call for each plugin in the context chain
3077
- */
3078
- iterate: <T extends ITelemetryPlugin = ITelemetryPlugin>(callback: (plugin: T) => void) => void;
3248
+ processNext: (env: ITelemetryItem) => boolean | void;
3079
3249
  /**
3080
- * Create a new context using the core and config from the current instance
3250
+ * Create a new context using the core and config from the current instance, returns a new instance of the same type
3081
3251
  * @param plugins - The execution order to process the plugins, if null or not supplied
3082
3252
  * then the current execution order will be copied.
3083
3253
  * @param startAt - The plugin to start processing from, if missing from the execution
3084
3254
  * order then the next plugin will be NOT set.
3085
3255
  */
3086
3256
  createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryContext;
3257
+ }
3258
+
3259
+ /**
3260
+ * The current context for the current call to processTelemetry(), used to support sharing the same plugin instance
3261
+ * between multiple AppInsights instances
3262
+ */
3263
+ interface IProcessTelemetryUnloadContext extends IBaseProcessingContext {
3087
3264
  /**
3088
- * Set the function to call when the current chain has executed all processNext or unloadNext items.
3265
+ * This Plugin has finished unloading, so unload the next one
3266
+ * @param uploadState - The state of the unload process
3267
+ * @returns boolean (true) if there is no more plugins to process otherwise false or undefined (void)
3089
3268
  */
3090
- onComplete: (onComplete: () => void) => void;
3269
+ processNext: (unloadState: ITelemetryUnloadState) => boolean | void;
3270
+ /**
3271
+ * Create a new context using the core and config from the current instance, returns a new instance of the same type
3272
+ * @param plugins - The execution order to process the plugins, if null or not supplied
3273
+ * then the current execution order will be copied.
3274
+ * @param startAt - The plugin to start processing from, if missing from the execution
3275
+ * order then the next plugin will be NOT set.
3276
+ */
3277
+ createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryUnloadContext;
3091
3278
  }
3092
3279
 
3093
3280
  interface IPropertiesPlugin {
@@ -3443,15 +3630,7 @@ declare namespace ApplicationInsights {
3443
3630
  /**
3444
3631
  * Configuration provided to SDK core
3445
3632
  */
3446
- interface ITelemetryPlugin extends IPlugin {
3447
- /**
3448
- * Call back for telemetry processing before it it is sent
3449
- * @param env - This is the current event being reported
3450
- * @param itemCtx - This is the context for the current request, ITelemetryPlugin instances
3451
- * can optionally use this to access the current core instance or define / pass additional information
3452
- * to later plugins (vs appending items to the telemetry item)
3453
- */
3454
- processTelemetry: (env: ITelemetryItem, itemCtx?: IProcessTelemetryContext) => void;
3633
+ interface ITelemetryPlugin extends ITelemetryProcessor, IPlugin {
3455
3634
  /**
3456
3635
  * Set next extension for telemetry processing, this is not optional as plugins should use the
3457
3636
  * processNext() function of the passed IProcessTelemetryContext instead. It is being kept for
@@ -3467,7 +3646,7 @@ declare namespace ApplicationInsights {
3467
3646
  /**
3468
3647
  * Configuration provided to SDK core
3469
3648
  */
3470
- interface ITelemetryPluginChain {
3649
+ interface ITelemetryPluginChain extends ITelemetryProcessor {
3471
3650
  /**
3472
3651
  * Returns the underlying plugin that is being proxied for the processTelemetry call
3473
3652
  */
@@ -3476,6 +3655,16 @@ declare namespace ApplicationInsights {
3476
3655
  * Returns the next plugin
3477
3656
  */
3478
3657
  getNext: () => ITelemetryPluginChain;
3658
+ /**
3659
+ * This plugin is being unloaded and should remove any hooked events and cleanup any global/scoped values, after this
3660
+ * call the plugin will be removed from the telemetry processing chain and will no longer receive any events..
3661
+ * @param unloadCtx - The unload context to use for this call.
3662
+ * @param unloadState - The details of the unload operation
3663
+ */
3664
+ unload?: (unloadCtx: IProcessTelemetryUnloadContext, unloadState: ITelemetryUnloadState) => void;
3665
+ }
3666
+
3667
+ interface ITelemetryProcessor {
3479
3668
  /**
3480
3669
  * Call back for telemetry processing before it it is sent
3481
3670
  * @param env - This is the current event being reported
@@ -3483,7 +3672,7 @@ declare namespace ApplicationInsights {
3483
3672
  * can optionally use this to access the current core instance or define / pass additional information
3484
3673
  * to later plugins (vs appending items to the telemetry item)
3485
3674
  */
3486
- processTelemetry: (env: ITelemetryItem, itemCtx: IProcessTelemetryContext) => void;
3675
+ processTelemetry: (env: ITelemetryItem, itemCtx?: IProcessTelemetryContext) => void;
3487
3676
  }
3488
3677
 
3489
3678
  interface ITelemetryTrace {
@@ -3505,6 +3694,12 @@ declare namespace ApplicationInsights {
3505
3694
  name?: string;
3506
3695
  }
3507
3696
 
3697
+ interface ITelemetryUnloadState {
3698
+ reason: TelemetryUnloadReason;
3699
+ isAsync: boolean;
3700
+ flushComplete?: boolean;
3701
+ }
3702
+
3508
3703
  interface ITraceState {
3509
3704
  }
3510
3705
 
@@ -3778,16 +3973,12 @@ declare namespace ApplicationInsights {
3778
3973
  domain: string;
3779
3974
  }
3780
3975
 
3781
- enum LoggingSeverity {
3782
- /**
3783
- * Error will be sent as internal telemetry
3784
- */
3785
- CRITICAL = 1,
3786
- /**
3787
- * Error will NOT be sent as internal telemetry, and will only be shown in browser console
3788
- */
3789
- WARNING = 2
3790
- }
3976
+ const LoggingSeverity: {
3977
+ CRITICAL: number;
3978
+ WARNING: number;
3979
+ };
3980
+
3981
+ type LoggingSeverity = number | eLoggingSeverity;
3791
3982
 
3792
3983
  /**
3793
3984
  * Instances of Message represent printf-like trace statements that are text-searched. Log4Net, NLog and other text-based log file entries are translated into intances of this type. The message does not have measurements.
@@ -4565,7 +4756,11 @@ declare namespace ApplicationInsights {
4565
4756
  SessionExt: string;
4566
4757
  SDKExt: string;
4567
4758
  };
4568
- DistributedTracingModes: typeof DistributedTracingModes;
4759
+ DistributedTracingModes: {
4760
+ AI: number;
4761
+ AI_AND_W3C: number;
4762
+ W3C: number;
4763
+ };
4569
4764
  };
4570
4765
 
4571
4766
  type TelemetryInitializerFunction = <T extends ITelemetryItem>(item: T) => boolean | void;
@@ -4587,6 +4782,16 @@ declare namespace ApplicationInsights {
4587
4782
  }): ITelemetryItem;
4588
4783
  }
4589
4784
 
4785
+ /**
4786
+ * The TelemetryUnloadReason enumeration contains the possible reasons for why a plugin is being unloaded / torndown().
4787
+ */
4788
+ const enum TelemetryUnloadReason {
4789
+ /**
4790
+ * Teardown has been called without any context.
4791
+ */
4792
+ ManualTeardown = 0
4793
+ }
4794
+
4590
4795
  class Trace extends MessageData implements ISerializable {
4591
4796
  static envelopeType: string;
4592
4797
  static dataType: string;