@microsoft/applicationinsights-core-js 3.0.0-beta.2211-01 → 3.0.0-beta.2211-04

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 (101) hide show
  1. package/browser/applicationinsights-core-js.integrity.json +9 -9
  2. package/browser/applicationinsights-core-js.js +1093 -1237
  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 +91 -89
  7. package/dist/applicationinsights-core-js.api.md +11 -10
  8. package/dist/applicationinsights-core-js.d.ts +10 -9
  9. package/dist/applicationinsights-core-js.js +1093 -1237
  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 +10 -9
  14. package/dist-esm/Config/ConfigDefaults.js +1 -1
  15. package/dist-esm/Config/DynamicConfig.js +1 -1
  16. package/dist-esm/Config/DynamicProperty.js +1 -1
  17. package/dist-esm/Config/DynamicState.js +3 -3
  18. package/dist-esm/Config/DynamicState.js.map +1 -1
  19. package/dist-esm/Config/DynamicSupport.js +1 -1
  20. package/dist-esm/Config/IConfigDefaults.js +1 -1
  21. package/dist-esm/Config/IDynamicConfigHandler.js +1 -1
  22. package/dist-esm/Config/IDynamicPropertyHandler.js +1 -1
  23. package/dist-esm/Config/IDynamicWatcher.js +1 -1
  24. package/dist-esm/Config/_IDynamicConfigHandlerState.js +1 -1
  25. package/dist-esm/JavaScriptSDK/AggregationError.js +1 -1
  26. package/dist-esm/JavaScriptSDK/AppInsightsCore.js +115 -72
  27. package/dist-esm/JavaScriptSDK/AppInsightsCore.js.map +1 -1
  28. package/dist-esm/JavaScriptSDK/BaseTelemetryPlugin.js +1 -1
  29. package/dist-esm/JavaScriptSDK/Constants.js +8 -0
  30. package/dist-esm/JavaScriptSDK/Constants.js.map +1 -0
  31. package/dist-esm/JavaScriptSDK/CookieMgr.js +1 -1
  32. package/dist-esm/JavaScriptSDK/CoreUtils.js +1 -1
  33. package/dist-esm/JavaScriptSDK/DataCacheHelper.js +2 -2
  34. package/dist-esm/JavaScriptSDK/DataCacheHelper.js.map +1 -1
  35. package/dist-esm/JavaScriptSDK/DbgExtensionUtils.js +1 -1
  36. package/dist-esm/JavaScriptSDK/DiagnosticLogger.js +1 -1
  37. package/dist-esm/JavaScriptSDK/EnvUtils.js +1 -1
  38. package/dist-esm/JavaScriptSDK/EventHelpers.js +1 -1
  39. package/dist-esm/JavaScriptSDK/HelperFuncs.js +1 -1
  40. package/dist-esm/JavaScriptSDK/InstrumentHooks.js +1 -1
  41. package/dist-esm/JavaScriptSDK/InternalConstants.js +1 -1
  42. package/dist-esm/JavaScriptSDK/NotificationManager.js +1 -1
  43. package/dist-esm/JavaScriptSDK/PerfManager.js +1 -1
  44. package/dist-esm/JavaScriptSDK/ProcessTelemetryContext.js +5 -5
  45. package/dist-esm/JavaScriptSDK/ProcessTelemetryContext.js.map +1 -1
  46. package/dist-esm/JavaScriptSDK/RandomHelper.js +1 -1
  47. package/dist-esm/JavaScriptSDK/TelemetryHelpers.js +1 -1
  48. package/dist-esm/JavaScriptSDK/TelemetryInitializerPlugin.js +1 -1
  49. package/dist-esm/JavaScriptSDK/UnloadHandlerContainer.js +1 -1
  50. package/dist-esm/JavaScriptSDK/W3cTraceParent.js +1 -1
  51. package/dist-esm/JavaScriptSDK.Enums/EnumHelperFuncs.js +1 -1
  52. package/dist-esm/JavaScriptSDK.Enums/EventsDiscardedReason.js +1 -1
  53. package/dist-esm/JavaScriptSDK.Enums/LoggingEnums.js +1 -1
  54. package/dist-esm/JavaScriptSDK.Enums/SendRequestReason.js +1 -1
  55. package/dist-esm/JavaScriptSDK.Enums/TelemetryUnloadReason.js +1 -1
  56. package/dist-esm/JavaScriptSDK.Enums/TelemetryUpdateReason.js +1 -1
  57. package/dist-esm/JavaScriptSDK.Interfaces/IAppInsightsCore.js +1 -1
  58. package/dist-esm/JavaScriptSDK.Interfaces/IChannelControls.js +1 -1
  59. package/dist-esm/JavaScriptSDK.Interfaces/IConfiguration.js +1 -1
  60. package/dist-esm/JavaScriptSDK.Interfaces/ICookieMgr.js +1 -1
  61. package/dist-esm/JavaScriptSDK.Interfaces/IDbgExtension.js +1 -1
  62. package/dist-esm/JavaScriptSDK.Interfaces/IDiagnosticLogger.js +1 -1
  63. package/dist-esm/JavaScriptSDK.Interfaces/IDistributedTraceContext.js +1 -1
  64. package/dist-esm/JavaScriptSDK.Interfaces/IInstrumentHooks.js +1 -1
  65. package/dist-esm/JavaScriptSDK.Interfaces/INotificationListener.js +1 -1
  66. package/dist-esm/JavaScriptSDK.Interfaces/INotificationManager.js +1 -1
  67. package/dist-esm/JavaScriptSDK.Interfaces/IPerfEvent.js +1 -1
  68. package/dist-esm/JavaScriptSDK.Interfaces/IPerfManager.js +1 -1
  69. package/dist-esm/JavaScriptSDK.Interfaces/IProcessTelemetryContext.js +1 -1
  70. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryInitializers.js +1 -1
  71. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryItem.js +1 -1
  72. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryPlugin.js +1 -1
  73. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryPluginChain.js +1 -1
  74. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUnloadState.js +1 -1
  75. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUpdateState.js +1 -1
  76. package/dist-esm/JavaScriptSDK.Interfaces/ITraceParent.js +1 -1
  77. package/dist-esm/JavaScriptSDK.Interfaces/IUnloadHook.js +1 -1
  78. package/dist-esm/JavaScriptSDK.Interfaces/IUnloadableComponent.js +1 -1
  79. package/dist-esm/__DynamicConstants.js +17 -17
  80. package/dist-esm/__DynamicConstants.js.map +1 -1
  81. package/dist-esm/applicationinsights-core-js.js +1 -1
  82. package/package.json +1 -1
  83. package/src/JavaScriptSDK/AppInsightsCore.ts +126 -79
  84. package/src/JavaScriptSDK/Constants.ts +4 -0
  85. package/src/JavaScriptSDK.Interfaces/IAppInsightsCore.ts +4 -3
  86. package/src/JavaScriptSDK.Interfaces/IChannelControls.ts +4 -4
  87. package/types/Config/IConfigDefaults.d.ts +3 -3
  88. package/types/Config/IDynamicWatcher.d.ts +1 -1
  89. package/types/JavaScriptSDK/AppInsightsCore.d.ts +3 -2
  90. package/types/JavaScriptSDK/Constants.d.ts +1 -0
  91. package/types/JavaScriptSDK/UnloadHandlerContainer.d.ts +1 -1
  92. package/types/JavaScriptSDK.Enums/EventsDiscardedReason.d.ts +1 -1
  93. package/types/JavaScriptSDK.Enums/LoggingEnums.d.ts +2 -2
  94. package/types/JavaScriptSDK.Interfaces/IAppInsightsCore.d.ts +3 -2
  95. package/types/JavaScriptSDK.Interfaces/IChannelControls.d.ts +4 -4
  96. package/types/JavaScriptSDK.Interfaces/IInstrumentHooks.d.ts +1 -1
  97. package/types/__DynamicConstants.d.ts +4 -4
  98. package/dist-esm/JavaScriptSDK/ChannelController.js +0 -217
  99. package/dist-esm/JavaScriptSDK/ChannelController.js.map +0 -1
  100. package/src/JavaScriptSDK/ChannelController.ts +0 -274
  101. package/types/JavaScriptSDK/ChannelController.d.ts +0 -19
