@microsoft/applicationinsights-web-basic 2.7.5-nightly.2204-03 → 2.7.6

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.2204-03
2
+ * Microsoft.ApplicationInsights, 2.7.6
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  *
5
5
  * Microsoft Application Insights Team
@@ -11,6 +11,26 @@ declare namespace ApplicationInsights {
11
11
  constructor();
12
12
  initialize(config: IConfiguration, extensions: IPlugin[], logger?: IDiagnosticLogger, notificationManager?: INotificationManager): void;
13
13
  track(telemetryItem: ITelemetryItem): void;
14
+ /**
15
+ * Adds a notification listener. The SDK calls methods on the listener when an appropriate notification is raised.
16
+ * The added plugins must raise notifications. If the plugins do not implement the notifications, then no methods will be
17
+ * called.
18
+ * @param {INotificationListener} listener - An INotificationListener object.
19
+ */
20
+ addNotificationListener(listener: INotificationListener): void;
21
+ /**
22
+ * Removes all instances of the listener.
23
+ * @param {INotificationListener} listener - INotificationListener to remove.
24
+ */
25
+ removeNotificationListener(listener: INotificationListener): void;
26
+ /**
27
+ * Periodically check logger.queue for
28
+ */
29
+ pollInternalLogs(eventName?: string): number;
30
+ /**
31
+ * Periodically check logger.queue for
32
+ */
33
+ stopPollingInternalLogs(): void;
14
34
  }
15
35
 
16
36
  /**
@@ -19,6 +39,7 @@ declare namespace ApplicationInsights {
19
39
  */
20
40
  class ApplicationInsights {
21
41
  config: IConfiguration & IConfig;
42
+ private core;
22
43
  /**
23
44
  * Creates an instance of ApplicationInsights.
24
45
  * @param {IConfiguration & IConfig} config
@@ -44,51 +65,11 @@ declare namespace ApplicationInsights {
44
65
  * @memberof ApplicationInsights
45
66
  */
46
67
  flush(async?: boolean): void;
47
- pollInternalLogs(): void;
68
+ private pollInternalLogs;
48
69
  stopPollingInternalLogs(): void;
49
- getSKUDefaults(): void;
50
- /**
51
- * Unload and Tear down the SDK and any initialized plugins, after calling this the SDK will be considered
52
- * to be un-initialized and non-operational, re-initializing the SDK should only be attempted if the previous
53
- * unload call return `true` stating that all plugins reported that they also unloaded, the recommended
54
- * approach is to create a new instance and initialize that instance.
55
- * This is due to possible unexpected side effects caused by plugins not supporting unload / teardown, unable
56
- * to successfully remove any global references or they may just be completing the unload process asynchronously.
57
- */
58
- unload(isAsync?: boolean, unloadComplete?: () => void): void;
59
- /**
60
- * Find and return the (first) plugin with the specified identifier if present
61
- * @param pluginIdentifier
62
- */
63
- getPlugin<T extends IPlugin = IPlugin>(pluginIdentifier: string): ILoadedPlugin<T>;
64
- /**
65
- * Add a new plugin to the installation
66
- * @param plugin - The new plugin to add
67
- * @param replaceExisting - should any existing plugin be replaced
68
- * @param doAsync - Should the add be performed asynchronously
69
- */
70
- addPlugin<T extends IPlugin = ITelemetryPlugin>(plugin: T, replaceExisting: boolean, doAsync: boolean, addCb?: (added?: boolean) => void): void;
71
- /**
72
- * Returns the unique event namespace that should be used
73
- */
74
- evtNamespace(): string;
75
- /**
76
- * Add an unload handler that will be called when the SDK is being unloaded
77
- * @param handler - the handler
78
- */
79
- addUnloadCb(handler: UnloadHandler): void;
70
+ private getSKUDefaults;
80
71
  }
81
72
 
