@microsoft/applicationinsights-core-js 3.0.0-beta.2211-03 → 3.0.0-beta.2212-03

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/browser/applicationinsights-core-js.integrity.json +9 -9
  2. package/browser/applicationinsights-core-js.js +1156 -1345
  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 +85 -85
  7. package/dist/applicationinsights-core-js.api.md +8 -8
  8. package/dist/applicationinsights-core-js.d.ts +7 -7
  9. package/dist/applicationinsights-core-js.js +1156 -1345
  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 +7 -7
  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 +1 -1
  18. package/dist-esm/Config/DynamicSupport.js +1 -1
  19. package/dist-esm/Config/IConfigDefaults.js +1 -1
  20. package/dist-esm/Config/IDynamicConfigHandler.js +1 -1
  21. package/dist-esm/Config/IDynamicPropertyHandler.js +1 -1
  22. package/dist-esm/Config/IDynamicWatcher.js +1 -1
  23. package/dist-esm/Config/_IDynamicConfigHandlerState.js +1 -1
  24. package/dist-esm/JavaScriptSDK/AggregationError.js +1 -1
  25. package/dist-esm/JavaScriptSDK/AppInsightsCore.js +93 -63
  26. package/dist-esm/JavaScriptSDK/AppInsightsCore.js.map +1 -1
  27. package/dist-esm/JavaScriptSDK/BaseTelemetryPlugin.js +1 -1
  28. package/dist-esm/JavaScriptSDK/Constants.js +8 -0
  29. package/dist-esm/JavaScriptSDK/Constants.js.map +1 -0
  30. package/dist-esm/JavaScriptSDK/CookieMgr.js +1 -1
  31. package/dist-esm/JavaScriptSDK/CoreUtils.js +1 -1
  32. package/dist-esm/JavaScriptSDK/DataCacheHelper.js +2 -2
  33. package/dist-esm/JavaScriptSDK/DataCacheHelper.js.map +1 -1
  34. package/dist-esm/JavaScriptSDK/DbgExtensionUtils.js +1 -1
  35. package/dist-esm/JavaScriptSDK/DiagnosticLogger.js +1 -1
  36. package/dist-esm/JavaScriptSDK/EnvUtils.js +1 -1
  37. package/dist-esm/JavaScriptSDK/EventHelpers.js +1 -1
  38. package/dist-esm/JavaScriptSDK/HelperFuncs.js +1 -1
  39. package/dist-esm/JavaScriptSDK/InstrumentHooks.js +1 -1
  40. package/dist-esm/JavaScriptSDK/InternalConstants.js +1 -1
  41. package/dist-esm/JavaScriptSDK/NotificationManager.js +1 -1
  42. package/dist-esm/JavaScriptSDK/PerfManager.js +1 -1
  43. package/dist-esm/JavaScriptSDK/ProcessTelemetryContext.js +5 -5
  44. package/dist-esm/JavaScriptSDK/ProcessTelemetryContext.js.map +1 -1
  45. package/dist-esm/JavaScriptSDK/RandomHelper.js +1 -1
  46. package/dist-esm/JavaScriptSDK/TelemetryHelpers.js +5 -8
  47. package/dist-esm/JavaScriptSDK/TelemetryHelpers.js.map +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 +15 -17
  80. package/dist-esm/__DynamicConstants.js.map +1 -1
  81. package/dist-esm/applicationinsights-core-js.js +1 -1
  82. package/package.json +2 -2
  83. package/src/JavaScriptSDK/AppInsightsCore.ts +98 -66
  84. package/src/JavaScriptSDK/Constants.ts +4 -0
  85. package/src/JavaScriptSDK/TelemetryHelpers.ts +5 -6
  86. package/src/JavaScriptSDK.Interfaces/IAppInsightsCore.ts +2 -2
  87. package/src/JavaScriptSDK.Interfaces/IChannelControls.ts +4 -4
  88. package/types/Config/IConfigDefaults.d.ts +3 -3
  89. package/types/Config/IDynamicWatcher.d.ts +1 -1
  90. package/types/JavaScriptSDK/AppInsightsCore.d.ts +1 -1
  91. package/types/JavaScriptSDK/Constants.d.ts +1 -0
  92. package/types/JavaScriptSDK/UnloadHandlerContainer.d.ts +1 -1
  93. package/types/JavaScriptSDK.Enums/EventsDiscardedReason.d.ts +1 -1
  94. package/types/JavaScriptSDK.Enums/LoggingEnums.d.ts +2 -2
  95. package/types/JavaScriptSDK.Interfaces/IAppInsightsCore.d.ts +1 -1
  96. package/types/JavaScriptSDK.Interfaces/IChannelControls.d.ts +4 -4
  97. package/types/JavaScriptSDK.Interfaces/IInstrumentHooks.d.ts +1 -1
  98. package/types/__DynamicConstants.d.ts +2 -4
  99. package/dist-esm/JavaScriptSDK/ChannelController.js +0 -217
  100. package/dist-esm/JavaScriptSDK/ChannelController.js.map +0 -1
  101. package/src/JavaScriptSDK/ChannelController.ts +0 -274
  102. 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-03
