@microsoft/applicationinsights-core-js 2.8.0-beta.2203-04 → 2.8.0-beta.2203-07

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 (102) hide show
  1. package/browser/applicationinsights-core-js.integrity.json +9 -9
  2. package/browser/applicationinsights-core-js.js +147 -33
  3. package/browser/applicationinsights-core-js.js.map +1 -1
  4. package/browser/applicationinsights-core-js.min.js +2 -2
  5. package/browser/applicationinsights-core-js.min.js.map +1 -1
  6. package/dist/applicationinsights-core-js.api.json +1832 -94
  7. package/dist/applicationinsights-core-js.api.md +70 -12
  8. package/dist/applicationinsights-core-js.d.ts +167 -11
  9. package/dist/applicationinsights-core-js.js +147 -33
  10. package/dist/applicationinsights-core-js.js.map +1 -1
  11. package/dist/applicationinsights-core-js.min.js +2 -2
  12. package/dist/applicationinsights-core-js.min.js.map +1 -1
  13. package/dist/applicationinsights-core-js.rollup.d.ts +170 -14
  14. package/dist-esm/JavaScriptSDK/AppInsightsCore.js +1 -1
  15. package/dist-esm/JavaScriptSDK/BaseCore.js +41 -17
  16. package/dist-esm/JavaScriptSDK/BaseCore.js.map +1 -1
  17. package/dist-esm/JavaScriptSDK/BaseTelemetryPlugin.js +31 -3
  18. package/dist-esm/JavaScriptSDK/BaseTelemetryPlugin.js.map +1 -1
  19. package/dist-esm/JavaScriptSDK/ChannelController.js +15 -2
  20. package/dist-esm/JavaScriptSDK/ChannelController.js.map +1 -1
  21. package/dist-esm/JavaScriptSDK/Constants.js +1 -1
  22. package/dist-esm/JavaScriptSDK/CookieMgr.js +3 -2
  23. package/dist-esm/JavaScriptSDK/CookieMgr.js.map +1 -1
  24. package/dist-esm/JavaScriptSDK/CoreUtils.js +1 -1
  25. package/dist-esm/JavaScriptSDK/DataCacheHelper.js +1 -1
  26. package/dist-esm/JavaScriptSDK/DbgExtensionUtils.js +1 -1
  27. package/dist-esm/JavaScriptSDK/DiagnosticLogger.js +14 -1
  28. package/dist-esm/JavaScriptSDK/DiagnosticLogger.js.map +1 -1
  29. package/dist-esm/JavaScriptSDK/EnvUtils.js +1 -1
  30. package/dist-esm/JavaScriptSDK/EventHelpers.js +18 -13
  31. package/dist-esm/JavaScriptSDK/EventHelpers.js.map +1 -1
  32. package/dist-esm/JavaScriptSDK/HelperFuncs.js +2 -12
  33. package/dist-esm/JavaScriptSDK/HelperFuncs.js.map +1 -1
  34. package/dist-esm/JavaScriptSDK/InstrumentHooks.js +1 -1
  35. package/dist-esm/JavaScriptSDK/InternalConstants.js +1 -1
  36. package/dist-esm/JavaScriptSDK/NotificationManager.js +1 -1
  37. package/dist-esm/JavaScriptSDK/PerfManager.js +1 -1
  38. package/dist-esm/JavaScriptSDK/ProcessTelemetryContext.js +56 -5
  39. package/dist-esm/JavaScriptSDK/ProcessTelemetryContext.js.map +1 -1
  40. package/dist-esm/JavaScriptSDK/RandomHelper.js +1 -1
  41. package/dist-esm/JavaScriptSDK/TelemetryHelpers.js +1 -1
  42. package/dist-esm/JavaScriptSDK/TelemetryInitializerPlugin.js +3 -2
  43. package/dist-esm/JavaScriptSDK/TelemetryInitializerPlugin.js.map +1 -1
  44. package/dist-esm/JavaScriptSDK/UnloadHandlerContainer.js +3 -2
  45. package/dist-esm/JavaScriptSDK/UnloadHandlerContainer.js.map +1 -1
  46. package/dist-esm/JavaScriptSDK.Enums/EventsDiscardedReason.js +1 -1
  47. package/dist-esm/JavaScriptSDK.Enums/LoggingEnums.js +1 -1
  48. package/dist-esm/JavaScriptSDK.Enums/SendRequestReason.js +1 -1
  49. package/dist-esm/JavaScriptSDK.Enums/TelemetryUnloadReason.js +1 -1
  50. package/dist-esm/JavaScriptSDK.Enums/TelemetryUpdateReason.js +8 -0
  51. package/dist-esm/JavaScriptSDK.Enums/TelemetryUpdateReason.js.map +1 -0
  52. package/dist-esm/JavaScriptSDK.Interfaces/IAppInsightsCore.js +1 -1
  53. package/dist-esm/JavaScriptSDK.Interfaces/IChannelControls.js +1 -1
  54. package/dist-esm/JavaScriptSDK.Interfaces/IConfiguration.js +1 -1
  55. package/dist-esm/JavaScriptSDK.Interfaces/ICookieMgr.js +1 -1
  56. package/dist-esm/JavaScriptSDK.Interfaces/IDbgExtension.js +1 -1
  57. package/dist-esm/JavaScriptSDK.Interfaces/IDiagnosticLogger.js +1 -1
  58. package/dist-esm/JavaScriptSDK.Interfaces/IInstrumentHooks.js +1 -1
  59. package/dist-esm/JavaScriptSDK.Interfaces/INotificationListener.js +1 -1
  60. package/dist-esm/JavaScriptSDK.Interfaces/INotificationManager.js +1 -1
  61. package/dist-esm/JavaScriptSDK.Interfaces/IPerfEvent.js +1 -1
  62. package/dist-esm/JavaScriptSDK.Interfaces/IPerfManager.js +1 -1
  63. package/dist-esm/JavaScriptSDK.Interfaces/IProcessTelemetryContext.js +1 -1
  64. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryInitializers.js +1 -1
  65. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryItem.js +1 -1
  66. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryPlugin.js +1 -1
  67. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryPluginChain.js +1 -1
  68. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUnloadState.js +1 -1
  69. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUpdateState.js +8 -0
  70. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUpdateState.js.map +1 -0
  71. package/dist-esm/applicationinsights-core-js.js +3 -3
  72. package/dist-esm/applicationinsights-core-js.js.map +1 -1
  73. package/package.json +1 -1
  74. package/src/JavaScriptSDK/BaseCore.ts +82 -17
  75. package/src/JavaScriptSDK/BaseTelemetryPlugin.ts +55 -3
  76. package/src/JavaScriptSDK/ChannelController.ts +20 -1
  77. package/src/JavaScriptSDK/CookieMgr.ts +3 -1
  78. package/src/JavaScriptSDK/DiagnosticLogger.ts +14 -0
  79. package/src/JavaScriptSDK/EventHelpers.ts +18 -12
  80. package/src/JavaScriptSDK/HelperFuncs.ts +3 -1
  81. package/src/JavaScriptSDK/ProcessTelemetryContext.ts +71 -8
  82. package/src/JavaScriptSDK/TelemetryInitializerPlugin.ts +3 -1
  83. package/src/JavaScriptSDK/UnloadHandlerContainer.ts +3 -1
  84. package/src/JavaScriptSDK.Enums/TelemetryUpdateReason.ts +27 -0
  85. package/src/JavaScriptSDK.Interfaces/IAppInsightsCore.ts +22 -5
  86. package/src/JavaScriptSDK.Interfaces/IInstrumentHooks.ts +11 -6
  87. package/src/JavaScriptSDK.Interfaces/IProcessTelemetryContext.ts +25 -2
  88. package/src/JavaScriptSDK.Interfaces/ITelemetryPlugin.ts +12 -1
  89. package/src/JavaScriptSDK.Interfaces/ITelemetryUpdateState.ts +34 -0
  90. package/types/JavaScriptSDK/BaseCore.d.ts +32 -3
  91. package/types/JavaScriptSDK/BaseTelemetryPlugin.d.ts +17 -1
  92. package/types/JavaScriptSDK/DiagnosticLogger.d.ts +10 -0
  93. package/types/JavaScriptSDK/EventHelpers.d.ts +4 -2
  94. package/types/JavaScriptSDK/HelperFuncs.d.ts +2 -1
  95. package/types/JavaScriptSDK/ProcessTelemetryContext.d.ts +9 -1
  96. package/types/JavaScriptSDK.Enums/TelemetryUpdateReason.d.ts +20 -0
  97. package/types/JavaScriptSDK.Interfaces/IAppInsightsCore.d.ts +20 -4
  98. package/types/JavaScriptSDK.Interfaces/IInstrumentHooks.d.ts +5 -0
  99. package/types/JavaScriptSDK.Interfaces/IProcessTelemetryContext.d.ts +23 -2
  100. package/types/JavaScriptSDK.Interfaces/ITelemetryPlugin.d.ts +11 -1
  101. package/types/JavaScriptSDK.Interfaces/ITelemetryUpdateState.d.ts +22 -0
  102. package/types/applicationinsights-core-js.d.ts +6 -3
