@microsoft/applicationinsights-web-basic 2.8.0-beta.2203-02 → 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-02
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
@@ -106,12 +106,34 @@ declare class BaseCore implements IAppInsightsCore {
106
106
  * @returns - A ITelemetryInitializerHandler to enable the initializer to be removed
107
107
  */
108
108
  addTelemetryInitializer(telemetryInitializer: TelemetryInitializerFunction): ITelemetryInitializerHandler | void;
109
+ /**
110
+ * Unload and Tear down the SDK and any initialized plugins, after calling this the SDK will be considered
111
+ * to be un-initialized and non-operational, re-initializing the SDK should only be attempted if the previous
112
+ * unload call return `true` stating that all plugins reported that they also unloaded, the recommended
113
+ * approach is to create a new instance and initialize that instance.
114
+ * This is due to possible unexpected side effects caused by plugins not supporting unload / teardown, unable
115
+ * to successfully remove any global references or they may just be completing the unload process asynchronously.
116
+ */
117
+ unload(isAsync?: boolean, unloadComplete?: (unloadState: ITelemetryUnloadState) => void, cbTimeout?: number): void;
109
118
  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;
110
120
  /**
111
121
  * Returns the unique event namespace that should be used
112
122
  */
113
123
  evtNamespace(): string;
124
+ /**
125
+ * Add an unload handler that will be called when the SDK is being unloaded
126
+ * @param handler - the handler
127
+ */
128
+ addUnloadCb(handler: UnloadHandler): void;
114
129
  protected releaseQueue(): void;
130
+ /**
131
+ * Hook for Core extensions to allow them to update their own configuration before updating all of the plugins.
132
+ * @param updateCtx - The plugin update context
133
+ * @param updateState - The Update State
134
+ * @returns boolean - True means the extension class will call updateState otherwise the Core will
135
+ */
136
+ protected _updateHook?(updateCtx: IProcessTelemetryUpdateContext, updateState: ITelemetryUpdateState): void | boolean;
115
137
  }
116
138
 
117
139
  /**
@@ -168,6 +190,14 @@ declare abstract class BaseTelemetryPlugin implements ITelemetryPlugin {
168
190
  * @returns boolean - true if the plugin has or will call asyncCallback, this allows the plugin to perform any asynchronous operations.
169
191
  */
170
192
  protected _doTeardown?: (unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState, asyncCallback?: () => void) => void | boolean;
193
+ /**
194
+ * Extension hook to allow implementations to perform some additional update operations before the BaseTelemetryPlugin finishes it's removal
195
+ * @param updateCtx - This is the context that should be used during updating.
196
+ * @param updateState - The details / state of the update process, it holds details like the current and previous configuration.
197
+ * @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.
198
+ * @returns boolean - true if the plugin has or will call asyncCallback, this allows the plugin to perform any asynchronous operations.
199
+ */
200
+ protected _doUpdate?: (updateCtx?: IProcessTelemetryUpdateContext, updateState?: ITelemetryUpdateState, asyncCallback?: () => void) => void | boolean;
171
201
  constructor();
172
202
  initialize(config: IConfiguration, core: IAppInsightsCore, extensions: IPlugin[], pluginChain?: ITelemetryPluginChain): void;
173
203
  /**
@@ -180,6 +210,18 @@ declare abstract class BaseTelemetryPlugin implements ITelemetryPlugin {
180
210
  */
181
211
  teardown(unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState): void | boolean;
