@microsoft/applicationinsights-web-basic 2.8.0-beta.2203-04 → 2.8.0-beta.2203-05

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.
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Microsoft.ApplicationInsights, 2.8.0-beta.2203-04
2
+ * Microsoft.ApplicationInsights, 2.8.0-beta.2203-05
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  *
5
5
  * Microsoft Application Insights Team
@@ -108,7 +108,7 @@ declare namespace ApplicationInsights {
108
108
  * This is due to possible unexpected side effects caused by plugins not supporting unload / teardown, unable
109
109
  * to successfully remove any global references or they may just be completing the unload process asynchronously.
110
110
  */
111
- unload(isAsync?: boolean, unloadComplete?: () => void): void;
111
+ unload(isAsync?: boolean, unloadComplete?: (unloadState: ITelemetryUnloadState) => void, cbTimeout?: number): void;
112
112
  getPlugin<T extends IPlugin = IPlugin>(pluginIdentifier: string): ILoadedPlugin<T>;
113
113
  addPlugin<T extends IPlugin = ITelemetryPlugin>(plugin: T, replaceExisting: boolean, doAsync: boolean, addCb?: (added?: boolean) => void): void;
114
114
  /**
@@ -121,6 +121,13 @@ declare namespace ApplicationInsights {
121
121
  */
122
122
  addUnloadCb(handler: UnloadHandler): void;
123
123
  protected releaseQueue(): void;
124
+ /**
125
+ * Hook for Core extensions to allow them to update their own configuration before updating all of the plugins.
126
+ * @param updateCtx - The plugin update context
127
+ * @param updateState - The Update State
128
+ * @returns boolean - True means the extension class will call updateState otherwise the Core will
129
+ */
130
+ protected _updateHook?(updateCtx: IProcessTelemetryUpdateContext, updateState: ITelemetryUpdateState): void | boolean;
124
131
  }
125
132
 
126
133
  /**
@@ -177,6 +184,14 @@ declare namespace ApplicationInsights {
177
184
  * @returns boolean - true if the plugin has or will call asyncCallback, this allows the plugin to perform any asynchronous operations.
178
185
  */
179
186
  protected _doTeardown?: (unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState, asyncCallback?: () => void) => void | boolean;
187
+ /**
188
+ * Extension hook to allow implementations to perform some additional update operations before the BaseTelemetryPlugin finishes it's removal
189
+ * @param updateCtx - This is the context that should be used during updating.
190
+ * @param updateState - The details / state of the update process, it holds details like the current and previous configuration.
191
+ * @param asyncCallback - An optional callback that the plugin must call if it returns true to inform the caller that it has completed any async update operations.
192
+ * @returns boolean - true if the plugin has or will call asyncCallback, this allows the plugin to perform any asynchronous operations.
193
+ */
194
+ protected _doUpdate?: (updateCtx?: IProcessTelemetryUpdateContext, updateState?: ITelemetryUpdateState, asyncCallback?: () => void) => void | boolean;
180
195
  constructor();
181
196
  initialize(config: IConfiguration, core: IAppInsightsCore, extensions: IPlugin[], pluginChain?: ITelemetryPluginChain): void;
182
197
  /**
@@ -189,6 +204,13 @@ declare namespace ApplicationInsights {
189
204
  */
190
205
  teardown(unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState): void | boolean;
