@microsoft/applicationinsights-web-basic 2.8.0-beta.2203-02 → 2.8.0-beta.2203-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.
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Microsoft.ApplicationInsights, 2.8.0-beta.2203-02
2
+ * Microsoft.ApplicationInsights, 2.8.0-beta.2203-03
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  *
5
5
  * Microsoft Application Insights Team
@@ -106,11 +106,26 @@ 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?: () => void): 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;
115
130
  }
116
131
 
@@ -180,6 +195,11 @@ declare abstract class BaseTelemetryPlugin implements ITelemetryPlugin {
180
195
  */
181
196
  teardown(unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState): void | boolean;
182
197
  abstract processTelemetry(env: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
198
+ /**
199
+ * Add an unload handler that will be called when the SDK is being unloaded
200
+ * @param handler - the handler
201
+ */
202
+ protected _addUnloadCb(handler: UnloadHandler): void;
183
203
  /**
184
204
  * Add this hook so that it is automatically removed during unloading
185
205
  * @param hooks - The single hook or an array of IInstrumentHook objects
@@ -367,15 +387,36 @@ export declare interface IAppInsightsCore extends IPerfManagerProvider {
367
387
  * Return a new instance of the IProcessTelemetryContext for processing events
368
388
  */
369
389
  getProcessTelContext(): IProcessTelemetryContext;
390
+ /**
391
+ * Unload and Tear down the SDK and any initialized plugins, after calling this the SDK will be considered
392
+ * to be un-initialized and non-operational, re-initializing the SDK should only be attempted if the previous
393
+ * unload call return `true` stating that all plugins reported that they also unloaded, the recommended
394
+ * approach is to create a new instance and initialize that instance.
395
+ * This is due to possible unexpected side effects caused by plugins not supporting unload / teardown, unable
396
+ * to successfully remove any global references or they may just be completing the unload process asynchronously.
397
+ */
398
+ unload(isAsync?: boolean, unloadComplete?: () => void): void;
370
399
  /**
371
400
  * Find and return the (first) plugin with the specified identifier if present
372
401
  * @param pluginIdentifier
373
402
  */
374
403
  getPlugin<T extends IPlugin = IPlugin>(pluginIdentifier: string): ILoadedPlugin<T>;
404
+ /**
405
+ * Add a new plugin to the installation
406
+ * @param plugin - The new plugin to add
407
+ * @param replaceExisting - should any existing plugin be replaced
408
+ * @param doAsync - Should the add be performed asynchronously
409
+ */
410
+ addPlugin<T extends IPlugin = ITelemetryPlugin>(plugin: T, replaceExisting: boolean, doAsync: boolean, addCb?: (added?: boolean) => void): void;
375
411
  /**
376
412
  * Returns the unique event namespace that should be used when registering events
377
413
  */
378
414
  evtNamespace(): string;
415
+ /**
416
+ * Add a handler that will be called when the SDK is being unloaded
417
+ * @param handler - the handler
418
+ */
419
+ addUnloadCb(handler: UnloadHandler): void;
379
420
  }
380
421
 
381
422
  /**
@@ -1466,6 +1507,7 @@ declare interface ILoadedPlugin<T extends IPlugin> {
1466
1507
  * (unless it's also been re-initialized)
1467
1508
  */
1468
1509
  setEnabled: (isEnabled: boolean) => void;
1510
+ remove: (isAsync?: boolean, removeCb?: (removed?: boolean) => void) => void;
1469
1511
  }
1470
1512
 
1471
1513
  export declare interface IMetricTelemetry extends IPartC {
@@ -2348,6 +2390,10 @@ declare const enum SendRequestReason {
2348
2390
  * The event(s) being sent as a retry
2349
2391
  */
2350
2392
  Retry = 5,
2393
+ /**
2394
+ * The SDK is unloading
2395
+ */
2396
+ SdkUnload = 6,
2351
2397
  /**
2352
2398
  * Maximum batch size would be exceeded
2353
2399
  */
@@ -2382,9 +2428,23 @@ declare const enum TelemetryUnloadReason {
2382
2428
  /**
2383
2429
  * Teardown has been called without any context.
2384
2430
  */
2385
- ManualTeardown = 0
2431
+ ManualTeardown = 0,
2432
+ /**
2433
+ * Just this plugin is being removed
2434
+ */
2435
+ PluginUnload = 1,
2436
+ /**
2437
+ * This instance of the plugin is being removed and replaced
2438
+ */
2439
+ PluginReplace = 2,
2440
+ /**
2441
+ * The entire SDK is being unloaded
2442
+ */
2443
+ SdkUnload = 50
2386
2444
  }
2387
2445
 
2446
+ declare type UnloadHandler = (itemCtx: IProcessTelemetryUnloadContext, unloadState: ITelemetryUnloadState) => void;
2447
+
2388
2448
  declare interface XDomainRequest extends XMLHttpRequestEventTarget {
2389
2449
  readonly responseText: string;
2390
2450
  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-03
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-03",
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-03",
53
+ "@microsoft/applicationinsights-channel-js": "2.8.0-beta.2203-03",
54
+ "@microsoft/applicationinsights-core-js": "2.8.0-beta.2203-03"
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
- }