@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
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Microsoft Application Insights Core Javascript SDK, 3.0.0-beta.2211-01
2
+ * Microsoft Application Insights Core Javascript SDK, 3.0.0-beta.2211-04
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  *
5
5
  * Microsoft Application Insights Team
@@ -48,6 +48,7 @@ import { isSymbol } from '@nevware21/ts-utils';
48
48
  import { isTruthy } from '@nevware21/ts-utils';
49
49
  import { isTypeof } from '@nevware21/ts-utils';
50
50
  import { isUndefined } from '@nevware21/ts-utils';
51
+ import { ITimerHandler } from '@nevware21/ts-utils';
51
52
  import { objCreateFn as objCreate } from '@microsoft/applicationinsights-shims';
52
53
  import { objDefineAccessors } from '@nevware21/ts-utils';
53
54
  import { objForEachKey } from '@nevware21/ts-utils';
@@ -156,7 +157,7 @@ export declare class AppInsightsCore implements IAppInsightsCore {
156
157
  getWParam: () => number;
157
158
  constructor();
158
159
  initialize(config: IConfiguration, extensions: IPlugin[], logger?: IDiagnosticLogger, notificationManager?: INotificationManager): void;
159
- getTransmissionControls(): IChannelControls[][];
160
+ getChannels(): IChannelControls[];
160
161
  track(telemetryItem: ITelemetryItem): void;
161
162
  getProcessTelContext(): IProcessTelemetryContext;
162
163
  getNotifyMgr(): INotificationManager;
@@ -187,7 +188,7 @@ export declare class AppInsightsCore implements IAppInsightsCore {
187
188
  /**
188
189
  * Periodically check logger.queue for
189
190
  */
190
- pollInternalLogs(eventName?: string): number;
191
+ pollInternalLogs(eventName?: string): ITimerHandler;
191
192
  /**
192
193
  * Periodically check logger.queue for
193
194
  */
@@ -859,7 +860,7 @@ export declare interface IAppInsightsCore extends IPerfManagerProvider {
859
860
  */
860
861
  isInitialized?: () => boolean;
861
862
  initialize(config: IConfiguration, extensions: IPlugin[], logger?: IDiagnosticLogger, notificationManager?: INotificationManager): void;
862
- getTransmissionControls(): IChannelControls[][];
863
+ getChannels(): IChannelControls[];
863
864
  track(telemetryItem: ITelemetryItem): void;
864
865
  /**
865
866
  * Get the current notification manager
@@ -892,7 +893,7 @@ export declare interface IAppInsightsCore extends IPerfManagerProvider {
892
893
  * @returns - A ITelemetryInitializerHandler to enable the initializer to be removed
893
894
  */
894
895
  addTelemetryInitializer(telemetryInitializer: TelemetryInitializerFunction): ITelemetryInitializerHandler;
895
- pollInternalLogs?(eventName?: string): number;
896
+ pollInternalLogs?(eventName?: string): ITimerHandler;
896
897
  stopPollingInternalLogs?(): void;
897
898
  /**
898
899
  * Return a new instance of the IProcessTelemetryContext for processing events
@@ -1045,11 +1046,11 @@ export declare interface IChannelControls extends ITelemetryPlugin {
1045
1046
  /**
1046
1047
  * Pause sending data
1047
1048
  */
1048
- pause(): void;
1049
+ pause?(): void;
1049
1050
  /**
1050
1051
  * Resume sending data
1051
1052
  */
1052
- resume(): void;
1053
+ resume?(): void;
1053
1054
  /**
1054
1055
  * Tear down the plugin and remove any hooked value, the plugin should be removed so that it is no longer initialized and
1055
1056
  * therefore could be re-initialized after being torn down. The plugin should ensure that once this has been called any further
@@ -1058,7 +1059,7 @@ export declare interface IChannelControls extends ITelemetryPlugin {
1058
1059
  * @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.
1059
1060
  * @returns boolean - true if the plugin has or will call processNext(), this for backward compatibility as previously teardown was synchronous and returned nothing.
1060
1061
  */
1061
- teardown: (unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState) => void | boolean;
1062
+ teardown?: (unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState) => void | boolean;
1062
1063
  /**
1063
1064
  * Flush to send data immediately; channel should default to sending data asynchronously
1064
1065
  * @param async - send data asynchronously when true
@@ -1067,7 +1068,7 @@ export declare interface IChannelControls extends ITelemetryPlugin {
1067
1068
  * @param sendReason - specify the reason that you are calling "flush" defaults to ManualFlush (1) if not specified
1068
1069
  * @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
1069
1070
  */
1070
- flush(async: boolean, callBack?: (flushComplete?: boolean) => void, sendReason?: SendRequestReason): boolean | void;
1071
+ flush?(async: boolean, callBack?: (flushComplete?: boolean) => void, sendReason?: SendRequestReason): boolean | void;
1071
1072
  }
1072
1073
 
1073
1074
  /**
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Core, 3.0.0-beta.2211-01
2
+ * Application Insights JavaScript SDK - Core, 3.0.0-beta.2211-04
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 - Core, 3.0.0-beta.2211-01
2
+ * Application Insights JavaScript SDK - Core, 3.0.0-beta.2211-04
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 - Core, 3.0.0-beta.2211-01
2
+ * Application Insights JavaScript SDK - Core, 3.0.0-beta.2211-04
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -1,12 +1,12 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Core, 3.0.0-beta.2211-01
2
+ * Application Insights JavaScript SDK - Core, 3.0.0-beta.2211-04
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
6
6
 
7
7
  import { arrForEach, arrIndexOf, dumpObj, newSymbol, scheduleTimeout } from "@nevware21/ts-utils";
8
8
  import { throwAggregationError } from "../JavaScriptSDK/AggregationError";
9
- import { _DYN_LENGTH, _DYN_LOGGER, _DYN_PUSH, _DYN_SET_DF, _DYN_THROW_INTERNAL } from "../__DynamicConstants";
9
+ import { _DYN_CANCEL, _DYN_LENGTH, _DYN_LOGGER, _DYN_PUSH, _DYN_SET_DF, _DYN_THROW_INTERNAL } from "../__DynamicConstants";
10
10
  var symPrefix = "[[ai_";
11
11
  var symPostfix = "]]";
12
12
  export function _createState(cfgHandler) {
@@ -51,7 +51,7 @@ export function _createState(cfgHandler) {
51
51
  var notifyHandlers = _waitingHandlers;
52
52
  _waitingHandlers = null;
53
53
  // Stop any timer as we are running them now anyway
54
- _watcherTimer && _watcherTimer.cancel();
54
+ _watcherTimer && _watcherTimer[_DYN_CANCEL /* @min:%2ecancel */]();
55
55
  _watcherTimer = null;
56
56
  var watcherFailures_1 = [];
57
57
  // Now run the handlers
@@ -1 +1 @@
1
- {"version":3,"file":"DynamicState.js.map","sources":["DynamicState.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\nimport { arrForEach, arrIndexOf, dumpObj, newSymbol, scheduleTimeout } from \"@nevware21/ts-utils\";\r\nimport { throwAggregationError } from \"../JavaScriptSDK/AggregationError\";\r\nimport { _DYN_LENGTH, _DYN_LOGGER, _DYN_PUSH, _DYN_SET_DF, _DYN_THROW_INTERNAL } from \"../__DynamicConstants\";\r\nvar symPrefix = \"[[ai_\";\r\nvar symPostfix = \"]]\";\r\nexport function _createState(cfgHandler) {\r\n var dynamicPropertySymbol = newSymbol(symPrefix + \"get\" + cfgHandler.uid + symPostfix);\r\n var dynamicPropertyReadOnly = newSymbol(symPrefix + \"ro\" + cfgHandler.uid + symPostfix);\r\n var dynamicPropertyDetail = newSymbol(symPrefix + \"dtl\" + cfgHandler.uid + symPostfix);\r\n var _waitingHandlers = null;\r\n var _watcherTimer = null;\r\n var theState;\r\n function _useHandler(activeHandler, callback) {\r\n var prevWatcher = theState.act;\r\n try {\r\n theState.act = activeHandler;\r\n if (activeHandler && activeHandler[dynamicPropertyDetail]) {\r\n // Clear out the previously tracked details for this handler, so that access are re-evaluated\r\n arrForEach(activeHandler[dynamicPropertyDetail], function (detail) {\r\n detail.clr(activeHandler);\r\n });\r\n activeHandler[dynamicPropertyDetail] = [];\r\n }\r\n callback({\r\n cfg: cfgHandler.cfg,\r\n set: cfgHandler.set.bind(cfgHandler),\r\n setDf: cfgHandler[_DYN_SET_DF /* @min:%2esetDf */].bind(cfgHandler)\r\n });\r\n }\r\n catch (e) {\r\n var logger = cfgHandler[_DYN_LOGGER /* @min:%2elogger */];\r\n if (logger) {\r\n // Don't let one individual failure break everyone\r\n logger[_DYN_THROW_INTERNAL /* @min:%2ethrowInternal */](1 /* eLoggingSeverity.CRITICAL */, 107 /* _eInternalMessageId.ConfigWatcherException */, dumpObj(e));\r\n }\r\n // Re-throw the exception so that any true \"error\" is reported back to the called\r\n throw e;\r\n }\r\n finally {\r\n theState.act = prevWatcher || null;\r\n }\r\n }\r\n function _notifyWatchers() {\r\n if (_waitingHandlers) {\r\n var notifyHandlers = _waitingHandlers;\r\n _waitingHandlers = null;\r\n // Stop any timer as we are running them now anyway\r\n _watcherTimer && _watcherTimer.cancel();\r\n _watcherTimer = null;\r\n var watcherFailures_1 = [];\r\n // Now run the handlers\r\n arrForEach(notifyHandlers, function (handler) {\r\n if (handler) {\r\n if (handler[dynamicPropertyDetail]) {\r\n arrForEach(handler[dynamicPropertyDetail], function (detail) {\r\n // Clear out this handler from previously tracked details, so that access are re-evaluated\r\n detail.clr(handler);\r\n });\r\n handler[dynamicPropertyDetail] = null;\r\n }\r\n // The handler may have self removed as part of another handler so re-check\r\n if (handler.fn) {\r\n try {\r\n _useHandler(handler, handler.fn);\r\n }\r\n catch (e) {\r\n // Don't let a single failing watcher cause other watches to fail\r\n watcherFailures_1[_DYN_PUSH /* @min:%2epush */](e);\r\n }\r\n }\r\n }\r\n });\r\n // During notification we may have had additional updates -- so notify those updates as well\r\n if (_waitingHandlers) {\r\n try {\r\n _notifyWatchers();\r\n }\r\n catch (e) {\r\n watcherFailures_1[_DYN_PUSH /* @min:%2epush */](e);\r\n }\r\n }\r\n if (watcherFailures_1[_DYN_LENGTH /* @min:%2elength */] > 0) {\r\n throwAggregationError(\"Watcher error(s): \", watcherFailures_1);\r\n }\r\n }\r\n }\r\n function _addWatcher(detail) {\r\n if (detail && detail.h[_DYN_LENGTH /* @min:%2elength */] > 0) {\r\n if (!_waitingHandlers) {\r\n _waitingHandlers = [];\r\n }\r\n if (!_watcherTimer) {\r\n _watcherTimer = scheduleTimeout(function () {\r\n _watcherTimer = null;\r\n _notifyWatchers();\r\n }, 0);\r\n }\r\n // Add all of the handlers for this detail (if not already present) - using normal for-loop for performance\r\n for (var idx = 0; idx < detail.h[_DYN_LENGTH /* @min:%2elength */]; idx++) {\r\n var handler = detail.h[idx];\r\n // Add this handler to the collection of handlers to re-execute\r\n if (handler && arrIndexOf(_waitingHandlers, handler) === -1) {\r\n _waitingHandlers[_DYN_PUSH /* @min:%2epush */](handler);\r\n }\r\n }\r\n }\r\n }\r\n function _trackHandler(handler, detail) {\r\n if (handler) {\r\n var details = handler[dynamicPropertyDetail] = handler[dynamicPropertyDetail] || [];\r\n if (arrIndexOf(details, detail) === -1) {\r\n // If this detail is not already listed as tracked then add it so that we re-evaluate it's usage\r\n details[_DYN_PUSH /* @min:%2epush */](detail);\r\n }\r\n }\r\n }\r\n theState = {\r\n prop: dynamicPropertySymbol,\r\n ro: dynamicPropertyReadOnly,\r\n hdlr: cfgHandler,\r\n add: _addWatcher,\r\n notify: _notifyWatchers,\r\n use: _useHandler,\r\n trk: _trackHandler\r\n };\r\n return theState;\r\n}\r\n//# sourceMappingURL=DynamicState.js.map"],"names":[],"mappings":";;;;AAA4D;AAC1B;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
1
+ {"version":3,"file":"DynamicState.js.map","sources":["DynamicState.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\nimport { arrForEach, arrIndexOf, dumpObj, newSymbol, scheduleTimeout } from \"@nevware21/ts-utils\";\r\nimport { throwAggregationError } from \"../JavaScriptSDK/AggregationError\";\r\nimport { _DYN_CANCEL, _DYN_LENGTH, _DYN_LOGGER, _DYN_PUSH, _DYN_SET_DF, _DYN_THROW_INTERNAL } from \"../__DynamicConstants\";\r\nvar symPrefix = \"[[ai_\";\r\nvar symPostfix = \"]]\";\r\nexport function _createState(cfgHandler) {\r\n var dynamicPropertySymbol = newSymbol(symPrefix + \"get\" + cfgHandler.uid + symPostfix);\r\n var dynamicPropertyReadOnly = newSymbol(symPrefix + \"ro\" + cfgHandler.uid + symPostfix);\r\n var dynamicPropertyDetail = newSymbol(symPrefix + \"dtl\" + cfgHandler.uid + symPostfix);\r\n var _waitingHandlers = null;\r\n var _watcherTimer = null;\r\n var theState;\r\n function _useHandler(activeHandler, callback) {\r\n var prevWatcher = theState.act;\r\n try {\r\n theState.act = activeHandler;\r\n if (activeHandler && activeHandler[dynamicPropertyDetail]) {\r\n // Clear out the previously tracked details for this handler, so that access are re-evaluated\r\n arrForEach(activeHandler[dynamicPropertyDetail], function (detail) {\r\n detail.clr(activeHandler);\r\n });\r\n activeHandler[dynamicPropertyDetail] = [];\r\n }\r\n callback({\r\n cfg: cfgHandler.cfg,\r\n set: cfgHandler.set.bind(cfgHandler),\r\n setDf: cfgHandler[_DYN_SET_DF /* @min:%2esetDf */].bind(cfgHandler)\r\n });\r\n }\r\n catch (e) {\r\n var logger = cfgHandler[_DYN_LOGGER /* @min:%2elogger */];\r\n if (logger) {\r\n // Don't let one individual failure break everyone\r\n logger[_DYN_THROW_INTERNAL /* @min:%2ethrowInternal */](1 /* eLoggingSeverity.CRITICAL */, 107 /* _eInternalMessageId.ConfigWatcherException */, dumpObj(e));\r\n }\r\n // Re-throw the exception so that any true \"error\" is reported back to the called\r\n throw e;\r\n }\r\n finally {\r\n theState.act = prevWatcher || null;\r\n }\r\n }\r\n function _notifyWatchers() {\r\n if (_waitingHandlers) {\r\n var notifyHandlers = _waitingHandlers;\r\n _waitingHandlers = null;\r\n // Stop any timer as we are running them now anyway\r\n _watcherTimer && _watcherTimer[_DYN_CANCEL /* @min:%2ecancel */]();\r\n _watcherTimer = null;\r\n var watcherFailures_1 = [];\r\n // Now run the handlers\r\n arrForEach(notifyHandlers, function (handler) {\r\n if (handler) {\r\n if (handler[dynamicPropertyDetail]) {\r\n arrForEach(handler[dynamicPropertyDetail], function (detail) {\r\n // Clear out this handler from previously tracked details, so that access are re-evaluated\r\n detail.clr(handler);\r\n });\r\n handler[dynamicPropertyDetail] = null;\r\n }\r\n // The handler may have self removed as part of another handler so re-check\r\n if (handler.fn) {\r\n try {\r\n _useHandler(handler, handler.fn);\r\n }\r\n catch (e) {\r\n // Don't let a single failing watcher cause other watches to fail\r\n watcherFailures_1[_DYN_PUSH /* @min:%2epush */](e);\r\n }\r\n }\r\n }\r\n });\r\n // During notification we may have had additional updates -- so notify those updates as well\r\n if (_waitingHandlers) {\r\n try {\r\n _notifyWatchers();\r\n }\r\n catch (e) {\r\n watcherFailures_1[_DYN_PUSH /* @min:%2epush */](e);\r\n }\r\n }\r\n if (watcherFailures_1[_DYN_LENGTH /* @min:%2elength */] > 0) {\r\n throwAggregationError(\"Watcher error(s): \", watcherFailures_1);\r\n }\r\n }\r\n }\r\n function _addWatcher(detail) {\r\n if (detail && detail.h[_DYN_LENGTH /* @min:%2elength */] > 0) {\r\n if (!_waitingHandlers) {\r\n _waitingHandlers = [];\r\n }\r\n if (!_watcherTimer) {\r\n _watcherTimer = scheduleTimeout(function () {\r\n _watcherTimer = null;\r\n _notifyWatchers();\r\n }, 0);\r\n }\r\n // Add all of the handlers for this detail (if not already present) - using normal for-loop for performance\r\n for (var idx = 0; idx < detail.h[_DYN_LENGTH /* @min:%2elength */]; idx++) {\r\n var handler = detail.h[idx];\r\n // Add this handler to the collection of handlers to re-execute\r\n if (handler && arrIndexOf(_waitingHandlers, handler) === -1) {\r\n _waitingHandlers[_DYN_PUSH /* @min:%2epush */](handler);\r\n }\r\n }\r\n }\r\n }\r\n function _trackHandler(handler, detail) {\r\n if (handler) {\r\n var details = handler[dynamicPropertyDetail] = handler[dynamicPropertyDetail] || [];\r\n if (arrIndexOf(details, detail) === -1) {\r\n // If this detail is not already listed as tracked then add it so that we re-evaluate it's usage\r\n details[_DYN_PUSH /* @min:%2epush */](detail);\r\n }\r\n }\r\n }\r\n theState = {\r\n prop: dynamicPropertySymbol,\r\n ro: dynamicPropertyReadOnly,\r\n hdlr: cfgHandler,\r\n add: _addWatcher,\r\n notify: _notifyWatchers,\r\n use: _useHandler,\r\n trk: _trackHandler\r\n };\r\n return theState;\r\n}\r\n//# sourceMappingURL=DynamicState.js.map"],"names":[],"mappings":";;;;AAA4D;AAC1B;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Core, 3.0.0-beta.2211-01
2
+ * Application Insights JavaScript SDK - Core, 3.0.0-beta.2211-04
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 - Core, 3.0.0-beta.2211-01
2
+ * Application Insights JavaScript SDK - Core, 3.0.0-beta.2211-04
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 - Core, 3.0.0-beta.2211-01
2
+ * Application Insights JavaScript SDK - Core, 3.0.0-beta.2211-04
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 - Core, 3.0.0-beta.2211-01
2
+ * Application Insights JavaScript SDK - Core, 3.0.0-beta.2211-04
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 - Core, 3.0.0-beta.2211-01
2
+ * Application Insights JavaScript SDK - Core, 3.0.0-beta.2211-04
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 - Core, 3.0.0-beta.2211-01
2
+ * Application Insights JavaScript SDK - Core, 3.0.0-beta.2211-04
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
  export {};
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Core, 3.0.0-beta.2211-01
2
+ * Application Insights JavaScript SDK - Core, 3.0.0-beta.2211-04
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 - Core, 3.0.0-beta.2211-01
2
+ * Application Insights JavaScript SDK - Core, 3.0.0-beta.2211-04
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -8,10 +8,10 @@
8
8
  var _a;
9
9
  import { __spreadArrayFn as __spreadArray } from "@microsoft/applicationinsights-shims";
10
10
  import dynamicProto from "@microsoft/dynamicproto-js";
11
- import { arrAppend, arrForEach, arrIndexOf, deepExtend, dumpObj, hasDocument, isFunction, isNullOrUndefined, isPlainObject, objDeepFreeze, objDefineProp, objForEachKey, objFreeze, objHasOwn, throwError } from "@nevware21/ts-utils";
11
+ import { arrAppend, arrForEach, arrIndexOf, deepExtend, dumpObj, hasDocument, isFunction, isNullOrUndefined, isPlainObject, objDeepFreeze, objDefineProp, objForEachKey, objFreeze, objHasOwn, scheduleInterval, scheduleTimeout, throwError } from "@nevware21/ts-utils";
12
12
  import { createDynamicConfig, onConfigChange } from "../Config/DynamicConfig";
13
- import { _DYN_ADD_NOTIFICATION_LIS1, _DYN_CALL, _DYN_CONFIGURABLE, _DYN_ENUMERABLE, _DYN_FLUSH, _DYN_GET_NOTIFY_MGR, _DYN_GET_PLUGIN, _DYN_GET_PROCESS_TEL_CONT0, _DYN_IDENTIFIER, _DYN_INITIALIZE, _DYN_IS_ASYNC, _DYN_IS_INITIALIZED, _DYN_LENGTH, _DYN_LOGGER, _DYN_LOGGING_LEVEL_CONSOL4, _DYN_MESSAGE, _DYN_MESSAGE_ID, _DYN_NAME, _DYN_NOTIFY, _DYN_ON_COMPLETE, _DYN_PROCESS_NEXT, _DYN_PUSH, _DYN_REMOVE_NOTIFICATION_2, _DYN_SET_DF, _DYN_SPLICE, _DYN_STOP_POLLING_INTERNA3, _DYN_TEARDOWN, _DYN_TIME, _DYN_VERSION, _DYN_WATCH } from "../__DynamicConstants";
14
- import { ChannelControllerPriority, createChannelControllerPlugin, createChannelQueues } from "./ChannelController";
13
+ import { _DYN_ADD_NOTIFICATION_LIS1, _DYN_CALL, _DYN_CANCEL, _DYN_CONFIGURABLE, _DYN_CREATE_NEW, _DYN_ENUMERABLE, _DYN_GET_NOTIFY_MGR, _DYN_GET_PLUGIN, _DYN_GET_PROCESS_TEL_CONT0, _DYN_IDENTIFIER, _DYN_INITIALIZE, _DYN_IS_ASYNC, _DYN_IS_INITIALIZED, _DYN_LENGTH, _DYN_LOGGER, _DYN_LOGGING_LEVEL_CONSOL4, _DYN_MESSAGE, _DYN_MESSAGE_ID, _DYN_NAME, _DYN_NOTIFY, _DYN_ON_COMPLETE, _DYN_POLL_INTERNAL_LOGS, _DYN_PROCESS_NEXT, _DYN_PUSH, _DYN_REMOVE_NOTIFICATION_2, _DYN_SET_DF, _DYN_SPLICE, _DYN_STOP_POLLING_INTERNA3, _DYN_TEARDOWN, _DYN_TIME, _DYN_VERSION, _DYN_WATCH } from "../__DynamicConstants";
14
+ import { ChannelControllerPriority } from "./Constants";
15
15
  import { createCookieMgr } from "./CookieMgr";
16
16
  import { createUniqueNamespace } from "./DataCacheHelper";
17
17
  import { getDebugListener } from "./DbgExtensionUtils";
@@ -56,6 +56,7 @@ function _validateExtensions(logger, channelPriority, allExtensions) {
56
56
  var _a;
57
57
  // Concat all available extensions
58
58
  var coreExtensions = [];
59
+ var channels = [];
59
60
  // Check if any two extensions have the same priority, then warn to console
60
61
  // And extract the local extensions from the
61
62
  var extPriorities = {};
@@ -76,16 +77,18 @@ function _validateExtensions(logger, channelPriority, allExtensions) {
76
77
  extPriorities[extPriority] = identifier;
77
78
  }
78
79
  }
79
- // Split extensions to core and channelController
80
+ // Split extensions to core and channels
80
81
  if (!extPriority || extPriority < channelPriority) {
81
82
  // Add to core extension that will be managed by AppInsightsCore
82
83
  coreExtensions[_DYN_PUSH /* @min:%2epush */](ext);
83
84
  }
85
+ else {
86
+ channels[_DYN_PUSH /* @min:%2epush */](ext);
87
+ }
84
88
  });
85
- return _a = {
86
- all: allExtensions
87
- },
89
+ return _a = {},
88
90
  _a[STR_CORE /* @min:core */] = coreExtensions,
91
+ _a[STR_CHANNELS /* @min:channels */] = channels,
89
92
  _a;
90
93
  }