@@ -4,8 +4,8 @@
4
4
 
5
5
  import dynamicProto from "@microsoft/dynamicproto-js";
6
6
  import {
7
- arrAppend, arrForEach, arrIndexOf, deepExtend, dumpObj, hasDocument, isFunction, isNullOrUndefined, isPlainObject, objDeepFreeze,
8
- objDefineProp, objForEachKey, objFreeze, objHasOwn, throwError
7
+ ITimerHandler, arrAppend, arrForEach, arrIndexOf, deepExtend, dumpObj, hasDocument, isFunction, isNullOrUndefined, isPlainObject,
8
+ objDeepFreeze, objDefineProp, objForEachKey, objFreeze, objHasOwn, scheduleInterval, scheduleTimeout, throwError
9
9
  } from "@nevware21/ts-utils";
10
10
  import { createDynamicConfig, onConfigChange } from "../Config/DynamicConfig";
11
11
  import { IConfigDefaults } from "../Config/IConfigDefaults";
@@ -33,10 +33,7 @@ import { ITelemetryPluginChain } from "../JavaScriptSDK.Interfaces/ITelemetryPlu
33
33
  import { ITelemetryUnloadState } from "../JavaScriptSDK.Interfaces/ITelemetryUnloadState";
34
34
  import { ITelemetryUpdateState } from "../JavaScriptSDK.Interfaces/ITelemetryUpdateState";
35
35
  import { ILegacyUnloadHook, IUnloadHook } from "../JavaScriptSDK.Interfaces/IUnloadHook";
36
- import {
37
- ChannelControllerPriority, IChannelController, IInternalChannelController, _IInternalChannels, createChannelControllerPlugin,
38
- createChannelQueues
39
- } from "./ChannelController";
36
+ import { ChannelControllerPriority } from "./Constants";
40
37
  import { createCookieMgr } from "./CookieMgr";
41
38
  import { createUniqueNamespace } from "./DataCacheHelper";
42
39
  import { getDebugListener } from "./DbgExtensionUtils";
@@ -84,9 +81,10 @@ function _createPerfManager (core: IAppInsightsCore, notificationMgr: INotificat
84
81
  return new PerfManager(notificationMgr);
85
82
  }
