@microsoft/applicationinsights-web-basic 2.8.0-beta.2202-07 → 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.2202-07
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,7 +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;
120
+ /**
121
+ * Returns the unique event namespace that should be used
122
+ */
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;
110
129
  protected releaseQueue(): void;
111
130
  }
112
131
 
@@ -155,9 +174,32 @@ declare abstract class BaseTelemetryPlugin implements ITelemetryPlugin {
155
174
  * Internal helper to allow setting of the internal initialized setting for inherited instances and unit testing
156
175
  */
157
176
  protected setInitialized: (isInitialized: boolean) => void;
177
+ /**
178
+ * Teardown / Unload hook to allow implementations to perform some additional unload operations before the BaseTelemetryPlugin
179
+ * finishes it's removal.
180
+ * @param unloadCtx - This is the context that should be used during unloading.
181
+ * @param unloadState - The details / state of the unload process, it holds details like whether it should be unloaded synchronously or asynchronously and the reason for the unload.
182
+ * @param asyncCallback - An optional callback that the plugin must call if it returns true to inform the caller that it has completed any async unload/teardown operations.
183
+ * @returns boolean - true if the plugin has or will call asyncCallback, this allows the plugin to perform any asynchronous operations.
184
+ */
185
+ protected _doTeardown?: (unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState, asyncCallback?: () => void) => void | boolean;
158
186
  constructor();
159
187
  initialize(config: IConfiguration, core: IAppInsightsCore, extensions: IPlugin[], pluginChain?: ITelemetryPluginChain): void;
188
+ /**
189
+ * Tear down the plugin and remove any hooked value, the plugin should be removed so that it is no longer initialized and
190
+ * therefore could be re-initialized after being torn down. The plugin should ensure that once this has been called any further
191
+ * processTelemetry calls are ignored and it just calls the processNext() with the provided context.
192
+ * @param unloadCtx - This is the context that should be used during unloading.
193
+ * @param unloadState - The details / state of the unload process, it holds details like whether it should be unloaded synchronously or asynchronously and the reason for the unload.
194
+ * @returns boolean - true if the plugin has or will call processNext(), this for backward compatibility as previously teardown was synchronous and returned nothing.
195
+ */
196
+ teardown(unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState): void | boolean;
160
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;
161
203
  /**
162
204
  * Add this hook so that it is automatically removed during unloading
163
205
  * @param hooks - The single hook or an array of IInstrumentHook objects
@@ -173,7 +215,15 @@ declare abstract class BaseTelemetryPlugin implements ITelemetryPlugin {
173
215
  */
174
216
  export declare const CoreUtils: ICoreUtils;
175
217
 
176
- declare enum DistributedTracingModes {
218
+ declare const DistributedTracingModes: {
219
+ AI: number;
220
+ AI_AND_W3C: number;
221
+ W3C: number;
222
+ };
223
+
224
+ declare type DistributedTracingModes = number | eDistributedTracingModes;
225
+
226
+ declare const enum eDistributedTracingModes {
177
227
  /**
178
228
  * (Default) Send Application Insights correlation headers
179
229
  */
@@ -188,6 +238,102 @@ declare enum DistributedTracingModes {
188
238
  W3C = 2
189
239
  }
190
240
 
241
+ declare const enum _eInternalMessageId {
242
+ BrowserDoesNotSupportLocalStorage = 0,
243
+ BrowserCannotReadLocalStorage = 1,
244
+ BrowserCannotReadSessionStorage = 2,
245
+ BrowserCannotWriteLocalStorage = 3,
246
+ BrowserCannotWriteSessionStorage = 4,
247
+ BrowserFailedRemovalFromLocalStorage = 5,
248
+ BrowserFailedRemovalFromSessionStorage = 6,
249
+ CannotSendEmptyTelemetry = 7,
250
+ ClientPerformanceMathError = 8,
251
+ ErrorParsingAISessionCookie = 9,
252
+ ErrorPVCalc = 10,
253
+ ExceptionWhileLoggingError = 11,
254
+ FailedAddingTelemetryToBuffer = 12,
255
+ FailedMonitorAjaxAbort = 13,
256
+ FailedMonitorAjaxDur = 14,
257
+ FailedMonitorAjaxOpen = 15,
258
+ FailedMonitorAjaxRSC = 16,
259
+ FailedMonitorAjaxSend = 17,
260
+ FailedMonitorAjaxGetCorrelationHeader = 18,
261
+ FailedToAddHandlerForOnBeforeUnload = 19,
262
+ FailedToSendQueuedTelemetry = 20,
263
+ FailedToReportDataLoss = 21,
264
+ FlushFailed = 22,
265
+ MessageLimitPerPVExceeded = 23,
266
+ MissingRequiredFieldSpecification = 24,
267
+ NavigationTimingNotSupported = 25,
268
+ OnError = 26,
269
+ SessionRenewalDateIsZero = 27,
270
+ SenderNotInitialized = 28,
271
+ StartTrackEventFailed = 29,
272
+ StopTrackEventFailed = 30,
273
+ StartTrackFailed = 31,
274
+ StopTrackFailed = 32,
275
+ TelemetrySampledAndNotSent = 33,
276
+ TrackEventFailed = 34,
277
+ TrackExceptionFailed = 35,
278
+ TrackMetricFailed = 36,
279
+ TrackPVFailed = 37,
280
+ TrackPVFailedCalc = 38,
281
+ TrackTraceFailed = 39,
282
+ TransmissionFailed = 40,
283
+ FailedToSetStorageBuffer = 41,
284
+ FailedToRestoreStorageBuffer = 42,
285
+ InvalidBackendResponse = 43,
286
+ FailedToFixDepricatedValues = 44,
287
+ InvalidDurationValue = 45,
288
+ TelemetryEnvelopeInvalid = 46,
289
+ CreateEnvelopeError = 47,
290
+ CannotSerializeObject = 48,
291
+ CannotSerializeObjectNonSerializable = 49,
292
+ CircularReferenceDetected = 50,
293
+ ClearAuthContextFailed = 51,
294
+ ExceptionTruncated = 52,
295
+ IllegalCharsInName = 53,
296
+ ItemNotInArray = 54,
297
+ MaxAjaxPerPVExceeded = 55,
298
+ MessageTruncated = 56,
299
+ NameTooLong = 57,
300
+ SampleRateOutOfRange = 58,
301
+ SetAuthContextFailed = 59,
302
+ SetAuthContextFailedAccountName = 60,
303
+ StringValueTooLong = 61,
304
+ StartCalledMoreThanOnce = 62,
305
+ StopCalledWithoutStart = 63,
306
+ TelemetryInitializerFailed = 64,
307
+ TrackArgumentsNotSpecified = 65,
308
+ UrlTooLong = 66,
309
+ SessionStorageBufferFull = 67,
310
+ CannotAccessCookie = 68,
311
+ IdTooLong = 69,
312
+ InvalidEvent = 70,
313
+ FailedMonitorAjaxSetRequestHeader = 71,
314
+ SendBrowserInfoOnUserInit = 72,
315
+ PluginException = 73,
316
+ NotificationException = 74,
317
+ SnippetScriptLoadFailure = 99,
318
+ InvalidInstrumentationKey = 100,
319
+ CannotParseAiBlobValue = 101,
320
+ InvalidContentBlob = 102,
321
+ TrackPageActionEventFailed = 103,
322
+ FailedAddingCustomDefinedRequestContext = 104,
323
+ InMemoryStorageBufferFull = 105
324
+ }
325
+
326
+ declare const enum eLoggingSeverity {
327
+ /**
328
+ * Error will be sent as internal telemetry
329
+ */
330
+ CRITICAL = 1,
331
+ /**
332
+ * Error will NOT be sent as internal telemetry, and will only be shown in browser console
333
+ */
334
+ WARNING = 2
335
+ }
336
+
191
337
  declare const enum GetExtCfgMergeType {
192
338
  None = 0,
193
339
  MergeDefaultOnly = 1,
@@ -241,11 +387,36 @@ export declare interface IAppInsightsCore extends IPerfManagerProvider {
241
387
  * Return a new instance of the IProcessTelemetryContext for processing events
242
388
  */
243
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;
244
399
  /**
245
400
  * Find and return the (first) plugin with the specified identifier if present
246
401
  * @param pluginIdentifier
247
402
  */
248
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;
411
+ /**
412
+ * Returns the unique event namespace that should be used when registering events
413
+ */
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;
249
420
  }
250
421
 
251
422
  /**
@@ -329,6 +500,67 @@ declare interface IBackendResponse {
329
500
  readonly appId?: string;
330
501
  }
331
502
 
503
+ declare interface IBaseProcessingContext {
504
+ /**
505
+ * The current core instance for the request
506
+ */
507
+ core: () => IAppInsightsCore;
508
+ /**
509
+ * THe current diagnostic logger for the request
510
+ */
511
+ diagLog: () => IDiagnosticLogger;
512
+ /**
513
+ * Gets the current core config instance
514
+ */
515
+ getCfg: () => IConfiguration;
516
+ /**
517
+ * Gets the named extension config
518
+ */
519
+ getExtCfg: <T>(identifier: string, defaultValue?: T | any, mergeDefault?: GetExtCfgMergeType) => T;
520
+ /**
521
+ * Gets the named config from either the named identifier extension or core config if neither exist then the
522
+ * default value is returned
523
+ * @param identifier The named extension identifier
524
+ * @param field The config field name
525
+ * @param defaultValue The default value to return if no defined config exists
526
+ */
527
+ getConfig: (identifier: string, field: string, defaultValue?: number | string | boolean | string[] | RegExp[] | Function) => number | string | boolean | string[] | RegExp[] | Function;
528
+ /**
529
+ * Helper to allow plugins to check and possibly shortcut executing code only
530
+ * required if there is a nextPlugin
531
+ */
532
+ hasNext: () => boolean;
533
+ /**
534
+ * Returns the next configured plugin proxy
535
+ */
536
+ getNext: () => ITelemetryPluginChain;
537
+ /**
538
+ * Helper to set the next plugin proxy
539
+ */
540
+ setNext: (nextCtx: ITelemetryPluginChain) => void;
541
+ /**
542
+ * Synchronously iterate over the context chain running the callback for each plugin, once
543
+ * every plugin has been executed via the callback, any associated onComplete will be called.
544
+ * @param callback - The function call for each plugin in the context chain
545
+ */
546
+ iterate: <T extends ITelemetryPlugin = ITelemetryPlugin>(callback: (plugin: T) => void) => void;
547
+ /**
548
+ * Set the function to call when the current chain has executed all processNext or unloadNext items.
549
+ * @param onComplete - The onComplete to call
550
+ * @param that - The "this" value to use for the onComplete call, if not provided or undefined defaults to the current context
551
+ * @param args - Any additional arguments to pass to the onComplete function
552
+ */
553
+ onComplete: (onComplete: Function, that?: any, ...args: any[]) => void;
554
+ /**
555
+ * Create a new context using the core and config from the current instance, returns a new instance of the same type
556
+ * @param plugins - The execution order to process the plugins, if null or not supplied
557
+ * then the current execution order will be copied.
558
+ * @param startAt - The plugin to start processing from, if missing from the execution
559
+ * order then the next plugin will be NOT set.
560
+ */
561
+ createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IBaseProcessingContext;
562
+ }
563
+
332
564
  /**
333
565
  * Provides data transmission capabilities
334
566
  */
@@ -342,9 +574,14 @@ declare interface IChannelControls extends ITelemetryPlugin {
342
574
  */
343
575
  resume(): void;
344
576
  /**
345
- * Tear down transmission pipeline
577
+ * Tear down the plugin and remove any hooked value, the plugin should be removed so that it is no longer initialized and
578
+ * therefore could be re-initialized after being torn down. The plugin should ensure that once this has been called any further
579
+ * processTelemetry calls are ignored and it just calls the processNext() with the provided context.
580
+ * @param unloadCtx - This is the context that should be used during unloading.
581
+ * @param unloadState - The details / state of the unload process, it holds details like whether it should be unloaded synchronously or asynchronously and the reason for the unload.
582
+ * @returns boolean - true if the plugin has or will call processNext(), this for backward compatibility as previously teardown was synchronous and returned nothing.
346
583
  */
347
- teardown(): void;
584
+ teardown: (unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState) => void | boolean;
348
585
  /**
349
586
  * Flush to send data immediately; channel should default to sending data asynchronously
350
587
  * @param async - send data asynchronously when true
@@ -1028,7 +1265,7 @@ declare interface ICoreUtils {
1028
1265
  * @param callback {any} - The callback function that needs to be executed for the given event
1029
1266
  * @return {boolean} - true if the handler was successfully added
1030
1267
  */
1031
- addEventHandler: (eventName: string, callback: any) => boolean;
1268
+ addEventHandler: (eventName: string, callback: any, evtNamespace?: string | string[]) => boolean;
1032
1269
  /**
1033
1270
  * Return the current time via the Date now() function (if available) and falls back to (new Date()).getTime() if now() is unavailable (IE8 or less)
1034
1271
  * https://caniuse.com/#search=Date.now
@@ -1257,6 +1494,20 @@ declare interface IInstrumentHooksCallbacks {
1257
1494
 
1258
1495
  declare interface ILoadedPlugin<T extends IPlugin> {
1259
1496
  plugin: T;
1497
+ /**
1498
+ * Identifies whether the plugin is enabled and can process events. This is slightly different from isInitialized as the plugin may be initialized but disabled
1499
+ * via the setEnabled() or it may be a shared plugin which has had it's teardown function called from another instance..
1500
+ * @returns boolean = true if the plugin is in a state where it is operational.
1501
+ */
1502
+ isEnabled: () => boolean;
1503
+ /**
1504
+ * You can optionally enable / disable a plugin from processing events.
1505
+ * Setting enabled to true will not necessarily cause the `isEnabled()` to also return true
1506
+ * as the plugin must also have been successfully initialized and not had it's `teardown` method called
1507
+ * (unless it's also been re-initialized)
1508
+ */
1509
+ setEnabled: (isEnabled: boolean) => void;
1510
+ remove: (isAsync?: boolean, removeCb?: (removed?: boolean) => void) => void;
1260
1511
  }
1261
1512
 
1262
1513
  export declare interface IMetricTelemetry extends IPartC {
@@ -1478,7 +1729,7 @@ declare const _InternalMessageId: {
1478
1729
  InMemoryStorageBufferFull: number;
1479
1730
  };
1480
1731
 
1481
- declare type _InternalMessageId = number | typeof _InternalMessageId;
1732
+ declare type _InternalMessageId = number | _eInternalMessageId;
1482
1733
 
1483
1734
  export declare interface IPageViewPerformanceTelemetry extends IPartC {
1484
1735
  /**
@@ -1693,10 +1944,14 @@ declare interface IPlugin {
1693
1944
  */
1694
1945
  isInitialized?: () => boolean;
1695
1946
  /**
1696
- * Tear down the plugin and remove any hooked value, the plugin should remove that it is no longer initialized and
1697
- * therefore can be re-initialized after being torn down.
1947
+ * Tear down the plugin and remove any hooked value, the plugin should be removed so that it is no longer initialized and
1948
+ * therefore could be re-initialized after being torn down. The plugin should ensure that once this has been called any further
1949
+ * processTelemetry calls are ignored and it just calls the processNext() with the provided context.
1950
+ * @param unloadCtx - This is the context that should be used during unloading.
1951
+ * @param unloadState - The details / state of the unload process, it holds details like whether it should be unloaded synchronously or asynchronously and the reason for the unload.
1952
+ * @returns boolean - true if the plugin has or will call processNext(), this for backward compatibility as previously teardown was synchronous and returned nothing.
1698
1953
  */
1699
- teardown?: () => void;
1954
+ teardown?: (unloadCtx: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState) => void | boolean;
1700
1955
  /**
1701
1956
  * Extension name
1702
1957
  */
@@ -1711,67 +1966,42 @@ declare interface IPlugin {
1711
1966
  * The current context for the current call to processTelemetry(), used to support sharing the same plugin instance
1712
1967
  * between multiple AppInsights instances
1713
1968
  */
1714
- declare interface IProcessTelemetryContext {
1715
- /**
1716
- * The current core instance for the request
1717
- */
1718
- core: () => IAppInsightsCore;
1719
- /**
1720
- * THe current diagnostic logger for the request
1721
- */
1722
- diagLog: () => IDiagnosticLogger;
1723
- /**
1724
- * Gets the current core config instance
1725
- */
1726
- getCfg: () => IConfiguration;
1727
- /**
1728
- * Gets the named extension config
1729
- */
1730
- getExtCfg: <T>(identifier: string, defaultValue?: T | any, mergeDefault?: GetExtCfgMergeType) => T;
1731
- /**
1732
- * Gets the named config from either the named identifier extension or core config if neither exist then the
1733
- * default value is returned
1734
- * @param identifier The named extension identifier
1735
- * @param field The config field name
1736
- * @param defaultValue The default value to return if no defined config exists
1737
- */
1738
- getConfig: (identifier: string, field: string, defaultValue?: number | string | boolean | string[] | RegExp[] | Function) => number | string | boolean | string[] | RegExp[] | Function;
1739
- /**
1740
- * Helper to allow plugins to check and possibly shortcut executing code only
1741
- * required if there is a nextPlugin
1742
- */
1743
- hasNext: () => boolean;
1744
- /**
1745
- * Returns the next configured plugin proxy
1746
- */
1747
- getNext: () => ITelemetryPluginChain;
1748
- /**
1749
- * Helper to set the next plugin proxy
1750
- */
1751
- setNext: (nextCtx: ITelemetryPluginChain) => void;
1969
+ declare interface IProcessTelemetryContext extends IBaseProcessingContext {
1752
1970
  /**
1753
1971
  * Call back for telemetry processing before it it is sent
1754
1972
  * @param env - This is the current event being reported
1973
+ * @returns boolean (true) if there is no more plugins to process otherwise false or undefined (void)
1755
1974
  */
1756
- processNext: (env: ITelemetryItem) => void;
1757
- /**
1758
- * Synchronously iterate over the context chain running the callback for each plugin, once
1759
- * every plugin has been executed via the callback, any associated onComplete will be called.
1760
- * @param callback - The function call for each plugin in the context chain
1761
- */
1762
- iterate: <T extends ITelemetryPlugin = ITelemetryPlugin>(callback: (plugin: T) => void) => void;
1975
+ processNext: (env: ITelemetryItem) => boolean | void;
1763
1976
  /**
1764
- * Create a new context using the core and config from the current instance
1977
+ * Create a new context using the core and config from the current instance, returns a new instance of the same type
1765
1978
  * @param plugins - The execution order to process the plugins, if null or not supplied
1766
1979
  * then the current execution order will be copied.
1767
1980
  * @param startAt - The plugin to start processing from, if missing from the execution
1768
1981
  * order then the next plugin will be NOT set.
1769
1982
  */
1770
1983
  createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryContext;
1984
+ }
1985
+
1986
+ /**
1987
+ * The current context for the current call to processTelemetry(), used to support sharing the same plugin instance
1988
+ * between multiple AppInsights instances
1989
+ */
1990
+ declare interface IProcessTelemetryUnloadContext extends IBaseProcessingContext {
1771
1991
  /**
1772
- * Set the function to call when the current chain has executed all processNext or unloadNext items.
1992
+ * This Plugin has finished unloading, so unload the next one
1993
+ * @param uploadState - The state of the unload process
1994
+ * @returns boolean (true) if there is no more plugins to process otherwise false or undefined (void)
1773
1995
  */
1774
- onComplete: (onComplete: () => void) => void;
1996
+ processNext: (unloadState: ITelemetryUnloadState) => boolean | void;
1997
+ /**
1998
+ * Create a new context using the core and config from the current instance, returns a new instance of the same type
1999
+ * @param plugins - The execution order to process the plugins, if null or not supplied
2000
+ * then the current execution order will be copied.
2001
+ * @param startAt - The plugin to start processing from, if missing from the execution
2002
+ * order then the next plugin will be NOT set.
2003
+ */
2004
+ createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryUnloadContext;
1775
2005
  }
1776
2006
 
1777
2007
  declare interface IRequestContext {
@@ -1966,15 +2196,7 @@ export declare interface ITelemetryItem {
1966
2196
  /**
1967
2197
  * Configuration provided to SDK core
1968
2198
  */
1969
- declare interface ITelemetryPlugin extends IPlugin {
1970
- /**
1971
- * Call back for telemetry processing before it it is sent
1972
- * @param env - This is the current event being reported
1973
- * @param itemCtx - This is the context for the current request, ITelemetryPlugin instances
1974
- * can optionally use this to access the current core instance or define / pass additional information
1975
- * to later plugins (vs appending items to the telemetry item)
1976
- */
1977
- processTelemetry: (env: ITelemetryItem, itemCtx?: IProcessTelemetryContext) => void;
2199
+ declare interface ITelemetryPlugin extends ITelemetryProcessor, IPlugin {
1978
2200
  /**
1979
2201
  * Set next extension for telemetry processing, this is not optional as plugins should use the
1980
2202
  * processNext() function of the passed IProcessTelemetryContext instead. It is being kept for
@@ -1990,7 +2212,7 @@ declare interface ITelemetryPlugin extends IPlugin {
1990
2212
  /**
1991
2213
  * Configuration provided to SDK core
1992
2214
  */
1993
- declare interface ITelemetryPluginChain {
2215
+ declare interface ITelemetryPluginChain extends ITelemetryProcessor {
1994
2216
  /**
1995
2217
  * Returns the underlying plugin that is being proxied for the processTelemetry call
1996
2218
  */
@@ -1999,6 +2221,16 @@ declare interface ITelemetryPluginChain {
1999
2221
  * Returns the next plugin
2000
2222
  */
2001
2223
  getNext: () => ITelemetryPluginChain;
2224
+ /**
2225
+ * This plugin is being unloaded and should remove any hooked events and cleanup any global/scoped values, after this
2226
+ * call the plugin will be removed from the telemetry processing chain and will no longer receive any events..
2227
+ * @param unloadCtx - The unload context to use for this call.
2228
+ * @param unloadState - The details of the unload operation
2229
+ */
2230
+ unload?: (unloadCtx: IProcessTelemetryUnloadContext, unloadState: ITelemetryUnloadState) => void;
2231
+ }
2232
+
2233
+ declare interface ITelemetryProcessor {
2002
2234
  /**
2003
2235
  * Call back for telemetry processing before it it is sent
2004
2236
  * @param env - This is the current event being reported
@@ -2006,7 +2238,13 @@ declare interface ITelemetryPluginChain {
2006
2238
  * can optionally use this to access the current core instance or define / pass additional information
2007
2239
  * to later plugins (vs appending items to the telemetry item)
2008
2240
  */
2009
- processTelemetry: (env: ITelemetryItem, itemCtx: IProcessTelemetryContext) => void;
2241
+ processTelemetry: (env: ITelemetryItem, itemCtx?: IProcessTelemetryContext) => void;
2242
+ }
2243
+
2244
+ declare interface ITelemetryUnloadState {
2245
+ reason: TelemetryUnloadReason;
2246
+ isAsync: boolean;
2247
+ flushComplete?: boolean;
2010
2248
  }
2011
2249
 
2012
2250
  export declare interface ITraceTelemetry extends IPartC {
@@ -2030,16 +2268,12 @@ export declare interface ITraceTelemetry extends IPartC {
2030
2268
  iKey?: string;
2031
2269
  }
2032
2270
 
2033
- declare enum LoggingSeverity {
2034
- /**
2035
- * Error will be sent as internal telemetry
2036
- */
2037
- CRITICAL = 1,
2038
- /**
2039
- * Error will NOT be sent as internal telemetry, and will only be shown in browser console
2040
- */
2041
- WARNING = 2
2042
- }
2271
+ declare const LoggingSeverity: {
2272
+ CRITICAL: number;
2273
+ WARNING: number;
2274
+ };
2275
+
2276
+ declare type LoggingSeverity = number | eLoggingSeverity;
2043
2277
 
2044
2278
  export declare class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
2045
2279
  static constructEnvelope(orig: ITelemetryItem, iKey: string, logger: IDiagnosticLogger, convertUndefined?: any): IEnvelope;
@@ -2156,6 +2390,10 @@ declare const enum SendRequestReason {
2156
2390
  * The event(s) being sent as a retry
2157
2391
  */
2158
2392
  Retry = 5,
2393
+ /**
2394
+ * The SDK is unloading
2395
+ */
2396
+ SdkUnload = 6,
2159
2397
  /**
2160
2398
  * Maximum batch size would be exceeded
2161
2399
  */
@@ -2183,6 +2421,30 @@ declare interface Tags {
2183
2421
 
2184
2422
  declare type TelemetryInitializerFunction = <T extends ITelemetryItem>(item: T) => boolean | void;
2185
2423
 
2424
+ /**
2425
+ * The TelemetryUnloadReason enumeration contains the possible reasons for why a plugin is being unloaded / torndown().
2426
+ */
2427
+ declare const enum TelemetryUnloadReason {
2428
+ /**
2429
+ * Teardown has been called without any context.
2430
+ */
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
2444
+ }
2445
+
2446
+ declare type UnloadHandler = (itemCtx: IProcessTelemetryUnloadContext, unloadState: ITelemetryUnloadState) => void;
2447
+
2186
2448
  declare interface XDomainRequest extends XMLHttpRequestEventTarget {
2187
2449
  readonly responseText: string;
2188
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.2202-07
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.2202-07",
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.2202-07",
53
- "@microsoft/applicationinsights-channel-js": "2.8.0-beta.2202-07",
54
- "@microsoft/applicationinsights-core-js": "2.8.0-beta.2202-07"
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.2202-07",
4
- "ext": {
5
- "@js": {
6
- "file": "aib.2.8.0-beta.2202-07.js",
7
- "type": "text/javascript; charset=utf-8",
8
- "integrity": "sha256-/jE9jDCTgKaw42c/SciSg/5fU2dYoiFFE0aTFWDKezU= sha384-I0HQbhCWlNmCB32bhjwzVxi0WrIPWeU89mQ/TxCW1U+NlglCDcY8Pd3qLGbFNRgx sha512-VuytWh9pRHMAA4HgtCs67aMOz1wpyfTAlGwNkmNnZNU0nCrHBx+ZVb/nO9RKYZcUUnLgYsHcdZ35wvFZn0rCjQ==",
9
- "hashes": {
10
- "sha256": "/jE9jDCTgKaw42c/SciSg/5fU2dYoiFFE0aTFWDKezU=",
11
- "sha384": "I0HQbhCWlNmCB32bhjwzVxi0WrIPWeU89mQ/TxCW1U+NlglCDcY8Pd3qLGbFNRgx",
12
- "sha512": "VuytWh9pRHMAA4HgtCs67aMOz1wpyfTAlGwNkmNnZNU0nCrHBx+ZVb/nO9RKYZcUUnLgYsHcdZ35wvFZn0rCjQ=="
13
- }
14
- },
15
- "@min.js": {
16
- "file": "aib.2.8.0-beta.2202-07.min.js",
17
- "type": "text/javascript; charset=utf-8",
18
- "integrity": "sha256-JiRszJemSh2CQdIjW89TGYu+q0pr3SzmUu9dvKOK+Pw= sha384-2RgIzyKlFEJ8divMlstNTyQGwj2yShTTGRCbDtKEUOn55zEqGwFEDDLYAEiokw3R sha512-sSRhL+sNkS44HKDoXak5fXdPy6zwfYqhREQWMIWd0mIbGkBIpVLgzw9pJRsL4B+TpzKyoDK/6A2nEBcK2YtwYQ==",
19
- "hashes": {
20
- "sha256": "JiRszJemSh2CQdIjW89TGYu+q0pr3SzmUu9dvKOK+Pw=",
21
- "sha384": "2RgIzyKlFEJ8divMlstNTyQGwj2yShTTGRCbDtKEUOn55zEqGwFEDDLYAEiokw3R",
22
- "sha512": "sSRhL+sNkS44HKDoXak5fXdPy6zwfYqhREQWMIWd0mIbGkBIpVLgzw9pJRsL4B+TpzKyoDK/6A2nEBcK2YtwYQ=="
23
- }
24
- }
25
- }
26
- }