@microsoft/applicationinsights-web 2.8.0-beta.2202-07 → 2.8.0-beta.2203-03

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-07.cjs.js → ai.2.8.0-beta.2203-03.cjs.js} +1069 -522
  3. package/browser/ai.2.8.0-beta.2203-03.cjs.js.map +1 -0
  4. package/browser/ai.2.8.0-beta.2203-03.cjs.min.js +6 -0
  5. package/browser/ai.2.8.0-beta.2203-03.cjs.min.js.map +1 -0
  6. package/browser/{ai.2.8.0-beta.2202-07.gbl.js → ai.2.8.0-beta.2203-03.gbl.js} +1069 -522
  7. package/browser/ai.2.8.0-beta.2203-03.gbl.js.map +1 -0
  8. package/browser/ai.2.8.0-beta.2203-03.gbl.min.js +6 -0
  9. package/browser/ai.2.8.0-beta.2203-03.gbl.min.js.map +1 -0
  10. package/browser/ai.2.8.0-beta.2203-03.integrity.json +66 -0
  11. package/browser/{ai.2.8.0-beta.2202-07.js → ai.2.8.0-beta.2203-03.js} +1069 -522
  12. package/browser/ai.2.8.0-beta.2203-03.js.map +1 -0
  13. package/browser/ai.2.8.0-beta.2203-03.min.js +6 -0
  14. package/browser/ai.2.8.0-beta.2203-03.min.js.map +1 -0
  15. package/browser/ai.2.cjs.js +1068 -521
  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 +1068 -521
  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 +1068 -521
  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 +925 -660
  28. package/dist/applicationinsights-web.api.md +53 -32
  29. package/dist/applicationinsights-web.d.ts +358 -93
  30. package/dist/applicationinsights-web.js +1134 -585
  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 +358 -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-07.cjs.js.map +0 -1
  43. package/browser/ai.2.8.0-beta.2202-07.cjs.min.js +0 -6
  44. package/browser/ai.2.8.0-beta.2202-07.cjs.min.js.map +0 -1
  45. package/browser/ai.2.8.0-beta.2202-07.gbl.js.map +0 -1
  46. package/browser/ai.2.8.0-beta.2202-07.gbl.min.js +0 -6
  47. package/browser/ai.2.8.0-beta.2202-07.gbl.min.js.map +0 -1
  48. package/browser/ai.2.8.0-beta.2202-07.integrity.json +0 -66
  49. package/browser/ai.2.8.0-beta.2202-07.js.map +0 -1
  50. package/browser/ai.2.8.0-beta.2202-07.min.js +0 -6
  51. package/browser/ai.2.8.0-beta.2202-07.min.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Microsoft.ApplicationInsights, 2.8.0-beta.2202-07
2
+ * Microsoft.ApplicationInsights, 2.8.0-beta.2203-03
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  *
5
5
  * Microsoft Application Insights Team
@@ -423,7 +423,26 @@ export declare class BaseCore implements IAppInsightsCore {
423
423
  * @returns - A ITelemetryInitializerHandler to enable the initializer to be removed
424
424
  */
425
425
  addTelemetryInitializer(telemetryInitializer: TelemetryInitializerFunction): ITelemetryInitializerHandler | void;
426
+ /**
427
+ * Unload and Tear down the SDK and any initialized plugins, after calling this the SDK will be considered
428
+ * to be un-initialized and non-operational, re-initializing the SDK should only be attempted if the previous
429
+ * unload call return `true` stating that all plugins reported that they also unloaded, the recommended
430
+ * approach is to create a new instance and initialize that instance.
431
+ * This is due to possible unexpected side effects caused by plugins not supporting unload / teardown, unable
432
+ * to successfully remove any global references or they may just be completing the unload process asynchronously.
433
+ */
434
+ unload(isAsync?: boolean, unloadComplete?: () => void): void;
426
435
  getPlugin<T extends IPlugin = IPlugin>(pluginIdentifier: string): ILoadedPlugin<T>;
436
+ addPlugin<T extends IPlugin = ITelemetryPlugin>(plugin: T, replaceExisting: boolean, doAsync: boolean, addCb?: (added?: boolean) => void): void;
437
+ /**
438
+ * Returns the unique event namespace that should be used
439
+ */
440
+ evtNamespace(): string;
441
+ /**
442
+ * Add an unload handler that will be called when the SDK is being unloaded
443
+ * @param handler - the handler
444
+ */
445
+ addUnloadCb(handler: UnloadHandler): void;
427
446
  protected releaseQueue(): void;
428
447
  }
