@microsoft/applicationinsights-web-basic 2.7.5-nightly.2202-11 → 2.7.5-nightly.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.7.5-nightly.2202-11
2
+ * Microsoft.ApplicationInsights, 2.7.5-nightly.2203-03
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  *
5
5
  * Microsoft Application Insights Team
@@ -17,26 +17,6 @@ export declare class AppInsightsCore extends BaseCore implements IAppInsightsCor
17
17
  constructor();
18
18
  initialize(config: IConfiguration, extensions: IPlugin[], logger?: IDiagnosticLogger, notificationManager?: INotificationManager): void;
19
19
  track(telemetryItem: ITelemetryItem): void;
20
- /**
21
- * Adds a notification listener. The SDK calls methods on the listener when an appropriate notification is raised.
22
- * The added plugins must raise notifications. If the plugins do not implement the notifications, then no methods will be
23
- * called.
24
- * @param {INotificationListener} listener - An INotificationListener object.
25
- */
26
- addNotificationListener(listener: INotificationListener): void;
27
- /**
28
- * Removes all instances of the listener.
29
- * @param {INotificationListener} listener - INotificationListener to remove.
30
- */
31
- removeNotificationListener(listener: INotificationListener): void;
32
- /**
33
- * Periodically check logger.queue for
34
- */
35
- pollInternalLogs(eventName?: string): number;
36
- /**
37
- * Periodically check logger.queue for
38
- */
39
- stopPollingInternalLogs(): void;
40
20
  }
41
21
 
42
22
  /**
@@ -45,7 +25,6 @@ export declare class AppInsightsCore extends BaseCore implements IAppInsightsCor
45
25
  */
46
26
  export declare class ApplicationInsights {
47
27
  config: IConfiguration & IConfig;
48
- private core;
49
28
  /**
50
29
  * Creates an instance of ApplicationInsights.
51
30
  * @param {IConfiguration & IConfig} config
@@ -71,11 +50,51 @@ export declare class ApplicationInsights {
71
50
  * @memberof ApplicationInsights
72
51
  */
73
52
  flush(async?: boolean): void;
74
- private pollInternalLogs;
53
+ pollInternalLogs(): void;
75
54
  stopPollingInternalLogs(): void;
76
- private getSKUDefaults;
55
+ getSKUDefaults(): void;
56
+ /**
57
+ * Unload and Tear down the SDK and any initialized plugins, after calling this the SDK will be considered
58
+ * to be un-initialized and non-operational, re-initializing the SDK should only be attempted if the previous
59
+ * unload call return `true` stating that all plugins reported that they also unloaded, the recommended
60
+ * approach is to create a new instance and initialize that instance.
61
+ * This is due to possible unexpected side effects caused by plugins not supporting unload / teardown, unable
62
+ * to successfully remove any global references or they may just be completing the unload process asynchronously.
63
+ */
64
+ unload(isAsync?: boolean, unloadComplete?: () => void): void;
65
+ /**
66
+ * Find and return the (first) plugin with the specified identifier if present
67
+ * @param pluginIdentifier
68
+ */
69
+ getPlugin<T extends IPlugin = IPlugin>(pluginIdentifier: string): ILoadedPlugin<T>;
70
+ /**
71
+ * Add a new plugin to the installation
72
+ * @param plugin - The new plugin to add
73
+ * @param replaceExisting - should any existing plugin be replaced
74
+ * @param doAsync - Should the add be performed asynchronously
75
+ */
76
+ addPlugin<T extends IPlugin = ITelemetryPlugin>(plugin: T, replaceExisting: boolean, doAsync: boolean, addCb?: (added?: boolean) => void): void;
77
+ /**
78
+ * Returns the unique event namespace that should be used
79
+ */
80
+ evtNamespace(): string;
81
+ /**
82
+ * Add an unload handler that will be called when the SDK is being unloaded
83
+ * @param handler - the handler
84
+ */
85
+ addUnloadCb(handler: UnloadHandler): void;
77
86
  }
78
87
 