86
83
 
87
- function _validateExtensions(logger: IDiagnosticLogger, channelPriority: number, allExtensions: IPlugin[]): { all: IPlugin[]; core: ITelemetryPlugin[] } {
84
+ function _validateExtensions(logger: IDiagnosticLogger, channelPriority: number, allExtensions: IPlugin[]): { core: IPlugin[], channels: IChannelControls[] } {
88
85
  // Concat all available extensions
89
86
  let coreExtensions: ITelemetryPlugin[] = [];
87
+ let channels: IChannelControls[] = [];
90
88
 
91
89
  // Check if any two extensions have the same priority, then warn to console
92
90
  // And extract the local extensions from the
@@ -111,16 +109,18 @@ function _validateExtensions(logger: IDiagnosticLogger, channelPriority: number,
111
109
  }
112
110
  }
113
111
 
114
- // Split extensions to core and channelController
112
+ // Split extensions to core and channels
115
113
  if (!extPriority || extPriority < channelPriority) {
116
114
  // Add to core extension that will be managed by AppInsightsCore
117
115
  coreExtensions.push(ext);
116
+ } else {
117
+ channels.push(ext);
118
118
  }
119
119
  });
120
120
 
121
121
  return {
122
- all: allExtensions,
123
- core: coreExtensions
122
+ core: coreExtensions,
123
+ channels: channels
124
124
  };
125
125
  }
126
126
 
