@microsoft/applicationinsights-core-js 3.0.0-beta.2209-03 → 3.0.0-beta.2210-02

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 (179) hide show
  1. package/browser/applicationinsights-core-js.integrity.json +9 -9
  2. package/browser/applicationinsights-core-js.js +1249 -675
  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 +3669 -1713
  7. package/dist/applicationinsights-core-js.api.md +131 -54
  8. package/dist/applicationinsights-core-js.d.ts +332 -131
  9. package/dist/applicationinsights-core-js.js +1249 -675
  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 +332 -131
  14. package/dist-esm/Config/ConfigDefaults.js +114 -0
  15. package/dist-esm/Config/ConfigDefaults.js.map +1 -0
  16. package/dist-esm/Config/DynamicConfig.js +129 -0
  17. package/dist-esm/Config/DynamicConfig.js.map +1 -0
  18. package/dist-esm/Config/DynamicProperty.js +139 -0
  19. package/dist-esm/Config/DynamicProperty.js.map +1 -0
  20. package/dist-esm/Config/DynamicState.js +109 -0
  21. package/dist-esm/Config/DynamicState.js.map +1 -0
  22. package/dist-esm/Config/DynamicSupport.js +57 -0
  23. package/dist-esm/Config/DynamicSupport.js.map +1 -0
  24. package/dist-esm/Config/IConfigDefaults.js +8 -0
  25. package/dist-esm/Config/IConfigDefaults.js.map +1 -0
  26. package/dist-esm/Config/IDynamicConfigHandler.js +8 -0
  27. package/dist-esm/Config/IDynamicConfigHandler.js.map +1 -0
  28. package/dist-esm/Config/IDynamicPropertyHandler.js +8 -0
  29. package/dist-esm/Config/IDynamicPropertyHandler.js.map +1 -0
  30. package/dist-esm/Config/IDynamicWatcher.js +8 -0
  31. package/dist-esm/Config/IDynamicWatcher.js.map +1 -0
  32. package/dist-esm/Config/_IDynamicConfigHandlerState.js +6 -0
  33. package/dist-esm/Config/_IDynamicConfigHandlerState.js.map +1 -0
  34. package/dist-esm/JavaScriptSDK/AppInsightsCore.js +808 -23
  35. package/dist-esm/JavaScriptSDK/AppInsightsCore.js.map +1 -1
  36. package/dist-esm/JavaScriptSDK/BaseTelemetryPlugin.js +22 -18
  37. package/dist-esm/JavaScriptSDK/BaseTelemetryPlugin.js.map +1 -1
  38. package/dist-esm/JavaScriptSDK/ChannelController.js +1 -1
  39. package/dist-esm/JavaScriptSDK/CookieMgr.js +78 -38
  40. package/dist-esm/JavaScriptSDK/CookieMgr.js.map +1 -1
  41. package/dist-esm/JavaScriptSDK/CoreUtils.js +6 -5
  42. package/dist-esm/JavaScriptSDK/CoreUtils.js.map +1 -1
  43. package/dist-esm/JavaScriptSDK/DataCacheHelper.js +10 -8
  44. package/dist-esm/JavaScriptSDK/DataCacheHelper.js.map +1 -1
  45. package/dist-esm/JavaScriptSDK/DbgExtensionUtils.js +1 -1
  46. package/dist-esm/JavaScriptSDK/DiagnosticLogger.js +40 -23
  47. package/dist-esm/JavaScriptSDK/DiagnosticLogger.js.map +1 -1
  48. package/dist-esm/JavaScriptSDK/EnvUtils.js +1 -115
  49. package/dist-esm/JavaScriptSDK/EnvUtils.js.map +1 -1
  50. package/dist-esm/JavaScriptSDK/EventHelpers.js +30 -29
  51. package/dist-esm/JavaScriptSDK/EventHelpers.js.map +1 -1
  52. package/dist-esm/JavaScriptSDK/HelperFuncs.js +19 -34
  53. package/dist-esm/JavaScriptSDK/HelperFuncs.js.map +1 -1
  54. package/dist-esm/JavaScriptSDK/InstrumentHooks.js +1 -1
  55. package/dist-esm/JavaScriptSDK/InternalConstants.js +5 -1
  56. package/dist-esm/JavaScriptSDK/InternalConstants.js.map +1 -1
  57. package/dist-esm/JavaScriptSDK/NotificationManager.js +18 -11
  58. package/dist-esm/JavaScriptSDK/NotificationManager.js.map +1 -1
  59. package/dist-esm/JavaScriptSDK/PerfManager.js +2 -3
  60. package/dist-esm/JavaScriptSDK/PerfManager.js.map +1 -1
  61. package/dist-esm/JavaScriptSDK/ProcessTelemetryContext.js +62 -53
  62. package/dist-esm/JavaScriptSDK/ProcessTelemetryContext.js.map +1 -1
  63. package/dist-esm/JavaScriptSDK/RandomHelper.js +1 -1
  64. package/dist-esm/JavaScriptSDK/TelemetryHelpers.js +8 -10
  65. package/dist-esm/JavaScriptSDK/TelemetryHelpers.js.map +1 -1
  66. package/dist-esm/JavaScriptSDK/TelemetryInitializerPlugin.js +3 -4
  67. package/dist-esm/JavaScriptSDK/TelemetryInitializerPlugin.js.map +1 -1
  68. package/dist-esm/JavaScriptSDK/UnloadHandlerContainer.js +1 -1
  69. package/dist-esm/JavaScriptSDK/W3cTraceParent.js +12 -10
  70. package/dist-esm/JavaScriptSDK/W3cTraceParent.js.map +1 -1
  71. package/dist-esm/JavaScriptSDK.Enums/EnumHelperFuncs.js +1 -2
  72. package/dist-esm/JavaScriptSDK.Enums/EnumHelperFuncs.js.map +1 -1
  73. package/dist-esm/JavaScriptSDK.Enums/EventsDiscardedReason.js +1 -1
  74. package/dist-esm/JavaScriptSDK.Enums/LoggingEnums.js +2 -107
  75. package/dist-esm/JavaScriptSDK.Enums/LoggingEnums.js.map +1 -1
  76. package/dist-esm/JavaScriptSDK.Enums/SendRequestReason.js +1 -1
  77. package/dist-esm/JavaScriptSDK.Enums/TelemetryUnloadReason.js +1 -1
  78. package/dist-esm/JavaScriptSDK.Enums/TelemetryUpdateReason.js +1 -1
  79. package/dist-esm/JavaScriptSDK.Interfaces/IAppInsightsCore.js +1 -1
  80. package/dist-esm/JavaScriptSDK.Interfaces/IChannelControls.js +1 -1
  81. package/dist-esm/JavaScriptSDK.Interfaces/IConfiguration.js +1 -1
  82. package/dist-esm/JavaScriptSDK.Interfaces/ICookieMgr.js +1 -1
  83. package/dist-esm/JavaScriptSDK.Interfaces/IDbgExtension.js +1 -1
  84. package/dist-esm/JavaScriptSDK.Interfaces/IDiagnosticLogger.js +1 -1
  85. package/dist-esm/JavaScriptSDK.Interfaces/IDistributedTraceContext.js +1 -1
  86. package/dist-esm/JavaScriptSDK.Interfaces/IInstrumentHooks.js +1 -1
  87. package/dist-esm/JavaScriptSDK.Interfaces/INotificationListener.js +1 -1
  88. package/dist-esm/JavaScriptSDK.Interfaces/INotificationManager.js +1 -1
  89. package/dist-esm/JavaScriptSDK.Interfaces/IPerfEvent.js +1 -1
  90. package/dist-esm/JavaScriptSDK.Interfaces/IPerfManager.js +1 -1
  91. package/dist-esm/JavaScriptSDK.Interfaces/IProcessTelemetryContext.js +1 -1
  92. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryInitializers.js +1 -1
  93. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryItem.js +1 -1
  94. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryPlugin.js +1 -1
  95. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryPluginChain.js +1 -1
  96. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUnloadState.js +1 -1
  97. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUpdateState.js +1 -1
  98. package/dist-esm/JavaScriptSDK.Interfaces/ITraceParent.js +1 -1
  99. package/dist-esm/JavaScriptSDK.Interfaces/IUnloadHook.js +8 -0
  100. package/dist-esm/JavaScriptSDK.Interfaces/IUnloadHook.js.map +1 -0
  101. package/dist-esm/JavaScriptSDK.Interfaces/IUnloadableComponent.js +3 -1
  102. package/dist-esm/JavaScriptSDK.Interfaces/IUnloadableComponent.js.map +1 -1
  103. package/dist-esm/__DynamicConstants.js +26 -23
  104. package/dist-esm/__DynamicConstants.js.map +1 -1
  105. package/dist-esm/applicationinsights-core-js.js +6 -4
  106. package/dist-esm/applicationinsights-core-js.js.map +1 -1
  107. package/package.json +2 -2
  108. package/src/JavaScriptSDK/AppInsightsCore.ts +1156 -16
  109. package/src/JavaScriptSDK/BaseTelemetryPlugin.ts +25 -17
  110. package/src/JavaScriptSDK/CookieMgr.ts +88 -41
  111. package/src/JavaScriptSDK/CoreUtils.ts +4 -3
  112. package/src/JavaScriptSDK/DiagnosticLogger.ts +51 -29
  113. package/src/JavaScriptSDK/EnvUtils.ts +0 -133
  114. package/src/JavaScriptSDK/EventHelpers.ts +29 -28
  115. package/src/JavaScriptSDK/HelperFuncs.ts +22 -39
  116. package/src/JavaScriptSDK/InternalConstants.ts +5 -0
  117. package/src/JavaScriptSDK/NotificationManager.ts +25 -14
  118. package/src/JavaScriptSDK/PerfManager.ts +2 -2
  119. package/src/JavaScriptSDK/ProcessTelemetryContext.ts +73 -56
  120. package/src/JavaScriptSDK/TelemetryHelpers.ts +8 -9
  121. package/src/JavaScriptSDK/TelemetryInitializerPlugin.ts +2 -2
  122. package/src/JavaScriptSDK/W3cTraceParent.ts +7 -6
  123. package/src/JavaScriptSDK.Enums/EnumHelperFuncs.ts +0 -1
  124. package/src/JavaScriptSDK.Enums/LoggingEnums.ts +9 -108
  125. package/src/JavaScriptSDK.Enums/TelemetryUpdateReason.ts +1 -1
  126. package/src/JavaScriptSDK.Interfaces/IAppInsightsCore.ts +28 -3
  127. package/src/JavaScriptSDK.Interfaces/ICookieMgr.ts +8 -0
  128. package/src/JavaScriptSDK.Interfaces/IDiagnosticLogger.ts +15 -8
  129. package/src/JavaScriptSDK.Interfaces/IInstrumentHooks.ts +3 -1
  130. package/src/JavaScriptSDK.Interfaces/INotificationListener.ts +5 -5
  131. package/src/JavaScriptSDK.Interfaces/INotificationManager.ts +8 -8
  132. package/src/JavaScriptSDK.Interfaces/IPerfManager.ts +3 -3
  133. package/src/JavaScriptSDK.Interfaces/IProcessTelemetryContext.ts +10 -9
  134. package/src/JavaScriptSDK.Interfaces/ITelemetryInitializers.ts +2 -1
  135. package/src/JavaScriptSDK.Interfaces/ITelemetryUpdateState.ts +15 -5
  136. package/src/JavaScriptSDK.Interfaces/IUnloadHook.ts +22 -0
  137. package/src/JavaScriptSDK.Interfaces/IUnloadableComponent.ts +3 -3
  138. package/tsconfig.json +3 -2
  139. package/types/Config/ConfigDefaults.d.ts +10 -0
  140. package/types/Config/DynamicConfig.d.ts +23 -0
  141. package/types/Config/DynamicProperty.d.ts +3 -0
  142. package/types/Config/DynamicState.d.ts +3 -0
  143. package/types/Config/DynamicSupport.d.ts +15 -0
  144. package/types/Config/IConfigDefaults.d.ts +42 -0
  145. package/types/Config/IDynamicConfigHandler.d.ts +46 -0
  146. package/types/Config/IDynamicPropertyHandler.d.ts +11 -0
  147. package/types/Config/IDynamicWatcher.d.ts +28 -0
  148. package/types/Config/_IDynamicConfigHandlerState.d.ts +35 -0
  149. package/types/JavaScriptSDK/AppInsightsCore.d.ts +136 -4
  150. package/types/JavaScriptSDK/BaseTelemetryPlugin.d.ts +2 -2
  151. package/types/JavaScriptSDK/CookieMgr.d.ts +0 -10
  152. package/types/JavaScriptSDK/DiagnosticLogger.d.ts +18 -16
  153. package/types/JavaScriptSDK/EventHelpers.d.ts +24 -24
  154. package/types/JavaScriptSDK/HelperFuncs.d.ts +13 -11
  155. package/types/JavaScriptSDK/InternalConstants.d.ts +4 -0
  156. package/types/JavaScriptSDK/NotificationManager.d.ts +7 -7
  157. package/types/JavaScriptSDK/PerfManager.d.ts +2 -2
  158. package/types/JavaScriptSDK/ProcessTelemetryContext.d.ts +3 -2
  159. package/types/JavaScriptSDK/TelemetryHelpers.d.ts +3 -3
  160. package/types/JavaScriptSDK.Enums/LoggingEnums.d.ts +7 -5
  161. package/types/JavaScriptSDK.Enums/TelemetryUpdateReason.d.ts +1 -0
  162. package/types/JavaScriptSDK.Interfaces/IAppInsightsCore.d.ts +25 -3
  163. package/types/JavaScriptSDK.Interfaces/ICookieMgr.d.ts +6 -0
  164. package/types/JavaScriptSDK.Interfaces/IDiagnosticLogger.d.ts +14 -8
  165. package/types/JavaScriptSDK.Interfaces/IInstrumentHooks.d.ts +2 -1
  166. package/types/JavaScriptSDK.Interfaces/INotificationListener.d.ts +5 -5
  167. package/types/JavaScriptSDK.Interfaces/INotificationManager.d.ts +8 -8
  168. package/types/JavaScriptSDK.Interfaces/IPerfManager.d.ts +3 -3
  169. package/types/JavaScriptSDK.Interfaces/IProcessTelemetryContext.d.ts +5 -9
  170. package/types/JavaScriptSDK.Interfaces/ITelemetryInitializers.d.ts +2 -1
  171. package/types/JavaScriptSDK.Interfaces/ITelemetryUpdateState.d.ts +13 -2
  172. package/types/JavaScriptSDK.Interfaces/IUnloadHook.d.ts +18 -0
  173. package/types/__DynamicConstants.d.ts +18 -15
  174. package/types/applicationinsights-core-js.d.ts +11 -4
  175. package/types/tsdoc-metadata.json +1 -1
  176. package/dist-esm/JavaScriptSDK/BaseCore.js +0 -654
  177. package/dist-esm/JavaScriptSDK/BaseCore.js.map +0 -1
  178. package/src/JavaScriptSDK/BaseCore.ts +0 -948
  179. package/types/JavaScriptSDK/BaseCore.d.ts +0 -124