429
448
 
@@ -472,9 +491,32 @@ export declare abstract class BaseTelemetryPlugin implements ITelemetryPlugin {
472
491
  * Internal helper to allow setting of the internal initialized setting for inherited instances and unit testing
473
492
  */
474
493
  protected setInitialized: (isInitialized: boolean) => void;
494
+ /**
495
+ * Teardown / Unload hook to allow implementations to perform some additional unload operations before the BaseTelemetryPlugin
496
+ * finishes it's removal.
497
+ * @param unloadCtx - This is the context that should be used during unloading.
498
+ * @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.
499
+ * @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.
500
+ * @returns boolean - true if the plugin has or will call asyncCallback, this allows the plugin to perform any asynchronous operations.
501
+ */
502
+ protected _doTeardown?: (unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState, asyncCallback?: () => void) => void | boolean;
475
503
  constructor();
476
504
  initialize(config: IConfiguration, core: IAppInsightsCore, extensions: IPlugin[], pluginChain?: ITelemetryPluginChain): void;
505
+ /**
506
+ * Tear down the plugin and remove any hooked value, the plugin should be removed so that it is no longer initialized and
507
+ * therefore could be re-initialized after being torn down. The plugin should ensure that once this has been called any further
508
+ * processTelemetry calls are ignored and it just calls the processNext() with the provided context.
509
+ * @param unloadCtx - This is the context that should be used during unloading.
510
+ * @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.
511
+ * @returns boolean - true if the plugin has or will call processNext(), this for backward compatibility as previously teardown was synchronous and returned nothing.
512
+ */
513
+ teardown(unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState): void | boolean;
477
514
  abstract processTelemetry(env: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
515
+ /**
516
+ * Add an unload handler that will be called when the SDK is being unloaded
517
+ * @param handler - the handler
518
+ */
519
+ protected _addUnloadCb(handler: UnloadHandler): void;
478
520
  /**
479
521
  * Add this hook so that it is automatically removed during unloading
480
522
  * @param hooks - The single hook or an array of IInstrumentHook objects
@@ -585,7 +627,6 @@ export declare class DependenciesPlugin extends BaseTelemetryPlugin implements I
585
627
  priority: number;
586
628
  constructor();
587
629
  initialize(config: IConfiguration & IConfig, core: IAppInsightsCore, extensions: IPlugin[], pluginChain?: ITelemetryPluginChain): void;
588
- teardown(): void;
589
630
  processTelemetry(item: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
590
631
  /**
591
632
  * Logs dependency call
@@ -608,20 +649,13 @@ export declare class DependenciesPlugin extends BaseTelemetryPlugin implements I
608
649
  }): void;
609
650
  }
610
651
 
611
- export declare enum DistributedTracingModes {
612
- /**
613
- * (Default) Send Application Insights correlation headers
614
- */
615
- AI = 0,
616
- /**
617
- * Send both W3C Trace Context headers and back-compatibility Application Insights headers
618
- */
619
- AI_AND_W3C = 1,
620
- /**
621
- * Send W3C Trace Context headers
622
- */
623
- W3C = 2
624
- }
652
+ export declare const DistributedTracingModes: {
653
+ AI: number;
654
+ AI_AND_W3C: number;
655
+ W3C: number;
656
+ };
657
+
658
+ export declare type DistributedTracingModes = number | eDistributedTracingModes;
625
659
 
626
660
  /**
627
661
  * The abstract common base of all domains.
@@ -639,6 +673,117 @@ declare interface Domain {
639
673
  */
640
674
  export declare function doPerf<T>(mgrSource: IPerfManagerProvider | IPerfManager, getSource: () => string, func: (perfEvt?: IPerfEvent) => T, details?: () => any, isAsync?: boolean): T;
641
675
 
676
+ declare const enum eDistributedTracingModes {
677
+ /**
678
+ * (Default) Send Application Insights correlation headers
679
+ */
680
+ AI = 0,
681
+ /**
682
+ * Send both W3C Trace Context headers and back-compatibility Application Insights headers
683
+ */
684
+ AI_AND_W3C = 1,
685
+ /**
686
+ * Send W3C Trace Context headers
687
+ */
688
+ W3C = 2
689
+ }
690
+
691
+ declare const enum _eInternalMessageId {
692
+ BrowserDoesNotSupportLocalStorage = 0,
693
+ BrowserCannotReadLocalStorage = 1,
694
+ BrowserCannotReadSessionStorage = 2,
695
+ BrowserCannotWriteLocalStorage = 3,
696
+ BrowserCannotWriteSessionStorage = 4,
697
+ BrowserFailedRemovalFromLocalStorage = 5,
698
+ BrowserFailedRemovalFromSessionStorage = 6,
699
+ CannotSendEmptyTelemetry = 7,
700
+ ClientPerformanceMathError = 8,
701
+ ErrorParsingAISessionCookie = 9,
702
+ ErrorPVCalc = 10,
703
+ ExceptionWhileLoggingError = 11,
704
+ FailedAddingTelemetryToBuffer = 12,
705
+ FailedMonitorAjaxAbort = 13,
706
+ FailedMonitorAjaxDur = 14,
707
+ FailedMonitorAjaxOpen = 15,
708
+ FailedMonitorAjaxRSC = 16,
709
+ FailedMonitorAjaxSend = 17,
710
+ FailedMonitorAjaxGetCorrelationHeader = 18,
711
+ FailedToAddHandlerForOnBeforeUnload = 19,
712
+ FailedToSendQueuedTelemetry = 20,
713
+ FailedToReportDataLoss = 21,
714
+ FlushFailed = 22,
715
+ MessageLimitPerPVExceeded = 23,
716
+ MissingRequiredFieldSpecification = 24,
717
+ NavigationTimingNotSupported = 25,
718
+ OnError = 26,
719
+ SessionRenewalDateIsZero = 27,
720
+ SenderNotInitialized = 28,
721
+ StartTrackEventFailed = 29,
722
+ StopTrackEventFailed = 30,
723
+ StartTrackFailed = 31,
724
+ StopTrackFailed = 32,
725
+ TelemetrySampledAndNotSent = 33,
726
+ TrackEventFailed = 34,
727
+ TrackExceptionFailed = 35,
728
+ TrackMetricFailed = 36,
729
+ TrackPVFailed = 37,
730
+ TrackPVFailedCalc = 38,
731
+ TrackTraceFailed = 39,
732
+ TransmissionFailed = 40,
733
+ FailedToSetStorageBuffer = 41,
734
+ FailedToRestoreStorageBuffer = 42,
735
+ InvalidBackendResponse = 43,
736
+ FailedToFixDepricatedValues = 44,
737
+ InvalidDurationValue = 45,
738
+ TelemetryEnvelopeInvalid = 46,
739
+ CreateEnvelopeError = 47,
740
+ CannotSerializeObject = 48,
741
+ CannotSerializeObjectNonSerializable = 49,
742
+ CircularReferenceDetected = 50,
743
+ ClearAuthContextFailed = 51,
744
+ ExceptionTruncated = 52,
745
+ IllegalCharsInName = 53,
746
+ ItemNotInArray = 54,
747
+ MaxAjaxPerPVExceeded = 55,
748
+ MessageTruncated = 56,
749
+ NameTooLong = 57,
750
+ SampleRateOutOfRange = 58,
751
+ SetAuthContextFailed = 59,
752
+ SetAuthContextFailedAccountName = 60,
753
+ StringValueTooLong = 61,
754
+ StartCalledMoreThanOnce = 62,
755
+ StopCalledWithoutStart = 63,
756
+ TelemetryInitializerFailed = 64,
757
+ TrackArgumentsNotSpecified = 65,
758
+ UrlTooLong = 66,
759
+ SessionStorageBufferFull = 67,
760
+ CannotAccessCookie = 68,
761
+ IdTooLong = 69,
762
+ InvalidEvent = 70,
763
+ FailedMonitorAjaxSetRequestHeader = 71,
764
+ SendBrowserInfoOnUserInit = 72,
765
+ PluginException = 73,
766
+ NotificationException = 74,
767
+ SnippetScriptLoadFailure = 99,
768
+ InvalidInstrumentationKey = 100,
769
+ CannotParseAiBlobValue = 101,
770
+ InvalidContentBlob = 102,
771
+ TrackPageActionEventFailed = 103,
772
+ FailedAddingCustomDefinedRequestContext = 104,
773
+ InMemoryStorageBufferFull = 105
774
+ }
775
+
776
+ declare const enum eLoggingSeverity {
777
+ /**
778
+ * Error will be sent as internal telemetry
779
+ */
780
+ CRITICAL = 1,
781
+ /**
782
+ * Error will NOT be sent as internal telemetry, and will only be shown in browser console
783
+ */
784
+ WARNING = 2
785
+ }
786
+
642
787
  declare class Envelope extends Envelope_2 implements IEnvelope {
643
788
  /**
644
789
  * The data contract for serializing this object.
@@ -931,11 +1076,36 @@ export declare interface IAppInsightsCore extends IPerfManagerProvider {
931
1076
  * Return a new instance of the IProcessTelemetryContext for processing events
932
1077
  */
933
1078
  getProcessTelContext(): IProcessTelemetryContext;
1079
+ /**
1080
+ * Unload and Tear down the SDK and any initialized plugins, after calling this the SDK will be considered
1081
+ * to be un-initialized and non-operational, re-initializing the SDK should only be attempted if the previous
1082
+ * unload call return `true` stating that all plugins reported that they also unloaded, the recommended
1083
+ * approach is to create a new instance and initialize that instance.
1084
+ * This is due to possible unexpected side effects caused by plugins not supporting unload / teardown, unable
1085
+ * to successfully remove any global references or they may just be completing the unload process asynchronously.
1086
+ */
1087
+ unload(isAsync?: boolean, unloadComplete?: () => void): void;
934
1088
  /**
935
1089
  * Find and return the (first) plugin with the specified identifier if present
936
1090
  * @param pluginIdentifier
937
1091
  */
938
1092
  getPlugin<T extends IPlugin = IPlugin>(pluginIdentifier: string): ILoadedPlugin<T>;
1093
+ /**
1094
+ * Add a new plugin to the installation
1095
+ * @param plugin - The new plugin to add
1096
+ * @param replaceExisting - should any existing plugin be replaced
1097
+ * @param doAsync - Should the add be performed asynchronously
1098
+ */
1099
+ addPlugin<T extends IPlugin = ITelemetryPlugin>(plugin: T, replaceExisting: boolean, doAsync: boolean, addCb?: (added?: boolean) => void): void;
1100
+ /**
1101
+ * Returns the unique event namespace that should be used when registering events
1102
+ */
1103
+ evtNamespace(): string;
1104
+ /**
1105
+ * Add a handler that will be called when the SDK is being unloaded
1106
+ * @param handler - the handler
1107
+ */
1108
+ addUnloadCb(handler: UnloadHandler): void;
939
1109
  }
940
1110
 
941
1111
  export declare interface IAppInsightsDeprecated {
@@ -1189,6 +1359,67 @@ declare interface IBackendResponse {
1189
1359
  readonly appId?: string;
1190
1360
  }
1191
1361
 
1362
+ declare interface IBaseProcessingContext {
1363
+ /**
1364
+ * The current core instance for the request
1365
+ */
1366
+ core: () => IAppInsightsCore;
1367
+ /**
1368
+ * THe current diagnostic logger for the request
1369
+ */
1370
+ diagLog: () => IDiagnosticLogger;
1371
+ /**
1372
+ * Gets the current core config instance
1373
+ */
1374
+ getCfg: () => IConfiguration;
1375
+ /**
1376
+ * Gets the named extension config
1377
+ */
1378
+ getExtCfg: <T>(identifier: string, defaultValue?: T | any, mergeDefault?: GetExtCfgMergeType) => T;
1379
+ /**
1380
+ * Gets the named config from either the named identifier extension or core config if neither exist then the
1381
+ * default value is returned
1382
+ * @param identifier The named extension identifier
1383
+ * @param field The config field name
1384
+ * @param defaultValue The default value to return if no defined config exists
1385
+ */
1386
+ getConfig: (identifier: string, field: string, defaultValue?: number | string | boolean | string[] | RegExp[] | Function) => number | string | boolean | string[] | RegExp[] | Function;
1387
+ /**
1388
+ * Helper to allow plugins to check and possibly shortcut executing code only
1389
+ * required if there is a nextPlugin
1390
+ */
1391
+ hasNext: () => boolean;
1392
+ /**
1393
+ * Returns the next configured plugin proxy
1394
+ */
1395
+ getNext: () => ITelemetryPluginChain;
1396
+ /**
1397
+ * Helper to set the next plugin proxy
1398
+ */
1399
+ setNext: (nextCtx: ITelemetryPluginChain) => void;
1400
+ /**
1401
+ * Synchronously iterate over the context chain running the callback for each plugin, once
1402
+ * every plugin has been executed via the callback, any associated onComplete will be called.
1403
+ * @param callback - The function call for each plugin in the context chain
1404
+ */
1405
+ iterate: <T extends ITelemetryPlugin = ITelemetryPlugin>(callback: (plugin: T) => void) => void;
1406
+ /**
1407
+ * Set the function to call when the current chain has executed all processNext or unloadNext items.
1408
+ * @param onComplete - The onComplete to call
1409
+ * @param that - The "this" value to use for the onComplete call, if not provided or undefined defaults to the current context
1410
+ * @param args - Any additional arguments to pass to the onComplete function
1411
+ */
1412
+ onComplete: (onComplete: Function, that?: any, ...args: any[]) => void;
1413
+ /**
1414
+ * Create a new context using the core and config from the current instance, returns a new instance of the same type
1415
+ * @param plugins - The execution order to process the plugins, if null or not supplied
1416
+ * then the current execution order will be copied.
1417
+ * @param startAt - The plugin to start processing from, if missing from the execution
1418
+ * order then the next plugin will be NOT set.
1419
+ */
1420
+ createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IBaseProcessingContext;
1421
+ }
1422
+
1192
1423
  /**
1193
1424
  * Provides data transmission capabilities
1194
1425
  */
@@ -1202,9 +1433,14 @@ declare interface IChannelControls extends ITelemetryPlugin {
1202
1433
  */
1203
1434
  resume(): void;
1204
1435
  /**
1205
- * Tear down transmission pipeline
1436
+ * Tear down the plugin and remove any hooked value, the plugin should be removed so that it is no longer initialized and
1437
+ * therefore could be re-initialized after being torn down. The plugin should ensure that once this has been called any further
1438
+ * processTelemetry calls are ignored and it just calls the processNext() with the provided context.
1439
+ * @param unloadCtx - This is the context that should be used during unloading.
1440
+ * @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.
1441
+ * @returns boolean - true if the plugin has or will call processNext(), this for backward compatibility as previously teardown was synchronous and returned nothing.
1206
1442
  */
1207
- teardown(): void;
1443
+ teardown: (unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState) => void | boolean;
1208
1444
  /**
1209
1445
  * Flush to send data immediately; channel should default to sending data asynchronously
1210
1446
  * @param async - send data asynchronously when true
@@ -2059,7 +2295,7 @@ export declare interface ICoreUtils {
2059
2295
  * @param callback {any} - The callback function that needs to be executed for the given event
2060
2296
  * @return {boolean} - true if the handler was successfully added
2061
2297
  */
2062
- addEventHandler: (eventName: string, callback: any) => boolean;
2298
+ addEventHandler: (eventName: string, callback: any, evtNamespace?: string | string[]) => boolean;
2063
2299
  /**
2064
2300
  * 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)
2065
2301
  * https://caniuse.com/#search=Date.now
@@ -2534,6 +2770,20 @@ declare interface IInternal {
2534
2770
 
2535
2771
  declare interface ILoadedPlugin<T extends IPlugin> {
2536
2772
  plugin: T;
2773
+ /**
2774
+ * Identifies whether the plugin is enabled and can process events. This is slightly different from isInitialized as the plugin may be initialized but disabled
2775
+ * via the setEnabled() or it may be a shared plugin which has had it's teardown function called from another instance..
2776
+ * @returns boolean = true if the plugin is in a state where it is operational.
2777
+ */
2778
+ isEnabled: () => boolean;
2779
+ /**
2780
+ * You can optionally enable / disable a plugin from processing events.
2781
+ * Setting enabled to true will not necessarily cause the `isEnabled()` to also return true
2782
+ * as the plugin must also have been successfully initialized and not had it's `teardown` method called
2783
+ * (unless it's also been re-initialized)
2784
+ */
2785
+ setEnabled: (isEnabled: boolean) => void;
2786
+ remove: (isAsync?: boolean, removeCb?: (removed?: boolean) => void) => void;
2537
2787
  }
2538
2788
 
2539
2789
  declare interface ILocation {
@@ -2762,7 +3012,7 @@ export declare const _InternalMessageId: {
2762
3012
  InMemoryStorageBufferFull: number;
2763
3013
  };
2764
3014
 
2765
- export declare type _InternalMessageId = number | typeof _InternalMessageId;
3015
+ export declare type _InternalMessageId = number | _eInternalMessageId;
2766
3016
 
2767
3017
  declare interface IOperatingSystem {
2768
3018
  name: string;
@@ -3015,10 +3265,14 @@ export declare interface IPlugin {
3015
3265
  */
3016
3266
  isInitialized?: () => boolean;
3017
3267
  /**
3018
- * Tear down the plugin and remove any hooked value, the plugin should remove that it is no longer initialized and
3019
- * therefore can be re-initialized after being torn down.
3268
+ * Tear down the plugin and remove any hooked value, the plugin should be removed so that it is no longer initialized and
3269
+ * therefore could be re-initialized after being torn down. The plugin should ensure that once this has been called any further
3270
+ * processTelemetry calls are ignored and it just calls the processNext() with the provided context.
3271
+ * @param unloadCtx - This is the context that should be used during unloading.
3272
+ * @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.
3273
+ * @returns boolean - true if the plugin has or will call processNext(), this for backward compatibility as previously teardown was synchronous and returned nothing.
3020
3274
  */
3021
- teardown?: () => void;
3275
+ teardown?: (unloadCtx: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState) => void | boolean;
3022
3276
  /**
3023
3277
  * Extension name
3024
3278
  */
@@ -3033,67 +3287,42 @@ export declare interface IPlugin {
3033
3287
  * The current context for the current call to processTelemetry(), used to support sharing the same plugin instance
3034
3288
  * between multiple AppInsights instances
3035
3289
  */
3036
- export declare interface IProcessTelemetryContext {
3037
- /**
3038
- * The current core instance for the request
3039
- */
3040
- core: () => IAppInsightsCore;
3041
- /**
3042
- * THe current diagnostic logger for the request
3043
- */
3044
- diagLog: () => IDiagnosticLogger;
3045
- /**
3046
- * Gets the current core config instance
3047
- */
3048
- getCfg: () => IConfiguration;
3049
- /**
3050
- * Gets the named extension config
3051
- */
3052
- getExtCfg: <T>(identifier: string, defaultValue?: T | any, mergeDefault?: GetExtCfgMergeType) => T;
3053
- /**
3054
- * Gets the named config from either the named identifier extension or core config if neither exist then the
3055
- * default value is returned
3056
- * @param identifier The named extension identifier
3057
- * @param field The config field name
3058
- * @param defaultValue The default value to return if no defined config exists
3059
- */
3060
- getConfig: (identifier: string, field: string, defaultValue?: number | string | boolean | string[] | RegExp[] | Function) => number | string | boolean | string[] | RegExp[] | Function;
3061
- /**
3062
- * Helper to allow plugins to check and possibly shortcut executing code only
3063
- * required if there is a nextPlugin
3064
- */
3065
- hasNext: () => boolean;
3066
- /**
3067
- * Returns the next configured plugin proxy
3068
- */
3069
- getNext: () => ITelemetryPluginChain;
3070
- /**
3071
- * Helper to set the next plugin proxy
3072
- */
3073
- setNext: (nextCtx: ITelemetryPluginChain) => void;
3290
+ export declare interface IProcessTelemetryContext extends IBaseProcessingContext {
3074
3291
  /**
3075
3292
  * Call back for telemetry processing before it it is sent
3076
3293
  * @param env - This is the current event being reported
3294
+ * @returns boolean (true) if there is no more plugins to process otherwise false or undefined (void)
3077
3295
  */
3078
- processNext: (env: ITelemetryItem) => void;
3296
+ processNext: (env: ITelemetryItem) => boolean | void;
3079
3297
  /**
3080
- * Synchronously iterate over the context chain running the callback for each plugin, once
3081
- * every plugin has been executed via the callback, any associated onComplete will be called.
3082
- * @param callback - The function call for each plugin in the context chain
3083
- */
3084
- iterate: <T extends ITelemetryPlugin = ITelemetryPlugin>(callback: (plugin: T) => void) => void;
3085
- /**
3086
- * Create a new context using the core and config from the current instance
3298
+ * Create a new context using the core and config from the current instance, returns a new instance of the same type
3087
3299
  * @param plugins - The execution order to process the plugins, if null or not supplied
3088
3300
  * then the current execution order will be copied.
3089
3301
  * @param startAt - The plugin to start processing from, if missing from the execution
3090
3302
  * order then the next plugin will be NOT set.
3091
3303
  */
3092
3304
  createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryContext;
3305
+ }
3306
+
3307
+ /**
3308
+ * The current context for the current call to processTelemetry(), used to support sharing the same plugin instance
3309
+ * between multiple AppInsights instances
3310
+ */
3311
+ declare interface IProcessTelemetryUnloadContext extends IBaseProcessingContext {
3093
3312
  /**
3094
- * Set the function to call when the current chain has executed all processNext or unloadNext items.
3313
+ * This Plugin has finished unloading, so unload the next one
3314
+ * @param uploadState - The state of the unload process
3315
+ * @returns boolean (true) if there is no more plugins to process otherwise false or undefined (void)
3316
+ */
3317
+ processNext: (unloadState: ITelemetryUnloadState) => boolean | void;
3318
+ /**
3319
+ * Create a new context using the core and config from the current instance, returns a new instance of the same type
3320
+ * @param plugins - The execution order to process the plugins, if null or not supplied
3321
+ * then the current execution order will be copied.
3322
+ * @param startAt - The plugin to start processing from, if missing from the execution
3323
+ * order then the next plugin will be NOT set.
3095
3324
  */
3096
- onComplete: (onComplete: () => void) => void;
3325
+ createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryUnloadContext;
3097
3326
  }
3098
3327
 
3099
3328
  declare interface IPropertiesPlugin {
@@ -3449,15 +3678,7 @@ export declare interface ITelemetryItem {
3449
3678
  /**
3450
3679
  * Configuration provided to SDK core
3451
3680
  */
3452
- export declare interface ITelemetryPlugin extends IPlugin {
3453
- /**
3454
- * Call back for telemetry processing before it it is sent
3455
- * @param env - This is the current event being reported
3456
- * @param itemCtx - This is the context for the current request, ITelemetryPlugin instances
3457
- * can optionally use this to access the current core instance or define / pass additional information
3458
- * to later plugins (vs appending items to the telemetry item)
3459
- */
3460
- processTelemetry: (env: ITelemetryItem, itemCtx?: IProcessTelemetryContext) => void;
3681
+ export declare interface ITelemetryPlugin extends ITelemetryProcessor, IPlugin {
3461
3682
  /**
3462
3683
  * Set next extension for telemetry processing, this is not optional as plugins should use the
3463
3684
  * processNext() function of the passed IProcessTelemetryContext instead. It is being kept for
@@ -3473,7 +3694,7 @@ export declare interface ITelemetryPlugin extends IPlugin {
3473
3694
  /**
3474
3695
  * Configuration provided to SDK core
3475
3696
  */
3476
- export declare interface ITelemetryPluginChain {
3697
+ export declare interface ITelemetryPluginChain extends ITelemetryProcessor {
3477
3698
  /**
3478
3699
  * Returns the underlying plugin that is being proxied for the processTelemetry call
3479
3700
  */
@@ -3482,6 +3703,16 @@ export declare interface ITelemetryPluginChain {
3482
3703
  * Returns the next plugin
3483
3704
  */
3484
3705
  getNext: () => ITelemetryPluginChain;
3706
+ /**
3707
+ * This plugin is being unloaded and should remove any hooked events and cleanup any global/scoped values, after this
3708
+ * call the plugin will be removed from the telemetry processing chain and will no longer receive any events..
3709
+ * @param unloadCtx - The unload context to use for this call.
3710
+ * @param unloadState - The details of the unload operation
3711
+ */
3712
+ unload?: (unloadCtx: IProcessTelemetryUnloadContext, unloadState: ITelemetryUnloadState) => void;
3713
+ }
3714
+
3715
+ declare interface ITelemetryProcessor {
3485
3716
  /**
3486
3717
  * Call back for telemetry processing before it it is sent
3487
3718
  * @param env - This is the current event being reported
@@ -3489,7 +3720,7 @@ export declare interface ITelemetryPluginChain {
3489
3720
  * can optionally use this to access the current core instance or define / pass additional information
3490
3721
  * to later plugins (vs appending items to the telemetry item)
3491
3722
  */
3492
- processTelemetry: (env: ITelemetryItem, itemCtx: IProcessTelemetryContext) => void;
3723
+ processTelemetry: (env: ITelemetryItem, itemCtx?: IProcessTelemetryContext) => void;
3493
3724
  }
3494
3725
 
3495
3726
  declare interface ITelemetryTrace {
@@ -3511,6 +3742,12 @@ declare interface ITelemetryTrace {
3511
3742
  name?: string;
3512
3743
  }
3513
3744
 
3745
+ declare interface ITelemetryUnloadState {
3746
+ reason: TelemetryUnloadReason;
3747
+ isAsync: boolean;
3748
+ flushComplete?: boolean;
3749
+ }
3750
+
3514
3751
  declare interface ITraceState {
3515
3752
  }
3516
3753
 
@@ -3784,16 +4021,12 @@ declare interface IWeb {
3784
4021
  domain: string;
3785
4022
  }
3786
4023
 
3787
- export declare enum LoggingSeverity {
3788
- /**
3789
- * Error will be sent as internal telemetry
3790
- */
3791
- CRITICAL = 1,
3792
- /**
3793
- * Error will NOT be sent as internal telemetry, and will only be shown in browser console
3794
- */
3795
- WARNING = 2
3796
- }
4024
+ export declare const LoggingSeverity: {
4025
+ CRITICAL: number;
4026
+ WARNING: number;
4027
+ };
4028
+
4029
+ export declare type LoggingSeverity = number | eLoggingSeverity;
3797
4030
 
3798
4031
  /**
3799
4032
  * 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.
@@ -4419,6 +4652,10 @@ declare const enum SendRequestReason {
4419
4652
  * The event(s) being sent as a retry
4420
4653
  */
4421
4654
  Retry = 5,
4655
+ /**
4656
+ * The SDK is unloading
4657
+ */
4658
+ SdkUnload = 6,
4422
4659
  /**
4423
4660
  * Maximum batch size would be exceeded
4424
4661
  */
@@ -4571,7 +4808,11 @@ export declare const Telemetry: {
4571
4808
  SessionExt: string;
4572
4809
  SDKExt: string;
4573
4810
  };
4574
- DistributedTracingModes: typeof DistributedTracingModes;
4811
+ DistributedTracingModes: {
4812
+ AI: number;
4813
+ AI_AND_W3C: number;
4814
+ W3C: number;
4815
+ };
4575
4816
  };
4576
4817
 
4577
4818
  declare type TelemetryInitializerFunction = <T extends ITelemetryItem>(item: T) => boolean | void;
@@ -4593,6 +4834,28 @@ declare class TelemetryItemCreator {
4593
4834
  }): ITelemetryItem;
4594
4835
  }
4595
4836
 
4837
+ /**
4838
+ * The TelemetryUnloadReason enumeration contains the possible reasons for why a plugin is being unloaded / torndown().
4839
+ */
4840
+ declare const enum TelemetryUnloadReason {
4841
+ /**
4842
+ * Teardown has been called without any context.
4843
+ */
4844
+ ManualTeardown = 0,
4845
+ /**
4846
+ * Just this plugin is being removed
4847
+ */
4848
+ PluginUnload = 1,
4849
+ /**
4850
+ * This instance of the plugin is being removed and replaced
4851
+ */
4852
+ PluginReplace = 2,
4853
+ /**
4854
+ * The entire SDK is being unloaded
4855
+ */
4856
+ SdkUnload = 50
4857
+ }
4858
+
4596
4859
  export declare class Trace extends MessageData implements ISerializable {
4597
4860
  static envelopeType: string;
4598
4861
  static dataType: string;
@@ -4610,6 +4873,8 @@ export declare class Trace extends MessageData implements ISerializable {
4610
4873
  });
4611
4874
  }
4612
4875
 
4876
+ declare type UnloadHandler = (itemCtx: IProcessTelemetryUnloadContext, unloadState: ITelemetryUnloadState) => void;
4877
+
4613
4878
  export declare const Util: IUtil;
4614
4879
 
4615
4880
  declare interface XDomainRequest extends XMLHttpRequestEventTarget {
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Web, 2.8.0-beta.2202-07
2
+ * Application Insights JavaScript SDK - Web, 2.8.0-beta.2203-03
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
  import { AppInsightsDeprecated } from "./ApplicationInsightsDeprecated";
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Web, 2.8.0-beta.2202-07
2
+ * Application Insights JavaScript SDK - Web, 2.8.0-beta.2203-03
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
  import { stringToBoolOrDefault, ProcessLegacy } from "@microsoft/applicationinsights-common";
package/dist-esm/Init.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Web, 2.8.0-beta.2202-07
2
+ * Application Insights JavaScript SDK - Web, 2.8.0-beta.2203-03
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Web, 2.8.0-beta.2202-07
2
+ * Application Insights JavaScript SDK - Web, 2.8.0-beta.2203-03
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Web, 2.8.0-beta.2202-07
2
+ * Application Insights JavaScript SDK - Web, 2.8.0-beta.2203-03
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
  export { Initialization as ApplicationInsights, Telemetry } from "./Initialization";