@@ -239,10 +239,8 @@ export class AppInsightsCore implements IAppInsightsCore {
239
239
  let _cookieManager: ICookieMgr | null;
240
240
  let _pluginChain: ITelemetryPluginChain | null;
241
241
  let _configExtensions: IPlugin[];
242
- let _coreExtensions: ITelemetryPlugin[] | null;
243
- let _channelControl: IChannelController | null;
244
242
  let _channelConfig: IChannelControls[][] | null | undefined;
245
- let _channelQueue: _IInternalChannels[] | null;
243
+ let _channels: IChannelControls[] | null;
246
244
  let _isUnloading: boolean;
247
245
  let _telemetryInitializerPlugin: TelemetryInitializerPlugin;
248
246
  let _internalLogsEventName: string | null;
@@ -260,7 +258,8 @@ export class AppInsightsCore implements IAppInsightsCore {
260
258
  /**
261
259
  * Internal log poller
262
260
  */
263
- let _internalLogPoller: number = 0;
261
+ let _internalLogPoller: ITimerHandler;
262
+ let _internalLogPollerListening: boolean;
264
263
 
265
264
  dynamicProto(AppInsightsCore, this, (_self) => {
266
265
 
@@ -316,22 +315,31 @@ export class AppInsightsCore implements IAppInsightsCore {
316
315
 
317
316
  _initPluginChain(null);
318
317
 
319
- if (!_channelQueue || _channelQueue.length === 0) {
318
+ if (!_channels || _channels.length === 0) {
320
319
  throwError("No " + STR_CHANNELS + " available");
321
320
  }
322
321
 
322
+ if (_channels.length > 1) {
323
+ let teeController = _self.getPlugin("TeeChannelController");
324
+ if (!teeController || !teeController.plugin) {
325
+ _throwInternal(_self.logger, eLoggingSeverity.CRITICAL, _eInternalMessageId.SenderNotInitialized, "TeeChannel required");
326
+ }
327
+ }
328
+
323
329
  _registerDelayedCfgListener(config, _cfgListeners, _self.logger);
324
330
  _cfgListeners = null;
325
331
 
326
332
  _isInitialized = true;
327
333
  _self.releaseQueue();
334
+
335
+ _self.pollInternalLogs();
328
336
  };
329
337
 
330
- _self.getTransmissionControls = (): IChannelControls[][] => {
331
- let controls: IChannelControls[][] = [];
332
- if (_channelQueue) {
333
- arrForEach(_channelQueue, (channels) => {
334
- controls.push(channels.queue);
338
+ _self.getChannels = (): IChannelControls[] => {
339
+ let controls: IChannelControls[] = [];
340
+ if (_channels) {
341
+ arrForEach(_channels, (channel) => {
342
+ controls.push(channel);
335
343
  });
336
344
  }
337
345
 
@@ -456,22 +464,31 @@ export class AppInsightsCore implements IAppInsightsCore {
456
464
  /**
457
465
  * Periodically check logger.queue for log messages to be flushed
458
466
  */
459
- _self.pollInternalLogs = (eventName?: string): number => {
467
+ _self.pollInternalLogs = (eventName?: string): ITimerHandler => {
460
468
  _internalLogsEventName = eventName || null;
461
469
 
462
- _addUnloadHook(_configHandler.watch((details) => {
463
- let interval: number = details.cfg.diagnosticLogInterval;
470
+ function _startLogPoller(config: IConfiguration) {
471
+ let interval: number = config.diagnosticLogInterval;
464
472
  if (!interval || !(interval > 0)) {
465
473
  interval = 10000;
466
474
  }
467
475
 
468
- if(_internalLogPoller) {
469
- clearInterval(_internalLogPoller);
470
- }
471
- _internalLogPoller = setInterval(() => {
476
+ _internalLogPoller && _internalLogPoller.cancel();
477
+ _internalLogPoller = scheduleInterval(() => {
472
478
  _flushInternalLogs();
473
479
  }, interval) as any;
474
- }));
480
+ }
481
+
482
+ if (!_internalLogPollerListening) {
483
+ _internalLogPollerListening = true;
484
+ // listen to the configuration
485
+ _addUnloadHook(_configHandler.watch((details) => {
486
+ _startLogPoller(details.cfg);
487
+ }));
488
+ } else {
489
+ // We are being called again, so make sure the poller is running
490
+ _startLogPoller(_configHandler.cfg);
491
+ }
475
492
 
476
493
  return _internalLogPoller;
477
494
  }
@@ -480,9 +497,9 @@ export class AppInsightsCore implements IAppInsightsCore {
480
497
  * Stop polling log messages from logger.queue
481
498
  */
482
499
  _self.stopPollingInternalLogs = (): void => {
483
- if(_internalLogPoller) {
484
- clearInterval(_internalLogPoller);
485
- _internalLogPoller = 0;
500
+ if (_internalLogPoller) {
501
+ _internalLogPoller.cancel();
502
+ _internalLogPoller = null;
486
503
  _flushInternalLogs();
487
504
  }
488
505
  }
@@ -774,11 +791,9 @@ export class AppInsightsCore implements IAppInsightsCore {
774
791
  _cfgPerfManager = null;
775
792
  _cookieManager = null;
776
793
  _pluginChain = null;
777
- _coreExtensions = null;
778
794
  _configExtensions = [];
779
- _channelControl = null;
780
795
  _channelConfig = null;
781
- _channelQueue = null;
796
+ _channels = null;
782
797
  _isUnloading = false;
783
798
  _internalLogsEventName = null;
784
799
  _evtNamespace = createUniqueNamespace("AIBaseCore", true);
@@ -800,50 +815,34 @@ export class AppInsightsCore implements IAppInsightsCore {
800
815
  // Extension validation
801
816
  let theExtensions = _validateExtensions(_self.logger, ChannelControllerPriority, _configExtensions);
802
817
 
803
- _coreExtensions = theExtensions.core;
804
818
  _pluginChain = null;
805
819
  _pluginVersionString = null;
806
820
  _pluginVersionStringArr = null;
807
821
 
808
- // Sort the complete set of extensions by priority
809
- let allExtensions = theExtensions.all;
810
-
811
- // Initialize the Channel Queues and the channel plugins first
812
- _channelQueue = objFreeze(createChannelQueues(_channelConfig, allExtensions, _self));
813
- if (_channelControl) {
814
- // During add / remove of a plugin this may get called again, so don't re-add if already present
815
- // But we also want the controller as the last, so remove if already present
816
- // And reusing the existing instance, just in case an installed plugin has a reference and
817
- // is using it.
818
- let idx = arrIndexOf(allExtensions, _channelControl);
819
- if (idx !== -1) {
820
- allExtensions.splice(idx, 1);
821
- }
822
-
823
- idx = arrIndexOf(_coreExtensions, _channelControl);
824
- if (idx !== -1) {
825
- _coreExtensions.splice(idx, 1);
826
- }
822
+ // Get the primary channel queue and include as part of the normal extensions
823
+ _channels = (_channelConfig || [])[0] ||[];
824
+
825
+ // Add any channels provided in the extensions and sort them
826
+ _channels = sortPlugins(arrAppend(_channels, theExtensions.channels));
827
827
 
828
- (_channelControl as IInternalChannelController)._setQueue(_channelQueue);
829
- } else {
830
- _channelControl = createChannelControllerPlugin(_channelQueue, _self);
831
- }
828
+ // Sort the complete set of extensions by priority
829
+ let allExtensions = sortPlugins(theExtensions.core);
832
830
 
833
831
  // Add on "channelController" as the last "plugin"
834
- allExtensions.push(_channelControl);
835
- _coreExtensions.push(_channelControl);
832
+ arrAppend(allExtensions, _channels);
836
833
 
837
834
  // Required to allow plugins to call core.getPlugin() during their own initialization
838
- _extensions = sortPlugins(allExtensions);
835
+ _extensions = objFreeze(allExtensions);
839
836
 
840
- // Initialize the controls
841
- _channelControl.initialize(_configHandler.cfg, _self, allExtensions);
837
+ let rootCtx = _createTelCtx();
842
838
 
843
- initializePlugins(_createTelCtx(), allExtensions);
839
+ // Initializing the channels first
840
+ if (_channels && _channels.length > 0) {
841
+ initializePlugins(rootCtx.createNew(_channels), allExtensions);
842
+ }
844
843
 
845
- // Now reset the extensions to just those being managed by AppInsightsCore
846
- _extensions = objFreeze(sortPlugins(_coreExtensions || [])).slice();
844
+ // Now initialize the normal extensions
845
+ initializePlugins(rootCtx, allExtensions);
847
846
 
848
847
  if (updateState) {
849
848
  _doUpdate(updateState);
@@ -855,16 +854,19 @@ export class AppInsightsCore implements IAppInsightsCore {
855
854
  let thePlugin: IPlugin = null;
856
855
 
857
856
  arrForEach(_extensions, (ext: any) => {
858
- if (ext.identifier === pluginIdentifier && ext !== _channelControl && ext !== _telemetryInitializerPlugin) {
857
+ if (ext.identifier === pluginIdentifier && ext !== _telemetryInitializerPlugin) {
859
858
  thePlugin = ext;
860
859
  return -1;
861
860
  }
861
+
862
+ // TODO: Check if the extension is an extension "host" (like the TeeChannel)
863
+ // So that if the extension is not found we can ask the "host" plugins for the plugin
862
864
  });
863
865
 
864
- if (!thePlugin && _channelControl) {
865
- // Check the channel Controller
866
- thePlugin = _channelControl.getChannel(pluginIdentifier);
867
- }
866
+ // if (!thePlugin && _channelControl) {
867
+ // // Check the channel Controller
868
+ // thePlugin = _channelControl.getChannel(pluginIdentifier);
869
+ // }
868
870
 
869
871
  if (thePlugin) {
870
872
  theExt = {
@@ -904,9 +906,9 @@ export class AppInsightsCore implements IAppInsightsCore {
904
906
  function _getPluginChain() {
905
907
  if (!_pluginChain) {
906
908
  // copy the collection of extensions
907
- let extensions = (_coreExtensions || []).slice();
909
+ let extensions = (_extensions || []).slice();
908
910
 
909
- // During add / remove this may get called again, so don't readd if already present
911
+ // During add / remove this may get called again, so don't read if already present
910
912
  if (arrIndexOf(extensions, _telemetryInitializerPlugin) === -1) {
911
913
  extensions.push(_telemetryInitializerPlugin);
912
914
  }
@@ -987,11 +989,56 @@ export class AppInsightsCore implements IAppInsightsCore {
987
989
  }
988
990
 
989
991
  function _flushChannels(isAsync?: boolean, callBack?: (flushComplete?: boolean) => void, sendReason?: SendRequestReason, cbTimeout?: number) {
990
- if (_channelControl) {
991
- return _channelControl.flush(isAsync, callBack, sendReason || SendRequestReason.SdkUnload, cbTimeout);
992
+ // Setting waiting to one so that we don't call the callBack until we finish iterating
993
+ let waiting = 1;
994
+ let doneIterating = false;
995
+ let cbTimer: ITimerHandler = null;
996
+ cbTimeout = cbTimeout || 5000;
997
+
998
+ function doCallback() {
999
+ waiting--;
1000
+ if (doneIterating && waiting === 0) {
1001
+ cbTimer && cbTimer.cancel();
1002
+ cbTimer = null;
1003
+
1004
+ callBack && callBack(doneIterating);
1005
+ callBack = null;
1006
+ }
1007
+ }
1008
+
1009
+ if (_channels && _channels.length > 0) {
1010
+ let flushCtx = _createTelCtx().createNew(_channels);
1011
+ flushCtx.iterate<IChannelControls>((plugin) => {
1012
+ if (plugin.flush) {
1013
+ waiting ++;
1014
+
1015
+ let handled = false;
1016
+ // Not all channels will call this callback for every scenario
1017
+ if (!plugin.flush(isAsync, () => {
1018
+ handled = true;
1019
+ doCallback();
1020
+ }, sendReason)) {
1021
+ if (!handled) {
1022
+ // If any channel doesn't return true and it didn't call the callback, then we should assume that the callback
1023
+ // will never be called, so use a timeout to allow the channel(s) some time to "finish" before triggering any
1024
+ // followup function (such as unloading)
1025
+ if (isAsync && cbTimer == null) {
1026
+ cbTimer = scheduleTimeout(() => {
1027
+ cbTimer = null;
1028
+ doCallback();
1029
+ }, cbTimeout);
1030
+ } else {
1031
+ doCallback();
1032
+ }
1033
+ }
1034
+ }
1035
+ }
1036
+ });
992
1037
  }
993
1038
 
994
- callBack && callBack(false);
1039
+ doneIterating = true;
1040
+ doCallback();
1041
+
995
1042
  return true;
996
1043
  }
997
1044
 
@@ -1070,7 +1117,7 @@ export class AppInsightsCore implements IAppInsightsCore {
1070
1117
  // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
1071
1118
  }
1072
1119
 
1073
- public getTransmissionControls(): IChannelControls[][] {
1120
+ public getChannels(): IChannelControls[] {
1074
1121
  // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
1075
1122
  return null;
1076
1123
  }
@@ -1140,9 +1187,9 @@ export class AppInsightsCore implements IAppInsightsCore {
1140
1187
  /**
1141
1188
  * Periodically check logger.queue for
1142
1189
  */
1143
- public pollInternalLogs(eventName?: string): number {
1190
+ public pollInternalLogs(eventName?: string): ITimerHandler {
1144
1191
  // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
1145
- return 0;
1192
+ return null;
1146
1193
  }
1147
1194
 
1148
1195
  /**
@@ -0,0 +1,4 @@
1
+ // Copyright (c) Microsoft Corporation. All rights reserved.
2
+ // Licensed under the MIT License.
3
+
4
+ export const ChannelControllerPriority = 500;
@@ -17,6 +17,7 @@ import { SendRequestReason } from "../JavaScriptSDK.Enums/SendRequestReason";
17
17
  import { IDistributedTraceContext } from "./IDistributedTraceContext";
18
18
  import { ILegacyUnloadHook, IUnloadHook } from "./IUnloadHook";
19
19
  import { WatcherFunction } from "../Config/IDynamicWatcher";
20
+ import { ITimerHandler } from "@nevware21/ts-utils";
20
21
 
21
22
  export interface ILoadedPlugin<T extends IPlugin> {
22
23
  plugin: T;
@@ -69,9 +70,9 @@ export interface IAppInsightsCore extends IPerfManagerProvider {
69
70
  initialize(config: IConfiguration, extensions: IPlugin[], logger?: IDiagnosticLogger, notificationManager?: INotificationManager): void;
70
71
 
71
72
  /*
72
- * Get transmission controls for controlling transmission behavior
73
+ * Get transmission channels for controlling transmission behavior
73
74
  */
74
- getTransmissionControls(): IChannelControls[][];
75
+ getChannels(): IChannelControls[];
75
76
 
76
77
  /*
77
78
  * Core track API
@@ -115,7 +116,7 @@ export interface IAppInsightsCore extends IPerfManagerProvider {
115
116
  */
116
117
  addTelemetryInitializer(telemetryInitializer: TelemetryInitializerFunction): ITelemetryInitializerHandler;
117
118
 
118
- pollInternalLogs?(eventName?: string): number;
119
+ pollInternalLogs?(eventName?: string): ITimerHandler;
119
120
 
120
121
  stopPollingInternalLogs?(): void;
121
122
 
@@ -15,12 +15,12 @@ export interface IChannelControls extends ITelemetryPlugin {
15
15
  /**
16
16
  * Pause sending data
17
17
  */
18
- pause(): void;
18
+ pause?(): void;
19
19
 
20
20
  /**
21
21
  * Resume sending data
22
22
  */
23
- resume(): void;
23
+ resume?(): void;
24
24
 
25
25
  /**
26
26
  * Tear down the plugin and remove any hooked value, the plugin should be removed so that it is no longer initialized and
@@ -30,7 +30,7 @@ export interface IChannelControls extends ITelemetryPlugin {
30
30
  * @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.
31
31
  * @returns boolean - true if the plugin has or will call processNext(), this for backward compatibility as previously teardown was synchronous and returned nothing.
32
32
  */
33
- teardown: (unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState) => void | boolean;
33
+ teardown?: (unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState) => void | boolean;
34
34
 
35
35
  /**
36
36
  * Flush to send data immediately; channel should default to sending data asynchronously
@@ -40,7 +40,7 @@ export interface IChannelControls extends ITelemetryPlugin {
40
40
  * @param sendReason - specify the reason that you are calling "flush" defaults to ManualFlush (1) if not specified
41
41
  * @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
42
42
  */
43
- flush(async: boolean, callBack?: (flushComplete?: boolean) => void, sendReason?: SendRequestReason): boolean | void;
43
+ flush?(async: boolean, callBack?: (flushComplete?: boolean) => void, sendReason?: SendRequestReason): boolean | void;
44
44
  }
45
45
 
46
46
  export const MinChannelPriorty: number = 100;
@@ -2,11 +2,11 @@ import { IConfiguration } from "../JavaScriptSDK.Interfaces/IConfiguration";
2
2
  /**
3
3
  * The type to identify whether the default value should be applied in preference to the provided value.
4
4
  */
5
- export declare type IConfigCheckFn<V> = (value: V) => boolean;
5
+ export type IConfigCheckFn<V> = (value: V) => boolean;
6
6
  /**
7
7
  * The type which identifies the function use to validate the user supplied value
8
8
  */
9
- export declare type IConfigSetFn<T, V> = (value: any, defValue: V, theConfig: T) => V;
9
+ export type IConfigSetFn<T, V> = (value: any, defValue: V, theConfig: T) => V;
10
10
  /**
11
11
  * The default values with a check function
12
12
  */
@@ -37,6 +37,6 @@ export interface IConfigDefaultCheck<T, V, C extends IConfiguration = IConfigura
37
37
  * The Type definition to define default values to be applied to the config
38
38
  * The value may be either the direct value or a ConfigDefaultCheck definition
39
39
  */
40
- export declare type IConfigDefaults<T, C extends IConfiguration = IConfiguration> = {
40
+ export type IConfigDefaults<T, C extends IConfiguration = IConfiguration> = {
41
41
  [key in keyof T]: T[key] | IConfigDefaultCheck<T, T[key], C>;
42
42
  };
@@ -21,7 +21,7 @@ export interface IWatchDetails<T extends IConfiguration> {
21
21
  */
22
22
  setDf: <C>(theConfig: C, defaultValues: IConfigDefaults<C>) => C;
23
23
  }
24
- export declare type WatcherFunction<T extends IConfiguration> = (details: IWatchDetails<T>) => void;
24
+ export type WatcherFunction<T extends IConfiguration> = (details: IWatchDetails<T>) => void;
25
25
  /**
26
26
  * @internal
27
27
  */
@@ -1,3 +1,4 @@
1
+ import { ITimerHandler } from "@nevware21/ts-utils";
1
2
  import { WatcherFunction } from "../Config/IDynamicWatcher";
2
3
  import { SendRequestReason } from "../JavaScriptSDK.Enums/SendRequestReason";
3
4
  import { IAppInsightsCore, ILoadedPlugin } from "../JavaScriptSDK.Interfaces/IAppInsightsCore";
@@ -39,7 +40,7 @@ export declare class AppInsightsCore implements IAppInsightsCore {
39
40
  getWParam: () => number;
40
41
  constructor();
41
42
  initialize(config: IConfiguration, extensions: IPlugin[], logger?: IDiagnosticLogger, notificationManager?: INotificationManager): void;
42
- getTransmissionControls(): IChannelControls[][];
43
+ getChannels(): IChannelControls[];
43
44
  track(telemetryItem: ITelemetryItem): void;
44
45
  getProcessTelContext(): IProcessTelemetryContext;
45
46
  getNotifyMgr(): INotificationManager;
@@ -70,7 +71,7 @@ export declare class AppInsightsCore implements IAppInsightsCore {
70
71
  /**
71
72
  * Periodically check logger.queue for
72
73
  */
73
- pollInternalLogs(eventName?: string): number;
74
+ pollInternalLogs(eventName?: string): ITimerHandler;
74
75
  /**
75
76
  * Periodically check logger.queue for
76
77
  */
@@ -0,0 +1 @@
1
+ export declare const ChannelControllerPriority = 500;
@@ -1,6 +1,6 @@
1
1
  import { IProcessTelemetryUnloadContext } from "../JavaScriptSDK.Interfaces/IProcessTelemetryContext";
2
2
  import { ITelemetryUnloadState } from "../JavaScriptSDK.Interfaces/ITelemetryUnloadState";
3
- export declare type UnloadHandler = (itemCtx: IProcessTelemetryUnloadContext, unloadState: ITelemetryUnloadState) => void;
3
+ export type UnloadHandler = (itemCtx: IProcessTelemetryUnloadContext, unloadState: ITelemetryUnloadState) => void;
4
4
  export interface IUnloadHandlerContainer {
5
5
  add: (handler: UnloadHandler) => void;
6
6
  run: (itemCtx: IProcessTelemetryUnloadContext, unloadState: ITelemetryUnloadState) => void;
@@ -31,4 +31,4 @@ export declare const enum eEventsDiscardedReason {
31
31
  * The EventsDiscardedReason enumeration contains a set of values that specify the reason for discarding an event.
32
32
  */
33
33
  export declare const EventsDiscardedReason: import("../JavaScriptSDK.Enums/EnumHelperFuncs").EnumValue<typeof eEventsDiscardedReason>;
34
- export declare type EventsDiscardedReason = number | eEventsDiscardedReason;
34
+ export type EventsDiscardedReason = number | eEventsDiscardedReason;
@@ -13,7 +13,7 @@ export declare const enum eLoggingSeverity {
13
13
  WARNING = 2
14
14
  }
15
15
  export declare const LoggingSeverity: import("../JavaScriptSDK.Enums/EnumHelperFuncs").EnumValue<typeof eLoggingSeverity>;
16
- export declare type LoggingSeverity = number | eLoggingSeverity;
16
+ export type LoggingSeverity = number | eLoggingSeverity;
17
17
  export declare const enum _eInternalMessageId {
18
18
  BrowserDoesNotSupportLocalStorage = 0,
19
19
  BrowserCannotReadLocalStorage = 1,
@@ -101,4 +101,4 @@ export declare const enum _eInternalMessageId {
101
101
  ConfigWatcherException = 107,
102
102
  DynamicConfigException = 108
103
103
  }
104
- export declare type _InternalMessageId = number | _eInternalMessageId;
104
+ export type _InternalMessageId = number | _eInternalMessageId;
@@ -15,6 +15,7 @@ import { SendRequestReason } from "../JavaScriptSDK.Enums/SendRequestReason";
15
15
  import { IDistributedTraceContext } from "./IDistributedTraceContext";
16
16
  import { ILegacyUnloadHook, IUnloadHook } from "./IUnloadHook";
17
17
  import { WatcherFunction } from "../Config/IDynamicWatcher";
18
+ import { ITimerHandler } from "@nevware21/ts-utils";
18
19
  export interface ILoadedPlugin<T extends IPlugin> {
19
20
  plugin: T;
20
21
  /**
@@ -48,7 +49,7 @@ export interface IAppInsightsCore extends IPerfManagerProvider {
48
49
  */
49
50
  isInitialized?: () => boolean;
50
51
  initialize(config: IConfiguration, extensions: IPlugin[], logger?: IDiagnosticLogger, notificationManager?: INotificationManager): void;
51
- getTransmissionControls(): IChannelControls[][];
52
+ getChannels(): IChannelControls[];
52
53
  track(telemetryItem: ITelemetryItem): void;
53
54
  /**
54
55
  * Get the current notification manager
@@ -81,7 +82,7 @@ export interface IAppInsightsCore extends IPerfManagerProvider {
81
82
  * @returns - A ITelemetryInitializerHandler to enable the initializer to be removed
82
83
  */
83
84
  addTelemetryInitializer(telemetryInitializer: TelemetryInitializerFunction): ITelemetryInitializerHandler;
84
- pollInternalLogs?(eventName?: string): number;
85
+ pollInternalLogs?(eventName?: string): ITimerHandler;
85
86
  stopPollingInternalLogs?(): void;
86
87
  /**
87
88
  * Return a new instance of the IProcessTelemetryContext for processing events
@@ -9,11 +9,11 @@ export interface IChannelControls extends ITelemetryPlugin {
9
9
  /**
10
10
  * Pause sending data
11
11
  */
12
- pause(): void;
12
+ pause?(): void;
13
13
  /**
14
14
  * Resume sending data
15
15
  */
16
- resume(): void;
16
+ resume?(): void;
17
17
  /**
18
18
  * Tear down the plugin and remove any hooked value, the plugin should be removed so that it is no longer initialized and
19
19
  * therefore could be re-initialized after being torn down. The plugin should ensure that once this has been called any further
@@ -22,7 +22,7 @@ export interface IChannelControls extends ITelemetryPlugin {
22
22
  * @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.
23
23
  * @returns boolean - true if the plugin has or will call processNext(), this for backward compatibility as previously teardown was synchronous and returned nothing.
24
24
  */
25
- teardown: (unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState) => void | boolean;
25
+ teardown?: (unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState) => void | boolean;
26
26
  /**
27
27
  * Flush to send data immediately; channel should default to sending data asynchronously
28
28
  * @param async - send data asynchronously when true
@@ -31,6 +31,6 @@ export interface IChannelControls extends ITelemetryPlugin {
31
31
  * @param sendReason - specify the reason that you are calling "flush" defaults to ManualFlush (1) if not specified
32
32
  * @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
33
33
  */
34
- flush(async: boolean, callBack?: (flushComplete?: boolean) => void, sendReason?: SendRequestReason): boolean | void;
34
+ flush?(async: boolean, callBack?: (flushComplete?: boolean) => void, sendReason?: SendRequestReason): boolean | void;
35
35
  }
36
36
  export declare const MinChannelPriorty: number;
@@ -3,7 +3,7 @@ import { IUnloadHook } from "./IUnloadHook";
3
3
  * A callback function that will be called for the wrapped instrumentation function
4
4
  * before the original function is executed.
5
5
  */
6
- export declare type InstrumentorHooksCallback = (funcArgs: IInstrumentCallDetails, ...orgArgs: any[]) => void;
6
+ export type InstrumentorHooksCallback = (funcArgs: IInstrumentCallDetails, ...orgArgs: any[]) => void;
7
7
  /**
8
8
  * The callbacks to call for the instrumented function, you must provide at least the request and/or response callbacks, both are not required.
9
9
  * You must always supply the error callback
@@ -9,9 +9,12 @@ export declare const _DYN_ENUMERABLE = "enumerable";
9
9
  export declare const _DYN_APPLY = "apply";
10
10
  export declare const _DYN_PUSH = "push";
11
11
  export declare const _DYN_SPLICE = "splice";
12
+ export declare const _DYN_CANCEL = "cancel";
12
13
  export declare const _DYN_INITIALIZE = "initialize";
13
14
  export declare const _DYN_IDENTIFIER = "identifier";
14
15
  export declare const _DYN_IS_INITIALIZED = "isInitialized";
16
+ export declare const _DYN_GET_PLUGIN = "getPlugin";
17
+ export declare const _DYN_POLL_INTERNAL_LOGS = "pollInternalLogs";
15
18
  export declare const _DYN_NAME = "name";
16
19
  export declare const _DYN_TIME = "time";
17
20
  export declare const _DYN_PROCESS_NEXT = "processNext";
@@ -22,10 +25,9 @@ export declare const _DYN_REMOVE_NOTIFICATION_2 = "removeNotificationListener";
22
25
  export declare const _DYN_STOP_POLLING_INTERNA3 = "stopPollingInternalLogs";
23
26
  export declare const _DYN_ON_COMPLETE = "onComplete";
24
27
  export declare const _DYN_CALL = "call";
25
- export declare const _DYN_GET_PLUGIN = "getPlugin";
26
- export declare const _DYN_FLUSH = "flush";
27
28
  export declare const _DYN_VERSION = "version";
28
29
  export declare const _DYN_LOGGING_LEVEL_CONSOL4 = "loggingLevelConsole";
30
+ export declare const _DYN_CREATE_NEW = "createNew";
29
31
  export declare const _DYN_TEARDOWN = "teardown";
30
32
  export declare const _DYN_MESSAGE_ID = "messageId";
31
33
  export declare const _DYN_MESSAGE = "message";
@@ -35,8 +37,6 @@ export declare const _DYN__DO_TEARDOWN = "_doTeardown";
35
37
  export declare const _DYN_UPDATE = "update";
36
38
  export declare const _DYN_GET_NEXT = "getNext";
37
39
  export declare const _DYN_SET_NEXT_PLUGIN = "setNextPlugin";
38
- export declare const _DYN_CREATE_NEW = "createNew";
39
- export declare const _DYN_CONFIG = "config";
40
40
  export declare const _DYN_USER_AGENT = "userAgent";
41
41
  export declare const _DYN_SPLIT = "split";
42
42
  export declare const _DYN_NODE_TYPE = "nodeType";