82
- /**
83
- * Performs the specified action for each element in an array. This helper exists to avoid adding a polyfil for older browsers
84
- * that do not define Array.prototype.xxxx (eg. ES3 only, IE8) just in case any page checks for presence/absence of the prototype
85
- * implementation. Note: For consistency this will not use the Array.prototype.xxxx implementation if it exists as this would
86
- * cause a testing requirement to test with and without the implementations
87
- * @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
88
- * @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.
89
- */
90
- function arrForEach<T = any>(arr: T[], callbackfn: (value: T, index?: number, array?: T[]) => undefined | void | number, thisArg?: any): void;
91
-
92
73
  class BaseCore implements IAppInsightsCore {
93
74
  static defaultConfig: IConfiguration;
94
75
  config: IConfiguration;
@@ -101,18 +82,6 @@ declare namespace ApplicationInsights {
101
82
  track(telemetryItem: ITelemetryItem): void;
102
83
  getProcessTelContext(): IProcessTelemetryContext;
103
84
  getNotifyMgr(): INotificationManager;
104
- /**
105
- * Adds a notification listener. The SDK calls methods on the listener when an appropriate notification is raised.
106
- * The added plugins must raise notifications. If the plugins do not implement the notifications, then no methods will be
107
- * called.
108
- * @param {INotificationListener} listener - An INotificationListener object.
109
- */
110
- addNotificationListener(listener: INotificationListener): void;
111
- /**
112
- * Removes all instances of the listener.
113
- * @param {INotificationListener} listener - INotificationListener to remove.
114
- */
115
- removeNotificationListener(listener: INotificationListener): void;
116
85
  /**
117
86
  * Get the current cookie manager for this instance
118
87
  */
@@ -125,67 +94,7 @@ declare namespace ApplicationInsights {
125
94
  getPerfMgr(): IPerfManager;
126
95
  setPerfMgr(perfMgr: IPerfManager): void;
127
96
  eventCnt(): number;
128
- /**
129
- * Periodically check logger.queue for
130
- */
131
- pollInternalLogs(eventName?: string): number;
132
- /**
133
- * Periodically check logger.queue for
134
- */
135
- stopPollingInternalLogs(): void;
136
- /**
137
- * Add a telemetry processor to decorate or drop telemetry events.
138
- * @param telemetryInitializer - The Telemetry Initializer function
139
- * @returns - A ITelemetryInitializerHandler to enable the initializer to be removed
140
- */
141
- addTelemetryInitializer(telemetryInitializer: TelemetryInitializerFunction): ITelemetryInitializerHandler | void;
142
- /**
143
- * Unload and Tear down the SDK and any initialized plugins, after calling this the SDK will be considered
144
- * to be un-initialized and non-operational, re-initializing the SDK should only be attempted if the previous
145
- * unload call return `true` stating that all plugins reported that they also unloaded, the recommended
146
- * approach is to create a new instance and initialize that instance.
147
- * This is due to possible unexpected side effects caused by plugins not supporting unload / teardown, unable
148
- * to successfully remove any global references or they may just be completing the unload process asynchronously.
149
- * @param isAsync - Can the unload be performed asynchronously (default)
150
- * @param unloadComplete - An optional callback that will be called once the unload has completed
151
- * @param cbTimeout - An optional timeout to wait for any flush operations to complete before proceeding with the unload. Defaults to 5 seconds.
152
- */
153
- unload(isAsync?: boolean, unloadComplete?: (unloadState: ITelemetryUnloadState) => void, cbTimeout?: number): void;
154
- getPlugin<T extends IPlugin = IPlugin>(pluginIdentifier: string): ILoadedPlugin<T>;
155
- /**
156
- * Add a new plugin to the installation
157
- * @param plugin - The new plugin to add
158
- * @param replaceExisting - should any existing plugin be replaced, default is false
159
- * @param doAsync - Should the add be performed asynchronously
160
- * @param addCb - [Optional] callback to call after the plugin has been added
161
- */
162
- addPlugin<T extends IPlugin = ITelemetryPlugin>(plugin: T, replaceExisting?: boolean, doAsync?: boolean, addCb?: (added?: boolean) => void): void;
163
- /**
164
- * Returns the unique event namespace that should be used
165
- */
166
- evtNamespace(): string;
167
- /**
168
- * Add an unload handler that will be called when the SDK is being unloaded
169
- * @param handler - the handler
170
- */
171
- addUnloadCb(handler: UnloadHandler): void;
172
- /**
173
- * Flush and send any batched / cached data immediately
174
- * @param async - send data asynchronously when true (defaults to true)
175
- * @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.
176
- * If the caller doesn't return true the caller should assume that it may never be called.
177
- * @param sendReason - specify the reason that you are calling "flush" defaults to ManualFlush (1) if not specified
178
- * @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
179
- */
180
- flush(isAsync?: boolean, callBack?: (flushComplete?: boolean) => void, sendReason?: SendRequestReason): void;
181
97
  protected releaseQueue(): void;
182
- /**
183
- * Hook for Core extensions to allow them to update their own configuration before updating all of the plugins.
184
- * @param updateCtx - The plugin update context
185
- * @param updateState - The Update State
186
- * @returns boolean - True means the extension class will call updateState otherwise the Core will
187
- */
188
- protected _updateHook?(updateCtx: IProcessTelemetryUpdateContext, updateState: ITelemetryUpdateState): void | boolean;
189
98
  }
190
99
 
191
100
  /**
@@ -194,13 +103,6 @@ declare namespace ApplicationInsights {
194
103
  * implementation so that new default implementations can be added without breaking all plugins.
195
104
  */
196
105
  abstract class BaseTelemetryPlugin implements ITelemetryPlugin {
197
- identifier: string;
198
- version?: string;
199
- /**
200
- * Holds the core instance that was used during initialization
201
- */
202
- core: IAppInsightsCore;
203
- priority: number;
204
106
  /**
205
107
  * Call back for telemetry processing before it it is sent
206
108
  * @param env - This is the current event being reported
@@ -222,6 +124,13 @@ declare namespace ApplicationInsights {
222
124
  * Returns whether the plugin has been initialized
223
125
  */
224
126
  isInitialized: () => boolean;
127
+ identifier: string;
128
+ version?: string;
129
+ /**
130
+ * Holds the core instance that was used during initialization
131
+ */
132
+ core: IAppInsightsCore;
133
+ priority: number;
225
134
  /**
226
135
  * Helper to return the current IProcessTelemetryContext, if the passed argument exists this just
227
136
  * returns that value (helps with minification for callers), otherwise it will return the configured
@@ -234,51 +143,12 @@ declare namespace ApplicationInsights {
234
143
  */
235
144
  protected setInitialized: (isInitialized: boolean) => void;
236
145
  /**
237
- * Teardown / Unload hook to allow implementations to perform some additional unload operations before the BaseTelemetryPlugin
238
- * finishes it's removal.
239
- * @param unloadCtx - This is the context that should be used during unloading.
240
- * @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.
241
- * @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.
242
- * @returns boolean - true if the plugin has or will call asyncCallback, this allows the plugin to perform any asynchronous operations.
146
+ * Internal helper to initialize the instance
243
147
  */
244
- protected _doTeardown?: (unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState, asyncCallback?: () => void) => void | boolean;
245
- /**
246
- * Extension hook to allow implementations to perform some additional update operations before the BaseTelemetryPlugin finishes it's removal
247
- * @param updateCtx - This is the context that should be used during updating.
248
- * @param updateState - The details / state of the update process, it holds details like the current and previous configuration.
249
- * @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.
250
- * @returns boolean - true if the plugin has or will call asyncCallback, this allows the plugin to perform any asynchronous operations.
251
- */
252
- protected _doUpdate?: (updateCtx?: IProcessTelemetryUpdateContext, updateState?: ITelemetryUpdateState, asyncCallback?: () => void) => void | boolean;
148
+ private _baseTelInit;
253
149
  constructor();
254
150
  initialize(config: IConfiguration, core: IAppInsightsCore, extensions: IPlugin[], pluginChain?: ITelemetryPluginChain): void;
255
- /**
256
- * Tear down the plugin and remove any hooked value, the plugin should be removed so that it is no longer initialized and
257
- * therefore could be re-initialized after being torn down. The plugin should ensure that once this has been called any further
258
- * processTelemetry calls are ignored and it just calls the processNext() with the provided context.
259
- * @param unloadCtx - This is the context that should be used during unloading.
260
- * @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.
261
- * @returns boolean - true if the plugin has or will call processNext(), this for backward compatibility as previously teardown was synchronous and returned nothing.
262
- */
263
- teardown(unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState): void | boolean;
264
151
  abstract processTelemetry(env: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
265
- /**
266
- * The the plugin should re-evaluate configuration and update any cached configuration settings.
267
- * @param updateCtx - This is the context that should be used during updating.
268
- * @param updateState - The details / state of the update process, it holds details like the current and previous configuration.
269
- * @returns boolean - true if the plugin has or will call updateCtx.processNext(), this allows the plugin to perform any asynchronous operations.
270
- */
271
- update(updateCtx: IProcessTelemetryUpdateContext, updateState: ITelemetryUpdateState): void | boolean;
272
- /**
273
- * Add an unload handler that will be called when the SDK is being unloaded
274
- * @param handler - the handler
275
- */
276
- protected _addUnloadCb(handler: UnloadHandler): void;
277
- /**
278
- * Add this hook so that it is automatically removed during unloading
279
- * @param hooks - The single hook or an array of IInstrumentHook objects
280
- */
281
- protected _addHook(hooks: IInstrumentHook | IInstrumentHook[]): void;
282
152
  }
283
153
 
284
154
  /**
@@ -289,15 +159,7 @@ declare namespace ApplicationInsights {
289
159
  */
290
160
  const CoreUtils: ICoreUtils;
291
161
 
292
- const DistributedTracingModes: {
293
- AI: number;
294
- AI_AND_W3C: number;
295
- W3C: number;
296
- };
297
-
298
- type DistributedTracingModes = number | eDistributedTracingModes;
299
-
300
- const enum eDistributedTracingModes {
162
+ enum DistributedTracingModes {
301
163
  /**
302
164
  * (Default) Send Application Insights correlation headers
303
165
  */
@@ -312,108 +174,6 @@ declare namespace ApplicationInsights {
312
174
  W3C = 2
313
175
  }
314
176
 
315
- const enum _eInternalMessageId {
316
- BrowserDoesNotSupportLocalStorage = 0,
317
- BrowserCannotReadLocalStorage = 1,
318
- BrowserCannotReadSessionStorage = 2,
319
- BrowserCannotWriteLocalStorage = 3,
320
- BrowserCannotWriteSessionStorage = 4,
321
- BrowserFailedRemovalFromLocalStorage = 5,
322
- BrowserFailedRemovalFromSessionStorage = 6,
323
- CannotSendEmptyTelemetry = 7,
324
- ClientPerformanceMathError = 8,
325
- ErrorParsingAISessionCookie = 9,
326
- ErrorPVCalc = 10,
327
- ExceptionWhileLoggingError = 11,
328
- FailedAddingTelemetryToBuffer = 12,
329
- FailedMonitorAjaxAbort = 13,
330
- FailedMonitorAjaxDur = 14,
331
- FailedMonitorAjaxOpen = 15,
332
- FailedMonitorAjaxRSC = 16,
333
- FailedMonitorAjaxSend = 17,
334
- FailedMonitorAjaxGetCorrelationHeader = 18,
335
- FailedToAddHandlerForOnBeforeUnload = 19,
336
- FailedToSendQueuedTelemetry = 20,
337
- FailedToReportDataLoss = 21,
338
- FlushFailed = 22,
339
- MessageLimitPerPVExceeded = 23,
340
- MissingRequiredFieldSpecification = 24,
341
- NavigationTimingNotSupported = 25,
342
- OnError = 26,
343
- SessionRenewalDateIsZero = 27,
344
- SenderNotInitialized = 28,
345
- StartTrackEventFailed = 29,
346
- StopTrackEventFailed = 30,
347
- StartTrackFailed = 31,
348
- StopTrackFailed = 32,
349
- TelemetrySampledAndNotSent = 33,
350
- TrackEventFailed = 34,
351
- TrackExceptionFailed = 35,
352
- TrackMetricFailed = 36,
353
- TrackPVFailed = 37,
354
- TrackPVFailedCalc = 38,
355
- TrackTraceFailed = 39,
356
- TransmissionFailed = 40,
357
- FailedToSetStorageBuffer = 41,
358
- FailedToRestoreStorageBuffer = 42,
359
- InvalidBackendResponse = 43,
360
- FailedToFixDepricatedValues = 44,
361
- InvalidDurationValue = 45,
362
- TelemetryEnvelopeInvalid = 46,
363
- CreateEnvelopeError = 47,
364
- CannotSerializeObject = 48,
365
- CannotSerializeObjectNonSerializable = 49,
366
- CircularReferenceDetected = 50,
367
- ClearAuthContextFailed = 51,
368
- ExceptionTruncated = 52,
369
- IllegalCharsInName = 53,
370
- ItemNotInArray = 54,
371
- MaxAjaxPerPVExceeded = 55,
372
- MessageTruncated = 56,
373
- NameTooLong = 57,
374
- SampleRateOutOfRange = 58,
375
- SetAuthContextFailed = 59,
376
- SetAuthContextFailedAccountName = 60,
377
- StringValueTooLong = 61,
378
- StartCalledMoreThanOnce = 62,
379
- StopCalledWithoutStart = 63,
380
- TelemetryInitializerFailed = 64,
381
- TrackArgumentsNotSpecified = 65,
382
- UrlTooLong = 66,
383
- SessionStorageBufferFull = 67,
384
- CannotAccessCookie = 68,
385
- IdTooLong = 69,
386
- InvalidEvent = 70,
387
- FailedMonitorAjaxSetRequestHeader = 71,
388
- SendBrowserInfoOnUserInit = 72,
389
- PluginException = 73,
390
- NotificationException = 74,
391
- SnippetScriptLoadFailure = 99,
392
- InvalidInstrumentationKey = 100,
393
- CannotParseAiBlobValue = 101,
394
- InvalidContentBlob = 102,
395
- TrackPageActionEventFailed = 103,
396
- FailedAddingCustomDefinedRequestContext = 104,
397
- InMemoryStorageBufferFull = 105
398
- }
399
-
400
- const enum eLoggingSeverity {
401
- /**
402
- * Error will be sent as internal telemetry
403
- */
404
- CRITICAL = 1,
405
- /**
406
- * Error will NOT be sent as internal telemetry, and will only be shown in browser console
407
- */
408
- WARNING = 2
409
- }
410
-
411
- const enum GetExtCfgMergeType {
412
- None = 0,
413
- MergeDefaultOnly = 1,
414
- MergeDefaultFromRootOrDefault = 2
415
- }
416
-
417
177
  interface IAppInsightsCore extends IPerfManagerProvider {
418
178
  config: IConfiguration;
419
179
  logger: IDiagnosticLogger;
@@ -449,62 +209,12 @@ declare namespace ApplicationInsights {
449
209
  * @param {INotificationListener} listener - INotificationListener to remove.
450
210
  */
451
211
  removeNotificationListener?(listener: INotificationListener): void;
452
- /**
453
- * Add a telemetry processor to decorate or drop telemetry events.
454
- * @param telemetryInitializer - The Telemetry Initializer function
455
- * @returns - A ITelemetryInitializerHandler to enable the initializer to be removed
456
- */
457
- addTelemetryInitializer(telemetryInitializer: TelemetryInitializerFunction): ITelemetryInitializerHandler | void;
458
212
  pollInternalLogs?(eventName?: string): number;
459
213
  stopPollingInternalLogs?(): void;
460
214
  /**
461
215
  * Return a new instance of the IProcessTelemetryContext for processing events
462
216
  */
463
217
  getProcessTelContext(): IProcessTelemetryContext;
464
- /**
465
- * Unload and Tear down the SDK and any initialized plugins, after calling this the SDK will be considered
466
- * to be un-initialized and non-operational, re-initializing the SDK should only be attempted if the previous
467
- * unload call return `true` stating that all plugins reported that they also unloaded, the recommended
468
- * approach is to create a new instance and initialize that instance.
469
- * This is due to possible unexpected side effects caused by plugins not supporting unload / teardown, unable
470
- * to successfully remove any global references or they may just be completing the unload process asynchronously.
471
- * @param isAsync - Can the unload be performed asynchronously (default)
472
- * @param unloadComplete - An optional callback that will be called once the unload has completed
473
- * @param cbTimeout - An optional timeout to wait for any flush operations to complete before proceeding with the unload. Defaults to 5 seconds.
474
- */
475
- unload(isAsync?: boolean, unloadComplete?: (unloadState: ITelemetryUnloadState) => void, cbTimeout?: number): void;
476
- /**
477
- * Find and return the (first) plugin with the specified identifier if present
478
- * @param pluginIdentifier
479
- */
480
- getPlugin<T extends IPlugin = IPlugin>(pluginIdentifier: string): ILoadedPlugin<T>;
481
- /**
482
- * Add a new plugin to the installation
483
- * @param plugin - The new plugin to add
484
- * @param replaceExisting - should any existing plugin be replaced, default is false
485
- * @param doAsync - Should the add be performed asynchronously
486
- * @param addCb - [Optional] callback to call after the plugin has been added
487
- */
488
- addPlugin<T extends IPlugin = ITelemetryPlugin>(plugin: T, replaceExisting?: boolean, doAsync?: boolean, addCb?: (added?: boolean) => void): void;
489
- /**
490
- * Returns the unique event namespace that should be used when registering events
491
- */
492
- evtNamespace(): string;
493
- /**
494
- * Add a handler that will be called when the SDK is being unloaded
495
- * @param handler - the handler
496
- */
497
- addUnloadCb(handler: UnloadHandler): void;
498
- /**
499
- * Flush and send any batched / cached data immediately
500
- * @param async - send data asynchronously when true (defaults to true)
501
- * @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.
502
- * If the caller doesn't return true the caller should assume that it may never be called.
503
- * @param sendReason - specify the reason that you are calling "flush" defaults to ManualFlush (1) if not specified
504
- * @param cbTimeout - An optional timeout to wait for any flush operations to complete before proceeding with the unload. Defaults to 5 seconds.
505
- * @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
506
- */
507
- flush(isAsync?: boolean, callBack?: (flushComplete?: boolean) => void, sendReason?: SendRequestReason, cbTimeout?: number): boolean | void;
508
218
  }
509
219
 
510
220
  /**
@@ -588,67 +298,6 @@ declare namespace ApplicationInsights {
588
298
  readonly appId?: string;
589
299
  }
590
300
 
591
- interface IBaseProcessingContext {
592
- /**
593
- * The current core instance for the request
594
- */
595
- core: () => IAppInsightsCore;
596
- /**
597
- * THe current diagnostic logger for the request
598
- */
599
- diagLog: () => IDiagnosticLogger;
600
- /**
601
- * Gets the current core config instance
602
- */
603
- getCfg: () => IConfiguration;
604
- /**
605
- * Gets the named extension config
606
- */
607
- getExtCfg: <T>(identifier: string, defaultValue?: T | any, mergeDefault?: GetExtCfgMergeType) => T;
608
- /**
609
- * Gets the named config from either the named identifier extension or core config if neither exist then the
610
- * default value is returned
611
- * @param identifier The named extension identifier
612
- * @param field The config field name
613
- * @param defaultValue The default value to return if no defined config exists
614
- */
615
- getConfig: (identifier: string, field: string, defaultValue?: number | string | boolean | string[] | RegExp[] | Function) => number | string | boolean | string[] | RegExp[] | Function;
616
- /**
617
- * Helper to allow plugins to check and possibly shortcut executing code only
618
- * required if there is a nextPlugin
619
- */
620
- hasNext: () => boolean;
621
- /**
622
- * Returns the next configured plugin proxy
623
- */
624
- getNext: () => ITelemetryPluginChain;
625
- /**
626
- * Helper to set the next plugin proxy
627
- */
628
- setNext: (nextCtx: ITelemetryPluginChain) => void;
629
- /**
630
- * Synchronously iterate over the context chain running the callback for each plugin, once
631
- * every plugin has been executed via the callback, any associated onComplete will be called.
632
- * @param callback - The function call for each plugin in the context chain
633
- */
634
- iterate: <T extends ITelemetryPlugin = ITelemetryPlugin>(callback: (plugin: T) => void) => void;
635
- /**
636
- * Set the function to call when the current chain has executed all processNext or unloadNext items.
637
- * @param onComplete - The onComplete to call
638
- * @param that - The "this" value to use for the onComplete call, if not provided or undefined defaults to the current context
639
- * @param args - Any additional arguments to pass to the onComplete function
640
- */
641
- onComplete: (onComplete: () => void, that?: any, ...args: any[]) => void;
642
- /**
643
- * Create a new context using the core and config from the current instance, returns a new instance of the same type
644
- * @param plugins - The execution order to process the plugins, if null or not supplied
645
- * then the current execution order will be copied.
646
- * @param startAt - The plugin to start processing from, if missing from the execution
647
- * order then the next plugin will be NOT set.
648
- */
649
- createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IBaseProcessingContext;
650
- }
651
-
652
301
  /**
653
302
  * Provides data transmission capabilities
654
303
  */
@@ -662,23 +311,15 @@ declare namespace ApplicationInsights {
662
311
  */
663
312
  resume(): void;
664
313
  /**
665
- * Tear down the plugin and remove any hooked value, the plugin should be removed so that it is no longer initialized and
666
- * therefore could be re-initialized after being torn down. The plugin should ensure that once this has been called any further
667
- * processTelemetry calls are ignored and it just calls the processNext() with the provided context.
668
- * @param unloadCtx - This is the context that should be used during unloading.
669
- * @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.
670
- * @returns boolean - true if the plugin has or will call processNext(), this for backward compatibility as previously teardown was synchronous and returned nothing.
314
+ * Tear down transmission pipeline
671
315
  */
672
- teardown: (unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState) => void | boolean;
316
+ teardown(): void;
673
317
  /**
674
318
  * Flush to send data immediately; channel should default to sending data asynchronously
675
- * @param async - send data asynchronously when true
676
- * @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.
677
- * If the caller doesn't return true the caller should assume that it may never be called.
678
- * @param sendReason - specify the reason that you are calling "flush" defaults to ManualFlush (1) if not specified
679
- * @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
319
+ * @param async: send data asynchronously when true
320
+ * @param callBack: if specified, notify caller when send is complete
680
321
  */
681
- flush(async: boolean, callBack?: (flushComplete?: boolean) => void, sendReason?: SendRequestReason): boolean | void;
322
+ flush(async: boolean, callBack?: () => void): void;
682
323
  }
683
324
 
684
325
  interface IChannelControlsAI extends IChannelControls {
@@ -1353,7 +994,7 @@ declare namespace ApplicationInsights {
1353
994
  * @param callback {any} - The callback function that needs to be executed for the given event
1354
995
  * @return {boolean} - true if the handler was successfully added
1355
996
  */
1356
- addEventHandler: (eventName: string, callback: any, evtNamespace?: string | string[]) => boolean;
997
+ addEventHandler: (eventName: string, callback: any) => boolean;
1357
998
  /**
1358
999
  * 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)
1359
1000
  * https://caniuse.com/#search=Date.now
@@ -1513,96 +1154,6 @@ declare namespace ApplicationInsights {
1513
1154
  iKey?: string;
1514
1155
  }
1515
1156
 
1516
- interface IInstrumentCallDetails {
1517
- name: string;
1518
- inst: any;
1519
- /**
1520
- * This returns an object that the hook function can use to store hook specific
1521
- * context, it it not shared with any other hook instances and is unique for the
1522
- * current call.
1523
- * A hook implementation can use this to pass / share context between different
1524
- * hook callbacks eg. request/response requst/hookErrors etc.
1525
- */
1526
- ctx: () => any;
1527
- /**
1528
- * Allows the hook functions to replace the original arguments
1529
- * @param idx - The argument index (0 based)
1530
- * @param value - The new value for the argument
1531
- */
1532
- set: (idx: number, value: any) => void;
1533
- /**
1534
- * The result of the original method, only populated after the original method has returned
1535
- */
1536
- rslt?: any;
1537
- /**
1538
- * The error (exception) which occurred while executing the original method
1539
- */
1540
- err?: Error;
1541
- /**
1542
- * The Event object from (window.event) at the start of the original call
1543
- */
1544
- evt?: Event;
1545
- }
1546
-
1547
- /**
1548
- * The holder of the specific instance callback
1549
- */
1550
- interface IInstrumentHook {
1551
- /** Unique Id for this callback on the hooked method */
1552
- id: number;
1553
- /** Holds the callbacks */
1554
- cbks: IInstrumentHooksCallbacks;
1555
- /** Remove this hook from the function */
1556
- rm: () => void;
1557
- }
1558
-
1559
- /**
1560
- * The callbacks to call for the instrumented function, you must provide at least the request and/or response callbacks, both are not required.
1561
- * You must always supply the error callback
1562
- */
1563
- interface IInstrumentHooksCallbacks {
1564
- /**
1565
- * [Optional] Namespace details (same as the namespace used for events), useful for debugging and testing to
1566
- * identify the source of the instrumented hooks
1567
- */
1568
- ns?: string | string[];
1569
- /**
1570
- * The hook callback to call before the original function is called
1571
- */
1572
- req?: InstrumentorHooksCallback;
1573
- /**
1574
- * The hook callback to call after the original function was called
1575
- */
1576
- rsp?: InstrumentorHooksCallback;
1577
- /**
1578
- * The callback to call if the hook function causes an exception
1579
- */
1580
- hkErr?: InstrumentorHooksCallback;
1581
- /**
1582
- * The callback to call if the original function causes an exception, even if you
1583
- * supply a callback the original exception will still be thrown
1584
- */
1585
- fnErr?: InstrumentorHooksCallback;
1586
- }
1587
-
1588
- interface ILoadedPlugin<T extends IPlugin> {
1589
- plugin: T;
1590
- /**
1591
- * Identifies whether the plugin is enabled and can process events. This is slightly different from isInitialized as the plugin may be initialized but disabled
1592
- * via the setEnabled() or it may be a shared plugin which has had it's teardown function called from another instance..
1593
- * @returns boolean = true if the plugin is in a state where it is operational.
1594
- */
1595
- isEnabled: () => boolean;
1596
- /**
1597
- * You can optionally enable / disable a plugin from processing events.
1598
- * Setting enabled to true will not necessarily cause the `isEnabled()` to also return true
1599
- * as the plugin must also have been successfully initialized and not had it's `teardown` method called
1600
- * (unless it's also been re-initialized)
1601
- */
1602
- setEnabled: (isEnabled: boolean) => void;
1603
- remove: (isAsync?: boolean, removeCb?: (removed?: boolean) => void) => void;
1604
- }
1605
-
1606
1157
  interface IMetricTelemetry extends IPartC {
1607
1158
  /**
1608
1159
  * @description (required) - name of this metric
@@ -1721,12 +1272,6 @@ declare namespace ApplicationInsights {
1721
1272
  perfEvent?(perfEvent: IPerfEvent): void;
1722
1273
  }
1723
1274
 
1724
- /**
1725
- * A callback function that will be called for the wrapped instrumentation function
1726
- * before the original function is executed.
1727
- */
1728
- type InstrumentorHooksCallback = (funcArgs: IInstrumentCallDetails, ...orgArgs: any[]) => void;
1729
-
1730
1275
  class _InternalLogMessage {
1731
1276
  static dataType: string;
1732
1277
  message: string;
@@ -1822,7 +1367,7 @@ declare namespace ApplicationInsights {
1822
1367
  InMemoryStorageBufferFull: number;
1823
1368
  };
1824
1369
 
1825
- type _InternalMessageId = number | _eInternalMessageId;
1370
+ type _InternalMessageId = number | typeof _InternalMessageId;
1826
1371
 
1827
1372
  interface IPageViewPerformanceTelemetry extends IPartC {
1828
1373
  /**
@@ -2037,14 +1582,10 @@ declare namespace ApplicationInsights {
2037
1582
  */
2038
1583
  isInitialized?: () => boolean;
2039
1584
  /**
2040
- * Tear down the plugin and remove any hooked value, the plugin should be removed so that it is no longer initialized and
2041
- * therefore could be re-initialized after being torn down. The plugin should ensure that once this has been called any further
2042
- * processTelemetry calls are ignored and it just calls the processNext() with the provided context.
2043
- * @param unloadCtx - This is the context that should be used during unloading.
2044
- * @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.
2045
- * @returns boolean - true if the plugin has or will call processNext(), this for backward compatibility as previously teardown was synchronous and returned nothing.
1585
+ * Tear down the plugin and remove any hooked value, the plugin should remove that it is no longer initialized and
1586
+ * therefore can be re-initialized after being torn down.
2046
1587
  */
2047
- teardown?: (unloadCtx: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState) => void | boolean;
1588
+ teardown?: () => void;
2048
1589
  /**
2049
1590
  * Extension name
2050
1591
  */
@@ -2059,63 +1600,57 @@ declare namespace ApplicationInsights {
2059
1600
  * The current context for the current call to processTelemetry(), used to support sharing the same plugin instance
2060
1601
  * between multiple AppInsights instances
2061
1602
  */
2062
- interface IProcessTelemetryContext extends IBaseProcessingContext {
1603
+ interface IProcessTelemetryContext {
2063
1604
  /**
2064
- * Call back for telemetry processing before it it is sent
2065
- * @param env - This is the current event being reported
2066
- * @returns boolean (true) if there is no more plugins to process otherwise false or undefined (void)
1605
+ * The current core instance for the request
2067
1606
  */
2068
- processNext: (env: ITelemetryItem) => boolean | void;
1607
+ core: () => IAppInsightsCore;
2069
1608
  /**
2070
- * Create a new context using the core and config from the current instance, returns a new instance of the same type
2071
- * @param plugins - The execution order to process the plugins, if null or not supplied
2072
- * then the current execution order will be copied.
2073
- * @param startAt - The plugin to start processing from, if missing from the execution
2074
- * order then the next plugin will be NOT set.
1609
+ * THe current diagnostic logger for the request
2075
1610
  */
2076
- createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryContext;
2077
- }
2078
-
2079
- /**
2080
- * The current context for the current call to teardown() implementations, used to support when plugins are being removed
2081
- * or the SDK is being unloaded.
2082
- */
2083
- interface IProcessTelemetryUnloadContext extends IBaseProcessingContext {
1611
+ diagLog: () => IDiagnosticLogger;
2084
1612
  /**
2085
- * This Plugin has finished unloading, so unload the next one
2086
- * @param uploadState - The state of the unload process
2087
- * @returns boolean (true) if there is no more plugins to process otherwise false or undefined (void)
1613
+ * Gets the current core config instance
2088
1614
  */
2089
- processNext: (unloadState: ITelemetryUnloadState) => boolean | void;
1615
+ getCfg: () => IConfiguration;
2090
1616
  /**
2091
- * Create a new context using the core and config from the current instance, returns a new instance of the same type
2092
- * @param plugins - The execution order to process the plugins, if null or not supplied
2093
- * then the current execution order will be copied.
2094
- * @param startAt - The plugin to start processing from, if missing from the execution
2095
- * order then the next plugin will be NOT set.
1617
+ * Gets the named extension config
2096
1618
  */
2097
- createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryUnloadContext;
2098
- }
2099
-
2100
- /**
2101
- * The current context for the current call to the plugin update() implementations, used to support the notifications
2102
- * for when plugins are added, removed or the configuration was changed.
2103
- */
2104
- interface IProcessTelemetryUpdateContext extends IBaseProcessingContext {
1619
+ getExtCfg: <T>(identifier: string, defaultValue?: T | any) => T;
2105
1620
  /**
2106
- * This Plugin has finished unloading, so unload the next one
2107
- * @param updateState - The update State
2108
- * @returns boolean (true) if there is no more plugins to process otherwise false or undefined (void)
1621
+ * Gets the named config from either the named identifier extension or core config if neither exist then the
1622
+ * default value is returned
1623
+ * @param identifier The named extension identifier
1624
+ * @param field The config field name
1625
+ * @param defaultValue The default value to return if no defined config exists
2109
1626
  */
2110
- processNext: (updateState: ITelemetryUpdateState) => boolean | void;
1627
+ getConfig: (identifier: string, field: string, defaultValue?: number | string | boolean) => number | string | boolean;
2111
1628
  /**
2112
- * Create a new context using the core and config from the current instance, returns a new instance of the same type
1629
+ * Helper to allow plugins to check and possibly shortcut executing code only
1630
+ * required if there is a nextPlugin
1631
+ */
1632
+ hasNext: () => boolean;
1633
+ /**
1634
+ * Returns the next configured plugin proxy
1635
+ */
1636
+ getNext: () => ITelemetryPluginChain;
1637
+ /**
1638
+ * Helper to set the next plugin proxy
1639
+ */
1640
+ setNext: (nextCtx: ITelemetryPluginChain) => void;
1641
+ /**
1642
+ * Call back for telemetry processing before it it is sent
1643
+ * @param env - This is the current event being reported
1644
+ */
1645
+ processNext: (env: ITelemetryItem) => void;
1646
+ /**
1647
+ * Create a new context using the core and config from the current instance
2113
1648
  * @param plugins - The execution order to process the plugins, if null or not supplied
2114
1649
  * then the current execution order will be copied.
2115
1650
  * @param startAt - The plugin to start processing from, if missing from the execution
2116
1651
  * order then the next plugin will be NOT set.
2117
1652
  */
2118
- createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryUpdateContext;
1653
+ createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryContext;
2119
1654
  }
2120
1655
 
2121
1656
  interface IRequestContext {
@@ -2252,17 +1787,11 @@ declare namespace ApplicationInsights {
2252
1787
  aiDataContract: any;
2253
1788
  }
2254
1789
 
2255
- function isNullOrUndefined(value: any): value is null | undefined;
2256
-
2257
1790
  interface IStackDetails {
2258
1791
  src: string;
2259
1792
  obj: string[];
2260
1793
  }
2261
1794
 
2262
- interface ITelemetryInitializerHandler {
2263
- remove(): void;
2264
- }
2265
-
2266
1795
  /**
2267
1796
  * Telemety item supported in Core
2268
1797
  */
@@ -2312,7 +1841,15 @@ declare namespace ApplicationInsights {
2312
1841
  /**
2313
1842
  * Configuration provided to SDK core
2314
1843
  */
2315
- interface ITelemetryPlugin extends ITelemetryProcessor, IPlugin {
1844
+ interface ITelemetryPlugin extends IPlugin {
1845
+ /**
1846
+ * Call back for telemetry processing before it it is sent
1847
+ * @param env - This is the current event being reported
1848
+ * @param itemCtx - This is the context for the current request, ITelemetryPlugin instances
1849
+ * can optionally use this to access the current core instance or define / pass additional information
1850
+ * to later plugins (vs appending items to the telemetry item)
1851
+ */
1852
+ processTelemetry: (env: ITelemetryItem, itemCtx?: IProcessTelemetryContext) => void;
2316
1853
  /**
2317
1854
  * Set next extension for telemetry processing, this is not optional as plugins should use the
2318
1855
  * processNext() function of the passed IProcessTelemetryContext instead. It is being kept for
@@ -2328,7 +1865,7 @@ declare namespace ApplicationInsights {
2328
1865
  /**
2329
1866
  * Configuration provided to SDK core
2330
1867
  */
2331
- interface ITelemetryPluginChain extends ITelemetryProcessor {
1868
+ interface ITelemetryPluginChain {
2332
1869
  /**
2333
1870
  * Returns the underlying plugin that is being proxied for the processTelemetry call
2334
1871
  */
@@ -2337,16 +1874,6 @@ declare namespace ApplicationInsights {
2337
1874
  * Returns the next plugin
2338
1875
  */
2339
1876
  getNext: () => ITelemetryPluginChain;
2340
- /**
2341
- * This plugin is being unloaded and should remove any hooked events and cleanup any global/scoped values, after this
2342
- * call the plugin will be removed from the telemetry processing chain and will no longer receive any events..
2343
- * @param unloadCtx - The unload context to use for this call.
2344
- * @param unloadState - The details of the unload operation
2345
- */
2346
- unload?: (unloadCtx: IProcessTelemetryUnloadContext, unloadState: ITelemetryUnloadState) => void;
2347
- }
2348
-
2349
- interface ITelemetryProcessor {
2350
1877
  /**
2351
1878
  * Call back for telemetry processing before it it is sent
2352
1879
  * @param env - This is the current event being reported
@@ -2354,43 +1881,7 @@ declare namespace ApplicationInsights {
2354
1881
  * can optionally use this to access the current core instance or define / pass additional information
2355
1882
  * to later plugins (vs appending items to the telemetry item)
2356
1883
  */
2357
- processTelemetry: (env: ITelemetryItem, itemCtx?: IProcessTelemetryContext) => void;
2358
- /**
2359
- * The the plugin should re-evaluate configuration and update any cached configuration settings or
2360
- * plugins. If implemented this method will be called whenever a plugin is added or removed and if
2361
- * the configuration has bee updated.
2362
- * @param updateCtx - This is the context that should be used during updating.
2363
- * @param updateState - The details / state of the update process, it holds details like the current and previous configuration.
2364
- * @returns boolean - true if the plugin has or will call updateCtx.processNext(), this allows the plugin to perform any asynchronous operations.
2365
- */
2366
- update?: (updateCtx: IProcessTelemetryUpdateContext, updateState: ITelemetryUpdateState) => void | boolean;
2367
- }
2368
-
2369
- interface ITelemetryUnloadState {
2370
- reason: TelemetryUnloadReason;
2371
- isAsync: boolean;
2372
- flushComplete?: boolean;
2373
- }
2374
-
2375
- interface ITelemetryUpdateState {
2376
- /**
2377
- * Identifies the reason for the update notification, this is a bitwise numeric value
2378
- */
2379
- reason: TelemetryUpdateReason;
2380
- /**
2381
- * If this is a configuration update this was the previous configuration that was used
2382
- */
2383
- /**
2384
- * If this is a configuration update is the new configuration that is being used
2385
- */
2386
- /**
2387
- * This holds a collection of plugins that have been added (if the reason identifies that one or more plugins have been added)
2388
- */
2389
- added?: IPlugin[];
2390
- /**
2391
- * This holds a collection of plugins that have been removed (if the reason identifies that one or more plugins have been removed)
2392
- */
2393
- removed?: IPlugin[];
1884
+ processTelemetry: (env: ITelemetryItem, itemCtx: IProcessTelemetryContext) => void;
2394
1885
  }
2395
1886
 
2396
1887
  interface ITraceTelemetry extends IPartC {
@@ -2414,21 +1905,16 @@ declare namespace ApplicationInsights {
2414
1905
  iKey?: string;
2415
1906
  }
2416
1907
 
2417
- const LoggingSeverity: {
2418
- CRITICAL: number;
2419
- WARNING: number;
2420
- };
2421
-
2422
- type LoggingSeverity = number | eLoggingSeverity;
2423
-
2424
- /**
2425
- * Creates proxy functions on the target which internally will call the source version with all arguments passed to the target method.
2426
- *
2427
- * @param target - The target object to be assigned with the source properties and functions
2428
- * @param source - The source object which will be assigned / called by setting / calling the targets proxies
2429
- * @param functionsToProxy - An array of function names that will be proxied on the target
2430
- */
2431
- function proxyFunctions<T, S>(target: T, source: S | (() => S), functionsToProxy: (keyof S)[], overwriteTarget?: boolean): T;
1908
+ enum LoggingSeverity {
1909
+ /**
1910
+ * Error will be sent as internal telemetry
1911
+ */
1912
+ CRITICAL = 1,
1913
+ /**
1914
+ * Error will NOT be sent as internal telemetry, and will only be shown in browser console
1915
+ */
1916
+ WARNING = 2
1917
+ }
2432
1918
 
2433
1919
  class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
2434
1920
  static constructEnvelope(orig: ITelemetryItem, iKey: string, logger: IDiagnosticLogger, convertUndefined?: any): IEnvelope;
@@ -2474,6 +1960,7 @@ declare namespace ApplicationInsights {
2474
1960
  * Will not flush if the Send has been paused.
2475
1961
  */
2476
1962
  onunloadFlush(): void;
1963
+ teardown(): void;
2477
1964
  initialize(config: IConfiguration & IConfig, core: IAppInsightsCore, extensions: IPlugin[], pluginChain?: ITelemetryPluginChain): void;
2478
1965
  processTelemetry(telemetryItem: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
2479
1966
  /**
@@ -2544,10 +2031,6 @@ declare namespace ApplicationInsights {
2544
2031
  * The event(s) being sent as a retry
2545
2032
  */
2546
2033
  Retry = 5,
2547
- /**
2548
- * The SDK is unloading
2549
- */
2550
- SdkUnload = 6,
2551
2034
  /**
2552
2035
  * Maximum batch size would be exceeded
2553
2036
  */
@@ -2573,55 +2056,6 @@ declare namespace ApplicationInsights {
2573
2056
  [key: string]: any;
2574
2057
  }
2575
2058
 
2576
- type TelemetryInitializerFunction = <T extends ITelemetryItem>(item: T) => boolean | void;
2577
-
2578
- /**
2579
- * The TelemetryUnloadReason enumeration contains the possible reasons for why a plugin is being unloaded / torndown().
2580
- */
2581
- const enum TelemetryUnloadReason {
2582
- /**
2583
- * Teardown has been called without any context.
2584
- */
2585
- ManualTeardown = 0,
2586
- /**
2587
- * Just this plugin is being removed
2588
- */
2589
- PluginUnload = 1,
2590
- /**
2591
- * This instance of the plugin is being removed and replaced
2592
- */
2593
- PluginReplace = 2,
2594
- /**
2595
- * The entire SDK is being unloaded
2596
- */
2597
- SdkUnload = 50
2598
- }
2599
-
2600
- /**
2601
- * The TelemetryUpdateReason enumeration contains a set of bit-wise values that specify the reason for update request.
2602
- */
2603
- const enum TelemetryUpdateReason {
2604
- /**
2605
- * Unknown.
2606
- */
2607
- Unknown = 0,
2608
- /**
2609
- * The configuration has ben updated or changed
2610
- */
2611
- /**
2612
- * One or more plugins have been added
2613
- */
2614
- PluginAdded = 16,
2615
- /**
2616
- * One or more plugins have been removed
2617
- */
2618
- PluginRemoved = 32
2619
- }
2620
-
2621
- function throwError(message: string): never;
2622
-
2623
- type UnloadHandler = (itemCtx: IProcessTelemetryUnloadContext, unloadState: ITelemetryUnloadState) => void;
2624
-
2625
2059
  interface XDomainRequest extends XMLHttpRequestEventTarget {
2626
2060
  readonly responseText: string;
2627
2061
  send(payload: string): void;