2
+ * Microsoft Application Insights Core Javascript SDK, 3.0.0-beta.2212-03
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  *
5
5
  * Microsoft Application Insights Team
@@ -157,7 +157,7 @@ export declare class AppInsightsCore implements IAppInsightsCore {
157
157
  getWParam: () => number;
158
158
  constructor();
159
159
  initialize(config: IConfiguration, extensions: IPlugin[], logger?: IDiagnosticLogger, notificationManager?: INotificationManager): void;
160
- getTransmissionControls(): IChannelControls[][];
160
+ getChannels(): IChannelControls[];
161
161
  track(telemetryItem: ITelemetryItem): void;
162
162
  getProcessTelContext(): IProcessTelemetryContext;
163
163
  getNotifyMgr(): INotificationManager;
@@ -860,7 +860,7 @@ export declare interface IAppInsightsCore extends IPerfManagerProvider {
860
860
  */
861
861
  isInitialized?: () => boolean;
862
862
  initialize(config: IConfiguration, extensions: IPlugin[], logger?: IDiagnosticLogger, notificationManager?: INotificationManager): void;
863
- getTransmissionControls(): IChannelControls[][];
863
+ getChannels(): IChannelControls[];
864
864
  track(telemetryItem: ITelemetryItem): void;
865
865
  /**
866
866
  * Get the current notification manager
@@ -1046,11 +1046,11 @@ export declare interface IChannelControls extends ITelemetryPlugin {
1046
1046
  /**
1047
1047
  * Pause sending data
1048
1048
  */
1049
- pause(): void;
1049
+ pause?(): void;
1050
1050
  /**
1051
1051
  * Resume sending data
1052
1052
  */
1053
- resume(): void;
1053
+ resume?(): void;
1054
1054
  /**
1055
1055
  * Tear down the plugin and remove any hooked value, the plugin should be removed so that it is no longer initialized and
1056
1056
  * therefore could be re-initialized after being torn down. The plugin should ensure that once this has been called any further
@@ -1059,7 +1059,7 @@ export declare interface IChannelControls extends ITelemetryPlugin {
1059
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.
1060
1060
  * @returns boolean - true if the plugin has or will call processNext(), this for backward compatibility as previously teardown was synchronous and returned nothing.
1061
1061
  */
1062
- teardown: (unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState) => void | boolean;
1062
+ teardown?: (unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState) => void | boolean;
1063
1063
  /**
1064
1064
  * Flush to send data immediately; channel should default to sending data asynchronously
1065
1065
  * @param async - send data asynchronously when true
@@ -1068,7 +1068,7 @@ export declare interface IChannelControls extends ITelemetryPlugin {
1068
1068
  * @param sendReason - specify the reason that you are calling "flush" defaults to ManualFlush (1) if not specified
1069
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
1070
1070
  */
1071
- flush(async: boolean, callBack?: (flushComplete?: boolean) => void, sendReason?: SendRequestReason): boolean | void;
1071
+ flush?(async: boolean, callBack?: (flushComplete?: boolean) => void, sendReason?: SendRequestReason): boolean | void;
1072
1072
  }
1073
1073
 
1074
1074
  /**
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Core, 3.0.0-beta.2211-03
2
+ * Application Insights JavaScript SDK - Core, 3.0.0-beta.2212-03
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Core, 3.0.0-beta.2211-03
2
+ * Application Insights JavaScript SDK - Core, 3.0.0-beta.2212-03
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Core, 3.0.0-beta.2211-03
2
+ * Application Insights JavaScript SDK - Core, 3.0.0-beta.2212-03
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Core, 3.0.0-beta.2211-03
2
+ * Application Insights JavaScript SDK - Core, 3.0.0-beta.2212-03
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Core, 3.0.0-beta.2211-03
2
+ * Application Insights JavaScript SDK - Core, 3.0.0-beta.2212-03
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Core, 3.0.0-beta.2211-03
2
+ * Application Insights JavaScript SDK - Core, 3.0.0-beta.2212-03
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Core, 3.0.0-beta.2211-03
2
+ * Application Insights JavaScript SDK - Core, 3.0.0-beta.2212-03
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Core, 3.0.0-beta.2211-03
2
+ * Application Insights JavaScript SDK - Core, 3.0.0-beta.2212-03
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Core, 3.0.0-beta.2211-03
2
+ * Application Insights JavaScript SDK - Core, 3.0.0-beta.2212-03
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Core, 3.0.0-beta.2211-03
2
+ * Application Insights JavaScript SDK - Core, 3.0.0-beta.2212-03
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-03
2
+ * Application Insights JavaScript SDK - Core, 3.0.0-beta.2212-03
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Core, 3.0.0-beta.2211-03
2
+ * Application Insights JavaScript SDK - Core, 3.0.0-beta.2212-03
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, scheduleInterval, 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_CANCEL, _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_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, 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;
@@ -229,20 +230,26 @@ var AppInsightsCore = /** @class */ (function () {
229
230
  _configExtensions[_DYN_PUSH /* @min:%2epush */].apply(_configExtensions, __spreadArray(__spreadArray([], extensions, false), cfgExtensions, false));
230
231
  _channelConfig = config[STR_CHANNELS /* @min:%2echannels */];
231
232
  _initPluginChain(null);
232
- if (!_channelQueue || _channelQueue[_DYN_LENGTH /* @min:%2elength */] === 0) {
233
+ if (!_channels || _channels[_DYN_LENGTH /* @min:%2elength */] === 0) {
233
234
  throwError("No " + STR_CHANNELS + " available");
234
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
+ }
235
242
  _registerDelayedCfgListener(config, _cfgListeners, _self[_DYN_LOGGER /* @min:%2elogger */]);
236
243
  _cfgListeners = null;
237
244
  _isInitialized = true;
238
245
  _self.releaseQueue();
239
246
  _self[_DYN_POLL_INTERNAL_LOGS /* @min:%2epollInternalLogs */]();
240
247
  };
241
- _self.getTransmissionControls = function () {
248
+ _self.getChannels = function () {
242
249
  var controls = [];
243
- if (_channelQueue) {
244
- arrForEach(_channelQueue, function (channels) {
245
- controls[_DYN_PUSH /* @min:%2epush */](channels.queue);
250
+ if (_channels) {
251
+ arrForEach(_channels, function (channel) {
252
+ controls[_DYN_PUSH /* @min:%2epush */](channel);
246
253
  });
247
254
  }
248
255
  return objFreeze(controls);
@@ -523,7 +530,7 @@ var AppInsightsCore = /** @class */ (function () {
523
530
  _self.evtNamespace = function () {
524
531
  return _evtNamespace;
525
532
  };
526
- _self[_DYN_FLUSH /* @min:%2eflush */] = _flushChannels;
533
+ _self.flush = _flushChannels;
527
534
  _self.getTraceCtx = function (createNew) {
528
535
  if (!_traceCtx) {
529
536
  _traceCtx = createDistributedTraceContext();
@@ -624,11 +631,9 @@ var AppInsightsCore = /** @class */ (function () {
624
631
  _cfgPerfManager = null;
625
632
  _cookieManager = null;
626
633
  _pluginChain = null;
627
- _coreExtensions = null;
628
634
  _configExtensions = [];
629
- _channelControl = null;
630
635
  _channelConfig = null;
631
- _channelQueue = null;
636
+ _channels = null;
632
637
  _isUnloading = false;
633
638
  _internalLogsEventName = null;
634
639
  _evtNamespace = createUniqueNamespace("AIBaseCore", true);
@@ -647,42 +652,24 @@ var AppInsightsCore = /** @class */ (function () {
647
652
  function _initPluginChain(updateState) {
648
653
  // Extension validation
649
654
  var theExtensions = _validateExtensions(_self[_DYN_LOGGER /* @min:%2elogger */], ChannelControllerPriority, _configExtensions);
650
- _coreExtensions = theExtensions[STR_CORE /* @min:%2ecore */];
651
655
  _pluginChain = null;
652
656
  _pluginVersionString = null;
653
657
  _pluginVersionStringArr = null;
654
- // Sort the complete set of extensions by priority
655
- var allExtensions = theExtensions.all;
656
- // Initialize the Channel Queues and the channel plugins first
657
- _channelQueue = objFreeze(createChannelQueues(_channelConfig, allExtensions, _self));
658
- if (_channelControl) {
659
- // During add / remove of a plugin this may get called again, so don't re-add if already present
660
- // But we also want the controller as the last, so remove if already present
661
- // And reusing the existing instance, just in case an installed plugin has a reference and
662
- // is using it.
663
- var idx = arrIndexOf(allExtensions, _channelControl);
664
- if (idx !== -1) {
665
- allExtensions[_DYN_SPLICE /* @min:%2esplice */](idx, 1);
666
- }
667
- idx = arrIndexOf(_coreExtensions, _channelControl);
668
- if (idx !== -1) {
669
- _coreExtensions[_DYN_SPLICE /* @min:%2esplice */](idx, 1);
670
- }
671
- _channelControl._setQueue(_channelQueue);
672
- }
673
- else {
674
- _channelControl = createChannelControllerPlugin(_channelQueue, _self);
675
- }
676
- // Add on "channelController" as the last "plugin"
677
- allExtensions[_DYN_PUSH /* @min:%2epush */](_channelControl);
678
- _coreExtensions[_DYN_PUSH /* @min:%2epush */](_channelControl);
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 */]));
662
+ // Create an array of all extensions, including the _channels
663
+ var allExtensions = arrAppend(sortPlugins(theExtensions[STR_CORE /* @min:%2ecore */]), _channels);
679
664
  // Required to allow plugins to call core.getPlugin() during their own initialization
680
- _extensions = sortPlugins(allExtensions);
681
- // Initialize the controls
682
- _channelControl[_DYN_INITIALIZE /* @min:%2einitialize */](_configHandler.cfg, _self, allExtensions);
683
- initializePlugins(_createTelCtx(), allExtensions);
684
- // Now reset the extensions to just those being managed by AppInsightsCore
685
- _extensions = objFreeze(sortPlugins(_coreExtensions || [])).slice();
665
+ _extensions = objFreeze(allExtensions);
666
+ var rootCtx = _createTelCtx();
667
+ // Initializing the channels first
668
+ if (_channels && _channels[_DYN_LENGTH /* @min:%2elength */] > 0) {
669
+ initializePlugins(rootCtx[_DYN_CREATE_NEW /* @min:%2ecreateNew */](_channels), allExtensions);
670
+ }
671
+ // Now initialize the normal extensions (explicitly not including the _channels as this can cause duplicate initialization)
672
+ initializePlugins(rootCtx, allExtensions);
686
673
  if (updateState) {
687
674
  _doUpdate(updateState);
688
675
  }
@@ -691,15 +678,17 @@ var AppInsightsCore = /** @class */ (function () {
691
678
  var theExt = null;
692
679
  var thePlugin = null;
693
680
  arrForEach(_extensions, function (ext) {
694
- if (ext[_DYN_IDENTIFIER /* @min:%2eidentifier */] === pluginIdentifier && ext !== _channelControl && ext !== _telemetryInitializerPlugin) {
681
+ if (ext[_DYN_IDENTIFIER /* @min:%2eidentifier */] === pluginIdentifier && ext !== _telemetryInitializerPlugin) {
695
682
  thePlugin = ext;
696
683
  return -1;
697
684
  }
685
+ // TODO: Check if the extension is an extension "host" (like the TeeChannel)
686
+ // So that if the extension is not found we can ask the "host" plugins for the plugin
698
687
  });
699
- if (!thePlugin && _channelControl) {
700
- // Check the channel Controller
701
- thePlugin = _channelControl.getChannel(pluginIdentifier);
702
- }
688
+ // if (!thePlugin && _channelControl) {
689
+ // // Check the channel Controller
690
+ // thePlugin = _channelControl.getChannel(pluginIdentifier);
691
+ // }
703
692
  if (thePlugin) {
704
693
  theExt = {
705
694
  plugin: thePlugin,
@@ -737,8 +726,8 @@ var AppInsightsCore = /** @class */ (function () {
737
726
  function _getPluginChain() {
738
727
  if (!_pluginChain) {
739
728
  // copy the collection of extensions
740
- var extensions = (_coreExtensions || []).slice();
741
- // During add / remove this may get called again, so don't readd if already present
729
+ var extensions = (_extensions || []).slice();
730
+ // During add / remove this may get called again, so don't read if already present
742
731
  if (arrIndexOf(extensions, _telemetryInitializerPlugin) === -1) {
743
732
  extensions[_DYN_PUSH /* @min:%2epush */](_telemetryInitializerPlugin);
744
733
  }
@@ -808,10 +797,51 @@ var AppInsightsCore = /** @class */ (function () {
808
797
  }
809
798
  }
810
799
  function _flushChannels(isAsync, callBack, sendReason, cbTimeout) {
811
- if (_channelControl) {
812
- return _channelControl[_DYN_FLUSH /* @min:%2eflush */](isAsync, callBack, sendReason || 6 /* SendRequestReason.SdkUnload */, cbTimeout);
800
+ // Setting waiting to one so that we don't call the callBack until we finish iterating
801
+ var waiting = 1;
802
+ var doneIterating = false;
803
+ var cbTimer = null;
804
+ cbTimeout = cbTimeout || 5000;
805
+ function doCallback() {
806
+ waiting--;
807
+ if (doneIterating && waiting === 0) {
808
+ cbTimer && cbTimer[_DYN_CANCEL /* @min:%2ecancel */]();
809
+ cbTimer = null;
810
+ callBack && callBack(doneIterating);
811
+ callBack = null;
812
+ }
813
+ }
814
+ if (_channels && _channels[_DYN_LENGTH /* @min:%2elength */] > 0) {
815
+ var flushCtx = _createTelCtx()[_DYN_CREATE_NEW /* @min:%2ecreateNew */](_channels);
816
+ flushCtx.iterate(function (plugin) {
817
+ if (plugin.flush) {
818
+ waiting++;
819
+ var handled_1 = false;
820
+ // Not all channels will call this callback for every scenario
821
+ if (!plugin.flush(isAsync, function () {
822
+ handled_1 = true;
823
+ doCallback();
824
+ }, sendReason)) {
825
+ if (!handled_1) {
826
+ // If any channel doesn't return true and it didn't call the callback, then we should assume that the callback
827
+ // will never be called, so use a timeout to allow the channel(s) some time to "finish" before triggering any
828
+ // followup function (such as unloading)
829
+ if (isAsync && cbTimer == null) {
830
+ cbTimer = scheduleTimeout(function () {
831
+ cbTimer = null;
832
+ doCallback();
833
+ }, cbTimeout);
834
+ }
835
+ else {
836
+ doCallback();
837
+ }
838
+ }
839
+ }
840
+ }
841
+ });
813
842
  }
814
- callBack && callBack(false);
843
+ doneIterating = true;
844
+ doCallback();
815
845
  return true;
816
846
  }
817
847
  function _initDebugListener() {
@@ -875,7 +905,7 @@ var AppInsightsCore = /** @class */ (function () {
875
905
  });
876
906
  }
877
907
  // Removed Stub for AppInsightsCore.prototype.initialize.
878
- // Removed Stub for AppInsightsCore.prototype.getTransmissionControls.
908
+ // Removed Stub for AppInsightsCore.prototype.getChannels.
879
909
  // Removed Stub for AppInsightsCore.prototype.track.
880
910
  // Removed Stub for AppInsightsCore.prototype.getProcessTelContext.
881
911
  // Removed Stub for AppInsightsCore.prototype.getNotifyMgr.