@@ -2,15 +2,17 @@
2
2
  // Licensed under the MIT License.
3
3
  "use strict";
4
4
 
5
- import {
6
- arrForEach, dumpObj, isArray, isFunction, isNullOrUndefined, isObject, isUndefined, objForEachKey, objFreeze, objKeys
7
- } from "@nevware21/ts-utils";
5
+ import { arrForEach, dumpObj, isArray, isFunction, isNullOrUndefined, isUndefined, objFreeze, objKeys } from "@nevware21/ts-utils";
6
+ import { _applyDefaultValue, applyDefaults } from "../Config/ConfigDefaults";
7
+ import { createDynamicConfig } from "../Config/DynamicConfig";
8
+ import { IConfigDefaults } from "../Config/IConfigDefaults";
9
+ import { IDynamicConfigHandler } from "../Config/IDynamicConfigHandler";
8
10
  import { _eInternalMessageId, eLoggingSeverity } from "../JavaScriptSDK.Enums/LoggingEnums";
9
11
  import { IAppInsightsCore } from "../JavaScriptSDK.Interfaces/IAppInsightsCore";
10
12
  import { IConfiguration } from "../JavaScriptSDK.Interfaces/IConfiguration";
11
13
  import { IDiagnosticLogger } from "../JavaScriptSDK.Interfaces/IDiagnosticLogger";