@@ -12,8 +12,8 @@ import { ITelemetryItem } from "../JavaScriptSDK.Interfaces/ITelemetryItem";
12
12
  import { INotificationManager } from "../JavaScriptSDK.Interfaces/INotificationManager";
13
13
  import { INotificationListener } from "../JavaScriptSDK.Interfaces/INotificationListener";
14
14
  import { IDiagnosticLogger } from "../JavaScriptSDK.Interfaces/IDiagnosticLogger";
15
- import { IProcessTelemetryContext } from "../JavaScriptSDK.Interfaces/IProcessTelemetryContext";
16
- import { createProcessTelemetryContext, createProcessTelemetryUnloadContext, createTelemetryProxyChain } from "./ProcessTelemetryContext";
15
+ import { IProcessTelemetryContext, IProcessTelemetryUpdateContext } from "../JavaScriptSDK.Interfaces/IProcessTelemetryContext";
16
+ import { createProcessTelemetryContext, createProcessTelemetryUnloadContext, createProcessTelemetryUpdateContext, createTelemetryProxyChain } from "./ProcessTelemetryContext";
17
17
  import { initializePlugins, sortPlugins, _getPluginState } from "./TelemetryHelpers";
18
18
  import { eLoggingSeverity, _eInternalMessageId } from "../JavaScriptSDK.Enums/LoggingEnums";
19
19
  import { IPerfManager } from "../JavaScriptSDK.Interfaces/IPerfManager";
@@ -22,7 +22,7 @@ import { ICookieMgr } from "../JavaScriptSDK.Interfaces/ICookieMgr";
22
22
  import { createCookieMgr } from "./CookieMgr";
23
23
  import { arrForEach, isNullOrUndefined, toISOString, getSetValue, setValue, throwError, isNotTruthy, isFunction, objFreeze, proxyFunctionAs, proxyFunctions } from "./HelperFuncs";
24
24
  import { strExtensionConfig, strIKey } from "./Constants";
25
- import { DiagnosticLogger, _InternalLogMessage } from "./DiagnosticLogger";
25
+ import { DiagnosticLogger, _InternalLogMessage, _throwInternal } from "./DiagnosticLogger";
26
26
  import { getDebugListener } from "./DbgExtensionUtils";
27
27
  import { ITelemetryPluginChain } from "../JavaScriptSDK.Interfaces/ITelemetryPluginChain";
28
28
  import { ChannelControllerPriority, createChannelControllerPlugin, createChannelQueues, IChannelController, IInternalChannelController, _IInternalChannels } from "./ChannelController";
@@ -30,6 +30,8 @@ import { ITelemetryInitializerHandler, TelemetryInitializerFunction } from "../J
30
30
  import { TelemetryInitializerPlugin } from "./TelemetryInitializerPlugin";
31
31
  import { createUniqueNamespace } from "./DataCacheHelper";
32
32
  import { createUnloadHandlerContainer, IUnloadHandlerContainer, UnloadHandler } from "./UnloadHandlerContainer";
33
+ import { TelemetryUpdateReason } from "../JavaScriptSDK.Enums/TelemetryUpdateReason";
34
+ import { ITelemetryUpdateState } from "../JavaScriptSDK.Interfaces/ITelemetryUpdateState";
33
35
  import { ITelemetryUnloadState } from "../JavaScriptSDK.Interfaces/ITelemetryUnloadState";