88
+ /**
89
+ * Performs the specified action for each element in an array. This helper exists to avoid adding a polyfil for older browsers
90
+ * that do not define Array.prototype.xxxx (eg. ES3 only, IE8) just in case any page checks for presence/absence of the prototype
91
+ * implementation. Note: For consistency this will not use the Array.prototype.xxxx implementation if it exists as this would
92
+ * cause a testing requirement to test with and without the implementations
93
+ * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array. It can return -1 to break out of the loop
94
+ * @param thisArg [Optional] An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
95
+ */
96
+ export declare function arrForEach<T = any>(arr: T[], callbackfn: (value: T, index?: number, array?: T[]) => undefined | void | number, thisArg?: any): void;
97
+
79
98
  declare class BaseCore implements IAppInsightsCore {
80
99
  static defaultConfig: IConfiguration;
81
100
  config: IConfiguration;
@@ -88,6 +107,18 @@ declare class BaseCore implements IAppInsightsCore {
88
107
  track(telemetryItem: ITelemetryItem): void;
89
108
  getProcessTelContext(): IProcessTelemetryContext;
90
109
  getNotifyMgr(): INotificationManager;
110
+ /**
111
+ * Adds a notification listener. The SDK calls methods on the listener when an appropriate notification is raised.
112
+ * The added plugins must raise notifications. If the plugins do not implement the notifications, then no methods will be
113
+ * called.
114
+ * @param {INotificationListener} listener - An INotificationListener object.
115
+ */
116
+ addNotificationListener(listener: INotificationListener): void;
117
+ /**
118
+ * Removes all instances of the listener.
119
+ * @param {INotificationListener} listener - INotificationListener to remove.
120
+ */
121
+ removeNotificationListener(listener: INotificationListener): void;
91
122
  /**
92
123
  * Get the current cookie manager for this instance
93
124
  */
@@ -100,7 +131,67 @@ declare class BaseCore implements IAppInsightsCore {
100
131
  getPerfMgr(): IPerfManager;
101
132
  setPerfMgr(perfMgr: IPerfManager): void;
102
133
  eventCnt(): number;
134
+ /**
135
+ * Periodically check logger.queue for
136
+ */
137
+ pollInternalLogs(eventName?: string): number;
138
+ /**
139
+ * Periodically check logger.queue for
140
+ */
141
+ stopPollingInternalLogs(): void;
142
+ /**
143
+ * Add a telemetry processor to decorate or drop telemetry events.
144
+ * @param telemetryInitializer - The Telemetry Initializer function
145
+ * @returns - A ITelemetryInitializerHandler to enable the initializer to be removed
146
+ */
147
+ addTelemetryInitializer(telemetryInitializer: TelemetryInitializerFunction): ITelemetryInitializerHandler | void;
148
+ /**
149
+ * Unload and Tear down the SDK and any initialized plugins, after calling this the SDK will be considered
150
+ * to be un-initialized and non-operational, re-initializing the SDK should only be attempted if the previous
151
+ * unload call return `true` stating that all plugins reported that they also unloaded, the recommended
152
+ * approach is to create a new instance and initialize that instance.
153
+ * This is due to possible unexpected side effects caused by plugins not supporting unload / teardown, unable
154
+ * to successfully remove any global references or they may just be completing the unload process asynchronously.
155
+ * @param isAsync - Can the unload be performed asynchronously (default)
156
+ * @param unloadComplete - An optional callback that will be called once the unload has completed
157
+ * @param cbTimeout - An optional timeout to wait for any flush operations to complete before proceeding with the unload. Defaults to 5 seconds.
158
+ */
159
+ unload(isAsync?: boolean, unloadComplete?: (unloadState: ITelemetryUnloadState) => void, cbTimeout?: number): void;
160
+ getPlugin<T extends IPlugin = IPlugin>(pluginIdentifier: string): ILoadedPlugin<T>;
161
+ /**
162
+ * Add a new plugin to the installation
163
+ * @param plugin - The new plugin to add
164
+ * @param replaceExisting - should any existing plugin be replaced, default is false
165
+ * @param doAsync - Should the add be performed asynchronously
166
+ * @param addCb - [Optional] callback to call after the plugin has been added
167
+ */
168
+ addPlugin<T extends IPlugin = ITelemetryPlugin>(plugin: T, replaceExisting?: boolean, doAsync?: boolean, addCb?: (added?: boolean) => void): void;
169
+ /**
170
+ * Returns the unique event namespace that should be used
171
+ */
172
+ evtNamespace(): string;
173
+ /**
174
+ * Add an unload handler that will be called when the SDK is being unloaded
175
+ * @param handler - the handler
176
+ */
177
+ addUnloadCb(handler: UnloadHandler): void;
178
+ /**
179
+ * Flush and send any batched / cached data immediately
180
+ * @param async - send data asynchronously when true (defaults to true)
181
+ * @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.
182
+ * If the caller doesn't return true the caller should assume that it may never be called.
183
+ * @param sendReason - specify the reason that you are calling "flush" defaults to ManualFlush (1) if not specified
184
+ * @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
185
+ */
186
+ flush(isAsync?: boolean, callBack?: (flushComplete?: boolean) => void, sendReason?: SendRequestReason): void;
103
187
  protected releaseQueue(): void;
188
+ /**
189
+ * Hook for Core extensions to allow them to update their own configuration before updating all of the plugins.
190
+ * @param updateCtx - The plugin update context
191
+ * @param updateState - The Update State
192
+ * @returns boolean - True means the extension class will call updateState otherwise the Core will
193
+ */
194
+ protected _updateHook?(updateCtx: IProcessTelemetryUpdateContext, updateState: ITelemetryUpdateState): void | boolean;
104
195
  }
105
196
 
106
197
  /**
@@ -109,6 +200,13 @@ declare class BaseCore implements IAppInsightsCore {
109
200
  * implementation so that new default implementations can be added without breaking all plugins.
110
201
  */
111
202
  declare abstract class BaseTelemetryPlugin implements ITelemetryPlugin {
203
+ identifier: string;
204
+ version?: string;
205
+ /**
206
+ * Holds the core instance that was used during initialization
207
+ */
208
+ core: IAppInsightsCore;
209
+ priority: number;
112
210
  /**
113
211
  * Call back for telemetry processing before it it is sent
114
212
  * @param env - This is the current event being reported
@@ -130,13 +228,6 @@ declare abstract class BaseTelemetryPlugin implements ITelemetryPlugin {
130
228
  * Returns whether the plugin has been initialized
131
229
  */
132
230
  isInitialized: () => boolean;
133
- identifier: string;
134
- version?: string;
135
- /**
136
- * Holds the core instance that was used during initialization
137
- */
138
- core: IAppInsightsCore;
139
- priority: number;
140
231
  /**
141
232
  * Helper to return the current IProcessTelemetryContext, if the passed argument exists this just
142
233
  * returns that value (helps with minification for callers), otherwise it will return the configured
@@ -149,12 +240,51 @@ declare abstract class BaseTelemetryPlugin implements ITelemetryPlugin {
149
240
  */
150
241
  protected setInitialized: (isInitialized: boolean) => void;
151
242
  /**
152
- * Internal helper to initialize the instance
243
+ * Teardown / Unload hook to allow implementations to perform some additional unload operations before the BaseTelemetryPlugin
244
+ * finishes it's removal.
245
+ * @param unloadCtx - This is the context that should be used during unloading.
246
+ * @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.
247
+ * @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.
248
+ * @returns boolean - true if the plugin has or will call asyncCallback, this allows the plugin to perform any asynchronous operations.
153
249
  */
154
- private _baseTelInit;
250
+ protected _doTeardown?: (unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState, asyncCallback?: () => void) => void | boolean;
251
+ /**
252
+ * Extension hook to allow implementations to perform some additional update operations before the BaseTelemetryPlugin finishes it's removal
253
+ * @param updateCtx - This is the context that should be used during updating.
254
+ * @param updateState - The details / state of the update process, it holds details like the current and previous configuration.
255
+ * @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.
256
+ * @returns boolean - true if the plugin has or will call asyncCallback, this allows the plugin to perform any asynchronous operations.
257
+ */
258
+ protected _doUpdate?: (updateCtx?: IProcessTelemetryUpdateContext, updateState?: ITelemetryUpdateState, asyncCallback?: () => void) => void | boolean;
155
259
  constructor();
156
260
  initialize(config: IConfiguration, core: IAppInsightsCore, extensions: IPlugin[], pluginChain?: ITelemetryPluginChain): void;
261
+ /**
262
+ * Tear down the plugin and remove any hooked value, the plugin should be removed so that it is no longer initialized and
263
+ * therefore could be re-initialized after being torn down. The plugin should ensure that once this has been called any further
264
+ * processTelemetry calls are ignored and it just calls the processNext() with the provided context.
265
+ * @param unloadCtx - This is the context that should be used during unloading.
266
+ * @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.
267
+ * @returns boolean - true if the plugin has or will call processNext(), this for backward compatibility as previously teardown was synchronous and returned nothing.
268
+ */
269
+ teardown(unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState): void | boolean;
157
270
  abstract processTelemetry(env: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
271
+ /**
272
+ * The the plugin should re-evaluate configuration and update any cached configuration settings.
273
+ * @param updateCtx - This is the context that should be used during updating.
274
+ * @param updateState - The details / state of the update process, it holds details like the current and previous configuration.
275
+ * @returns boolean - true if the plugin has or will call updateCtx.processNext(), this allows the plugin to perform any asynchronous operations.
276
+ */
277
+ update(updateCtx: IProcessTelemetryUpdateContext, updateState: ITelemetryUpdateState): void | boolean;
278
+ /**
279
+ * Add an unload handler that will be called when the SDK is being unloaded
280
+ * @param handler - the handler
281
+ */
282
+ protected _addUnloadCb(handler: UnloadHandler): void;
283
+ /**
284
+ * Add this hook so that it is automatically removed during unloading
285
+ * @param hooks - The single hook or an array of IInstrumentHook objects
286
+ */
287
+ protected _addHook(hooks: IInstrumentHook | IInstrumentHook[]): void;
158
288
  }
159
289
 
160
290
  /**
@@ -165,7 +295,15 @@ declare abstract class BaseTelemetryPlugin implements ITelemetryPlugin {
165
295
  */
166
296
  export declare const CoreUtils: ICoreUtils;
167
297
 
168
- declare enum DistributedTracingModes {
298
+ declare const DistributedTracingModes: {
299
+ AI: number;
300
+ AI_AND_W3C: number;
301
+ W3C: number;
302
+ };
303
+
304
+ declare type DistributedTracingModes = number | eDistributedTracingModes;
305
+
306
+ declare const enum eDistributedTracingModes {
169
307
  /**
170
308
  * (Default) Send Application Insights correlation headers
171
309
  */
@@ -180,6 +318,108 @@ declare enum DistributedTracingModes {
180
318
  W3C = 2
181
319
  }
182
320
 
321
+ export declare const enum _eInternalMessageId {
322
+ BrowserDoesNotSupportLocalStorage = 0,
323
+ BrowserCannotReadLocalStorage = 1,
324
+ BrowserCannotReadSessionStorage = 2,
325
+ BrowserCannotWriteLocalStorage = 3,
326
+ BrowserCannotWriteSessionStorage = 4,
327
+ BrowserFailedRemovalFromLocalStorage = 5,
328
+ BrowserFailedRemovalFromSessionStorage = 6,
329
+ CannotSendEmptyTelemetry = 7,
330
+ ClientPerformanceMathError = 8,
331
+ ErrorParsingAISessionCookie = 9,
332
+ ErrorPVCalc = 10,
333
+ ExceptionWhileLoggingError = 11,
334
+ FailedAddingTelemetryToBuffer = 12,
335
+ FailedMonitorAjaxAbort = 13,
336
+ FailedMonitorAjaxDur = 14,
337
+ FailedMonitorAjaxOpen = 15,
338
+ FailedMonitorAjaxRSC = 16,
339
+ FailedMonitorAjaxSend = 17,
340
+ FailedMonitorAjaxGetCorrelationHeader = 18,
341
+ FailedToAddHandlerForOnBeforeUnload = 19,
342
+ FailedToSendQueuedTelemetry = 20,
343
+ FailedToReportDataLoss = 21,
344
+ FlushFailed = 22,
345
+ MessageLimitPerPVExceeded = 23,
346
+ MissingRequiredFieldSpecification = 24,
347
+ NavigationTimingNotSupported = 25,
348
+ OnError = 26,
349
+ SessionRenewalDateIsZero = 27,
350
+ SenderNotInitialized = 28,
351
+ StartTrackEventFailed = 29,
352
+ StopTrackEventFailed = 30,
353
+ StartTrackFailed = 31,
354
+ StopTrackFailed = 32,
355
+ TelemetrySampledAndNotSent = 33,
356
+ TrackEventFailed = 34,
357
+ TrackExceptionFailed = 35,
358
+ TrackMetricFailed = 36,
359
+ TrackPVFailed = 37,
360
+ TrackPVFailedCalc = 38,
361
+ TrackTraceFailed = 39,
362
+ TransmissionFailed = 40,
363
+ FailedToSetStorageBuffer = 41,
364
+ FailedToRestoreStorageBuffer = 42,
365
+ InvalidBackendResponse = 43,
366
+ FailedToFixDepricatedValues = 44,
367
+ InvalidDurationValue = 45,
368
+ TelemetryEnvelopeInvalid = 46,
369
+ CreateEnvelopeError = 47,
370
+ CannotSerializeObject = 48,
371
+ CannotSerializeObjectNonSerializable = 49,
372
+ CircularReferenceDetected = 50,
373
+ ClearAuthContextFailed = 51,
374
+ ExceptionTruncated = 52,
375
+ IllegalCharsInName = 53,
376
+ ItemNotInArray = 54,
377
+ MaxAjaxPerPVExceeded = 55,
378
+ MessageTruncated = 56,
379
+ NameTooLong = 57,
380
+ SampleRateOutOfRange = 58,
381
+ SetAuthContextFailed = 59,
382
+ SetAuthContextFailedAccountName = 60,
383
+ StringValueTooLong = 61,
384
+ StartCalledMoreThanOnce = 62,
385
+ StopCalledWithoutStart = 63,
386
+ TelemetryInitializerFailed = 64,
387
+ TrackArgumentsNotSpecified = 65,
388
+ UrlTooLong = 66,
389
+ SessionStorageBufferFull = 67,
390
+ CannotAccessCookie = 68,
391
+ IdTooLong = 69,
392
+ InvalidEvent = 70,
393
+ FailedMonitorAjaxSetRequestHeader = 71,
394
+ SendBrowserInfoOnUserInit = 72,
395
+ PluginException = 73,
396
+ NotificationException = 74,
397
+ SnippetScriptLoadFailure = 99,
398
+ InvalidInstrumentationKey = 100,
399
+ CannotParseAiBlobValue = 101,
400
+ InvalidContentBlob = 102,
401
+ TrackPageActionEventFailed = 103,
402
+ FailedAddingCustomDefinedRequestContext = 104,
403
+ InMemoryStorageBufferFull = 105
404
+ }
405
+
406
+ declare const enum eLoggingSeverity {
407
+ /**
408
+ * Error will be sent as internal telemetry
409
+ */
410
+ CRITICAL = 1,
411
+ /**
412
+ * Error will NOT be sent as internal telemetry, and will only be shown in browser console
413
+ */
414
+ WARNING = 2
415
+ }
416
+
417
+ declare const enum GetExtCfgMergeType {
418
+ None = 0,
419
+ MergeDefaultOnly = 1,
420
+ MergeDefaultFromRootOrDefault = 2
421
+ }
422
+
183
423
  export declare interface IAppInsightsCore extends IPerfManagerProvider {
184
424
  config: IConfiguration;
185
425
  logger: IDiagnosticLogger;
@@ -215,12 +455,62 @@ export declare interface IAppInsightsCore extends IPerfManagerProvider {
215
455
  * @param {INotificationListener} listener - INotificationListener to remove.
216
456
  */
217
457
  removeNotificationListener?(listener: INotificationListener): void;
458
+ /**
459
+ * Add a telemetry processor to decorate or drop telemetry events.
460
+ * @param telemetryInitializer - The Telemetry Initializer function
461
+ * @returns - A ITelemetryInitializerHandler to enable the initializer to be removed
462
+ */
463
+ addTelemetryInitializer(telemetryInitializer: TelemetryInitializerFunction): ITelemetryInitializerHandler | void;
218
464
  pollInternalLogs?(eventName?: string): number;
219
465
  stopPollingInternalLogs?(): void;
220
466
  /**
221
467
  * Return a new instance of the IProcessTelemetryContext for processing events
222
468
  */
223
469
  getProcessTelContext(): IProcessTelemetryContext;
470
+ /**
471
+ * Unload and Tear down the SDK and any initialized plugins, after calling this the SDK will be considered
472
+ * to be un-initialized and non-operational, re-initializing the SDK should only be attempted if the previous
473
+ * unload call return `true` stating that all plugins reported that they also unloaded, the recommended
474
+ * approach is to create a new instance and initialize that instance.
475
+ * This is due to possible unexpected side effects caused by plugins not supporting unload / teardown, unable
476
+ * to successfully remove any global references or they may just be completing the unload process asynchronously.
477
+ * @param isAsync - Can the unload be performed asynchronously (default)
478
+ * @param unloadComplete - An optional callback that will be called once the unload has completed
479
+ * @param cbTimeout - An optional timeout to wait for any flush operations to complete before proceeding with the unload. Defaults to 5 seconds.
480
+ */
481
+ unload(isAsync?: boolean, unloadComplete?: (unloadState: ITelemetryUnloadState) => void, cbTimeout?: number): void;
482
+ /**
483
+ * Find and return the (first) plugin with the specified identifier if present
484
+ * @param pluginIdentifier
485
+ */
486
+ getPlugin<T extends IPlugin = IPlugin>(pluginIdentifier: string): ILoadedPlugin<T>;
487
+ /**
488
+ * Add a new plugin to the installation
489
+ * @param plugin - The new plugin to add
490
+ * @param replaceExisting - should any existing plugin be replaced, default is false
491
+ * @param doAsync - Should the add be performed asynchronously
492
+ * @param addCb - [Optional] callback to call after the plugin has been added
493
+ */
494
+ addPlugin<T extends IPlugin = ITelemetryPlugin>(plugin: T, replaceExisting?: boolean, doAsync?: boolean, addCb?: (added?: boolean) => void): void;
495
+ /**
496
+ * Returns the unique event namespace that should be used when registering events
497
+ */
498
+ evtNamespace(): string;
499
+ /**
500
+ * Add a handler that will be called when the SDK is being unloaded
501
+ * @param handler - the handler
502
+ */
503
+ addUnloadCb(handler: UnloadHandler): void;
504
+ /**
505
+ * Flush and send any batched / cached data immediately
506
+ * @param async - send data asynchronously when true (defaults to true)
507
+ * @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.
508
+ * If the caller doesn't return true the caller should assume that it may never be called.
509
+ * @param sendReason - specify the reason that you are calling "flush" defaults to ManualFlush (1) if not specified
510
+ * @param cbTimeout - An optional timeout to wait for any flush operations to complete before proceeding with the unload. Defaults to 5 seconds.
511
+ * @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
512
+ */
513
+ flush(isAsync?: boolean, callBack?: (flushComplete?: boolean) => void, sendReason?: SendRequestReason, cbTimeout?: number): boolean | void;
224
514
  }
225
515
 
226
516
  /**
@@ -304,6 +594,67 @@ declare interface IBackendResponse {
304
594
  readonly appId?: string;
305
595
  }
306
596
 
597
+ declare interface IBaseProcessingContext {
598
+ /**
599
+ * The current core instance for the request
600
+ */
601
+ core: () => IAppInsightsCore;
602
+ /**
603
+ * THe current diagnostic logger for the request
604
+ */
605
+ diagLog: () => IDiagnosticLogger;
606
+ /**
607
+ * Gets the current core config instance
608
+ */
609
+ getCfg: () => IConfiguration;
610
+ /**
611
+ * Gets the named extension config
612
+ */
613
+ getExtCfg: <T>(identifier: string, defaultValue?: T | any, mergeDefault?: GetExtCfgMergeType) => T;
614
+ /**
615
+ * Gets the named config from either the named identifier extension or core config if neither exist then the
616
+ * default value is returned
617
+ * @param identifier The named extension identifier
618
+ * @param field The config field name
619
+ * @param defaultValue The default value to return if no defined config exists
620
+ */
621
+ getConfig: (identifier: string, field: string, defaultValue?: number | string | boolean | string[] | RegExp[] | Function) => number | string | boolean | string[] | RegExp[] | Function;
622
+ /**
623
+ * Helper to allow plugins to check and possibly shortcut executing code only
624
+ * required if there is a nextPlugin
625
+ */
626
+ hasNext: () => boolean;
627
+ /**
628
+ * Returns the next configured plugin proxy
629
+ */
630
+ getNext: () => ITelemetryPluginChain;
631
+ /**
632
+ * Helper to set the next plugin proxy
633
+ */
634
+ setNext: (nextCtx: ITelemetryPluginChain) => void;
635
+ /**
636
+ * Synchronously iterate over the context chain running the callback for each plugin, once
637
+ * every plugin has been executed via the callback, any associated onComplete will be called.
638
+ * @param callback - The function call for each plugin in the context chain
639
+ */
640
+ iterate: <T extends ITelemetryPlugin = ITelemetryPlugin>(callback: (plugin: T) => void) => void;
641
+ /**
642
+ * Set the function to call when the current chain has executed all processNext or unloadNext items.
643
+ * @param onComplete - The onComplete to call
644
+ * @param that - The "this" value to use for the onComplete call, if not provided or undefined defaults to the current context
645
+ * @param args - Any additional arguments to pass to the onComplete function
646
+ */
647
+ onComplete: (onComplete: () => void, that?: any, ...args: any[]) => void;
648
+ /**
649
+ * Create a new context using the core and config from the current instance, returns a new instance of the same type
650
+ * @param plugins - The execution order to process the plugins, if null or not supplied
651
+ * then the current execution order will be copied.
652
+ * @param startAt - The plugin to start processing from, if missing from the execution
653
+ * order then the next plugin will be NOT set.
654
+ */
655
+ createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IBaseProcessingContext;
656
+ }
657
+
307
658
  /**
308
659
  * Provides data transmission capabilities
309
660
  */
@@ -317,15 +668,23 @@ declare interface IChannelControls extends ITelemetryPlugin {
317
668
  */
318
669
  resume(): void;
319
670
  /**
320
- * Tear down transmission pipeline
671
+ * Tear down the plugin and remove any hooked value, the plugin should be removed so that it is no longer initialized and
672
+ * therefore could be re-initialized after being torn down. The plugin should ensure that once this has been called any further
673
+ * processTelemetry calls are ignored and it just calls the processNext() with the provided context.
674
+ * @param unloadCtx - This is the context that should be used during unloading.
675
+ * @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.
676
+ * @returns boolean - true if the plugin has or will call processNext(), this for backward compatibility as previously teardown was synchronous and returned nothing.
321
677
  */
322
- teardown(): void;
678
+ teardown: (unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState) => void | boolean;
323
679
  /**
324
680
  * Flush to send data immediately; channel should default to sending data asynchronously
325
- * @param async: send data asynchronously when true
326
- * @param callBack: if specified, notify caller when send is complete
681
+ * @param async - send data asynchronously when true
682
+ * @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.
683
+ * If the caller doesn't return true the caller should assume that it may never be called.
684
+ * @param sendReason - specify the reason that you are calling "flush" defaults to ManualFlush (1) if not specified
685
+ * @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
327
686
  */
328
- flush(async: boolean, callBack?: () => void): void;
687
+ flush(async: boolean, callBack?: (flushComplete?: boolean) => void, sendReason?: SendRequestReason): boolean | void;
329
688
  }
330
689
 
331
690
  declare interface IChannelControlsAI extends IChannelControls {
@@ -1000,7 +1359,7 @@ declare interface ICoreUtils {
1000
1359
  * @param callback {any} - The callback function that needs to be executed for the given event
1001
1360
  * @return {boolean} - true if the handler was successfully added
1002
1361
  */
1003
- addEventHandler: (eventName: string, callback: any) => boolean;
1362
+ addEventHandler: (eventName: string, callback: any, evtNamespace?: string | string[]) => boolean;
1004
1363
  /**
1005
1364
  * 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)
1006
1365
  * https://caniuse.com/#search=Date.now
@@ -1160,6 +1519,96 @@ export declare interface IEventTelemetry extends IPartC {
1160
1519
  iKey?: string;
1161
1520
  }
1162
1521
 
1522
+ declare interface IInstrumentCallDetails {
1523
+ name: string;
1524
+ inst: any;
1525
+ /**
1526
+ * This returns an object that the hook function can use to store hook specific
1527
+ * context, it it not shared with any other hook instances and is unique for the
1528
+ * current call.
1529
+ * A hook implementation can use this to pass / share context between different
1530
+ * hook callbacks eg. request/response requst/hookErrors etc.
1531
+ */
1532
+ ctx: () => any;
1533
+ /**
1534
+ * Allows the hook functions to replace the original arguments
1535
+ * @param idx - The argument index (0 based)
1536
+ * @param value - The new value for the argument
1537
+ */
1538
+ set: (idx: number, value: any) => void;
1539
+ /**
1540
+ * The result of the original method, only populated after the original method has returned
1541
+ */
1542
+ rslt?: any;
1543
+ /**
1544
+ * The error (exception) which occurred while executing the original method
1545
+ */
1546
+ err?: Error;
1547
+ /**
1548
+ * The Event object from (window.event) at the start of the original call
1549
+ */
1550
+ evt?: Event;
1551
+ }
1552
+
1553
+ /**
1554
+ * The holder of the specific instance callback
1555
+ */
1556
+ declare interface IInstrumentHook {
1557
+ /** Unique Id for this callback on the hooked method */
1558
+ id: number;
1559
+ /** Holds the callbacks */
1560
+ cbks: IInstrumentHooksCallbacks;
1561
+ /** Remove this hook from the function */
1562
+ rm: () => void;
1563
+ }
1564
+
1565
+ /**
1566
+ * The callbacks to call for the instrumented function, you must provide at least the request and/or response callbacks, both are not required.
1567
+ * You must always supply the error callback
1568
+ */
1569
+ declare interface IInstrumentHooksCallbacks {
1570
+ /**
1571
+ * [Optional] Namespace details (same as the namespace used for events), useful for debugging and testing to
1572
+ * identify the source of the instrumented hooks
1573
+ */
1574
+ ns?: string | string[];
1575
+ /**
1576
+ * The hook callback to call before the original function is called
1577
+ */
1578
+ req?: InstrumentorHooksCallback;
1579
+ /**
1580
+ * The hook callback to call after the original function was called
1581
+ */
1582
+ rsp?: InstrumentorHooksCallback;
1583
+ /**
1584
+ * The callback to call if the hook function causes an exception
1585
+ */
1586
+ hkErr?: InstrumentorHooksCallback;
1587
+ /**
1588
+ * The callback to call if the original function causes an exception, even if you
1589
+ * supply a callback the original exception will still be thrown
1590
+ */
1591
+ fnErr?: InstrumentorHooksCallback;
1592
+ }
1593
+
1594
+ export declare interface ILoadedPlugin<T extends IPlugin> {
1595
+ plugin: T;
1596
+ /**
1597
+ * Identifies whether the plugin is enabled and can process events. This is slightly different from isInitialized as the plugin may be initialized but disabled
1598
+ * via the setEnabled() or it may be a shared plugin which has had it's teardown function called from another instance..
1599
+ * @returns boolean = true if the plugin is in a state where it is operational.
1600
+ */
1601
+ isEnabled: () => boolean;
1602
+ /**
1603
+ * You can optionally enable / disable a plugin from processing events.
1604
+ * Setting enabled to true will not necessarily cause the `isEnabled()` to also return true
1605
+ * as the plugin must also have been successfully initialized and not had it's `teardown` method called
1606
+ * (unless it's also been re-initialized)
1607
+ */
1608
+ setEnabled: (isEnabled: boolean) => void;
1609
+ remove: (isAsync?: boolean, removeCb?: (removed?: boolean) => void) => void;
1610
+ }
1611
+
1163
1612
  export declare interface IMetricTelemetry extends IPartC {
1164
1613
  /**
1165
1614
  * @description (required) - name of this metric
@@ -1278,6 +1727,12 @@ declare interface INotificationManager {
1278
1727
  perfEvent?(perfEvent: IPerfEvent): void;
1279
1728
  }
1280
1729
 
1730
+ /**
1731
+ * A callback function that will be called for the wrapped instrumentation function
1732
+ * before the original function is executed.
1733
+ */
1734
+ declare type InstrumentorHooksCallback = (funcArgs: IInstrumentCallDetails, ...orgArgs: any[]) => void;
1735
+
1281
1736
  declare class _InternalLogMessage {
1282
1737
  static dataType: string;
1283
1738
  message: string;
@@ -1288,7 +1743,7 @@ declare class _InternalLogMessage {
1288
1743
  /**
1289
1744
  * Internal message ID. Please create a new one for every conceptually different message. Please keep alphabetically ordered
1290
1745
  */
1291
- declare const _InternalMessageId: {
1746
+ export declare const _InternalMessageId: {
1292
1747
  BrowserDoesNotSupportLocalStorage: number;
1293
1748
  BrowserCannotReadLocalStorage: number;
1294
1749
  BrowserCannotReadSessionStorage: number;
@@ -1373,7 +1828,7 @@ declare const _InternalMessageId: {
1373
1828
  InMemoryStorageBufferFull: number;
1374
1829
  };
1375
1830
 
1376
- declare type _InternalMessageId = number | typeof _InternalMessageId;
1831
+ export declare type _InternalMessageId = number | _eInternalMessageId;
1377
1832
 
1378
1833
  export declare interface IPageViewPerformanceTelemetry extends IPartC {
1379
1834
  /**
@@ -1572,7 +2027,7 @@ declare interface IPerfManagerProvider {
1572
2027
  setPerfMgr(perfMgr: IPerfManager): void;
1573
2028
  }
1574
2029
 
1575
- declare interface IPlugin {
2030
+ export declare interface IPlugin {
1576
2031
  /**
1577
2032
  * Initialize plugin loaded by SDK
1578
2033
  * @param config - The config for the plugin to use
@@ -1588,10 +2043,14 @@ declare interface IPlugin {
1588
2043
  */
1589
2044
  isInitialized?: () => boolean;
1590
2045
  /**
1591
- * Tear down the plugin and remove any hooked value, the plugin should remove that it is no longer initialized and
1592
- * therefore can be re-initialized after being torn down.
2046
+ * Tear down the plugin and remove any hooked value, the plugin should be removed so that it is no longer initialized and
2047
+ * therefore could be re-initialized after being torn down. The plugin should ensure that once this has been called any further
2048
+ * processTelemetry calls are ignored and it just calls the processNext() with the provided context.
2049
+ * @param unloadCtx - This is the context that should be used during unloading.
2050
+ * @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.
2051
+ * @returns boolean - true if the plugin has or will call processNext(), this for backward compatibility as previously teardown was synchronous and returned nothing.
1593
2052
  */
1594
- teardown?: () => void;
2053
+ teardown?: (unloadCtx: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState) => void | boolean;
1595
2054
  /**
1596
2055
  * Extension name
1597
2056
  */
@@ -1606,57 +2065,63 @@ declare interface IPlugin {
1606
2065
  * The current context for the current call to processTelemetry(), used to support sharing the same plugin instance
1607
2066
  * between multiple AppInsights instances
1608
2067
  */
1609
- declare interface IProcessTelemetryContext {
1610
- /**
1611
- * The current core instance for the request
1612
- */
1613
- core: () => IAppInsightsCore;
1614
- /**
1615
- * THe current diagnostic logger for the request
1616
- */
1617
- diagLog: () => IDiagnosticLogger;
1618
- /**
1619
- * Gets the current core config instance
1620
- */
1621
- getCfg: () => IConfiguration;
2068
+ declare interface IProcessTelemetryContext extends IBaseProcessingContext {
1622
2069
  /**
1623
- * Gets the named extension config
1624
- */
1625
- getExtCfg: <T>(identifier: string, defaultValue?: T | any) => T;
1626
- /**
1627
- * Gets the named config from either the named identifier extension or core config if neither exist then the
1628
- * default value is returned
1629
- * @param identifier The named extension identifier
1630
- * @param field The config field name
1631
- * @param defaultValue The default value to return if no defined config exists
2070
+ * Call back for telemetry processing before it it is sent
2071
+ * @param env - This is the current event being reported
2072
+ * @returns boolean (true) if there is no more plugins to process otherwise false or undefined (void)
1632
2073
  */
1633
- getConfig: (identifier: string, field: string, defaultValue?: number | string | boolean) => number | string | boolean;
2074
+ processNext: (env: ITelemetryItem) => boolean | void;
1634
2075
  /**
1635
- * Helper to allow plugins to check and possibly shortcut executing code only
1636
- * required if there is a nextPlugin
2076
+ * Create a new context using the core and config from the current instance, returns a new instance of the same type
2077
+ * @param plugins - The execution order to process the plugins, if null or not supplied
2078
+ * then the current execution order will be copied.
2079
+ * @param startAt - The plugin to start processing from, if missing from the execution
2080
+ * order then the next plugin will be NOT set.
1637
2081
  */
1638
- hasNext: () => boolean;
2082
+ createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryContext;
2083
+ }
2084
+
2085
+ /**
2086
+ * The current context for the current call to teardown() implementations, used to support when plugins are being removed
2087
+ * or the SDK is being unloaded.
2088
+ */
2089
+ declare interface IProcessTelemetryUnloadContext extends IBaseProcessingContext {
1639
2090
  /**
1640
- * Returns the next configured plugin proxy
2091
+ * This Plugin has finished unloading, so unload the next one
2092
+ * @param uploadState - The state of the unload process
2093
+ * @returns boolean (true) if there is no more plugins to process otherwise false or undefined (void)
1641
2094
  */
1642
- getNext: () => ITelemetryPluginChain;
2095
+ processNext: (unloadState: ITelemetryUnloadState) => boolean | void;
1643
2096
  /**
1644
- * Helper to set the next plugin proxy
2097
+ * Create a new context using the core and config from the current instance, returns a new instance of the same type
2098
+ * @param plugins - The execution order to process the plugins, if null or not supplied
2099
+ * then the current execution order will be copied.
2100
+ * @param startAt - The plugin to start processing from, if missing from the execution
2101
+ * order then the next plugin will be NOT set.
1645
2102
  */
1646
- setNext: (nextCtx: ITelemetryPluginChain) => void;
2103
+ createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryUnloadContext;
2104
+ }
2105
+
2106
+ /**
2107
+ * The current context for the current call to the plugin update() implementations, used to support the notifications
2108
+ * for when plugins are added, removed or the configuration was changed.
2109
+ */
2110
+ declare interface IProcessTelemetryUpdateContext extends IBaseProcessingContext {
1647
2111
  /**
1648
- * Call back for telemetry processing before it it is sent
1649
- * @param env - This is the current event being reported
2112
+ * This Plugin has finished unloading, so unload the next one
2113
+ * @param updateState - The update State
2114
+ * @returns boolean (true) if there is no more plugins to process otherwise false or undefined (void)
1650
2115
  */
1651
- processNext: (env: ITelemetryItem) => void;
2116
+ processNext: (updateState: ITelemetryUpdateState) => boolean | void;
1652
2117
  /**
1653
- * Create a new context using the core and config from the current instance
2118
+ * Create a new context using the core and config from the current instance, returns a new instance of the same type
1654
2119
  * @param plugins - The execution order to process the plugins, if null or not supplied
1655
2120
  * then the current execution order will be copied.
1656
2121
  * @param startAt - The plugin to start processing from, if missing from the execution
1657
2122
  * order then the next plugin will be NOT set.
1658
2123
  */
1659
- createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryContext;
2124
+ createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryUpdateContext;
1660
2125
  }
1661
2126
 
1662
2127
  declare interface IRequestContext {
@@ -1793,11 +2258,17 @@ declare interface ISerializable {
1793
2258
  aiDataContract: any;
1794
2259
  }
1795
2260
 
2261
+ export declare function isNullOrUndefined(value: any): value is null | undefined;
2262
+
1796
2263
  declare interface IStackDetails {
1797
2264
  src: string;
1798
2265
  obj: string[];
1799
2266
  }
1800
2267
 
2268
+ declare interface ITelemetryInitializerHandler {
2269
+ remove(): void;
2270
+ }
2271
+
1801
2272
  /**
1802
2273
  * Telemety item supported in Core
1803
2274
  */
@@ -1847,15 +2318,7 @@ export declare interface ITelemetryItem {
1847
2318
  /**
1848
2319
  * Configuration provided to SDK core
1849
2320
  */
1850
- declare interface ITelemetryPlugin extends IPlugin {
1851
- /**
1852
- * Call back for telemetry processing before it it is sent
1853
- * @param env - This is the current event being reported
1854
- * @param itemCtx - This is the context for the current request, ITelemetryPlugin instances
1855
- * can optionally use this to access the current core instance or define / pass additional information
1856
- * to later plugins (vs appending items to the telemetry item)
1857
- */
1858
- processTelemetry: (env: ITelemetryItem, itemCtx?: IProcessTelemetryContext) => void;
2321
+ export declare interface ITelemetryPlugin extends ITelemetryProcessor, IPlugin {
1859
2322
  /**
1860
2323
  * Set next extension for telemetry processing, this is not optional as plugins should use the
1861
2324
  * processNext() function of the passed IProcessTelemetryContext instead. It is being kept for
@@ -1871,7 +2334,7 @@ declare interface ITelemetryPlugin extends IPlugin {
1871
2334
  /**
1872
2335
  * Configuration provided to SDK core
1873
2336
  */
1874
- declare interface ITelemetryPluginChain {
2337
+ declare interface ITelemetryPluginChain extends ITelemetryProcessor {
1875
2338
  /**
1876
2339
  * Returns the underlying plugin that is being proxied for the processTelemetry call
1877
2340
  */
@@ -1880,6 +2343,16 @@ declare interface ITelemetryPluginChain {
1880
2343
  * Returns the next plugin
1881
2344
  */
1882
2345
  getNext: () => ITelemetryPluginChain;
2346
+ /**
2347
+ * This plugin is being unloaded and should remove any hooked events and cleanup any global/scoped values, after this
2348
+ * call the plugin will be removed from the telemetry processing chain and will no longer receive any events..
2349
+ * @param unloadCtx - The unload context to use for this call.
2350
+ * @param unloadState - The details of the unload operation
2351
+ */
2352
+ unload?: (unloadCtx: IProcessTelemetryUnloadContext, unloadState: ITelemetryUnloadState) => void;
2353
+ }
2354
+
2355
+ declare interface ITelemetryProcessor {
1883
2356
  /**
1884
2357
  * Call back for telemetry processing before it it is sent
1885
2358
  * @param env - This is the current event being reported
@@ -1887,7 +2360,43 @@ declare interface ITelemetryPluginChain {
1887
2360
  * can optionally use this to access the current core instance or define / pass additional information
1888
2361
  * to later plugins (vs appending items to the telemetry item)
1889
2362
  */
1890
- processTelemetry: (env: ITelemetryItem, itemCtx: IProcessTelemetryContext) => void;
2363
+ processTelemetry: (env: ITelemetryItem, itemCtx?: IProcessTelemetryContext) => void;
2364
+ /**
2365
+ * The the plugin should re-evaluate configuration and update any cached configuration settings or
2366
+ * plugins. If implemented this method will be called whenever a plugin is added or removed and if
2367
+ * the configuration has bee updated.
2368
+ * @param updateCtx - This is the context that should be used during updating.
2369
+ * @param updateState - The details / state of the update process, it holds details like the current and previous configuration.
2370
+ * @returns boolean - true if the plugin has or will call updateCtx.processNext(), this allows the plugin to perform any asynchronous operations.
2371
+ */
2372
+ update?: (updateCtx: IProcessTelemetryUpdateContext, updateState: ITelemetryUpdateState) => void | boolean;
2373
+ }
2374
+
2375
+ declare interface ITelemetryUnloadState {
2376
+ reason: TelemetryUnloadReason;
2377
+ isAsync: boolean;
2378
+ flushComplete?: boolean;
2379
+ }
2380
+
2381
+ declare interface ITelemetryUpdateState {
2382
+ /**
2383
+ * Identifies the reason for the update notification, this is a bitwise numeric value
2384
+ */
2385
+ reason: TelemetryUpdateReason;
2386
+ /**
2387
+ * If this is a configuration update this was the previous configuration that was used
2388
+ */
2389
+ /**
2390
+ * If this is a configuration update is the new configuration that is being used
2391
+ */
2392
+ /**
2393
+ * This holds a collection of plugins that have been added (if the reason identifies that one or more plugins have been added)
2394
+ */
2395
+ added?: IPlugin[];
2396
+ /**
2397
+ * This holds a collection of plugins that have been removed (if the reason identifies that one or more plugins have been removed)
2398
+ */
2399
+ removed?: IPlugin[];
1891
2400
  }
1892
2401
 
1893
2402
  export declare interface ITraceTelemetry extends IPartC {
@@ -1911,16 +2420,21 @@ export declare interface ITraceTelemetry extends IPartC {
1911
2420
  iKey?: string;
1912
2421
  }
1913
2422
 
1914
- declare enum LoggingSeverity {
1915
- /**
1916
- * Error will be sent as internal telemetry
1917
- */
1918
- CRITICAL = 1,
1919
- /**
1920
- * Error will NOT be sent as internal telemetry, and will only be shown in browser console
1921
- */
1922
- WARNING = 2
1923
- }
2423
+ declare const LoggingSeverity: {
2424
+ CRITICAL: number;
2425
+ WARNING: number;
2426
+ };
2427
+
2428
+ declare type LoggingSeverity = number | eLoggingSeverity;
2429
+
2430
+ /**
2431
+ * Creates proxy functions on the target which internally will call the source version with all arguments passed to the target method.
2432
+ *
2433
+ * @param target - The target object to be assigned with the source properties and functions
2434
+ * @param source - The source object which will be assigned / called by setting / calling the targets proxies
2435
+ * @param functionsToProxy - An array of function names that will be proxied on the target
2436
+ */
2437
+ export declare function proxyFunctions<T, S>(target: T, source: S | (() => S), functionsToProxy: (keyof S)[], overwriteTarget?: boolean): T;
1924
2438
 
1925
2439
  export declare class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
1926
2440
  static constructEnvelope(orig: ITelemetryItem, iKey: string, logger: IDiagnosticLogger, convertUndefined?: any): IEnvelope;
@@ -1966,7 +2480,6 @@ export declare class Sender extends BaseTelemetryPlugin implements IChannelContr
1966
2480
  * Will not flush if the Send has been paused.
1967
2481
  */
1968
2482
  onunloadFlush(): void;
1969
- teardown(): void;
1970
2483
  initialize(config: IConfiguration & IConfig, core: IAppInsightsCore, extensions: IPlugin[], pluginChain?: ITelemetryPluginChain): void;
1971
2484
  processTelemetry(telemetryItem: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
1972
2485
  /**
@@ -2008,7 +2521,7 @@ declare type SenderFunction = (payload: string[], isAsync: boolean) => void;
2008
2521
  /**
2009
2522
  * The EventsDiscardedReason enumeration contains a set of values that specify the reason for discarding an event.
2010
2523
  */
2011
- declare const enum SendRequestReason {
2524
+ export declare const enum SendRequestReason {
2012
2525
  /**
2013
2526
  * No specific reason was specified
2014
2527
  */
@@ -2037,6 +2550,10 @@ declare const enum SendRequestReason {
2037
2550
  * The event(s) being sent as a retry
2038
2551
  */
2039
2552
  Retry = 5,
2553
+ /**
2554
+ * The SDK is unloading
2555
+ */
2556
+ SdkUnload = 6,
2040
2557
  /**
2041
2558
  * Maximum batch size would be exceeded
2042
2559
  */
@@ -2062,6 +2579,55 @@ declare interface Tags {
2062
2579
  [key: string]: any;
2063
2580
  }
2064
2581
 
2582
+ declare type TelemetryInitializerFunction = <T extends ITelemetryItem>(item: T) => boolean | void;
2583
+
2584
+ /**
2585
+ * The TelemetryUnloadReason enumeration contains the possible reasons for why a plugin is being unloaded / torndown().
2586
+ */
2587
+ declare const enum TelemetryUnloadReason {
2588
+ /**
2589
+ * Teardown has been called without any context.
2590
+ */
2591
+ ManualTeardown = 0,
2592
+ /**
2593
+ * Just this plugin is being removed
2594
+ */
2595
+ PluginUnload = 1,
2596
+ /**
2597
+ * This instance of the plugin is being removed and replaced
2598
+ */
2599
+ PluginReplace = 2,
2600
+ /**
2601
+ * The entire SDK is being unloaded
2602
+ */
2603
+ SdkUnload = 50
2604
+ }
2605
+
2606
+ /**
2607
+ * The TelemetryUpdateReason enumeration contains a set of bit-wise values that specify the reason for update request.
2608
+ */
2609
+ declare const enum TelemetryUpdateReason {
2610
+ /**
2611
+ * Unknown.
2612
+ */
2613
+ Unknown = 0,
2614
+ /**
2615
+ * The configuration has ben updated or changed
2616
+ */
2617
+ /**
2618
+ * One or more plugins have been added
2619
+ */
2620
+ PluginAdded = 16,
2621
+ /**
2622
+ * One or more plugins have been removed
2623
+ */
2624
+ PluginRemoved = 32
2625
+ }
2626
+
2627
+ export declare function throwError(message: string): never;
2628
+
2629
+ declare type UnloadHandler = (itemCtx: IProcessTelemetryUnloadContext, unloadState: ITelemetryUnloadState) => void;
2630
+
2065
2631
  declare interface XDomainRequest extends XMLHttpRequestEventTarget {
2066
2632
  readonly responseText: string;
2067
2633
  send(payload: string): void;