12
14
  import {
13
- GetExtCfgMergeType, IBaseProcessingContext, IProcessTelemetryContext, IProcessTelemetryUnloadContext, IProcessTelemetryUpdateContext
15
+ IBaseProcessingContext, IProcessTelemetryContext, IProcessTelemetryUnloadContext, IProcessTelemetryUpdateContext
14
16
  } from "../JavaScriptSDK.Interfaces/IProcessTelemetryContext";
15
17
  import { ITelemetryItem } from "../JavaScriptSDK.Interfaces/ITelemetryItem";
16
18
  import { IPlugin, ITelemetryPlugin } from "../JavaScriptSDK.Interfaces/ITelemetryPlugin";
@@ -18,7 +20,7 @@ import { ITelemetryPluginChain } from "../JavaScriptSDK.Interfaces/ITelemetryPlu
18
20
  import { ITelemetryUnloadState } from "../JavaScriptSDK.Interfaces/ITelemetryUnloadState";
19
21
  import { ITelemetryUpdateState } from "../JavaScriptSDK.Interfaces/ITelemetryUpdateState";
20
22
  import { _throwInternal, safeGetLogger } from "./DiagnosticLogger";
21
- import { objExtend, proxyFunctions } from "./HelperFuncs";
23
+ import { objForEachKey, proxyFunctions } from "./HelperFuncs";
22
24
  import { STR_CORE, STR_DISABLED, STR_EMPTY } from "./InternalConstants";
23
25
  import { doPerf } from "./PerfManager";
24
26
  import { _getPluginState } from "./TelemetryHelpers";
@@ -47,7 +49,7 @@ interface IInternalContext<T extends IBaseProcessingContext> {
47
49
  ctx: T
48
50
  }
49
51
 