191
206
  abstract processTelemetry(env: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
207
+ /**
208
+ * The the plugin should re-evaluate configuration and update any cached configuration settings.
209
+ * @param updateCtx - This is the context that should be used during updating.
210
+ * @param updateState - The details / state of the update process, it holds details like the current and previous configuration.
211
+ * @returns boolean - true if the plugin has or will call updateCtx.processNext(), this allows the plugin to perform any asynchronous operations.
212
+ */
213
+ update(updateCtx: IProcessTelemetryUpdateContext, updateState: ITelemetryUpdateState): void | boolean;
192
214
  /**
193
215
  * Add an unload handler that will be called when the SDK is being unloaded
194
216
  * @param handler - the handler
@@ -1467,6 +1489,11 @@ declare namespace ApplicationInsights {
1467
1489
  * You must always supply the error callback
1468
1490
  */
1469
1491
  interface IInstrumentHooksCallbacks {
1492
+ /**
1493
+ * [Optional] Namespace details (same as the namespace used for events), useful for debugging and testing to
1494
+ * identify the source of the instrumented hooks
1495
+ */
1496
+ ns?: string | string[];
1470
1497
  /**
1471
1498
  * The hook callback to call before the original function is called
1472
1499
  */
@@ -1978,8 +2005,8 @@ declare namespace ApplicationInsights {
1978
2005
  }
1979
2006
 
1980
2007
  /**
1981
- * The current context for the current call to processTelemetry(), used to support sharing the same plugin instance
1982
- * between multiple AppInsights instances
2008
+ * The current context for the current call to teardown() implementations, used to support when plugins are being removed
2009
+ * or the SDK is being unloaded.
1983
2010
  */
1984
2011
  interface IProcessTelemetryUnloadContext extends IBaseProcessingContext {
1985
2012
  /**
@@ -1998,6 +2025,27 @@ declare namespace ApplicationInsights {
1998
2025
  createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryUnloadContext;
1999
2026
  }
2000
2027
 
2028
+ /**
2029
+ * The current context for the current call to the plugin update() implementations, used to support the notifications
2030
+ * for when plugins are added, removed or the configuration was changed.
2031
+ */
2032
+ interface IProcessTelemetryUpdateContext extends IBaseProcessingContext {
2033
+ /**
2034
+ * This Plugin has finished unloading, so unload the next one
2035
+ * @param updateState - The update State
2036
+ * @returns boolean (true) if there is no more plugins to process otherwise false or undefined (void)
2037
+ */
2038
+ processNext: (updateState: ITelemetryUpdateState) => boolean | void;
2039
+ /**
2040
+ * Create a new context using the core and config from the current instance, returns a new instance of the same type
2041
+ * @param plugins - The execution order to process the plugins, if null or not supplied
2042
+ * then the current execution order will be copied.
2043
+ * @param startAt - The plugin to start processing from, if missing from the execution
2044
+ * order then the next plugin will be NOT set.
2045
+ */
2046
+ createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryUpdateContext;
2047
+ }
2048
+
2001
2049
  interface IRequestContext {
2002
2050
  status?: number;
2003
2051
  xhr?: XMLHttpRequest;
@@ -2233,6 +2281,15 @@ declare namespace ApplicationInsights {
2233
2281
  * to later plugins (vs appending items to the telemetry item)
2234
2282
  */
2235
2283
  processTelemetry: (env: ITelemetryItem, itemCtx?: IProcessTelemetryContext) => void;
2284
+ /**
2285
+ * The the plugin should re-evaluate configuration and update any cached configuration settings or
2286
+ * plugins. If implemented this method will be called whenever a plugin is added or removed and if
2287
+ * the configuration has bee updated.
2288
+ * @param updateCtx - This is the context that should be used during updating.
2289
+ * @param updateState - The details / state of the update process, it holds details like the current and previous configuration.
2290
+ * @returns boolean - true if the plugin has or will call updateCtx.processNext(), this allows the plugin to perform any asynchronous operations.
2291
+ */
2292
+ update?: (updateCtx: IProcessTelemetryUpdateContext, updateState: ITelemetryUpdateState) => void | boolean;
2236
2293
  }
2237
2294
 
2238
2295
  interface ITelemetryUnloadState {
@@ -2241,6 +2298,27 @@ declare namespace ApplicationInsights {
2241
2298
  flushComplete?: boolean;
2242
2299
  }
2243
2300
 
2301
+ interface ITelemetryUpdateState {
2302
+ /**
2303
+ * Identifies the reason for the update notification, this is a bitwise numeric value
2304
+ */
2305
+ reason: TelemetryUpdateReason;
2306
+ /**
2307
+ * If this is a configuration update this was the previous configuration that was used
2308
+ */
2309
+ /**
2310
+ * If this is a configuration update is the new configuration that is being used
2311
+ */
2312
+ /**
2313
+ * This holds a collection of plugins that have been added (if the reason identifies that one or more plugins have been added)
2314
+ */
2315
+ added?: IPlugin[];
2316
+ /**
2317
+ * This holds a collection of plugins that have been removed (if the reason identifies that one or more plugins have been removed)
2318
+ */
2319
+ removed?: IPlugin[];
2320
+ }
2321
+
2244
2322
  interface ITraceTelemetry extends IPartC {
2245
2323
  /**
2246
2324
  * @description A message string
@@ -2437,6 +2515,27 @@ declare namespace ApplicationInsights {
2437
2515
  SdkUnload = 50
2438
2516
  }
2439
2517
 
2518
+ /**
2519
+ * The TelemetryUpdateReason enumeration contains a set of bit-wise values that specify the reason for update request.
2520
+ */
2521
+ const enum TelemetryUpdateReason {
2522
+ /**
2523
+ * Unknown.
2524
+ */
2525
+ Unknown = 0,
2526
+ /**
2527
+ * The configuration has ben updated or changed
2528
+ */
2529
+ /**
2530
+ * One or more plugins have been added
2531
+ */
2532
+ PluginAdded = 16,
2533
+ /**
2534
+ * One or more plugins have been removed
2535
+ */
2536
+ PluginRemoved = 32
2537
+ }
2538
+
2440
2539
  type UnloadHandler = (itemCtx: IProcessTelemetryUnloadContext, unloadState: ITelemetryUnloadState) => void;
2441
2540
 
2442
2541
  interface XDomainRequest extends XMLHttpRequestEventTarget {