34
36
  import { TelemetryUnloadReason } from "../JavaScriptSDK.Enums/TelemetryUnloadReason";
35
37
  import { SendRequestReason } from "../JavaScriptSDK.Enums/SendRequestReason";
@@ -190,9 +192,9 @@ export class BaseCore implements IAppInsightsCore {
190
192
  _configExtensions.push(...extensions, ...config.extensions);
191
193
  _channelConfig = (config||{}).channels;
192
194
 
193
- _initPluginChain(config);
195
+ _initPluginChain(config, null);
194
196
 
195
- if (_self.getTransmissionControls().length === 0) {
197
+ if (!_channelQueue || _channelQueue.length === 0) {
196
198
  throwError("No channels available");
197
199
  }
198
200
 
@@ -377,16 +379,14 @@ export class BaseCore implements IAppInsightsCore {
377
379
  processUnloadCtx.processNext(unloadState);
378
380
  }
379
381
 
380
- if (_channelControl) {
381
- _channelControl.flush(isAsync, _doUnload, SendRequestReason.SdkUnload, cbTimeout);
382
- } else {
383
- _doUnload(true);
382
+ if (!_flushChannels(isAsync, _doUnload, SendRequestReason.SdkUnload, cbTimeout)) {
383
+ _doUnload(false);
384
384
  }
385
385
  };
386
386
 
387
387
  _self.getPlugin = _getPlugin;
388
388
 
389
- _self.addPlugin = <T extends IPlugin = ITelemetryPlugin>(plugin: T, replaceExisting: boolean, isAsync: boolean = true, addCb?: (added?: boolean) => void): void => {
389
+ _self.addPlugin = <T extends IPlugin = ITelemetryPlugin>(plugin: T, replaceExisting?: boolean, isAsync?: boolean, addCb?: (added?: boolean) => void): void => {
390
390
  if (!plugin) {
391
391
  addCb && addCb(false);
392
392
  _logOrThrowError(strValidationError);
@@ -401,11 +401,16 @@ export class BaseCore implements IAppInsightsCore {
401
401
  return;
402
402
  }
403
403
 
404
+ let updateState: ITelemetryUpdateState = {
405
+ reason: TelemetryUpdateReason.PluginAdded
406
+ };
407
+
404
408
  function _addPlugin(removed: boolean) {
405
409
  _configExtensions.push(plugin);
410
+ updateState.added = [plugin];
406
411
 
407
412
  // Re-Initialize the plugin chain
408
- _initPluginChain(_self.config);
413
+ _initPluginChain(_self.config, updateState);
409
414
  addCb && addCb(true);
410
415
  }
411
416
 
@@ -421,6 +426,8 @@ export class BaseCore implements IAppInsightsCore {
421
426
  // Previous plugin was successfully removed or was not installed
422
427
  addCb && addCb(false);
423
428
  } else {
429
+ updateState.removed = removedPlugins
430
+ updateState.reason |= TelemetryUpdateReason.PluginRemoved;
424
431
  _addPlugin(true);
425
432
  }
426
433
  });
@@ -433,6 +440,8 @@ export class BaseCore implements IAppInsightsCore {
433
440
  return _evtNamespace;
434
441
  };
435
442
 
443
+ _self.flush = _flushChannels;
444
+
436
445
  // Create the addUnloadCb
437
446
  proxyFunctionAs(_self, "addUnloadCb", () => _unloadHandlers, "add");
438
447
 
@@ -467,7 +476,7 @@ export class BaseCore implements IAppInsightsCore {
467
476
  }
468
477
 
469
478
  // Initialize or Re-initialize the plugins
470
- function _initPluginChain(config: IConfiguration) {
479
+ function _initPluginChain(config: IConfiguration, updateState: ITelemetryUpdateState) {
471
480
  // Extension validation
472
481
  let theExtensions = _validateExtensions(_self.logger, ChannelControllerPriority, _configExtensions);
473
482
 
@@ -513,6 +522,10 @@ export class BaseCore implements IAppInsightsCore {
513
522
 
514
523
  // Now reset the extensions to just those being managed by Basecore
515
524
  _self._extensions = objFreeze(sortPlugins(_coreExtensions || [])).slice();
525
+
526
+ if (updateState) {
527
+ _doUpdate(updateState);
528
+ }
516
529
  }
517
530
 
518
531
  function _getPlugin<T extends IPlugin = IPlugin>(pluginIdentifier: string): ILoadedPlugin<T> {
@@ -551,7 +564,10 @@ export class BaseCore implements IAppInsightsCore {
551
564
  _removePlugins(pluginsToRemove, unloadState, (removed) => {
552
565
  if (removed) {
553
566
  // Re-Initialize the plugin chain
554
- _initPluginChain(_self.config);
567
+ _initPluginChain(_self.config, {
568
+ reason: TelemetryUpdateReason.PluginRemoved,
569
+ removed: pluginsToRemove
570
+ });
555
571
  }
556
572
 
557
573
  removeCb && removeCb(removed);
@@ -646,6 +662,15 @@ export class BaseCore implements IAppInsightsCore {
646
662
  }
647
663
  }
648
664
 
665
+ function _flushChannels(isAsync?: boolean, callBack?: (flushComplete?: boolean) => void, sendReason?: SendRequestReason, cbTimeout?: number) {
666
+ if (_channelControl) {
667
+ return _channelControl.flush(isAsync, callBack, sendReason || SendRequestReason.SdkUnload, cbTimeout);
668
+ }
669
+
670
+ callBack && callBack(false);
671
+ return true;
672
+ }
673
+
649
674
  function _initDebugListener(config: IConfiguration) {
650
675
 
651
676
  if (config.disableDbgExt === true && _debugListener) {
@@ -677,11 +702,19 @@ export class BaseCore implements IAppInsightsCore {
677
702
  extConfig.NotificationManager = _notificationManager;
678
703
  }
679
704
 
705
+ function _doUpdate(updateState: ITelemetryUpdateState): void {
706
+ let updateCtx = createProcessTelemetryUpdateContext(_getPluginChain(), _self.config, _self);
707
+
708
+ if (!_self._updateHook || _self._updateHook(updateCtx, updateState) !== true) {
709
+ updateCtx.processNext(updateState);
710
+ }
711
+ }
712
+
680
713
  function _logOrThrowError(message: string) {
681
714
  let logger = _self.logger;
682
715
  if (logger) {
683
716
  // there should always be a logger
684
- logger.throwInternal(eLoggingSeverity.WARNING, _eInternalMessageId.PluginException, message);
717
+ _throwInternal(logger, eLoggingSeverity.WARNING, _eInternalMessageId.PluginException, message);
685
718
  } else {
686
719
  throwError(message);
687
720
  }
@@ -791,10 +824,12 @@ export class BaseCore implements IAppInsightsCore {
791
824
  * approach is to create a new instance and initialize that instance.
792
825
  * This is due to possible unexpected side effects caused by plugins not supporting unload / teardown, unable
793
826
  * to successfully remove any global references or they may just be completing the unload process asynchronously.
827
+ * @param isAsync - Can the unload be performed asynchronously (default)
828
+ * @param unloadComplete - An optional callback that will be called once the unload has completed
829
+ * @param cbTimeout - An optional timeout to wait for any flush operations to complete before proceeding with the unload. Defaults to 5 seconds.
794
830
  */
795
- public unload(isAsync?: boolean, unloadComplete?: () => void): void {
831
+ public unload(isAsync?: boolean, unloadComplete?: (unloadState: ITelemetryUnloadState) => void, cbTimeout?: number): void {
796
832
  // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
797
- return null;
798
833
  }
799
834
 
800
835
  public getPlugin<T extends IPlugin = IPlugin>(pluginIdentifier: string): ILoadedPlugin<T> {
@@ -802,7 +837,14 @@ export class BaseCore implements IAppInsightsCore {
802
837
  return null;
803
838
  }
804
839
 
805
- public addPlugin<T extends IPlugin = ITelemetryPlugin>(plugin: T, replaceExisting: boolean, doAsync: boolean, addCb?: (added?: boolean) => void): void {
840
+ /**
841
+ * Add a new plugin to the installation
842
+ * @param plugin - The new plugin to add
843
+ * @param replaceExisting - should any existing plugin be replaced, default is false
844
+ * @param doAsync - Should the add be performed asynchronously
845
+ * @param addCb - [Optional] callback to call after the plugin has been added
846
+ */
847
+ public addPlugin<T extends IPlugin = ITelemetryPlugin>(plugin: T, replaceExisting?: boolean, doAsync?: boolean, addCb?: (added?: boolean) => void): void {
806
848
  // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
807
849
  }
808
850
 
@@ -822,7 +864,30 @@ export class BaseCore implements IAppInsightsCore {
822
864
  // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
823
865
  }
824
866
 
867
+ /**
868
+ * Flush and send any batched / cached data immediately
869
+ * @param async - send data asynchronously when true (defaults to true)
870
+ * @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.
871
+ * If the caller doesn't return true the caller should assume that it may never be called.
872
+ * @param sendReason - specify the reason that you are calling "flush" defaults to ManualFlush (1) if not specified
873
+ * @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
874
+ */
875
+ public flush(isAsync?: boolean, callBack?: (flushComplete?: boolean) => void, sendReason?: SendRequestReason): void {
876
+ // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
877
+ }
878
+
825
879
  protected releaseQueue() {
826
880
  // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
827
881
  }
882
+
883
+ /**
884
+ * Hook for Core extensions to allow them to update their own configuration before updating all of the plugins.
885
+ * @param updateCtx - The plugin update context
886
+ * @param updateState - The Update State
887
+ * @returns boolean - True means the extension class will call updateState otherwise the Core will
888
+ */
889
+ protected _updateHook?(updateCtx: IProcessTelemetryUpdateContext, updateState: ITelemetryUpdateState): void | boolean {
890
+ // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
891
+ return false;
892
+ }
828
893
  }
@@ -9,15 +9,17 @@ import { IConfiguration } from "../JavaScriptSDK.Interfaces/IConfiguration";
9
9
  import { IDiagnosticLogger } from "../JavaScriptSDK.Interfaces/IDiagnosticLogger";
10
10
  import { IPlugin, ITelemetryPlugin } from "../JavaScriptSDK.Interfaces/ITelemetryPlugin";
11
11
  import { ITelemetryItem } from "../JavaScriptSDK.Interfaces/ITelemetryItem";
12
- import { IProcessTelemetryContext, IProcessTelemetryUnloadContext } from "../JavaScriptSDK.Interfaces/IProcessTelemetryContext";
12
+ import { IProcessTelemetryContext, IProcessTelemetryUnloadContext, IProcessTelemetryUpdateContext } from "../JavaScriptSDK.Interfaces/IProcessTelemetryContext";
13
13
  import { ITelemetryPluginChain } from "../JavaScriptSDK.Interfaces/ITelemetryPluginChain";
14
- import { createProcessTelemetryContext, createProcessTelemetryUnloadContext } from "./ProcessTelemetryContext";
14
+ import { createProcessTelemetryContext, createProcessTelemetryUnloadContext, createProcessTelemetryUpdateContext } from "./ProcessTelemetryContext";
15
15
  import { arrForEach, isArray, isFunction, isNullOrUndefined, proxyFunctionAs, setValue } from "./HelperFuncs";
16
16
  import { strExtensionConfig } from "./Constants";
17
17
  import { createUnloadHandlerContainer, IUnloadHandlerContainer, UnloadHandler } from "./UnloadHandlerContainer";
18
18
  import { IInstrumentHook } from "../JavaScriptSDK.Interfaces/IInstrumentHooks";
19
19
  import { ITelemetryUnloadState } from "../JavaScriptSDK.Interfaces/ITelemetryUnloadState";
20
20
  import { TelemetryUnloadReason } from "../JavaScriptSDK.Enums/TelemetryUnloadReason";
21
+ import { ITelemetryUpdateState } from "../JavaScriptSDK.Interfaces/ITelemetryUpdateState";
22
+ import { TelemetryUpdateReason } from "../JavaScriptSDK.Enums/TelemetryUpdateReason";
21
23
  import { strDoTeardown, strIsInitialized, strSetNextPlugin } from "./InternalConstants";
22
24
 
23
25
  let strGetPlugin = "getPlugin";
@@ -87,6 +89,15 @@ export abstract class BaseTelemetryPlugin implements ITelemetryPlugin {
87
89
  */
88
90
  protected _doTeardown?: (unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState, asyncCallback?: () => void) => void | boolean;
89
91
 
92
+ /**
93
+ * Extension hook to allow implementations to perform some additional update operations before the BaseTelemetryPlugin finishes it's removal
94
+ * @param updateCtx - This is the context that should be used during updating.
95
+ * @param updateState - The details / state of the update process, it holds details like the current and previous configuration.
96
+ * @param asyncCallback - An optional callback that the plugin must call if it returns true to inform the caller that it has completed any async update operations.
97
+ * @returns boolean - true if the plugin has or will call asyncCallback, this allows the plugin to perform any asynchronous operations.
98
+ */
99
+ protected _doUpdate?: (updateCtx?: IProcessTelemetryUpdateContext, updateState?: ITelemetryUpdateState, asyncCallback?: () => void) => void | boolean;
100
+
90
101
  constructor() {
91
102
  let _self = this; // Setting _self here as it's used outside of the dynamicProto as well
92
103
 
@@ -110,7 +121,7 @@ export abstract class BaseTelemetryPlugin implements ITelemetryPlugin {
110
121
  // If this plugin has already been torn down (not operational) or is not initialized (core is not set)
111
122
  // or the core being used for unload was not the same core used for initialization.
112
123
  if (!_self.core || (unloadCtx && _self.core !== unloadCtx.core())) {
113
- // Do Nothing
124
+ // Do Nothing as either the plugin is not initialized or was not initialized by the current core
114
125
  return;
115
126
  }
116
127
 
@@ -151,6 +162,37 @@ export abstract class BaseTelemetryPlugin implements ITelemetryPlugin {
151
162
 
152
163
  return result;
153
164
  };
165
+
166
+ _self.update = (updateCtx: IProcessTelemetryUpdateContext, updateState: ITelemetryUpdateState) => {
167
+ // If this plugin has already been torn down (not operational) or is not initialized (core is not set)
168
+ // or the core being used for unload was not the same core used for initialization.
169
+ if (!_self.core || (updateCtx && _self.core !== updateCtx.core())) {
170
+ // Do Nothing
171
+ return;
172
+ }
173
+
174
+ let result: void | boolean;
175
+ let updateDone = false;
176
+ let theUpdateCtx = updateCtx || createProcessTelemetryUpdateContext(null, {}, _self.core, _nextPlugin && _nextPlugin[strGetPlugin] ? _nextPlugin[strGetPlugin]() : _nextPlugin);
177
+ let theUpdateState: ITelemetryUpdateState = updateState || {
178
+ reason: TelemetryUpdateReason.Unknown
179
+ };
180
+
181
+ function _updateCallback() {
182
+ if (!updateDone) {
183
+ updateDone = true;
184
+ _setDefaults(theUpdateCtx.getCfg(), theUpdateCtx.core(), theUpdateCtx.getNext());
185
+ }
186
+ }
187
+
188
+ if (!_self._doUpdate || _self._doUpdate(theUpdateCtx, theUpdateState, _updateCallback) !== true) {
189
+ _updateCallback();
190
+ } else {
191
+ result = true;
192
+ }
193
+
194
+ return result;
195
+ };
154
196
 
155
197
  _self._addHook = (hooks: IInstrumentHook | IInstrumentHook[]) => {
156
198
  if (hooks) {
@@ -268,6 +310,16 @@ export abstract class BaseTelemetryPlugin implements ITelemetryPlugin {
268
310
 
269
311
  public abstract processTelemetry(env: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
270
312
 
313
+ /**
314
+ * The the plugin should re-evaluate configuration and update any cached configuration settings.
315
+ * @param updateCtx - This is the context that should be used during updating.
316
+ * @param updateState - The details / state of the update process, it holds details like the current and previous configuration.
317
+ * @returns boolean - true if the plugin has or will call updateCtx.processNext(), this allows the plugin to perform any asynchronous operations.
318
+ */
319
+ public update(updateCtx: IProcessTelemetryUpdateContext, updateState: ITelemetryUpdateState): void | boolean{
320
+ // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
321
+ }
322
+
271
323
  /**
272
324
  * Add an unload handler that will be called when the SDK is being unloaded
273
325
  * @param handler - the handler
@@ -3,14 +3,16 @@
3
3
 
4
4
  import { SendRequestReason } from "../JavaScriptSDK.Enums/SendRequestReason";
5
5
  import { TelemetryUnloadReason } from "../JavaScriptSDK.Enums/TelemetryUnloadReason";
6
+ import { TelemetryUpdateReason } from "../JavaScriptSDK.Enums/TelemetryUpdateReason";
6
7
  import { IAppInsightsCore } from "../JavaScriptSDK.Interfaces/IAppInsightsCore";
7
8
  import { IChannelControls } from "../JavaScriptSDK.Interfaces/IChannelControls";
8
9
  import { IConfiguration } from "../JavaScriptSDK.Interfaces/IConfiguration";
9
- import { IBaseProcessingContext, IProcessTelemetryContext, IProcessTelemetryUnloadContext } from "../JavaScriptSDK.Interfaces/IProcessTelemetryContext";
10
+ import { IBaseProcessingContext, IProcessTelemetryContext, IProcessTelemetryUnloadContext, IProcessTelemetryUpdateContext } from "../JavaScriptSDK.Interfaces/IProcessTelemetryContext";
10
11
  import { ITelemetryItem } from "../JavaScriptSDK.Interfaces/ITelemetryItem";
11
12
  import { IPlugin } from "../JavaScriptSDK.Interfaces/ITelemetryPlugin";
12
13
  import { ITelemetryPluginChain } from "../JavaScriptSDK.Interfaces/ITelemetryPluginChain";
13
14
  import { ITelemetryUnloadState } from "../JavaScriptSDK.Interfaces/ITelemetryUnloadState";
15
+ import { ITelemetryUpdateState } from "../JavaScriptSDK.Interfaces/ITelemetryUpdateState";
14
16
  import { arrForEach, isArray, objFreeze, throwError } from "./HelperFuncs";
15
17
  import { strPause, strProcessNext, strResume, strTeardown } from "./InternalConstants";
16
18
  import { createProcessTelemetryContext, createTelemetryProxyChain } from "./ProcessTelemetryContext";
@@ -90,6 +92,20 @@ export function createChannelControllerPlugin(channelQueue: _IInternalChannels[]
90
92
  _runChainOnComplete();
91
93
  }
92
94
 
95
+ function _doUpdate(updateCtx: IProcessTelemetryUpdateContext, updateState: ITelemetryUpdateState) {
96
+ let theUpdateState: ITelemetryUpdateState = updateState || {
97
+ reason: TelemetryUpdateReason.Unknown
98
+ };
99
+
100
+ _processChannelQueue(channelQueue, updateCtx, (chainCtx: IProcessTelemetryUpdateContext) => {
101
+ chainCtx[strProcessNext](theUpdateState);
102
+ }, () => {
103
+ updateCtx[strProcessNext](theUpdateState);
104
+ });
105
+
106
+ return true;
107
+ }
108
+
93
109
  function _doTeardown(unloadCtx: IProcessTelemetryUnloadContext, unloadState: ITelemetryUnloadState) {
94
110
  let theUnloadState: ITelemetryUnloadState = unloadState || {
95
111
  reason: TelemetryUnloadReason.ManualTeardown,
@@ -152,6 +168,7 @@ export function createChannelControllerPlugin(channelQueue: _IInternalChannels[]
152
168
  itemCtx[strProcessNext](item);
153
169
  });
154
170
  },
171
+ update: _doUpdate,
155
172
  [strPause]: () => {
156
173
  _processChannelQueue(channelQueue, _getTelCtx(), (chainCtx: IProcessTelemetryContext) => {
157
174
  chainCtx.iterate<IChannelControls>((plugin) => {
@@ -220,6 +237,8 @@ export function createChannelControllerPlugin(channelQueue: _IInternalChannels[]
220
237
  doneIterating = true;
221
238
  doCallback();
222
239
  });
240
+
241
+ return true;
223
242
  },
224
243
  _setQueue: (queue: _IInternalChannels[]) => {
225
244
  channelQueue = queue;
@@ -11,6 +11,7 @@ import {
11
11
  import { IConfiguration } from "../JavaScriptSDK.Interfaces/IConfiguration";
12
12
  import { IAppInsightsCore } from "../JavaScriptSDK.Interfaces/IAppInsightsCore";
13
13
  import { strEmpty } from "./InternalConstants";
14
+ import { _throwInternal } from "./DiagnosticLogger";
14
15
 
15
16
  const strToGMTString = "toGMTString";
16
17
  const strToUTCString = "toUTCString";
@@ -252,7 +253,8 @@ export function areCookiesSupported(logger?: IDiagnosticLogger): any {
252
253
  let doc = _doc || {} as Document;
253
254
  _supportsCookies = doc[strCookie] !== undefined;
254
255
  } catch (e) {
255
- logger && logger.throwInternal(
256
+ _throwInternal(
257
+ logger,
256
258
  eLoggingSeverity.WARNING,
257
259
  _eInternalMessageId.CannotAccessCookie,
258
260
  "Cannot access document.cookie - " + getExceptionName(e),
@@ -320,3 +320,17 @@ export class DiagnosticLogger implements IDiagnosticLogger {
320
320
  // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
321
321
  }
322
322
  }
323
+
324
+ /**
325
+ * This is a helper method which will call throwInternal on the passed logger, will throw exceptions in
326
+ * debug mode or attempt to log the error as a console warning. This helper is provided mostly to better
327
+ * support minification as logger.throwInternal() will not compress the publish "throwInternal" used throughout
328
+ * the code.
329
+ * @param logger - The Diagnostic Logger instance to use.
330
+ * @param severity {LoggingSeverity} - The severity of the log message
331
+ * @param message {_InternalLogMessage} - The log message.
332
+ */
333
+ export function _throwInternal(logger: IDiagnosticLogger, severity: LoggingSeverity, msgId: _InternalMessageId, msg: string, properties?: Object, isUserAct = false) {
334
+ (logger || new DiagnosticLogger()).throwInternal(severity, msgId, msg, properties, isUserAct);
335
+ }
336
+
@@ -49,12 +49,12 @@ function _normalizeNamespace(name: string) {
49
49
  return name;
50
50
  }
51
51
 
52
- function _getEvtNamespace(eventName: string, namespaces: string | string[]): IEventDetails {
53
- if (namespaces) {
52
+ function _getEvtNamespace(eventName: string, evtNamespace?: string | string[]): IEventDetails {
53
+ if (evtNamespace) {
54
54
  let theNamespace: string = "";
55
- if (isArray(namespaces)) {
55
+ if (isArray(evtNamespace)) {
56
56
  theNamespace = "";
57
- arrForEach(namespaces, (name) => {
57
+ arrForEach(evtNamespace, (name) => {
58
58
  name = _normalizeNamespace(name);
59
59
  if (name) {
60
60
  if (name[0] !== ".") {
@@ -65,7 +65,7 @@ function _getEvtNamespace(eventName: string, namespaces: string | string[]): IEv
65
65
  }
66
66
  });
67
67
  } else {
68
- theNamespace = _normalizeNamespace(namespaces);
68
+ theNamespace = _normalizeNamespace(evtNamespace);
69
69
  }
70
70
 
71
71
  if (theNamespace) {
@@ -96,18 +96,24 @@ export interface _IRegisteredEvents {
96
96
  * Get all of the registered events on the target object, this is primarily used for testing cleanup but may also be used by
97
97
  * applications to remove their own events
98
98
  * @param target - The EventTarget that has registered events
99
- * @param evtName - [Optional] The name of the event to return the registered handlers and full name (with namespaces)
99
+ * @param eventName - [Optional] The name of the event to return the registered handlers and full name (with namespaces)
100
+ * @param evtNamespace - [Optional] Additional namespace(s) to append to the event listeners so they can be uniquely identified and removed based on this namespace,
101
+ * if the eventName also includes a namespace the namespace(s) are merged into a single namespace
100
102
  */
101
- export function __getRegisteredEvents(target: any, evtName?: string): _IRegisteredEvents[] {
103
+ export function __getRegisteredEvents(target: any, eventName?: string, evtNamespace?: string | string[]): _IRegisteredEvents[] {
102
104
  let theEvents: _IRegisteredEvents[] = [];
103
105
  let eventCache = elmNodeData.get<IAiEvents>(target, strEvents, {}, false);
106
+ let evtName = _getEvtNamespace(eventName, evtNamespace);
107
+
104
108
  objForEachKey(eventCache, (evtType, registeredEvents) => {
105
109
  arrForEach(registeredEvents, (value) => {
106
- if (!evtName || evtName === value.evtName.type) {
107
- theEvents.push({
108
- name: value.evtName.type + (value.evtName.ns ? "." + value.evtName.ns : ""),
109
- handler: value.handler
110
- });
110
+ if (!evtName.type || evtName.type === value.evtName.type) {
111
+ if (!evtName.ns || evtName.ns === evtName.ns) {
112
+ theEvents.push({
113
+ name: value.evtName.type + (value.evtName.ns ? "." + value.evtName.ns : ""),
114
+ handler: value.handler
115
+ });
116
+ }
111
117
  }
112
118
  });
113
119
  });
@@ -871,7 +871,9 @@ export function optimizeObject<T>(theObject: T): T {
871
871
  * @param obj5 - object to merge.
872
872
  * @returns The extended first object.
873
873
  */
874
- export function objExtend<T1, T2, T3, T4, T5, T6>(obj?: boolean | T1, obj2?: T2, obj3?: T3, obj4?: T4, obj5?: T5, obj6?: T6): T1 & T2 & T3 & T4 & T5 & T6 {
874
+ export function objExtend<T2, T3, T4, T5, T6>(deepExtend?: boolean, obj2?: T2, obj3?: T3, obj4?: T4, obj5?: T5, obj6?: T6): T2 & T3 & T4 & T5 & T6
875
+ export function objExtend<T1, T2, T3, T4, T5, T6>(obj1?: T1, obj2?: T2, obj3?: T3, obj4?: T4, obj5?: T5, obj6?: T6): T1 & T2 & T3 & T4 & T5 & T6
876
+ export function objExtend<T1, T2, T3, T4, T5, T6>(obj1?: T1 | any, obj2?: T2, obj3?: T3, obj4?: T4, obj5?: T5, obj6?: T6): T1 & T2 & T3 & T4 & T5 & T6 {
875
877
  // Variables
876
878
  let theArgs = arguments as any;
877
879
  let extended: T1 & T2 & T3 & T4 & T5 & T6 = theArgs[0] || {};
@@ -6,16 +6,17 @@ import { IAppInsightsCore } from "../JavaScriptSDK.Interfaces/IAppInsightsCore";
6
6
  import { IConfiguration } from "../JavaScriptSDK.Interfaces/IConfiguration";
7
7
  import { ITelemetryItem } from "../JavaScriptSDK.Interfaces/ITelemetryItem";
8
8
  import { IPlugin, ITelemetryPlugin } from "../JavaScriptSDK.Interfaces/ITelemetryPlugin";
9
- import { GetExtCfgMergeType, IBaseProcessingContext, IProcessTelemetryContext, IProcessTelemetryUnloadContext } from "../JavaScriptSDK.Interfaces/IProcessTelemetryContext";
9
+ import { GetExtCfgMergeType, IBaseProcessingContext, IProcessTelemetryContext, IProcessTelemetryUnloadContext, IProcessTelemetryUpdateContext } from "../JavaScriptSDK.Interfaces/IProcessTelemetryContext";
10
10
  import { ITelemetryPluginChain } from "../JavaScriptSDK.Interfaces/ITelemetryPluginChain";
11
- import { safeGetLogger } from "./DiagnosticLogger";
11
+ import { safeGetLogger, _throwInternal } from "./DiagnosticLogger";
12
12
  import { arrForEach, isArray, isFunction, isNullOrUndefined, isObject, isUndefined, objExtend, objForEachKey, objFreeze, objKeys, proxyFunctions } from "./HelperFuncs";
13
13
  import { doPerf } from "./PerfManager";
14
14
  import { eLoggingSeverity, _eInternalMessageId } from "../JavaScriptSDK.Enums/LoggingEnums";
15
15
  import { dumpObj } from "./EnvUtils";
16
- import { strCore, strDisabled, strEmpty, strIsInitialized, strTeardown } from "./InternalConstants";
16
+ import { strCore, strDisabled, strEmpty, strIsInitialized, strTeardown, strUpdate } from "./InternalConstants";
17
17
  import { IDiagnosticLogger } from "../JavaScriptSDK.Interfaces/IDiagnosticLogger";
18
18
  import { ITelemetryUnloadState } from "../JavaScriptSDK.Interfaces/ITelemetryUnloadState";
19
+ import { ITelemetryUpdateState } from "../JavaScriptSDK.Interfaces/ITelemetryUpdateState";
19
20
  import { _getPluginState } from "./TelemetryHelpers";
20
21
 
21
22
  const strTelemetryPluginChain = "TelemetryPluginChain";
@@ -123,10 +124,11 @@ function _createInternalContext<T extends IBaseProcessingContext>(telemetryChain
123
124
  try {
124
125
  completeDetails.func.call(completeDetails.self, completeDetails.args);
125
126
  } catch (e) {
126
- core.logger.throwInternal(
127
- eLoggingSeverity.WARNING,
128
- _eInternalMessageId.PluginException,
129
- "Unexpected Exception during onComplete - " + dumpObj(e));
127
+ _throwInternal(
128
+ core.logger,
129
+ eLoggingSeverity.WARNING,
130
+ _eInternalMessageId.PluginException,
131
+ "Unexpected Exception during onComplete - " + dumpObj(e));
130
132
  }
131
133
  });
132
134
 
@@ -265,6 +267,38 @@ export function createProcessTelemetryUnloadContext(telemetryChain: ITelemetryPl
265
267
  return context;
266
268
  }
267
269
 
270
+ /**
271
+ * Creates a new Telemetry Item context with the current config, core and plugin execution chain for updating the configuration
272
+ * @param plugins - The plugin instances that will be executed
273
+ * @param config - The current config
274
+ * @param core - The current core instance
275
+ * @param startAt - Identifies the next plugin to execute, if null there is no "next" plugin and if undefined it should assume the start of the chain
276
+ */
277
+ export function createProcessTelemetryUpdateContext(telemetryChain: ITelemetryPluginChain, config: IConfiguration, core:IAppInsightsCore, startAt?: IPlugin): IProcessTelemetryUpdateContext {
278
+ let internalContext: IInternalContext<IProcessTelemetryUpdateContext> = _createInternalContext<IProcessTelemetryUpdateContext>(telemetryChain, config, core, startAt);
279
+ let context = internalContext.ctx;
280
+
281
+ function _processNext(updateState: ITelemetryUpdateState) {
282
+ return context.iterate((plugin) => {
283
+ if (isFunction(plugin[strUpdate])) {
284
+ plugin[strUpdate](context, updateState);
285
+ }
286
+ });
287
+ }
288
+
289
+ function _createNew(plugins: IPlugin[] | ITelemetryPluginChain = null, startAt?: IPlugin) {
290
+ if (isArray(plugins)) {
291
+ plugins = createTelemetryProxyChain(plugins, config, core, startAt);
292
+ }
293
+
294
+ return createProcessTelemetryUpdateContext(plugins || context.getNext(), config, core, startAt);
295
+ }
296
+
297
+ context.processNext = _processNext;
298
+ context.createNew = _createNew;
299
+
300
+ return context;
301
+ }
268
302
 
269
303
  /**
270
304
  * Creates an execution chain from the array of plugins
@@ -340,6 +374,7 @@ export function createTelemetryPluginProxy(plugin: ITelemetryPlugin, config: ICo
340
374
  },
341
375
  processTelemetry: _processTelemetry,
342
376
  unload: _unloadPlugin,
377
+ update: _updatePlugin,
343
378
  _id: chainId,
344
379
  _setNext: (nextPlugin: IInternalTelemetryPluginChain) => {
345
380
  nextProxy = nextPlugin;
@@ -405,7 +440,8 @@ export function createTelemetryPluginProxy(plugin: ITelemetryPlugin, config: ICo
405
440
 
406
441
  // Either we have no next plugin or the current one did not attempt to call the next plugin
407
442
  // Which means the current one is the root of the failure so log/report this failure
408
- itemCtx.diagLog().throwInternal(
443
+ _throwInternal(
444
+ itemCtx.diagLog(),
409
445
  eLoggingSeverity.CRITICAL,
410
446
  _eInternalMessageId.PluginException,
411
447
  "Plugin [" + plugin.identifier + "] failed during " + name + " - " + dumpObj(error) + ", run flags: " + dumpObj(hasRunContext));
@@ -482,6 +518,33 @@ export function createTelemetryPluginProxy(plugin: ITelemetryPlugin, config: ICo
482
518
  }
483
519
  }
484
520
 
521
+ function _updatePlugin(updateCtx: IProcessTelemetryUpdateContext, updateState: ITelemetryUpdateState) {
522
+
523
+ function _callUpdate() {
524
+ // Setting default of hasRun as false so the proxyProcessFn() is called as teardown() doesn't have to exist or call unloadNext().
525
+ let hasRun = false;
526
+ if (plugin) {
527
+ let pluginState = _getPluginState(plugin);
528
+ let pluginCore = plugin[strCore] || pluginState.core;
529
+
530
+ // Only update the plugin if it was initialized by the current core (i.e. It's not a shared plugin)
531
+ if (plugin && (!pluginCore || pluginCore === updateCtx[strCore]()) && !pluginState[strTeardown]) {
532
+ if (plugin[strUpdate] && plugin[strUpdate](updateCtx, updateState) === true) {
533
+ // plugin told us that it was going to (or has) call unloadCtx.processNext()
534
+ hasRun = true;
535
+ }
536
+ }
537
+ }
538
+
539
+ return hasRun;
540
+ }
541
+
542
+ if (!_processChain(updateCtx, _callUpdate, "update", () => {}, false)) {
543
+ // Only called if we hasRun was not true
544
+ updateCtx.processNext(updateState);
545
+ }
546
+ }
547
+
485
548
  return objFreeze(proxyChain);
486
549
  }
487
550
 
@@ -7,6 +7,7 @@ import { IProcessTelemetryContext } from "../JavaScriptSDK.Interfaces/IProcessTe
7
7
  import { ITelemetryInitializerContainer, ITelemetryInitializerHandler, TelemetryInitializerFunction } from "../JavaScriptSDK.Interfaces/ITelemetryInitializers";
8
8
  import { ITelemetryItem } from "../JavaScriptSDK.Interfaces/ITelemetryItem";
9
9
  import { BaseTelemetryPlugin } from "./BaseTelemetryPlugin";
10
+ import { _throwInternal } from "./DiagnosticLogger";
10
11
  import { dumpObj } from "./EnvUtils";
11
12
  import { arrForEach, getExceptionName } from "./HelperFuncs";
12
13
  import { strDoTeardown } from "./InternalConstants";
@@ -68,7 +69,8 @@ export class TelemetryInitializerPlugin extends BaseTelemetryPlugin implements I
68
69
  } catch (e) {
69
70
  // log error but dont stop executing rest of the telemetry initializers
70
71
  // doNotSendItem = true;
71
- itemCtx.diagLog().throwInternal(
72
+ _throwInternal(
73
+ itemCtx.diagLog(),
72
74
  eLoggingSeverity.CRITICAL,
73
75
  _eInternalMessageId.TelemetryInitializerFailed,
74
76
  "One of telemetry initializers failed, telemetry item will not be sent: " + getExceptionName(e),
@@ -4,6 +4,7 @@
4
4
  import { eLoggingSeverity, _eInternalMessageId } from "../JavaScriptSDK.Enums/LoggingEnums";
5
5
  import { IProcessTelemetryUnloadContext } from "../JavaScriptSDK.Interfaces/IProcessTelemetryContext";
6
6
  import { ITelemetryUnloadState } from "../JavaScriptSDK.Interfaces/ITelemetryUnloadState";
7
+ import { _throwInternal } from "./DiagnosticLogger";
7
8
  import { dumpObj } from "./EnvUtils";
8
9
  import { arrForEach } from "./HelperFuncs";
9
10
 
@@ -28,7 +29,8 @@ export function createUnloadHandlerContainer() {
28
29
  try {
29
30
  handler(unloadCtx, unloadState);
30
31
  } catch (e) {
31
- unloadCtx.diagLog().throwInternal(
32
+ _throwInternal(
33
+ unloadCtx.diagLog(),
32
34
  eLoggingSeverity.WARNING,
33
35
  _eInternalMessageId.PluginException,
34
36
  "Unexpected error calling unload handler - " + dumpObj(e));