50
- function _getNextProxyStart<T, C = IConfiguration>(proxy: ITelemetryPluginChain, core: IAppInsightsCore, startAt: IPlugin): ITelemetryPluginChain {
52
+ function _getNextProxyStart(proxy: ITelemetryPluginChain, core: IAppInsightsCore, startAt: IPlugin): ITelemetryPluginChain {
51
53
  while (proxy) {
52
54
  if (proxy.getPlugin() === startAt) {
53
55
  return proxy;
@@ -63,17 +65,21 @@ function _getNextProxyStart<T, C = IConfiguration>(proxy: ITelemetryPluginChain,
63
65
  /**
64
66
  * @ignore
65
67
  * @param telemetryChain
66
- * @param config
68
+ * @param dynamicConfig
67
69
  * @param core
68
70
  * @param startAt - Identifies the next plugin to execute, if null there is no "next" plugin and if undefined it should assume the start of the chain
69
71
  * @returns
70
72
  */
71
- function _createInternalContext<T extends IBaseProcessingContext>(telemetryChain: ITelemetryPluginChain, config: IConfiguration, core: IAppInsightsCore, startAt?: IPlugin): IInternalContext<T> {
73
+ function _createInternalContext<T extends IBaseProcessingContext>(telemetryChain: ITelemetryPluginChain, dynamicConfig: IDynamicConfigHandler<IConfiguration>, core: IAppInsightsCore, startAt?: IPlugin): IInternalContext<T> {
72
74
  // We have a special case where we want to start execution from this specific plugin
73
75
  // or we simply reuse the existing telemetry plugin chain (normal execution case)
74
76
  let _nextProxy: ITelemetryPluginChain | null = null; // By Default set as no next plugin
75
77
  let _onComplete: OnCompleteCallback[] = [];
76
78
 
79
+ if (!dynamicConfig) {
80
+ dynamicConfig = createDynamicConfig({}, null, core.logger);
81
+ }
82
+
77
83
  if (startAt !== null) {
78
84
  // There is no next element (null) vs not defined (undefined) so use the full chain
79
85
  _nextProxy = startAt ? _getNextProxyStart(telemetryChain, core, startAt) : telemetryChain;
@@ -86,12 +92,12 @@ function _createInternalContext<T extends IBaseProcessingContext>(telemetryChain
86
92
  return core
87
93
  },
88
94
  diagLog: () => {
89
- return safeGetLogger(core, config);
95
+ return safeGetLogger(core, dynamicConfig.cfg);
90
96
  },
91
97
  getCfg: () => {
92
- return config;
98
+ return dynamicConfig.cfg;
93
99
  },
94
- getExtCfg: _getExtCfg,
100
+ getExtCfg: _resolveExtCfg,
95
101
  getConfig: _getConfig,
96
102
  hasNext: () => {
97
103
  return !!_nextProxy;
@@ -145,54 +151,61 @@ function _createInternalContext<T extends IBaseProcessingContext>(telemetryChain
145
151
  return nextProxy;
146
152
  }
147
153
 
148
- function _getExtCfg<T>(identifier: string, defaultValue: T|any = {}, mergeDefault: GetExtCfgMergeType = GetExtCfgMergeType.None) {
149
- let theConfig: T;
150
- if (config) {
151
- let extConfig = config.extensionConfig;
152
- if (extConfig && identifier) {
153
- theConfig = extConfig[identifier];
154
+ function _getExtCfg<T>(identifier: string, createIfMissing: boolean) {
155
+ let idCfg: T = null;
156
+ if (dynamicConfig.cfg && identifier) {
157
+ let extCfg = dynamicConfig.cfg.extensionConfig;
158
+ if (!extCfg && createIfMissing) {
159
+ dynamicConfig.set(dynamicConfig.cfg, "extensionConfig", {});
160
+ extCfg = dynamicConfig.cfg.extensionConfig;
161
+ }
162
+
163
+ if (extCfg) {
164
+ idCfg = extCfg[identifier];
165
+ if (!idCfg && createIfMissing) {
166
+ dynamicConfig.set(extCfg, identifier, {});
167
+ idCfg = extCfg[identifier];
168
+ }
154
169
  }
155
170
  }
156
171
 
157
- if (!theConfig) {
158
- // Just use the defaults
159
- theConfig = defaultValue as T;
160
- } else if (isObject(defaultValue)) {
161
- if (mergeDefault !== GetExtCfgMergeType.None) {
162
- // Merge the defaults and configured values
163
- let newConfig = objExtend(true, defaultValue, theConfig);
164
-
165
- if (config && mergeDefault === GetExtCfgMergeType.MergeDefaultFromRootOrDefault) {
166
- // Enumerate over the defaultValues and if not already populated attempt to
167
- // find a value from the root config
168
- objForEachKey(defaultValue, (field) => {
169
- // for each unspecified field, set the default value
170
- if (isNullOrUndefined(newConfig[field])) {
171
- let cfgValue = config[field];
172
- if (!isNullOrUndefined(cfgValue)) {
173
- newConfig[field] = cfgValue;
174
- }
175
- }
176
- });
172
+ return idCfg;
173
+ }
174
+
175
+ function _resolveExtCfg<T>(identifier: string, defaultValues: IConfigDefaults<T>): T {
176
+ let newConfig: T = _getExtCfg(identifier, true);
177
+
178
+ if (defaultValues) {
179
+ // Enumerate over the defaultValues and if not already populated attempt to
180
+ // find a value from the root config or use the default value
181
+ objForEachKey(defaultValues, (field, defaultValue) => {
182
+ // for each unspecified field, set the default value
183
+ if (isNullOrUndefined(newConfig[field])) {
184
+ let cfgValue = dynamicConfig.cfg[field];
185
+ if (cfgValue || !isNullOrUndefined(cfgValue)) {
186
+ newConfig[field] = cfgValue;
187
+ }
177
188
  }
178
189
 
179
- theConfig = newConfig;
180
- }
190
+ _applyDefaultValue(newConfig, field, defaultValue);
191
+ });
181
192
  }
182
193
 
183
- return theConfig;
194
+ return applyDefaults(newConfig, defaultValues);
184
195
  }
185
196
 
186
197
  function _getConfig(identifier:string, field: string, defaultValue: number | string | boolean | string[] | RegExp[] | Function = false) {
187
198
  let theValue;
188
- let extConfig = _getExtCfg(identifier, null);
189
- if (extConfig && !isNullOrUndefined(extConfig[field])) {
199
+ let extConfig: T = _getExtCfg(identifier, false);
200
+ let rootConfig = dynamicConfig.cfg;
201
+
202
+ if (extConfig && (extConfig[field] || !isNullOrUndefined(extConfig[field]))) {
190
203
  theValue = extConfig[field];
191
- } else if (config && !isNullOrUndefined(config[field])) {
192
- theValue = config[field];
204
+ } else if (rootConfig[field] || !isNullOrUndefined(rootConfig[field])) {
205
+ theValue = rootConfig[field];
193
206
  }
194
207
 
195
- return !isNullOrUndefined(theValue) ? theValue : defaultValue;
208
+ return (theValue || !isNullOrUndefined(theValue)) ? theValue : defaultValue;
196
209
  }
197
210
 
198
211
  function _iterateChain<T extends ITelemetryPlugin = ITelemetryPlugin>(cb: (plugin: T) => void) {
@@ -217,24 +230,28 @@ function _createInternalContext<T extends IBaseProcessingContext>(telemetryChain
217
230
  * @param core - The current core instance
218
231
  * @param startAt - Identifies the next plugin to execute, if null there is no "next" plugin and if undefined it should assume the start of the chain
219
232
  */
220
- export function createProcessTelemetryContext(telemetryChain: ITelemetryPluginChain | null, config: IConfiguration, core:IAppInsightsCore, startAt?: IPlugin): IProcessTelemetryContext {
233
+ export function createProcessTelemetryContext(telemetryChain: ITelemetryPluginChain | null, cfg: IConfiguration, core:IAppInsightsCore, startAt?: IPlugin): IProcessTelemetryContext {
234
+ let config = createDynamicConfig(cfg);
221
235
  let internalContext: IInternalContext<IProcessTelemetryContext> = _createInternalContext<IProcessTelemetryContext>(telemetryChain, config, core, startAt);
222
236
  let context = internalContext.ctx;
223
237
 
224
238
  function _processNext(env: ITelemetryItem) {
225
239
  let nextPlugin: ITelemetryPluginChain = internalContext._next();
226
- // Run the next plugin which will call "processNext()"
227
- nextPlugin && nextPlugin.processTelemetry(env, context);
240
+
241
+ if (nextPlugin) {
242
+ // Run the next plugin which will call "processNext()"
243
+ nextPlugin.processTelemetry(env, context);
244
+ }
228
245
 
229
246
  return !nextPlugin;
230
247
  }
231
248
 
232
249
  function _createNew(plugins: IPlugin[] | ITelemetryPluginChain | null = null, startAt?: IPlugin) {
233
250
  if (isArray(plugins)) {
234
- plugins = createTelemetryProxyChain(plugins, config, core, startAt);
251
+ plugins = createTelemetryProxyChain(plugins, config.cfg, core, startAt);
235
252
  }
236
253
 
237
- return createProcessTelemetryContext(plugins || context.getNext(), config, core, startAt);
254
+ return createProcessTelemetryContext(plugins || context.getNext(), config.cfg, core, startAt);
238
255
  }
239
256
 
240
257
  context.processNext = _processNext;
@@ -251,7 +268,7 @@ export function createProcessTelemetryContext(telemetryChain: ITelemetryPluginCh
251
268
  * @param startAt - Identifies the next plugin to execute, if null there is no "next" plugin and if undefined it should assume the start of the chain
252
269
  */
253
270
  export function createProcessTelemetryUnloadContext(telemetryChain: ITelemetryPluginChain, core: IAppInsightsCore, startAt?: IPlugin): IProcessTelemetryUnloadContext {
254
- let config = core.config || {};
271
+ let config = createDynamicConfig(core.config);
255
272
  let internalContext: IInternalContext<IProcessTelemetryUnloadContext> = _createInternalContext<IProcessTelemetryUnloadContext>(telemetryChain, config, core, startAt);
256
273
  let context = internalContext.ctx;
257
274
 
@@ -264,7 +281,7 @@ export function createProcessTelemetryUnloadContext(telemetryChain: ITelemetryPl
264
281
 
265
282
  function _createNew(plugins: IPlugin[] | ITelemetryPluginChain = null, startAt?: IPlugin): IProcessTelemetryUnloadContext {
266
283
  if (isArray(plugins)) {
267
- plugins = createTelemetryProxyChain(plugins, config, core, startAt);
284
+ plugins = createTelemetryProxyChain(plugins, config.cfg, core, startAt);
268
285
  }
269
286
 
270
287
  return createProcessTelemetryUnloadContext(plugins || context.getNext(), core, startAt);
@@ -284,7 +301,7 @@ export function createProcessTelemetryUnloadContext(telemetryChain: ITelemetryPl
284
301
  * @param startAt - Identifies the next plugin to execute, if null there is no "next" plugin and if undefined it should assume the start of the chain
285
302
  */
286
303
  export function createProcessTelemetryUpdateContext(telemetryChain: ITelemetryPluginChain, core: IAppInsightsCore, startAt?: IPlugin): IProcessTelemetryUpdateContext {
287
- let config = core.config || {};
304
+ let config = createDynamicConfig(core.config);
288
305
  let internalContext: IInternalContext<IProcessTelemetryUpdateContext> = _createInternalContext<IProcessTelemetryUpdateContext>(telemetryChain, config, core, startAt);
289
306
  let context = internalContext.ctx;
290
307
 
@@ -298,7 +315,7 @@ export function createProcessTelemetryUpdateContext(telemetryChain: ITelemetryPl
298
315
 
299
316
  function _createNew(plugins: IPlugin[] | ITelemetryPluginChain = null, startAt?: IPlugin) {
300
317
  if (isArray(plugins)) {
301
- plugins = createTelemetryProxyChain(plugins, config, core, startAt);
318
+ plugins = createTelemetryProxyChain(plugins, config.cfg, core, startAt);
302
319
  }
303
320
 
304
321
  return createProcessTelemetryUpdateContext(plugins || context.getNext(), core, startAt);
@@ -568,8 +585,8 @@ export class ProcessTelemetryContext implements IProcessTelemetryContext {
568
585
  */
569
586
  public getCfg: () => IConfiguration;
570
587
 
571
- public getExtCfg: <T>(identifier:string, defaultValue?:T|any) => T;
572
-
588
+ public getExtCfg: <T>(identifier:string, defaultValue?: IConfigDefaults<T>) => T;
589
+
573
590
  public getConfig: (identifier:string, field: string, defaultValue?: number | string | boolean | string[] | RegExp[] | Function) => number | string | boolean | string[] | RegExp[] | Function;
574
591
 
575
592
  /**
@@ -31,9 +31,9 @@ export function _getPluginState(plugin: IPlugin): IPluginState {
31
31
  /**
32
32
  * Initialize the queue of plugins
33
33
  * @param plugins - The array of plugins to initialize and setting of the next plugin
34
- * @param config The current config for the instance
35
- * @param core THe current core instance
36
- * @param extensions The extensions
34
+ * @param config - The current config for the instance
35
+ * @param core - THe current core instance
36
+ * @param extensions - The extensions
37
37
  */
38
38
  export function initializePlugins(processContext: IProcessTelemetryContext, extensions: IPlugin[]) {
39
39
 
@@ -42,12 +42,11 @@ export function initializePlugins(processContext: IProcessTelemetryContext, exte
42
42
  let lastPlugin: ITelemetryPlugin = null;
43
43
  let proxy: ITelemetryPluginChain = processContext.getNext();
44
44
  let pluginState: IPluginState;
45
+
45
46
  while (proxy) {
46
47
  let thePlugin = proxy.getPlugin();
47
48
  if (thePlugin) {
48
- if (lastPlugin &&
49
- isFunction(lastPlugin.setNextPlugin) &&
50
- isFunction(thePlugin.processTelemetry)) {
49
+ if (lastPlugin && lastPlugin.setNextPlugin && thePlugin.processTelemetry) {
51
50
  // Set this plugin as the next for the previous one
52
51
  lastPlugin.setNextPlugin(thePlugin);
53
52
  }
@@ -71,7 +70,7 @@ export function initializePlugins(processContext: IProcessTelemetryContext, exte
71
70
 
72
71
  // Now initialize the plugins
73
72
  arrForEach(initPlugins, thePlugin => {
74
- let core = processContext[STR_CORE]();
73
+ let core = processContext.core();
75
74
 
76
75
  thePlugin.initialize(
77
76
  processContext.getCfg(),
@@ -96,8 +95,8 @@ export function sortPlugins<T = IPlugin>(plugins:T[]) {
96
95
  return plugins.sort((extA, extB) => {
97
96
  let result = 0;
98
97
  if (extB) {
99
- let bHasProcess = isFunction(extB[STR_PROCESS_TELEMETRY]);
100
- if (isFunction(extA[STR_PROCESS_TELEMETRY])) {
98
+ let bHasProcess = extB[STR_PROCESS_TELEMETRY];
99
+ if (extA[STR_PROCESS_TELEMETRY]) {
101
100
  result = bHasProcess ? extA[STR_PRIORITY] - extB[STR_PRIORITY] : 1;
102
101
  } else if (bHasProcess) {
103
102
  result = -1;
@@ -72,9 +72,9 @@ export class TelemetryInitializerPlugin extends BaseTelemetryPlugin implements I
72
72
  // doNotSendItem = true;
73
73
  _throwInternal(
74
74
  itemCtx.diagLog(),
75
- eLoggingSeverity.CRITICAL,
75
+ eLoggingSeverity.WARNING,
76
76
  _eInternalMessageId.TelemetryInitializerFailed,
77
- "One of telemetry initializers failed, telemetry item will not be sent: " + getExceptionName(e),
77
+ "Telemetry initializer failed: " + getExceptionName(e),
78
78
  { exception: dumpObj(e) }, true);
79
79
  }
80
80
  }
@@ -2,9 +2,10 @@ import { isArray, isString, strTrim } from "@nevware21/ts-utils";
2
2
  import { ITraceParent } from "../JavaScriptSDK.Interfaces/ITraceParent";
3
3
  import { generateW3CId } from "./CoreUtils";
4
4
  import { findMetaTag, findNamedServerTiming } from "./EnvUtils";
5
+ import { STR_EMPTY } from "./InternalConstants";
5
6
 
6
7
  // using {0,16} for leading and trailing whitespace just to constrain the possible runtime of a random string
7
- const TRACE_PARENT_REGEX = /^([\da-f]{2})-([\da-f]{32})-([\da-f]{16})-([\da-f]{2})(-[^\s]*)?$/;
8
+ const TRACE_PARENT_REGEX = /^([\da-f]{2})-([\da-f]{32})-([\da-f]{16})-([\da-f]{2})(-[^\s]{1,64})?$/i;
8
9
  const DEFAULT_VERSION = "00";
9
10
  const INVALID_VERSION = "ff";
10
11
  const INVALID_TRACE_ID = "00000000000000000000000000000000";
@@ -13,7 +14,7 @@ const SAMPLED_FLAG = 0x01;
13
14
 
14
15
  function _isValid(value: string, len: number, invalidValue?: string): boolean {
15
16
  if (value && value.length === len && value !== invalidValue) {
16
- return !!value.match(/^[\da-f]*$/);
17
+ return !!value.match(/^[\da-f]*$/i);
17
18
  }
18
19
 
19
20
  return false;
@@ -90,9 +91,9 @@ export function parseTraceParent(value: string): ITraceParent {
90
91
  }
91
92
 
92
93
  return {
93
- version: match[1],
94
- traceId: match[2],
95
- spanId: match[3],
94
+ version: (match[1] || STR_EMPTY).toLowerCase(),
95
+ traceId: (match[2] || STR_EMPTY).toLowerCase(),
96
+ spanId: (match[3] || STR_EMPTY).toLowerCase(),
96
97
  traceFlags: parseInt(match[4], 16)
97
98
  }
98
99
  }
@@ -175,7 +176,7 @@ export function formatTraceParent(value: ITraceParent) {
175
176
  }
176
177
 
177
178
  // Format as version 00
178
- return `${version}-${_formatValue(value.traceId, 32, INVALID_TRACE_ID)}-${_formatValue(value.spanId, 16, INVALID_SPAN_ID)}-${flags}`;
179
+ return `${version.toLowerCase()}-${_formatValue(value.traceId, 32, INVALID_TRACE_ID).toLowerCase()}-${_formatValue(value.spanId, 16, INVALID_SPAN_ID).toLowerCase()}-${flags.toLowerCase()}`;
179
180
  }
180
181
 
181
182
  return "";
@@ -4,7 +4,6 @@
4
4
  import { EnumCls, createEnum, createTypeMap } from "@nevware21/ts-utils";
5
5
 
6
6
  export declare type EnumValue<E = any> = EnumCls<E>;
7
- // export declare type EnumMap<E = any, I = E> = EnumNameMap<E, I>;
8
7
 
9
8
  /**
10
9
  * Create an enum style object which has both the key => value and value => key mappings
@@ -4,23 +4,12 @@
4
4
 
5
5
  import { createEnumStyle } from "../JavaScriptSDK.Enums/EnumHelperFuncs";
6
6
 
7
- const FAILED = "Failed";
8
- const FAILED_MONITOR_AJAX = FAILED + "MonitorAjax";
9
- const TRACK = "Track";
10
- const START = "Start";
11
- const STOP = "Stop";
12
- const EVENT = "Event";
13
- const AUTH_CONTEXT = "AuthContext";
14
- const EXCEPTION = "Exception";
15
- const LOCAL = "Local";
16
- const SESSION = "Session";
17
- const STORAGE = "Storage";
18
- const BROWSER = "Browser";
19
- const CANNOT = "Cannot";
20
- const BUFFER = "Buffer";
21
- const INSTRUMENTATION_KEY = "InstrumentationKey";
22
-
23
7
  export const enum eLoggingSeverity {
8
+ /**
9
+ * No Logging will be enabled
10
+ */
11
+ DISABLED = 0,
12
+
24
13
  /**
25
14
  * Error will be sent as internal telemetry
26
15
  */
@@ -33,6 +22,7 @@ export const enum eLoggingSeverity {
33
22
  }
34
23
 
35
24
  export const LoggingSeverity = createEnumStyle<typeof eLoggingSeverity>({
25
+ DISABLED: eLoggingSeverity.DISABLED,
36
26
  CRITICAL: eLoggingSeverity.CRITICAL,
37
27
  WARNING: eLoggingSeverity.WARNING
38
28
  });
@@ -123,98 +113,9 @@ export const enum _eInternalMessageId {
123
113
  TrackPageActionEventFailed = 103,
124
114
  FailedAddingCustomDefinedRequestContext = 104,
125
115
  InMemoryStorageBufferFull = 105,
126
- InstrumentationKeyDeprecation = 106
116
+ InstrumentationKeyDeprecation = 106,
117
+ ConfigWatcherException = 107,
118
+ DynamicConfigException = 108
127
119
  }
128
120
 
129
- /**
130
- * Internal message ID. Please create a new one for every conceptually different message. Please keep alphabetically ordered
131
- */
132
- export const _InternalMessageId = createEnumStyle<typeof _eInternalMessageId>({
133
- // Non user actionable
134
- [BROWSER + "DoesNotSupport" + LOCAL + STORAGE as "BrowserDoesNotSupportLocalStorage"]: _eInternalMessageId.BrowserDoesNotSupportLocalStorage,
135
- [BROWSER + CANNOT + "Read" + LOCAL + STORAGE as "BrowserCannotReadLocalStorage"]: _eInternalMessageId.BrowserCannotReadLocalStorage,
136
- [BROWSER + CANNOT + "Read" + SESSION + STORAGE as "BrowserCannotReadSessionStorage"]: _eInternalMessageId.BrowserCannotReadSessionStorage,
137
- [BROWSER + CANNOT + "Write" + LOCAL + STORAGE as "BrowserCannotWriteLocalStorage"]: _eInternalMessageId.BrowserCannotWriteLocalStorage,
138
- [BROWSER + CANNOT + "Write" + SESSION + STORAGE as "BrowserCannotWriteSessionStorage"]: _eInternalMessageId.BrowserCannotWriteSessionStorage,
139
- [BROWSER + FAILED + "RemovalFrom" + LOCAL + STORAGE as "BrowserFailedRemovalFromLocalStorage"]: _eInternalMessageId.BrowserFailedRemovalFromLocalStorage,
140
- [BROWSER + FAILED + "RemovalFrom" + SESSION + STORAGE as "BrowserFailedRemovalFromSessionStorage"]: _eInternalMessageId.BrowserFailedRemovalFromSessionStorage,
141
- [CANNOT + "SendEmptyTelemetry" as "CannotSendEmptyTelemetry"]: _eInternalMessageId.CannotSendEmptyTelemetry,
142
- ClientPerformanceMathError: _eInternalMessageId.ClientPerformanceMathError,
143
- ["ErrorParsingAI" + SESSION + "Cookie" as "ErrorParsingAISessionCookie"]: _eInternalMessageId.ErrorParsingAISessionCookie,
144
- ErrorPVCalc: _eInternalMessageId.ErrorPVCalc,
145
- [EXCEPTION + "WhileLoggingError" as "ExceptionWhileLoggingError"]: _eInternalMessageId.ExceptionWhileLoggingError,
146
- [FAILED + "AddingTelemetryTo" + BUFFER as "FailedAddingTelemetryToBuffer"]: _eInternalMessageId.FailedAddingTelemetryToBuffer,
147
- [FAILED_MONITOR_AJAX + "Abort" as "FailedMonitorAjaxAbort"]: _eInternalMessageId.FailedMonitorAjaxAbort,
148
- [FAILED_MONITOR_AJAX + "Dur" as "FailedMonitorAjaxDur"]: _eInternalMessageId.FailedMonitorAjaxDur,
149
- [FAILED_MONITOR_AJAX + "Open" as "FailedMonitorAjaxOpen"]: _eInternalMessageId.FailedMonitorAjaxOpen,
150
- [FAILED_MONITOR_AJAX + "RSC" as "FailedMonitorAjaxRSC"]: _eInternalMessageId.FailedMonitorAjaxRSC,
151
- [FAILED_MONITOR_AJAX + "Send" as "FailedMonitorAjaxSend"]: _eInternalMessageId.FailedMonitorAjaxSend,
152
- [FAILED_MONITOR_AJAX + "GetCorrelationHeader" as "FailedMonitorAjaxGetCorrelationHeader"]: _eInternalMessageId.FailedMonitorAjaxGetCorrelationHeader,
153
- [FAILED + "ToAddHandlerForOnBeforeUnload" as "FailedToAddHandlerForOnBeforeUnload"]: _eInternalMessageId.FailedToAddHandlerForOnBeforeUnload,
154
- [FAILED + "ToSendQueuedTelemetry" as "FailedToSendQueuedTelemetry"]: _eInternalMessageId.FailedToSendQueuedTelemetry,
155
- [FAILED + "ToReportDataLoss" as "FailedToReportDataLoss"]: _eInternalMessageId.FailedToReportDataLoss,
156
- ["Flush" + FAILED as "FlushFailed"]: _eInternalMessageId.FlushFailed,
157
- MessageLimitPerPVExceeded: _eInternalMessageId.MessageLimitPerPVExceeded,
158
- MissingRequiredFieldSpecification: _eInternalMessageId.MissingRequiredFieldSpecification,
159
- NavigationTimingNotSupported: _eInternalMessageId.NavigationTimingNotSupported,
160
- OnError: _eInternalMessageId.OnError,
161
- [SESSION + "RenewalDateIsZero" as "SessionRenewalDateIsZero"]: _eInternalMessageId.SessionRenewalDateIsZero,
162
- SenderNotInitialized: _eInternalMessageId.SenderNotInitialized,
163
- [START + TRACK + EVENT + FAILED as "StartTrackEventFailed"]: _eInternalMessageId.StartTrackEventFailed,
164
- [STOP + TRACK + EVENT + FAILED as "StopTrackEventFailed"]: _eInternalMessageId.StopTrackEventFailed,
165
- [START + TRACK + FAILED as "StartTrackFailed"]: _eInternalMessageId.StartTrackFailed,
166
- [STOP + TRACK + FAILED as "StopTrackFailed"]: _eInternalMessageId.StopTrackFailed,
167
- TelemetrySampledAndNotSent: _eInternalMessageId.TelemetrySampledAndNotSent,
168
- [TRACK + EVENT + FAILED as "TrackEventFailed"]: _eInternalMessageId.TrackEventFailed,
169
- [TRACK + EXCEPTION + FAILED as "TrackExceptionFailed"]: _eInternalMessageId.TrackExceptionFailed,
170
- [TRACK + "Metric" + FAILED as "TrackMetricFailed"]: _eInternalMessageId.TrackMetricFailed,
171
- [TRACK + "PV" + FAILED as "TrackPVFailed"]: _eInternalMessageId.TrackPVFailed,
172
- [TRACK + "PV" + FAILED + "Calc" as "TrackPVFailedCalc"]: _eInternalMessageId.TrackPVFailedCalc,
173
- [TRACK + "Trace" + FAILED as "TrackTraceFailed"]: _eInternalMessageId.TrackTraceFailed,
174
- ["Transmission" + FAILED as "TransmissionFailed"]: _eInternalMessageId.TransmissionFailed,
175
- [FAILED + "ToSet" + STORAGE + BUFFER as "FailedToSetStorageBuffer"]: _eInternalMessageId.FailedToSetStorageBuffer,
176
- [FAILED + "ToRestore" + STORAGE + BUFFER as "FailedToRestoreStorageBuffer"]: _eInternalMessageId.FailedToRestoreStorageBuffer,
177
- InvalidBackendResponse: _eInternalMessageId.InvalidBackendResponse,
178
- [FAILED + "ToFixDepricatedValues" as "FailedToFixDepricatedValues"]: _eInternalMessageId.FailedToFixDepricatedValues,
179
- InvalidDurationValue: _eInternalMessageId.InvalidDurationValue,
180
- TelemetryEnvelopeInvalid: _eInternalMessageId.TelemetryEnvelopeInvalid,
181
- CreateEnvelopeError: _eInternalMessageId.CreateEnvelopeError,
182
-
183
- // User actionable
184
- [CANNOT + "SerializeObject" as "CannotSerializeObject"]: _eInternalMessageId.CannotSerializeObject,
185
- [CANNOT + "SerializeObjectNonSerializable" as "CannotSerializeObjectNonSerializable"]: _eInternalMessageId.CannotSerializeObjectNonSerializable,
186
- CircularReferenceDetected: _eInternalMessageId.CircularReferenceDetected,
187
- ["Clear" + AUTH_CONTEXT + FAILED as "ClearAuthContextFailed"]: _eInternalMessageId.ClearAuthContextFailed,
188
- [EXCEPTION + "Truncated" as "ExceptionTruncated"]: _eInternalMessageId.ExceptionTruncated,
189
- IllegalCharsInName: _eInternalMessageId.IllegalCharsInName,
190
- ItemNotInArray: _eInternalMessageId.ItemNotInArray,
191
- MaxAjaxPerPVExceeded: _eInternalMessageId.MaxAjaxPerPVExceeded,
192
- MessageTruncated: _eInternalMessageId.MessageTruncated,
193
- NameTooLong: _eInternalMessageId.NameTooLong,
194
- SampleRateOutOfRange: _eInternalMessageId.SampleRateOutOfRange,
195
- ["Set" + AUTH_CONTEXT + FAILED as "SetAuthContextFailed"]: _eInternalMessageId.SetAuthContextFailed,
196
- ["Set" + AUTH_CONTEXT + FAILED + "AccountName" as "SetAuthContextFailedAccountName"]: _eInternalMessageId.SetAuthContextFailedAccountName,
197
- StringValueTooLong: _eInternalMessageId.StringValueTooLong,
198
- StartCalledMoreThanOnce: _eInternalMessageId.StartCalledMoreThanOnce,
199
- StopCalledWithoutStart: _eInternalMessageId.StopCalledWithoutStart,
200
- ["TelemetryInitializer" + FAILED as "TelemetryInitializerFailed"]: _eInternalMessageId.TelemetryInitializerFailed,
201
- TrackArgumentsNotSpecified: _eInternalMessageId.TrackArgumentsNotSpecified,
202
- UrlTooLong: _eInternalMessageId.UrlTooLong,
203
- [SESSION + STORAGE + BUFFER + "Full" as "SessionStorageBufferFull"]: _eInternalMessageId.SessionStorageBufferFull,
204
- [CANNOT + "AccessCookie" as "CannotAccessCookie"]: _eInternalMessageId.CannotAccessCookie,
205
- IdTooLong: _eInternalMessageId.IdTooLong,
206
- InvalidEvent: _eInternalMessageId.InvalidEvent,
207
- [FAILED_MONITOR_AJAX + "SetRequestHeader" as "FailedMonitorAjaxSetRequestHeader"]: _eInternalMessageId.FailedMonitorAjaxSetRequestHeader,
208
- ["Send" + BROWSER + "InfoOnUserInit" as "SendBrowserInfoOnUserInit"]: _eInternalMessageId.SendBrowserInfoOnUserInit,
209
- ["Plugin" + EXCEPTION as "PluginException"]: _eInternalMessageId.PluginException,
210
- ["Notification" + EXCEPTION as "NotificationException"]: _eInternalMessageId.NotificationException,
211
- SnippetScriptLoadFailure: _eInternalMessageId.SnippetScriptLoadFailure,
212
- ["Invalid" + INSTRUMENTATION_KEY as "InvalidInstrumentationKey"]: _eInternalMessageId.InvalidInstrumentationKey,
213
- [CANNOT + "ParseAiBlobValue" as "CannotParseAiBlobValue"]: _eInternalMessageId.CannotParseAiBlobValue,
214
- InvalidContentBlob: _eInternalMessageId.InvalidContentBlob,
215
- [TRACK + "PageAction" + EVENT + FAILED as "TrackPageActionEventFailed"]: _eInternalMessageId.TrackPageActionEventFailed,
216
- [FAILED + "AddingCustomDefinedRequestContext" as "FailedAddingCustomDefinedRequestContext"]: _eInternalMessageId.FailedAddingCustomDefinedRequestContext,
217
- ["InMemory" + STORAGE + BUFFER + "Full" as "InMemoryStorageBufferFull"]: _eInternalMessageId.InMemoryStorageBufferFull,
218
- [INSTRUMENTATION_KEY + "Deprecation" as "InstrumentationKeyDeprecation"]: _eInternalMessageId.InstrumentationKeyDeprecation
219
- });
220
121
  export type _InternalMessageId = number | _eInternalMessageId;
@@ -13,7 +13,7 @@ export const enum TelemetryUpdateReason {
13
13
  /**
14
14
  * The configuration has ben updated or changed
15
15
  */
16
- //ConfigurationChanged = 0x01,
16
+ ConfigurationChanged = 0x01,
17
17
 
18
18
  /**
19
19
  * One or more plugins have been added
@@ -15,6 +15,8 @@ import { ITelemetryUnloadState } from "./ITelemetryUnloadState";
15
15
  import { UnloadHandler } from "../JavaScriptSDK/UnloadHandlerContainer";
16
16
  import { SendRequestReason } from "../JavaScriptSDK.Enums/SendRequestReason";
17
17
  import { IDistributedTraceContext } from "./IDistributedTraceContext";
18
+ import { ILegacyUnloadHook, IUnloadHook } from "./IUnloadHook";
19
+ import { WatcherFunction } from "../Config/IDynamicWatcher";
18
20
 
19
21
  export interface ILoadedPlugin<T extends IPlugin> {
20
22
  plugin: T;
@@ -86,13 +88,13 @@ export interface IAppInsightsCore extends IPerfManagerProvider {
86
88
  * Adds a notification listener. The SDK calls methods on the listener when an appropriate notification is raised.
87
89
  * The added plugins must raise notifications. If the plugins do not implement the notifications, then no methods will be
88
90
  * called.
89
- * @param {INotificationListener} listener - An INotificationListener object.
91
+ * @param listener - An INotificationListener object.
90
92
  */
91
93
  addNotificationListener?(listener: INotificationListener): void;
92
94
 
93
95
  /**
94
96
  * Removes all instances of the listener.
95
- * @param {INotificationListener} listener - INotificationListener to remove.
97
+ * @param listener - INotificationListener to remove.
96
98
  */
97
99
  removeNotificationListener?(listener: INotificationListener): void;
98
100
 
@@ -101,7 +103,7 @@ export interface IAppInsightsCore extends IPerfManagerProvider {
101
103
  * @param telemetryInitializer - The Telemetry Initializer function
102
104
  * @returns - A ITelemetryInitializerHandler to enable the initializer to be removed
103
105
  */
104
- addTelemetryInitializer(telemetryInitializer: TelemetryInitializerFunction): ITelemetryInitializerHandler | void;
106
+ addTelemetryInitializer(telemetryInitializer: TelemetryInitializerFunction): ITelemetryInitializerHandler;
105
107
 
106
108
  pollInternalLogs?(eventName?: string): number;
107
109
 
@@ -140,6 +142,15 @@ export interface IAppInsightsCore extends IPerfManagerProvider {
140
142
  */
141
143
  addPlugin<T extends IPlugin = ITelemetryPlugin>(plugin: T, replaceExisting?: boolean, doAsync?: boolean, addCb?: (added?: boolean) => void): void;
142
144
 
145
+ /**
146
+ * Update the configuration used and broadcast the changes to all loaded plugins, this does NOT support updating, adding or removing
147
+ * any the plugins (extensions or channels). It will notify each plugin (if supported) that the configuration has changed but it will
148
+ * not remove or add any new plugins, you need to call addPlugin or getPlugin(identifier).remove();
149
+ * @param newConfig - The new configuration is apply
150
+ * @param mergeExisting - Should the new configuration merge with the existing or just replace it. Default is to merge.
151
+ */
152
+ updateCfg<T extends IConfiguration = IConfiguration>(newConfig: T, mergeExisting?: boolean): void;
153
+
143
154
  /**
144
155
  * Returns the unique event namespace that should be used when registering events
145
156
  */
@@ -151,6 +162,12 @@ export interface IAppInsightsCore extends IPerfManagerProvider {
151
162
  */
152
163
  addUnloadCb(handler: UnloadHandler): void;
153
164
 
165
+ /**
166
+ * Add this hook so that it is automatically removed during unloading
167
+ * @param hooks - The single hook or an array of IInstrumentHook objects
168
+ */
169
+ addUnloadHook(hooks: IUnloadHook | IUnloadHook[] | Iterator<IUnloadHook> | ILegacyUnloadHook | ILegacyUnloadHook[] | Iterator<ILegacyUnloadHook>): void;
170
+
154
171
  /**
155
172
  * Flush and send any batched / cached data immediately
156
173
  * @param async - send data asynchronously when true (defaults to true)
@@ -172,4 +189,12 @@ export interface IAppInsightsCore extends IPerfManagerProvider {
172
189
  * Sets the current distributed trace context for this instance if available
173
190
  */
174
191
  setTraceCtx(newTraceCtx: IDistributedTraceContext | null | undefined): void;
192
+
193
+ /**
194
+ * Watches and tracks changes for accesses to the current config, and if the accessed config changes the
195
+ * handler will be recalled.
196
+ * @param handler
197
+ * @returns A watcher handler instance that can be used to remove itself when being unloaded
198
+ */
199
+ onCfgChange<T extends IConfiguration = IConfiguration>(handler: WatcherFunction<T>): IUnloadHook;
175
200
  }
@@ -1,6 +1,8 @@
1
1
  // Copyright (c) Microsoft Corporation. All rights reserved.
2
2
  // Licensed under the MIT License.
3
3
 
4
+ import { ITelemetryUpdateState } from "./ITelemetryUpdateState";
5
+
4
6
  export interface ICookieMgr {
5
7
 
6
8
  /**
@@ -48,6 +50,12 @@ export interface ICookieMgr {
48
50
  * @returns - True if the cookie was marked for deletion otherwise false (Because cookie usage is not available)
49
51
  */
50
52
  purge(name: string, path?: string): boolean;
53
+
54
+ /**
55
+ * Optional Callback hook to allow the diagnostic logger to update it's configuration
56
+ * @param updateState
57
+ */
58
+ update?(updateState: ITelemetryUpdateState): void;
51
59
  }
52
60
 
53
61
  /**