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

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-07
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  *
5
5
  * Microsoft Application Insights Team
@@ -113,10 +113,20 @@ declare class BaseCore implements IAppInsightsCore {
113
113
  * approach is to create a new instance and initialize that instance.
114
114
  * This is due to possible unexpected side effects caused by plugins not supporting unload / teardown, unable
115
115
  * to successfully remove any global references or they may just be completing the unload process asynchronously.
116
+ * @param isAsync - Can the unload be performed asynchronously (default)
117
+ * @param unloadComplete - An optional callback that will be called once the unload has completed
118
+ * @param cbTimeout - An optional timeout to wait for any flush operations to complete before proceeding with the unload. Defaults to 5 seconds.
116
119
  */
117
- unload(isAsync?: boolean, unloadComplete?: () => void): void;
120
+ unload(isAsync?: boolean, unloadComplete?: (unloadState: ITelemetryUnloadState) => void, cbTimeout?: number): void;
118
121
  getPlugin<T extends IPlugin = IPlugin>(pluginIdentifier: string): ILoadedPlugin<T>;
119
- addPlugin<T extends IPlugin = ITelemetryPlugin>(plugin: T, replaceExisting: boolean, doAsync: boolean, addCb?: (added?: boolean) => void): void;
122
+ /**
123
+ * Add a new plugin to the installation
124
+ * @param plugin - The new plugin to add
125
+ * @param replaceExisting - should any existing plugin be replaced, default is false
126
+ * @param doAsync - Should the add be performed asynchronously
127
+ * @param addCb - [Optional] callback to call after the plugin has been added
128
+ */
129
+ addPlugin<T extends IPlugin = ITelemetryPlugin>(plugin: T, replaceExisting?: boolean, doAsync?: boolean, addCb?: (added?: boolean) => void): void;
120
130
  /**
121
131
  * Returns the unique event namespace that should be used
122
132
  */
@@ -126,7 +136,23 @@ declare class BaseCore implements IAppInsightsCore {
126
136
  * @param handler - the handler
127
137
  */
128
138
  addUnloadCb(handler: UnloadHandler): void;
139
+ /**
140
+ * Flush and send any batched / cached data immediately
141
+ * @param async - send data asynchronously when true (defaults to true)
142
+ * @param callBack - if specified, notify caller when send is complete, the channel should return true to indicate to the caller that it will be called.
143
+ * If the caller doesn't return true the caller should assume that it may never be called.
144
+ * @param sendReason - specify the reason that you are calling "flush" defaults to ManualFlush (1) if not specified
145
+ * @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
146
+ */
147
+ flush(isAsync?: boolean, callBack?: (flushComplete?: boolean) => void, sendReason?: SendRequestReason): void;
129
148
  protected releaseQueue(): void;
149
+ /**
150
+ * Hook for Core extensions to allow them to update their own configuration before updating all of the plugins.
151
+ * @param updateCtx - The plugin update context
152
+ * @param updateState - The Update State
153
+ * @returns boolean - True means the extension class will call updateState otherwise the Core will
154
+ */
155
+ protected _updateHook?(updateCtx: IProcessTelemetryUpdateContext, updateState: ITelemetryUpdateState): void | boolean;
130
156
  }
131
157
 
132
158
  /**
@@ -183,6 +209,14 @@ declare abstract class BaseTelemetryPlugin implements ITelemetryPlugin {
183
209
  * @returns boolean - true if the plugin has or will call asyncCallback, this allows the plugin to perform any asynchronous operations.
184
210
  */
185
211
  protected _doTeardown?: (unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState, asyncCallback?: () => void) => void | boolean;
212
+ /**
213
+ * Extension hook to allow implementations to perform some additional update operations before the BaseTelemetryPlugin finishes it's removal
214
+ * @param updateCtx - This is the context that should be used during updating.
215
+ * @param updateState - The details / state of the update process, it holds details like the current and previous configuration.
216
+ * @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.
217
+ * @returns boolean - true if the plugin has or will call asyncCallback, this allows the plugin to perform any asynchronous operations.
218
+ */
219
+ protected _doUpdate?: (updateCtx?: IProcessTelemetryUpdateContext, updateState?: ITelemetryUpdateState, asyncCallback?: () => void) => void | boolean;
186
220
  constructor();
187
221
  initialize(config: IConfiguration, core: IAppInsightsCore, extensions: IPlugin[], pluginChain?: ITelemetryPluginChain): void;
188
222
  /**
@@ -195,6 +229,13 @@ declare abstract class BaseTelemetryPlugin implements ITelemetryPlugin {
195
229
  */
196
230
  teardown(unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState): void | boolean;
197
231
  abstract processTelemetry(env: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
232
+ /**
233
+ * The the plugin should re-evaluate configuration and update any cached configuration settings.
234
+ * @param updateCtx - This is the context that should be used during updating.
235
+ * @param updateState - The details / state of the update process, it holds details like the current and previous configuration.
236
+ * @returns boolean - true if the plugin has or will call updateCtx.processNext(), this allows the plugin to perform any asynchronous operations.
237
+ */
238
+ update(updateCtx: IProcessTelemetryUpdateContext, updateState: ITelemetryUpdateState): void | boolean;
198
239
  /**
199
240
  * Add an unload handler that will be called when the SDK is being unloaded
200
241
  * @param handler - the handler
@@ -394,8 +435,11 @@ export declare interface IAppInsightsCore extends IPerfManagerProvider {
394
435
  * approach is to create a new instance and initialize that instance.
395
436
  * This is due to possible unexpected side effects caused by plugins not supporting unload / teardown, unable
396
437
  * to successfully remove any global references or they may just be completing the unload process asynchronously.
438
+ * @param isAsync - Can the unload be performed asynchronously (default)
439
+ * @param unloadComplete - An optional callback that will be called once the unload has completed
440
+ * @param cbTimeout - An optional timeout to wait for any flush operations to complete before proceeding with the unload. Defaults to 5 seconds.
397
441
  */
398
- unload(isAsync?: boolean, unloadComplete?: () => void): void;
442
+ unload(isAsync?: boolean, unloadComplete?: (unloadState: ITelemetryUnloadState) => void, cbTimeout?: number): void;
399
443
  /**
400
444
  * Find and return the (first) plugin with the specified identifier if present
401
445
  * @param pluginIdentifier
@@ -404,10 +448,11 @@ export declare interface IAppInsightsCore extends IPerfManagerProvider {
404
448
  /**
405
449
  * Add a new plugin to the installation
406
450
  * @param plugin - The new plugin to add
407
- * @param replaceExisting - should any existing plugin be replaced
451
+ * @param replaceExisting - should any existing plugin be replaced, default is false
408
452
  * @param doAsync - Should the add be performed asynchronously
453
+ * @param addCb - [Optional] callback to call after the plugin has been added
409
454
  */
410
- addPlugin<T extends IPlugin = ITelemetryPlugin>(plugin: T, replaceExisting: boolean, doAsync: boolean, addCb?: (added?: boolean) => void): void;
455
+ addPlugin<T extends IPlugin = ITelemetryPlugin>(plugin: T, replaceExisting?: boolean, doAsync?: boolean, addCb?: (added?: boolean) => void): void;
411
456
  /**
412
457
  * Returns the unique event namespace that should be used when registering events
413
458
  */
@@ -417,6 +462,16 @@ export declare interface IAppInsightsCore extends IPerfManagerProvider {
417
462
  * @param handler - the handler
418
463
  */
419
464
  addUnloadCb(handler: UnloadHandler): void;
465
+ /**
466
+ * Flush and send any batched / cached data immediately
467
+ * @param async - send data asynchronously when true (defaults to true)
468
+ * @param callBack - if specified, notify caller when send is complete, the channel should return true to indicate to the caller that it will be called.
469
+ * If the caller doesn't return true the caller should assume that it may never be called.
470
+ * @param sendReason - specify the reason that you are calling "flush" defaults to ManualFlush (1) if not specified
471
+ * @param cbTimeout - An optional timeout to wait for any flush operations to complete before proceeding with the unload. Defaults to 5 seconds.
472
+ * @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
473
+ */
474
+ flush(isAsync?: boolean, callBack?: (flushComplete?: boolean) => void, sendReason?: SendRequestReason, cbTimeout?: number): boolean | void;
420
475
  }
421
476
 
422
477
  /**
@@ -1473,6 +1528,11 @@ declare interface IInstrumentHook {
1473
1528
  * You must always supply the error callback
1474
1529
  */
1475
1530
  declare interface IInstrumentHooksCallbacks {
1531
+ /**
1532
+ * [Optional] Namespace details (same as the namespace used for events), useful for debugging and testing to
1533
+ * identify the source of the instrumented hooks
1534
+ */
1535
+ ns?: string | string[];
1476
1536
  /**
1477
1537
  * The hook callback to call before the original function is called
1478
1538
  */
@@ -1984,8 +2044,8 @@ declare interface IProcessTelemetryContext extends IBaseProcessingContext {
1984
2044
  }
1985
2045
 
1986
2046
  /**
1987
- * The current context for the current call to processTelemetry(), used to support sharing the same plugin instance
1988
- * between multiple AppInsights instances
2047
+ * The current context for the current call to teardown() implementations, used to support when plugins are being removed
2048
+ * or the SDK is being unloaded.
1989
2049
  */
1990
2050
  declare interface IProcessTelemetryUnloadContext extends IBaseProcessingContext {
1991
2051
  /**
@@ -2004,6 +2064,27 @@ declare interface IProcessTelemetryUnloadContext extends IBaseProcessingContext
2004
2064
  createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryUnloadContext;
2005
2065
  }
2006
2066
 
2067
+ /**
2068
+ * The current context for the current call to the plugin update() implementations, used to support the notifications
2069
+ * for when plugins are added, removed or the configuration was changed.
2070
+ */
2071
+ declare interface IProcessTelemetryUpdateContext extends IBaseProcessingContext {
2072
+ /**
2073
+ * This Plugin has finished unloading, so unload the next one
2074
+ * @param updateState - The update State
2075
+ * @returns boolean (true) if there is no more plugins to process otherwise false or undefined (void)
2076
+ */
2077
+ processNext: (updateState: ITelemetryUpdateState) => boolean | void;
2078
+ /**
2079
+ * Create a new context using the core and config from the current instance, returns a new instance of the same type
2080
+ * @param plugins - The execution order to process the plugins, if null or not supplied
2081
+ * then the current execution order will be copied.
2082
+ * @param startAt - The plugin to start processing from, if missing from the execution
2083
+ * order then the next plugin will be NOT set.
2084
+ */
2085
+ createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryUpdateContext;
2086
+ }
2087
+
2007
2088
  declare interface IRequestContext {
2008
2089
  status?: number;
2009
2090
  xhr?: XMLHttpRequest;
@@ -2239,6 +2320,15 @@ declare interface ITelemetryProcessor {
2239
2320
  * to later plugins (vs appending items to the telemetry item)
2240
2321
  */
2241
2322
  processTelemetry: (env: ITelemetryItem, itemCtx?: IProcessTelemetryContext) => void;
2323
+ /**
2324
+ * The the plugin should re-evaluate configuration and update any cached configuration settings or
2325
+ * plugins. If implemented this method will be called whenever a plugin is added or removed and if
2326
+ * the configuration has bee updated.
2327
+ * @param updateCtx - This is the context that should be used during updating.
2328
+ * @param updateState - The details / state of the update process, it holds details like the current and previous configuration.
2329
+ * @returns boolean - true if the plugin has or will call updateCtx.processNext(), this allows the plugin to perform any asynchronous operations.
2330
+ */
2331
+ update?: (updateCtx: IProcessTelemetryUpdateContext, updateState: ITelemetryUpdateState) => void | boolean;
2242
2332
  }
2243
2333
 
2244
2334
  declare interface ITelemetryUnloadState {
@@ -2247,6 +2337,27 @@ declare interface ITelemetryUnloadState {
2247
2337
  flushComplete?: boolean;
2248
2338
  }
2249
2339
 
2340
+ declare interface ITelemetryUpdateState {
2341
+ /**
2342
+ * Identifies the reason for the update notification, this is a bitwise numeric value
2343
+ */
2344
+ reason: TelemetryUpdateReason;
2345
+ /**
2346
+ * If this is a configuration update this was the previous configuration that was used
2347
+ */
2348
+ /**
2349
+ * If this is a configuration update is the new configuration that is being used
2350
+ */
2351
+ /**
2352
+ * This holds a collection of plugins that have been added (if the reason identifies that one or more plugins have been added)
2353
+ */
2354
+ added?: IPlugin[];
2355
+ /**
2356
+ * This holds a collection of plugins that have been removed (if the reason identifies that one or more plugins have been removed)
2357
+ */
2358
+ removed?: IPlugin[];
2359
+ }
2360
+
2250
2361
  export declare interface ITraceTelemetry extends IPartC {
2251
2362
  /**
2252
2363
  * @description A message string
@@ -2443,6 +2554,27 @@ declare const enum TelemetryUnloadReason {
2443
2554
  SdkUnload = 50
2444
2555
  }
2445
2556
 
2557
+ /**
2558
+ * The TelemetryUpdateReason enumeration contains a set of bit-wise values that specify the reason for update request.
2559
+ */
2560
+ declare const enum TelemetryUpdateReason {
2561
+ /**
2562
+ * Unknown.
2563
+ */
2564
+ Unknown = 0,
2565
+ /**
2566
+ * The configuration has ben updated or changed
2567
+ */
2568
+ /**
2569
+ * One or more plugins have been added
2570
+ */
2571
+ PluginAdded = 16,
2572
+ /**
2573
+ * One or more plugins have been removed
2574
+ */
2575
+ PluginRemoved = 32
2576
+ }
2577
+
2446
2578
  declare type UnloadHandler = (itemCtx: IProcessTelemetryUnloadContext, unloadState: ITelemetryUnloadState) => void;
2447
2579
 
2448
2580
  declare interface XDomainRequest extends XMLHttpRequestEventTarget {
package/dist-esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript Web SDK - Basic, 2.8.0-beta.2203-04
2
+ * Application Insights JavaScript Web SDK - Basic, 2.8.0-beta.2203-07
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microsoft/applicationinsights-web-basic",
3
- "version": "2.8.0-beta.2203-04",
3
+ "version": "2.8.0-beta.2203-07",
4
4
  "description": "Microsoft Application Insights Javascript SDK core and channel",
5
5
  "homepage": "https://github.com/microsoft/ApplicationInsights-JS#readme",
6
6
  "author": "Microsoft Application Insights Team",
@@ -49,9 +49,9 @@
49
49
  "dependencies": {
50
50
  "@microsoft/dynamicproto-js": "^1.1.4",
51
51
  "@microsoft/applicationinsights-shims": "2.0.1",
52
- "@microsoft/applicationinsights-common": "2.8.0-beta.2203-04",
53
- "@microsoft/applicationinsights-channel-js": "2.8.0-beta.2203-04",
54
- "@microsoft/applicationinsights-core-js": "2.8.0-beta.2203-04"
52
+ "@microsoft/applicationinsights-common": "2.8.0-beta.2203-07",
53
+ "@microsoft/applicationinsights-channel-js": "2.8.0-beta.2203-07",
54
+ "@microsoft/applicationinsights-core-js": "2.8.0-beta.2203-07"
55
55
  },
56
56
  "license": "MIT",
57
57
  "publishConfig": {
@@ -1,26 +0,0 @@
1
- {
2
- "name": "aib",
3
- "version": "2.8.0-beta.2203-04",
4
- "ext": {
5
- "@js": {
6
- "file": "aib.2.8.0-beta.2203-04.js",
7
- "type": "text/javascript; charset=utf-8",
8
- "integrity": "sha256-jf7SNn8jwON6bIJJ1kHXDOvHq7tL6DDn2KHm66bFB1g= sha384-iGUVpD8Kw1h9irCex4NSBebbJ88MBDP4gc92xJiyWtUFDLgM36L3pUPdJEkNIYjS sha512-+d/1rf6zTA7824akyNFRIaIeQW7wmSjqwiLmRooWVUSQO4k/LH6HVpbXPYtyIwdvYNiArno4axyOdTKNoXq3Qw==",
9
- "hashes": {
10
- "sha256": "jf7SNn8jwON6bIJJ1kHXDOvHq7tL6DDn2KHm66bFB1g=",
11
- "sha384": "iGUVpD8Kw1h9irCex4NSBebbJ88MBDP4gc92xJiyWtUFDLgM36L3pUPdJEkNIYjS",
12
- "sha512": "+d/1rf6zTA7824akyNFRIaIeQW7wmSjqwiLmRooWVUSQO4k/LH6HVpbXPYtyIwdvYNiArno4axyOdTKNoXq3Qw=="
13
- }
14
- },
15
- "@min.js": {
16
- "file": "aib.2.8.0-beta.2203-04.min.js",
17
- "type": "text/javascript; charset=utf-8",
18
- "integrity": "sha256-f3MCk+/gx1y7kuIeq5MeIGsfw9ZD3mGsEVtDarhbpdo= sha384-LqoDEkW5ot0qWo/HZNB6n5U6ZGfYSh6Ky426qdocdByvQohbffN0Lm7LRTZp9XB6 sha512-hN78HLUacgdBUdKJD7vS5mzcLYo9wSn+RuatGQjFoK0zy2ktObEP6S7F1nKWgbos7mvoMgEb312PUIgDy7V/YQ==",
19
- "hashes": {
20
- "sha256": "f3MCk+/gx1y7kuIeq5MeIGsfw9ZD3mGsEVtDarhbpdo=",
21
- "sha384": "LqoDEkW5ot0qWo/HZNB6n5U6ZGfYSh6Ky426qdocdByvQohbffN0Lm7LRTZp9XB6",
22
- "sha512": "hN78HLUacgdBUdKJD7vS5mzcLYo9wSn+RuatGQjFoK0zy2ktObEP6S7F1nKWgbos7mvoMgEb312PUIgDy7V/YQ=="
23
- }
24
- }
25
- }
26
- }