182
212
  abstract processTelemetry(env: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
213
+ /**
214
+ * The the plugin should re-evaluate configuration and update any cached configuration settings.
215
+ * @param updateCtx - This is the context that should be used during updating.
216
+ * @param updateState - The details / state of the update process, it holds details like the current and previous configuration.
217
+ * @returns boolean - true if the plugin has or will call updateCtx.processNext(), this allows the plugin to perform any asynchronous operations.
218
+ */
219
+ update(updateCtx: IProcessTelemetryUpdateContext, updateState: ITelemetryUpdateState): void | boolean;
220
+ /**
221
+ * Add an unload handler that will be called when the SDK is being unloaded
222
+ * @param handler - the handler
223
+ */
224
+ protected _addUnloadCb(handler: UnloadHandler): void;
183
225
  /**
184
226
  * Add this hook so that it is automatically removed during unloading
185
227
  * @param hooks - The single hook or an array of IInstrumentHook objects
@@ -367,15 +409,36 @@ export declare interface IAppInsightsCore extends IPerfManagerProvider {
367
409
  * Return a new instance of the IProcessTelemetryContext for processing events
368
410
  */
369
411
  getProcessTelContext(): IProcessTelemetryContext;
412
+ /**
413
+ * Unload and Tear down the SDK and any initialized plugins, after calling this the SDK will be considered
414
+ * to be un-initialized and non-operational, re-initializing the SDK should only be attempted if the previous
415
+ * unload call return `true` stating that all plugins reported that they also unloaded, the recommended
416
+ * approach is to create a new instance and initialize that instance.
417
+ * This is due to possible unexpected side effects caused by plugins not supporting unload / teardown, unable
418
+ * to successfully remove any global references or they may just be completing the unload process asynchronously.
419
+ */
420
+ unload(isAsync?: boolean, unloadComplete?: () => void): void;
370
421
  /**
371
422
  * Find and return the (first) plugin with the specified identifier if present
372
423
  * @param pluginIdentifier
373
424
  */
374
425
  getPlugin<T extends IPlugin = IPlugin>(pluginIdentifier: string): ILoadedPlugin<T>;
426
+ /**
427
+ * Add a new plugin to the installation
428
+ * @param plugin - The new plugin to add
429
+ * @param replaceExisting - should any existing plugin be replaced
430
+ * @param doAsync - Should the add be performed asynchronously
431
+ */
432
+ addPlugin<T extends IPlugin = ITelemetryPlugin>(plugin: T, replaceExisting: boolean, doAsync: boolean, addCb?: (added?: boolean) => void): void;
375
433
  /**
376
434
  * Returns the unique event namespace that should be used when registering events
377
435
  */
378
436
  evtNamespace(): string;
437
+ /**
438
+ * Add a handler that will be called when the SDK is being unloaded
439
+ * @param handler - the handler
440
+ */
441
+ addUnloadCb(handler: UnloadHandler): void;
379
442
  }
380
443
 
381
444
  /**
@@ -1432,6 +1495,11 @@ declare interface IInstrumentHook {
1432
1495
  * You must always supply the error callback
1433
1496
  */