91
94
  function _isPluginPresent(thePlugin, plugins) {
@@ -169,10 +172,8 @@ var AppInsightsCore = /** @class */ (function () {
169
172
  var _cookieManager;
170
173
  var _pluginChain;
171
174
  var _configExtensions;
172
- var _coreExtensions;
173
- var _channelControl;
174
175
  var _channelConfig;
175
- var _channelQueue;
176
+ var _channels;
176
177
  var _isUnloading;
177
178
  var _telemetryInitializerPlugin;
178
179
  var _internalLogsEventName;
@@ -189,7 +190,8 @@ var AppInsightsCore = /** @class */ (function () {
189
190
  /**
190
191
  * Internal log poller
191
192
  */
192
- var _internalLogPoller = 0;
193
+ var _internalLogPoller;
194
+ var _internalLogPollerListening;
193
195
  dynamicProto(AppInsightsCore, this, function (_self) {
194
196
  // Set the default values (also called during teardown)
195
197
  _initDefaults();
@@ -228,19 +230,26 @@ var AppInsightsCore = /** @class */ (function () {
228
230
  _configExtensions[_DYN_PUSH /* @min:%2epush */].apply(_configExtensions, __spreadArray(__spreadArray([], extensions, false), cfgExtensions, false));
229
231
  _channelConfig = config[STR_CHANNELS /* @min:%2echannels */];
230
232
  _initPluginChain(null);
231
- if (!_channelQueue || _channelQueue[_DYN_LENGTH /* @min:%2elength */] === 0) {
233
+ if (!_channels || _channels[_DYN_LENGTH /* @min:%2elength */] === 0) {
232
234
  throwError("No " + STR_CHANNELS + " available");
233
235
  }
236
+ if (_channels[_DYN_LENGTH /* @min:%2elength */] > 1) {
237
+ var teeController = _self[_DYN_GET_PLUGIN /* @min:%2egetPlugin */]("TeeChannelController");
238
+ if (!teeController || !teeController.plugin) {
239
+ _throwInternal(_self[_DYN_LOGGER /* @min:%2elogger */], 1 /* eLoggingSeverity.CRITICAL */, 28 /* _eInternalMessageId.SenderNotInitialized */, "TeeChannel required");
240
+ }
241
+ }
234
242
  _registerDelayedCfgListener(config, _cfgListeners, _self[_DYN_LOGGER /* @min:%2elogger */]);
235
243
  _cfgListeners = null;
236
244
  _isInitialized = true;
237
245
  _self.releaseQueue();
246
+ _self[_DYN_POLL_INTERNAL_LOGS /* @min:%2epollInternalLogs */]();
238
247
  };
239
- _self.getTransmissionControls = function () {
248
+ _self.getChannels = function () {
240
249
  var controls = [];
241
- if (_channelQueue) {
242
- arrForEach(_channelQueue, function (channels) {
243
- controls[_DYN_PUSH /* @min:%2epush */](channels.queue);
250
+ if (_channels) {
251
+ arrForEach(_channels, function (channel) {
252
+ controls[_DYN_PUSH /* @min:%2epush */](channel);
244
253
  });
245
254
  }
246
255
  return objFreeze(controls);
@@ -344,20 +353,29 @@ var AppInsightsCore = /** @class */ (function () {
344
353
  /**
345
354
  * Periodically check logger.queue for log messages to be flushed
346
355
  */
347
- _self.pollInternalLogs = function (eventName) {
356
+ _self[_DYN_POLL_INTERNAL_LOGS /* @min:%2epollInternalLogs */] = function (eventName) {
348
357
  _internalLogsEventName = eventName || null;
349
- _addUnloadHook(_configHandler[_DYN_WATCH /* @min:%2ewatch */](function (details) {
350
- var interval = details.cfg.diagnosticLogInterval;
358
+ function _startLogPoller(config) {
359
+ var interval = config.diagnosticLogInterval;
351
360
  if (!interval || !(interval > 0)) {
352
361
  interval = 10000;
353
362
  }
354
- if (_internalLogPoller) {
355
- clearInterval(_internalLogPoller);
356
- }
357
- _internalLogPoller = setInterval(function () {
363
+ _internalLogPoller && _internalLogPoller[_DYN_CANCEL /* @min:%2ecancel */]();
364
+ _internalLogPoller = scheduleInterval(function () {
358
365
  _flushInternalLogs();
359
366
  }, interval);
360
- }));
367
+ }
368
+ if (!_internalLogPollerListening) {
369
+ _internalLogPollerListening = true;
370
+ // listen to the configuration
371
+ _addUnloadHook(_configHandler[_DYN_WATCH /* @min:%2ewatch */](function (details) {
372
+ _startLogPoller(details.cfg);
373
+ }));
374
+ }
375
+ else {
376
+ // We are being called again, so make sure the poller is running
377
+ _startLogPoller(_configHandler.cfg);
378
+ }
361
379
  return _internalLogPoller;
362
380
  };
363
381
  /**
@@ -365,8 +383,8 @@ var AppInsightsCore = /** @class */ (function () {
365
383
  */
366
384
  _self[_DYN_STOP_POLLING_INTERNA3 /* @min:%2estopPollingInternalLogs */] = function () {
367
385
  if (_internalLogPoller) {
368
- clearInterval(_internalLogPoller);
369
- _internalLogPoller = 0;
386
+ _internalLogPoller[_DYN_CANCEL /* @min:%2ecancel */]();
387
+ _internalLogPoller = null;
370
388
  _flushInternalLogs();
371
389
  }
372
390
  };
@@ -512,7 +530,7 @@ var AppInsightsCore = /** @class */ (function () {
512
530
  _self.evtNamespace = function () {
513
531
  return _evtNamespace;
514
532
  };
515
- _self[_DYN_FLUSH /* @min:%2eflush */] = _flushChannels;
533
+ _self.flush = _flushChannels;
516
534
  _self.getTraceCtx = function (createNew) {
517
535
  if (!_traceCtx) {
518
536
  _traceCtx = createDistributedTraceContext();
@@ -613,11 +631,9 @@ var AppInsightsCore = /** @class */ (function () {
613
631
  _cfgPerfManager = null;
614
632
  _cookieManager = null;
615
633
  _pluginChain = null;
616
- _coreExtensions = null;
617
634
  _configExtensions = [];
618
- _channelControl = null;
619
635
  _channelConfig = null;
620
- _channelQueue = null;
636
+ _channels = null;
621
637
  _isUnloading = false;
622
638
  _internalLogsEventName = null;
623
639
  _evtNamespace = createUniqueNamespace("AIBaseCore", true);
@@ -636,42 +652,26 @@ var AppInsightsCore = /** @class */ (function () {
636
652
  function _initPluginChain(updateState) {
637
653
  // Extension validation
638
654
  var theExtensions = _validateExtensions(_self[_DYN_LOGGER /* @min:%2elogger */], ChannelControllerPriority, _configExtensions);
639
- _coreExtensions = theExtensions[STR_CORE /* @min:%2ecore */];
640
655
  _pluginChain = null;
641
656
  _pluginVersionString = null;
642
657
  _pluginVersionStringArr = null;
658
+ // Get the primary channel queue and include as part of the normal extensions
659
+ _channels = (_channelConfig || [])[0] || [];
660
+ // Add any channels provided in the extensions and sort them
661
+ _channels = sortPlugins(arrAppend(_channels, theExtensions[STR_CHANNELS /* @min:%2echannels */]));
643
662
  // Sort the complete set of extensions by priority
644
- var allExtensions = theExtensions.all;
645
- // Initialize the Channel Queues and the channel plugins first
646
- _channelQueue = objFreeze(createChannelQueues(_channelConfig, allExtensions, _self));
647
- if (_channelControl) {
648
- // During add / remove of a plugin this may get called again, so don't re-add if already present
649
- // But we also want the controller as the last, so remove if already present
650
- // And reusing the existing instance, just in case an installed plugin has a reference and
651
- // is using it.
652
- var idx = arrIndexOf(allExtensions, _channelControl);
653
- if (idx !== -1) {
654
- allExtensions[_DYN_SPLICE /* @min:%2esplice */](idx, 1);
655
- }
656
- idx = arrIndexOf(_coreExtensions, _channelControl);
657
- if (idx !== -1) {
658
- _coreExtensions[_DYN_SPLICE /* @min:%2esplice */](idx, 1);
659
- }
660
- _channelControl._setQueue(_channelQueue);
661
- }
662
- else {
663
- _channelControl = createChannelControllerPlugin(_channelQueue, _self);
664
- }
663
+ var allExtensions = sortPlugins(theExtensions[STR_CORE /* @min:%2ecore */]);
665
664
  // Add on "channelController" as the last "plugin"
666
- allExtensions[_DYN_PUSH /* @min:%2epush */](_channelControl);
667
- _coreExtensions[_DYN_PUSH /* @min:%2epush */](_channelControl);
665
+ arrAppend(allExtensions, _channels);
668
666
  // Required to allow plugins to call core.getPlugin() during their own initialization
669
- _extensions = sortPlugins(allExtensions);
670
- // Initialize the controls
671
- _channelControl[_DYN_INITIALIZE /* @min:%2einitialize */](_configHandler.cfg, _self, allExtensions);
672
- initializePlugins(_createTelCtx(), allExtensions);
673
- // Now reset the extensions to just those being managed by AppInsightsCore
674
- _extensions = objFreeze(sortPlugins(_coreExtensions || [])).slice();
667
+ _extensions = objFreeze(allExtensions);
668
+ var rootCtx = _createTelCtx();
669
+ // Initializing the channels first
670
+ if (_channels && _channels[_DYN_LENGTH /* @min:%2elength */] > 0) {
671
+ initializePlugins(rootCtx[_DYN_CREATE_NEW /* @min:%2ecreateNew */](_channels), allExtensions);
672
+ }
673
+ // Now initialize the normal extensions
674
+ initializePlugins(rootCtx, allExtensions);
675
675
  if (updateState) {
676
676
  _doUpdate(updateState);
677
677
  }
@@ -680,15 +680,17 @@ var AppInsightsCore = /** @class */ (function () {
680
680
  var theExt = null;
681
681
  var thePlugin = null;
682
682
  arrForEach(_extensions, function (ext) {
683
- if (ext[_DYN_IDENTIFIER /* @min:%2eidentifier */] === pluginIdentifier && ext !== _channelControl && ext !== _telemetryInitializerPlugin) {
683
+ if (ext[_DYN_IDENTIFIER /* @min:%2eidentifier */] === pluginIdentifier && ext !== _telemetryInitializerPlugin) {
684
684
  thePlugin = ext;
685
685
  return -1;
686
686
  }
687
+ // TODO: Check if the extension is an extension "host" (like the TeeChannel)
688
+ // So that if the extension is not found we can ask the "host" plugins for the plugin
687
689
  });
688
- if (!thePlugin && _channelControl) {
689
- // Check the channel Controller
690
- thePlugin = _channelControl.getChannel(pluginIdentifier);
691
- }
690
+ // if (!thePlugin && _channelControl) {
691
+ // // Check the channel Controller
692
+ // thePlugin = _channelControl.getChannel(pluginIdentifier);
693
+ // }
692
694
  if (thePlugin) {
693
695
  theExt = {
694
696
  plugin: thePlugin,
@@ -726,8 +728,8 @@ var AppInsightsCore = /** @class */ (function () {
726
728
  function _getPluginChain() {
727
729
  if (!_pluginChain) {
728
730
  // copy the collection of extensions
729
- var extensions = (_coreExtensions || []).slice();
730
- // During add / remove this may get called again, so don't readd if already present
731
+ var extensions = (_extensions || []).slice();
732
+ // During add / remove this may get called again, so don't read if already present
731
733
  if (arrIndexOf(extensions, _telemetryInitializerPlugin) === -1) {
732
734
  extensions[_DYN_PUSH /* @min:%2epush */](_telemetryInitializerPlugin);
733
735
  }
@@ -797,10 +799,51 @@ var AppInsightsCore = /** @class */ (function () {
797
799
  }
798
800
  }
799
801
  function _flushChannels(isAsync, callBack, sendReason, cbTimeout) {
800
- if (_channelControl) {
801
- return _channelControl[_DYN_FLUSH /* @min:%2eflush */](isAsync, callBack, sendReason || 6 /* SendRequestReason.SdkUnload */, cbTimeout);
802
+ // Setting waiting to one so that we don't call the callBack until we finish iterating
803
+ var waiting = 1;
804
+ var doneIterating = false;
805
+ var cbTimer = null;
806
+ cbTimeout = cbTimeout || 5000;
807
+ function doCallback() {
808
+ waiting--;
809
+ if (doneIterating && waiting === 0) {
810
+ cbTimer && cbTimer[_DYN_CANCEL /* @min:%2ecancel */]();
811
+ cbTimer = null;
812
+ callBack && callBack(doneIterating);
813
+ callBack = null;
814
+ }
815
+ }
816
+ if (_channels && _channels[_DYN_LENGTH /* @min:%2elength */] > 0) {
817
+ var flushCtx = _createTelCtx()[_DYN_CREATE_NEW /* @min:%2ecreateNew */](_channels);
818
+ flushCtx.iterate(function (plugin) {
819
+ if (plugin.flush) {
820
+ waiting++;
821
+ var handled_1 = false;
822
+ // Not all channels will call this callback for every scenario
823
+ if (!plugin.flush(isAsync, function () {
824
+ handled_1 = true;
825
+ doCallback();
826
+ }, sendReason)) {
827
+ if (!handled_1) {
828
+ // If any channel doesn't return true and it didn't call the callback, then we should assume that the callback
829
+ // will never be called, so use a timeout to allow the channel(s) some time to "finish" before triggering any
830
+ // followup function (such as unloading)
831
+ if (isAsync && cbTimer == null) {
832
+ cbTimer = scheduleTimeout(function () {
833
+ cbTimer = null;
834
+ doCallback();
835
+ }, cbTimeout);
836
+ }
837
+ else {
838
+ doCallback();
839
+ }
840
+ }
841
+ }
842
+ }
843
+ });
802
844
  }
803
- callBack && callBack(false);
845
+ doneIterating = true;
846
+ doCallback();
804
847
  return true;
805
848
  }
806
849
  function _initDebugListener() {
@@ -864,7 +907,7 @@ var AppInsightsCore = /** @class */ (function () {
864
907
  });
865
908
  }
866
909
  // Removed Stub for AppInsightsCore.prototype.initialize.
867
- // Removed Stub for AppInsightsCore.prototype.getTransmissionControls.
910
+ // Removed Stub for AppInsightsCore.prototype.getChannels.
868
911
  // Removed Stub for AppInsightsCore.prototype.track.
869
912
  // Removed Stub for AppInsightsCore.prototype.getProcessTelContext.
870
913
  // Removed Stub for AppInsightsCore.prototype.getNotifyMgr.