1434
1497
  declare interface IInstrumentHooksCallbacks {
1498
+ /**
1499
+ * [Optional] Namespace details (same as the namespace used for events), useful for debugging and testing to
1500
+ * identify the source of the instrumented hooks
1501
+ */
1502
+ ns?: string | string[];
1435
1503
  /**
1436
1504
  * The hook callback to call before the original function is called
1437
1505
  */
@@ -1466,6 +1534,7 @@ declare interface ILoadedPlugin<T extends IPlugin> {
1466
1534
  * (unless it's also been re-initialized)
1467
1535
  */
1468
1536
  setEnabled: (isEnabled: boolean) => void;
1537
+ remove: (isAsync?: boolean, removeCb?: (removed?: boolean) => void) => void;
1469
1538
  }
1470
1539
 
1471
1540
  export declare interface IMetricTelemetry extends IPartC {
@@ -1942,8 +2011,8 @@ declare interface IProcessTelemetryContext extends IBaseProcessingContext {
1942
2011
  }
1943
2012
 
1944
2013
  /**
1945
- * The current context for the current call to processTelemetry(), used to support sharing the same plugin instance
1946
- * between multiple AppInsights instances
2014
+ * The current context for the current call to teardown() implementations, used to support when plugins are being removed
2015
+ * or the SDK is being unloaded.
1947
2016
  */
1948
2017
  declare interface IProcessTelemetryUnloadContext extends IBaseProcessingContext {
1949
2018
  /**
@@ -1962,6 +2031,27 @@ declare interface IProcessTelemetryUnloadContext extends IBaseProcessingContext
1962
2031
  createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryUnloadContext;
1963
2032
  }
1964
2033
 
2034
+ /**
2035
+ * The current context for the current call to the plugin update() implementations, used to support the notifications
2036
+ * for when plugins are added, removed or the configuration was changed.
2037
+ */
2038
+ declare interface IProcessTelemetryUpdateContext extends IBaseProcessingContext {
2039
+ /**
2040
+ * This Plugin has finished unloading, so unload the next one
2041
+ * @param updateState - The update State
2042
+ * @returns boolean (true) if there is no more plugins to process otherwise false or undefined (void)
2043
+ */
2044
+ processNext: (updateState: ITelemetryUpdateState) => boolean | void;
2045
+ /**
2046
+ * Create a new context using the core and config from the current instance, returns a new instance of the same type
2047
+ * @param plugins - The execution order to process the plugins, if null or not supplied
2048
+ * then the current execution order will be copied.
2049
+ * @param startAt - The plugin to start processing from, if missing from the execution
2050
+ * order then the next plugin will be NOT set.
2051
+ */
2052
+ createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryUpdateContext;
2053
+ }
2054
+
1965
2055
  declare interface IRequestContext {
1966
2056
  status?: number;
1967
2057
  xhr?: XMLHttpRequest;
@@ -2197,6 +2287,15 @@ declare interface ITelemetryProcessor {
2197
2287
  * to later plugins (vs appending items to the telemetry item)
2198
2288
  */
2199
2289
  processTelemetry: (env: ITelemetryItem, itemCtx?: IProcessTelemetryContext) => void;
2290
+ /**
2291
+ * The the plugin should re-evaluate configuration and update any cached configuration settings or
2292
+ * plugins. If implemented this method will be called whenever a plugin is added or removed and if
2293
+ * the configuration has bee updated.
2294
+ * @param updateCtx - This is the context that should be used during updating.
2295
+ * @param updateState - The details / state of the update process, it holds details like the current and previous configuration.
2296
+ * @returns boolean - true if the plugin has or will call updateCtx.processNext(), this allows the plugin to perform any asynchronous operations.
2297
+ */
2298
+ update?: (updateCtx: IProcessTelemetryUpdateContext, updateState: ITelemetryUpdateState) => void | boolean;
2200
2299
  }
2201
2300
 
2202
2301
  declare interface ITelemetryUnloadState {
@@ -2205,6 +2304,27 @@ declare interface ITelemetryUnloadState {
2205
2304
  flushComplete?: boolean;
2206
2305
  }
2207
2306
 
2307
+ declare interface ITelemetryUpdateState {
2308
+ /**
2309
+ * Identifies the reason for the update notification, this is a bitwise numeric value
2310
+ */
2311
+ reason: TelemetryUpdateReason;
2312
+ /**
2313
+ * If this is a configuration update this was the previous configuration that was used
2314
+ */
2315
+ /**
2316
+ * If this is a configuration update is the new configuration that is being used
2317
+ */
2318
+ /**
2319
+ * This holds a collection of plugins that have been added (if the reason identifies that one or more plugins have been added)
2320
+ */
2321
+ added?: IPlugin[];
2322
+ /**
2323
+ * This holds a collection of plugins that have been removed (if the reason identifies that one or more plugins have been removed)
2324
+ */
2325
+ removed?: IPlugin[];
2326
+ }
2327
+
2208
2328
  export declare interface ITraceTelemetry extends IPartC {
2209
2329
  /**
2210
2330
  * @description A message string
@@ -2348,6 +2468,10 @@ declare const enum SendRequestReason {
2348
2468
  * The event(s) being sent as a retry
2349
2469
  */
2350
2470
  Retry = 5,
2471
+ /**
2472
+ * The SDK is unloading
2473
+ */
2474
+ SdkUnload = 6,
2351
2475
  /**
2352
2476
  * Maximum batch size would be exceeded
2353
2477
  */
@@ -2382,9 +2506,44 @@ declare const enum TelemetryUnloadReason {
2382
2506
  /**
2383
2507
  * Teardown has been called without any context.
2384
2508
  */
2385
- ManualTeardown = 0
2509
+ ManualTeardown = 0,
2510
+ /**
2511
+ * Just this plugin is being removed
2512
+ */
2513
+ PluginUnload = 1,
2514
+ /**
2515
+ * This instance of the plugin is being removed and replaced
2516
+ */
2517
+ PluginReplace = 2,
2518
+ /**
2519
+ * The entire SDK is being unloaded
2520
+ */
2521
+ SdkUnload = 50
2522
+ }
2523
+
2524
+ /**
2525
+ * The TelemetryUpdateReason enumeration contains a set of bit-wise values that specify the reason for update request.
2526
+ */
2527
+ declare const enum TelemetryUpdateReason {
2528
+ /**
2529
+ * Unknown.
2530
+ */
2531
+ Unknown = 0,
2532
+ /**
2533
+ * The configuration has ben updated or changed
2534
+ */
2535
+ /**
2536
+ * One or more plugins have been added
2537
+ */
2538
+ PluginAdded = 16,
2539
+ /**
2540
+ * One or more plugins have been removed
2541
+ */
2542
+ PluginRemoved = 32
2386
2543
  }
2387
2544
 
2545
+ declare type UnloadHandler = (itemCtx: IProcessTelemetryUnloadContext, unloadState: ITelemetryUnloadState) => void;
2546
+
2388
2547
  declare interface XDomainRequest extends XMLHttpRequestEventTarget {
2389
2548
  readonly responseText: string;
2390
2549
  send(payload: string): void;
package/dist-esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript Web SDK - Basic, 2.8.0-beta.2203-02
2
+ * Application Insights JavaScript Web SDK - Basic, 2.8.0-beta.2203-05
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-02",
3
+ "version": "2.8.0-beta.2203-05",
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-02",
53
- "@microsoft/applicationinsights-channel-js": "2.8.0-beta.2203-02",
54
- "@microsoft/applicationinsights-core-js": "2.8.0-beta.2203-02"
52
+ "@microsoft/applicationinsights-common": "2.8.0-beta.2203-05",
53
+ "@microsoft/applicationinsights-channel-js": "2.8.0-beta.2203-05",
54
+ "@microsoft/applicationinsights-core-js": "2.8.0-beta.2203-05"
55
55
  },
56
56
  "license": "MIT",
57
57
  "publishConfig": {
@@ -1,26 +0,0 @@
1
- {
2
- "name": "aib",
3
- "version": "2.8.0-beta.2203-02",
4
- "ext": {
5
- "@js": {
6
- "file": "aib.2.8.0-beta.2203-02.js",
7
- "type": "text/javascript; charset=utf-8",
8
- "integrity": "sha256-0UJ6Qz9AxedzebIXQPhaYM258vg3O2oS6KmBrzM5tUM= sha384-C0GWlj4YH2IeW0jVKB4bJ6q3pgjyWuRU/RdRnKrmFvNThfSuCXnLNGrMpzy7ajHS sha512-VEN+rKe91Grcf+49tzqSoFKaW2u4YgXb8bWhVLyY206R+Ae/EzFs0+obwdDM1P7YjCPBAlshQPc/XNfjbV9Z/g==",
9
- "hashes": {
10
- "sha256": "0UJ6Qz9AxedzebIXQPhaYM258vg3O2oS6KmBrzM5tUM=",
11
- "sha384": "C0GWlj4YH2IeW0jVKB4bJ6q3pgjyWuRU/RdRnKrmFvNThfSuCXnLNGrMpzy7ajHS",
12
- "sha512": "VEN+rKe91Grcf+49tzqSoFKaW2u4YgXb8bWhVLyY206R+Ae/EzFs0+obwdDM1P7YjCPBAlshQPc/XNfjbV9Z/g=="
13
- }
14
- },
15
- "@min.js": {
16
- "file": "aib.2.8.0-beta.2203-02.min.js",
17
- "type": "text/javascript; charset=utf-8",
18
- "integrity": "sha256-paOqvLRc9AgzcyFwZOqTO4H2qFhCmrnLAuPjOoSyaJA= sha384-vxCQFW7eaF9SuU2n1gsUIgZ7X8D/zGr8kJDABixhxooRogzV0s4g2P4TwsQUraUd sha512-UN91wRxjdRvmzFyx3sG8te8pKsxhkNumyc96LwOMdzXc9EEMh/wAREKJNFzRqyIq4s0YJWHb3Lkm/UrSbC50JQ==",
19
- "hashes": {
20
- "sha256": "paOqvLRc9AgzcyFwZOqTO4H2qFhCmrnLAuPjOoSyaJA=",
21
- "sha384": "vxCQFW7eaF9SuU2n1gsUIgZ7X8D/zGr8kJDABixhxooRogzV0s4g2P4TwsQUraUd",
22
- "sha512": "UN91wRxjdRvmzFyx3sG8te8pKsxhkNumyc96LwOMdzXc9EEMh/wAREKJNFzRqyIq4s0YJWHb3Lkm/UrSbC50JQ=="
23
- }
24
- }
25
- }
26
- }