@microsoft/applicationinsights-web-basic 3.0.7 → 3.0.9

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.
Files changed (45) hide show
  1. package/browser/es5/{aib.3.0.7.gbl.js → aib.3.0.9.cjs.js} +379 -336
  2. package/browser/es5/aib.3.0.9.cjs.js.map +1 -0
  3. package/browser/es5/aib.3.0.9.cjs.min.js +6 -0
  4. package/browser/es5/aib.3.0.9.cjs.min.js.map +1 -0
  5. package/browser/es5/{aib.3.0.7.cjs.js → aib.3.0.9.gbl.js} +402 -313
  6. package/browser/es5/aib.3.0.9.gbl.js.map +1 -0
  7. package/browser/es5/aib.3.0.9.gbl.min.js +6 -0
  8. package/browser/es5/aib.3.0.9.gbl.min.js.map +1 -0
  9. package/browser/es5/aib.3.0.9.integrity.json +66 -0
  10. package/browser/es5/{aib.3.0.7.js → aib.3.0.9.js} +381 -315
  11. package/browser/es5/aib.3.0.9.js.map +1 -0
  12. package/browser/es5/aib.3.0.9.min.js +6 -0
  13. package/browser/es5/aib.3.0.9.min.js.map +1 -0
  14. package/browser/es5/aib.3.cjs.js +378 -312
  15. package/browser/es5/aib.3.cjs.js.map +1 -1
  16. package/browser/es5/aib.3.cjs.min.js +2 -2
  17. package/browser/es5/aib.3.cjs.min.js.map +1 -1
  18. package/browser/es5/aib.3.gbl.js +380 -314
  19. package/browser/es5/aib.3.gbl.js.map +1 -1
  20. package/browser/es5/aib.3.gbl.min.js +2 -2
  21. package/browser/es5/aib.3.gbl.min.js.map +1 -1
  22. package/browser/es5/aib.3.integrity.json +25 -25
  23. package/browser/es5/aib.3.js +380 -314
  24. package/browser/es5/aib.3.js.map +1 -1
  25. package/browser/es5/aib.3.min.js +2 -2
  26. package/browser/es5/aib.3.min.js.map +1 -1
  27. package/dist/es5/applicationinsights-web-basic.js +378 -312
  28. package/dist/es5/applicationinsights-web-basic.js.map +1 -1
  29. package/dist/es5/applicationinsights-web-basic.min.js +2 -2
  30. package/dist/es5/applicationinsights-web-basic.min.js.map +1 -1
  31. package/dist-es5/__DynamicConstants.js +1 -1
  32. package/dist-es5/index.js +1 -1
  33. package/package.json +70 -67
  34. package/types/applicationinsights-web-basic.d.ts +26 -2
  35. package/types/applicationinsights-web-basic.namespaced.d.ts +3287 -57
  36. package/browser/es5/aib.3.0.7.cjs.js.map +0 -1
  37. package/browser/es5/aib.3.0.7.cjs.min.js +0 -6
  38. package/browser/es5/aib.3.0.7.cjs.min.js.map +0 -1
  39. package/browser/es5/aib.3.0.7.gbl.js.map +0 -1
  40. package/browser/es5/aib.3.0.7.gbl.min.js +0 -6
  41. package/browser/es5/aib.3.0.7.gbl.min.js.map +0 -1
  42. package/browser/es5/aib.3.0.7.integrity.json +0 -66
  43. package/browser/es5/aib.3.0.7.js.map +0 -1
  44. package/browser/es5/aib.3.0.7.min.js +0 -6
  45. package/browser/es5/aib.3.0.7.min.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Microsoft.ApplicationInsights, 3.0.7
2
+ * Microsoft.ApplicationInsights, 3.0.9
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  *
5
5
  * Microsoft Application Insights Team
@@ -7,38 +7,159 @@
7
7
  */
8
8
 
9
9
  declare namespace ApplicationInsights {
10
- import { AppInsightsCore } from '@microsoft/applicationinsights-core-js';
11
- import { arrForEach } from '@microsoft/applicationinsights-core-js';
12
- import { _eInternalMessageId } from '@microsoft/applicationinsights-core-js';
13
- import { eSeverityLevel } from '@microsoft/applicationinsights-common';
14
- import { IAppInsightsCore } from '@microsoft/applicationinsights-core-js';
15
- import { IAutoExceptionTelemetry } from '@microsoft/applicationinsights-common';
16
- import { IConfig } from '@microsoft/applicationinsights-common';
17
- import { IConfiguration } from '@microsoft/applicationinsights-core-js';
18
- import { IDependencyTelemetry } from '@microsoft/applicationinsights-common';
19
- import { IEventTelemetry } from '@microsoft/applicationinsights-common';
20
- import { ILoadedPlugin } from '@microsoft/applicationinsights-core-js';
21
- import { IMetricTelemetry } from '@microsoft/applicationinsights-common';
22
- import { IPageViewPerformanceTelemetry } from '@microsoft/applicationinsights-common';
23
- import { IPageViewTelemetry } from '@microsoft/applicationinsights-common';
24
- import { IPlugin } from '@microsoft/applicationinsights-core-js';
25
- import { IPromise } from '@nevware21/ts-async';
26
- import { ISenderConfig } from '@microsoft/applicationinsights-channel-js';
27
- import { isNullOrUndefined } from '@microsoft/applicationinsights-core-js';
28
- import { ITelemetryItem } from '@microsoft/applicationinsights-core-js';
29
- import { ITelemetryPlugin } from '@microsoft/applicationinsights-core-js';
30
- import { ITelemetryUnloadState } from '@microsoft/applicationinsights-core-js';
31
- import { ITraceTelemetry } from '@microsoft/applicationinsights-common';
32
- import { IUnloadHook } from '@microsoft/applicationinsights-core-js';
33
- import { proxyFunctions } from '@microsoft/applicationinsights-core-js';
34
- import { Sender } from '@microsoft/applicationinsights-channel-js';
35
- import { SendRequestReason } from '@microsoft/applicationinsights-core-js';
36
- import { SeverityLevel } from '@microsoft/applicationinsights-common';
37
- import { throwError } from '@microsoft/applicationinsights-core-js';
38
- import { UnloadHandler } from '@microsoft/applicationinsights-core-js';
39
- import { WatcherFunction } from '@microsoft/applicationinsights-core-js';
40
-
41
-
10
+ /**
11
+ * @group Classes
12
+ * @group Entrypoint
13
+ */
14
+ class AppInsightsCore<CfgType extends IConfiguration = IConfiguration> implements IAppInsightsCore<CfgType> {
15
+ config: CfgType;
16
+ logger: IDiagnosticLogger;
17
+ /**
18
+ * An array of the installed plugins that provide a version
19
+ */
20
+ readonly pluginVersionStringArr: string[];
21
+ /**
22
+ * The formatted string of the installed plugins that contain a version number
23
+ */
24
+ readonly pluginVersionString: string;
25
+ /**
26
+ * Returns a value that indicates whether the instance has already been previously initialized.
27
+ */
28
+ isInitialized: () => boolean;
29
+ /**
30
+ * Function used to identify the get w parameter used to identify status bit to some channels
31
+ */
32
+ getWParam: () => number;
33
+ constructor();
34
+ initialize(config: CfgType, extensions: IPlugin[], logger?: IDiagnosticLogger, notificationManager?: INotificationManager): void;
35
+ getChannels(): IChannelControls[];
36
+ track(telemetryItem: ITelemetryItem): void;
37
+ getProcessTelContext(): IProcessTelemetryContext;
38
+ getNotifyMgr(): INotificationManager;
39
+ /**
40
+ * Adds a notification listener. The SDK calls methods on the listener when an appropriate notification is raised.
41
+ * The added plugins must raise notifications. If the plugins do not implement the notifications, then no methods will be
42
+ * called.
43
+ * @param listener - An INotificationListener object.
44
+ */
45
+ addNotificationListener(listener: INotificationListener): void;
46
+ /**
47
+ * Removes all instances of the listener.
48
+ * @param listener - INotificationListener to remove.
49
+ */
50
+ removeNotificationListener(listener: INotificationListener): void;
51
+ /**
52
+ * Get the current cookie manager for this instance
53
+ */
54
+ getCookieMgr(): ICookieMgr;
55
+ /**
56
+ * Set the current cookie manager for this instance
57
+ * @param cookieMgr - The manager, if set to null/undefined will cause the default to be created
58
+ */
59
+ setCookieMgr(cookieMgr: ICookieMgr): void;
60
+ getPerfMgr(): IPerfManager;
61
+ setPerfMgr(perfMgr: IPerfManager): void;
62
+ eventCnt(): number;
63
+ /**
64
+ * Enable the timer that checks the logger.queue for log messages to be flushed.
65
+ * Note: Since 3.0.1 and 2.8.13 this is no longer an interval timer but is a normal
66
+ * timer that is only started when this function is called and then subsequently
67
+ * only _if_ there are any logger.queue messages to be sent.
68
+ */
69
+ pollInternalLogs(eventName?: string): ITimerHandler;
70
+ /**
71
+ * Stop the timer that log messages from logger.queue when available
72
+ */
73
+ stopPollingInternalLogs(): void;
74
+ /**
75
+ * Add a telemetry processor to decorate or drop telemetry events.
76
+ * @param telemetryInitializer - The Telemetry Initializer function
77
+ * @returns - A ITelemetryInitializerHandler to enable the initializer to be removed
78
+ */
79
+ addTelemetryInitializer(telemetryInitializer: TelemetryInitializerFunction): ITelemetryInitializerHandler;
80
+ /**
81
+ * Unload and Tear down the SDK and any initialized plugins, after calling this the SDK will be considered
82
+ * to be un-initialized and non-operational, re-initializing the SDK should only be attempted if the previous
83
+ * unload call return `true` stating that all plugins reported that they also unloaded, the recommended
84
+ * approach is to create a new instance and initialize that instance.
85
+ * This is due to possible unexpected side effects caused by plugins not supporting unload / teardown, unable
86
+ * to successfully remove any global references or they may just be completing the unload process asynchronously.
87
+ * If you pass isAsync as `true` (also the default) and DO NOT pass a callback function then an [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html)
88
+ * will be returned which will resolve once the unload is complete. The actual implementation of the `IPromise`
89
+ * will be a native Promise (if supported) or the default as supplied by [ts-async library](https://github.com/nevware21/ts-async)
90
+ * @param isAsync - Can the unload be performed asynchronously (default)
91
+ * @param unloadComplete - An optional callback that will be called once the unload has completed
92
+ * @param cbTimeout - An optional timeout to wait for any flush operations to complete before proceeding with the
93
+ * unload. Defaults to 5 seconds.
94
+ * @return Nothing or if occurring asynchronously a [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html)
95
+ * which will be resolved once the unload is complete, the [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html)
96
+ * will only be returned when no callback is provided and isAsync is true
97
+ */
98
+ unload(isAsync?: boolean, unloadComplete?: (unloadState: ITelemetryUnloadState) => void, cbTimeout?: number): void | IPromise<ITelemetryUnloadState>;
99
+ getPlugin<T extends IPlugin = IPlugin>(pluginIdentifier: string): ILoadedPlugin<T>;
100
+ /**
101
+ * Add a new plugin to the installation
102
+ * @param plugin - The new plugin to add
103
+ * @param replaceExisting - should any existing plugin be replaced, default is false
104
+ * @param doAsync - Should the add be performed asynchronously
105
+ * @param addCb - [Optional] callback to call after the plugin has been added
106
+ */
107
+ addPlugin<T extends IPlugin = ITelemetryPlugin>(plugin: T, replaceExisting?: boolean, doAsync?: boolean, addCb?: (added?: boolean) => void): void;
108
+ /**
109
+ * Update the configuration used and broadcast the changes to all loaded plugins
110
+ * @param newConfig - The new configuration is apply
111
+ * @param mergeExisting - Should the new configuration merge with the existing or just replace it. Default is to true.
112
+ */
113
+ updateCfg(newConfig: CfgType, mergeExisting?: boolean): void;
114
+ /**
115
+ * Returns the unique event namespace that should be used
116
+ */
117
+ evtNamespace(): string;
118
+ /**
119
+ * Add an unload handler that will be called when the SDK is being unloaded
120
+ * @param handler - the handler
121
+ */
122
+ addUnloadCb(handler: UnloadHandler): void;
123
+ /**
124
+ * Flush and send any batched / cached data immediately
125
+ * @param async - send data asynchronously when true (defaults to true)
126
+ * @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.
127
+ * If the caller doesn't return true the caller should assume that it may never be called.
128
+ * @param sendReason - specify the reason that you are calling "flush" defaults to ManualFlush (1) if not specified
129
+ * @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
130
+ */
131
+ flush(isAsync?: boolean, callBack?: (flushComplete?: boolean) => void, sendReason?: SendRequestReason): void;
132
+ /**
133
+ * Gets the current distributed trace context for this instance if available
134
+ * @param createNew - Optional flag to create a new instance if one doesn't currently exist, defaults to true
135
+ */
136
+ getTraceCtx(createNew?: boolean): IDistributedTraceContext | null;
137
+ /**
138
+ * Sets the current distributed trace context for this instance if available
139
+ */
140
+ setTraceCtx(newTracectx: IDistributedTraceContext): void;
141
+ /**
142
+ * Add this hook so that it is automatically removed during unloading
143
+ * @param hooks - The single hook or an array of IInstrumentHook objects
144
+ */
145
+ addUnloadHook(hooks: IUnloadHook | IUnloadHook[] | Iterator<IUnloadHook> | ILegacyUnloadHook | ILegacyUnloadHook[] | Iterator<ILegacyUnloadHook>): void;
146
+ /**
147
+ * Watches and tracks changes for accesses to the current config, and if the accessed config changes the
148
+ * handler will be recalled.
149
+ * @param handler
150
+ * @returns A watcher handler instance that can be used to remove itself when being unloaded
151
+ */
152
+ onCfgChange(handler: WatcherFunction<CfgType>): IUnloadHook;
153
+ protected releaseQueue(): void;
154
+ /**
155
+ * Hook for Core extensions to allow them to update their own configuration before updating all of the plugins.
156
+ * @param updateCtx - The plugin update context
157
+ * @param updateState - The Update State
158
+ * @returns boolean - True means the extension class will call updateState otherwise the Core will
159
+ */
160
+ protected _updateHook?(updateCtx: IProcessTelemetryUpdateContext, updateState: ITelemetryUpdateState): void | boolean;
161
+ }
162
+
42
163
  /**
43
164
  * @export
44
165
  * @class ApplicationInsights
@@ -118,28 +239,3137 @@ declare namespace ApplicationInsights {
118
239
  onCfgChange(handler: WatcherFunction<IConfiguration>): IUnloadHook;
119
240
  }
120
241
 
121
-
122
-
123
-
124
-
125
-
126
-
127
-
128
-
129
-
130
-
131
-
132
-
133
-
134
-
135
-
136
-
137
-
138
-
139
-
140
-
141
-
142
-
143
-
144
-
242
+ class ArraySendBuffer extends BaseSendBuffer implements ISendBuffer {
243
+ constructor(logger: IDiagnosticLogger, config: ISenderConfig);
244
+ markAsSent(payload: string[]): void;
245
+ clearSent(payload: string[]): void;
246
+ }
247
+
248
+ /**
249
+ * Calls the provided `callbackFn` function once for each element in an array in ascending index order. It is not invoked for index properties
250
+ * that have been deleted or are uninitialized. And unlike the ES6 forEach() you CAN stop or break the iteration by returning -1 from the
251
+ * `callbackFn` function.
252
+ *
253
+ * The range (number of elements) processed by arrForEach() is set before the first call to the `callbackFn`. Any elements added beyond the range
254
+ * or elements which as assigned to indexes already processed will not be visited by the `callbackFn`.
255
+ * @group Array
256
+ * @group ArrayLike
257
+ * @typeParam T - Identifies the element type of the array
258
+ * @param theArray - The array or array like object of elements to be searched.
259
+ * @param callbackfn A `synchronous` function that accepts up to three arguments. arrForEach calls the callbackfn function one time for each element in the array.
260
+ * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, null or undefined
261
+ * the array will be used as the this value.
262
+ * @remarks
263
+ * arrForEach expects a `synchronous` function.
264
+ * arrForEach does not wait for promises. Make sure you are aware of the implications while using promises (or async functions) as forEach callback.
265
+ * @example
266
+ * ```ts
267
+ * const items = ['item1', 'item2', 'item3'];
268
+ * const copyItems = [];
269
+ *
270
+ * // before using for loop
271
+ * for (let i = 0; i < items.length; i++) {
272
+ * copyItems.push(items[i]);
273
+ * }
274
+ *
275
+ * // before using forEach()
276
+ * items.forEach((item) => {
277
+ * copyItems.push(item);
278
+ * });
279
+ *
280
+ * // after
281
+ * arrForEach(items, (item) => {
282
+ * copyItems.push(item);
283
+ * // May return -1 to abort the iteration
284
+ * });
285
+ *
286
+ * // Also supports input as an array like object
287
+ * const items = { length: 3, 0: 'item1', 1: 'item2', 2: 'item3' };
288
+ * ```
289
+ */
290
+ function arrForEach<T = any>(theArray: ArrayLike<T>, callbackfn: (value: T, index: number, array: T[]) => void | number, thisArg?: any): void;
291
+
292
+ abstract class BaseSendBuffer {
293
+ protected _get: () => string[];
294
+ protected _set: (buffer: string[]) => string[];
295
+ constructor(logger: IDiagnosticLogger, config: ISenderConfig);
296
+ enqueue(payload: string): void;
297
+ count(): number;
298
+ size(): number;
299
+ clear(): void;
300
+ getItems(): string[];
301
+ batchPayloads(payload: string[]): string;
302
+ createNew(newLogger?: IDiagnosticLogger, newConfig?: ISenderConfig, canUseSessionStorage?: boolean): ArraySendBuffer | SessionStorageSendBuffer;
303
+ }
304
+
305
+ /**
306
+ * BaseTelemetryPlugin provides a basic implementation of the ITelemetryPlugin interface so that plugins
307
+ * can avoid implementation the same set of boiler plate code as well as provide a base
308
+ * implementation so that new default implementations can be added without breaking all plugins.
309
+ */
310
+ abstract class BaseTelemetryPlugin implements ITelemetryPlugin {
311
+ identifier: string;
312
+ version?: string;
313
+ /**
314
+ * Holds the core instance that was used during initialization
315
+ */
316
+ core: IAppInsightsCore;
317
+ priority: number;
318
+ /**
319
+ * Call back for telemetry processing before it it is sent
320
+ * @param env - This is the current event being reported
321
+ * @param itemCtx - This is the context for the current request, ITelemetryPlugin instances
322
+ * can optionally use this to access the current core instance or define / pass additional information
323
+ * to later plugins (vs appending items to the telemetry item)
324
+ */
325
+ processNext: (env: ITelemetryItem, itemCtx: IProcessTelemetryContext) => void;
326
+ /**
327
+ * Set next extension for telemetry processing
328
+ */
329
+ setNextPlugin: (next: ITelemetryPlugin | ITelemetryPluginChain) => void;
330
+ /**
331
+ * Returns the current diagnostic logger that can be used to log issues, if no logger is currently
332
+ * assigned a new default one will be created and returned.
333
+ */
334
+ diagLog: (itemCtx?: IProcessTelemetryContext) => IDiagnosticLogger;
335
+ /**
336
+ * Returns whether the plugin has been initialized
337
+ */
338
+ isInitialized: () => boolean;
339
+ /**
340
+ * Helper to return the current IProcessTelemetryContext, if the passed argument exists this just
341
+ * returns that value (helps with minification for callers), otherwise it will return the configured
342
+ * context or a temporary one.
343
+ * @param currentCtx - [Optional] The current execution context
344
+ */
345
+ protected _getTelCtx: (currentCtx?: IProcessTelemetryContext) => IProcessTelemetryContext;
346
+ /**
347
+ * Internal helper to allow setting of the internal initialized setting for inherited instances and unit testing
348
+ */
349
+ protected setInitialized: (isInitialized: boolean) => void;
350
+ /**
351
+ * Teardown / Unload hook to allow implementations to perform some additional unload operations before the BaseTelemetryPlugin
352
+ * finishes it's removal.
353
+ * @param unloadCtx - This is the context that should be used during unloading.
354
+ * @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.
355
+ * @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.
356
+ * @returns boolean - true if the plugin has or will call asyncCallback, this allows the plugin to perform any asynchronous operations.
357
+ */
358
+ protected _doTeardown?: (unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState, asyncCallback?: () => void) => void | boolean;
359
+ /**
360
+ * Extension hook to allow implementations to perform some additional update operations before the BaseTelemetryPlugin finishes it's removal
361
+ * @param updateCtx - This is the context that should be used during updating.
362
+ * @param updateState - The details / state of the update process, it holds details like the current and previous configuration.
363
+ * @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.
364
+ * @returns boolean - true if the plugin has or will call asyncCallback, this allows the plugin to perform any asynchronous operations.
365
+ */
366
+ protected _doUpdate?: (updateCtx?: IProcessTelemetryUpdateContext, updateState?: ITelemetryUpdateState, asyncCallback?: () => void) => void | boolean;
367
+ /**
368
+ * Exposes the underlying unload hook container instance for this extension to allow it to be passed down to any sub components of the class.
369
+ * This should NEVER be exposed or called publically as it's scope is for internal use by BaseTelemetryPlugin and any derived class (which is why
370
+ * it's scoped as protected)
371
+ */
372
+ protected readonly _unloadHooks: IUnloadHookContainer;
373
+ constructor();
374
+ initialize(config: IConfiguration, core: IAppInsightsCore, extensions: IPlugin[], pluginChain?: ITelemetryPluginChain): void;
375
+ /**
376
+ * Tear down the plugin and remove any hooked value, the plugin should be removed so that it is no longer initialized and
377
+ * therefore could be re-initialized after being torn down. The plugin should ensure that once this has been called any further
378
+ * processTelemetry calls are ignored and it just calls the processNext() with the provided context.
379
+ * @param unloadCtx - This is the context that should be used during unloading.
380
+ * @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.
381
+ * @returns boolean - true if the plugin has or will call processNext(), this for backward compatibility as previously teardown was synchronous and returned nothing.
382
+ */
383
+ teardown(unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState): void | boolean;
384
+ abstract processTelemetry(env: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
385
+ /**
386
+ * The the plugin should re-evaluate configuration and update any cached configuration settings.
387
+ * @param updateCtx - This is the context that should be used during updating.
388
+ * @param updateState - The details / state of the update process, it holds details like the current and previous configuration.
389
+ * @returns boolean - true if the plugin has or will call updateCtx.processNext(), this allows the plugin to perform any asynchronous operations.
390
+ */
391
+ update(updateCtx: IProcessTelemetryUpdateContext, updateState: ITelemetryUpdateState): void | boolean;
392
+ /**
393
+ * Add an unload handler that will be called when the SDK is being unloaded
394
+ * @param handler - the handler
395
+ */
396
+ protected _addUnloadCb(handler: UnloadHandler): void;
397
+ /**
398
+ * Add this hook so that it is automatically removed during unloading
399
+ * @param hooks - The single hook or an array of IInstrumentHook objects
400
+ */
401
+ protected _addHook(hooks: IUnloadHook | IUnloadHook[] | Iterator<IUnloadHook> | ILegacyUnloadHook | ILegacyUnloadHook[] | Iterator<ILegacyUnloadHook>): void;
402
+ }
403
+
404
+ const DistributedTracingModes: EnumValue<typeof eDistributedTracingModes>;
405
+
406
+ type DistributedTracingModes = number | eDistributedTracingModes;
407
+
408
+ const enum eDistributedTracingModes {
409
+ /**
410
+ * (Default) Send Application Insights correlation headers
411
+ */
412
+ AI = 0,
413
+ /**
414
+ * Send both W3C Trace Context headers and back-compatibility Application Insights headers
415
+ */
416
+ AI_AND_W3C = 1,
417
+ /**
418
+ * Send W3C Trace Context headers
419
+ */
420
+ W3C = 2
421
+ }
422
+
423
+ const enum _eInternalMessageId {
424
+ BrowserDoesNotSupportLocalStorage = 0,
425
+ BrowserCannotReadLocalStorage = 1,
426
+ BrowserCannotReadSessionStorage = 2,
427
+ BrowserCannotWriteLocalStorage = 3,
428
+ BrowserCannotWriteSessionStorage = 4,
429
+ BrowserFailedRemovalFromLocalStorage = 5,
430
+ BrowserFailedRemovalFromSessionStorage = 6,
431
+ CannotSendEmptyTelemetry = 7,
432
+ ClientPerformanceMathError = 8,
433
+ ErrorParsingAISessionCookie = 9,
434
+ ErrorPVCalc = 10,
435
+ ExceptionWhileLoggingError = 11,
436
+ FailedAddingTelemetryToBuffer = 12,
437
+ FailedMonitorAjaxAbort = 13,
438
+ FailedMonitorAjaxDur = 14,
439
+ FailedMonitorAjaxOpen = 15,
440
+ FailedMonitorAjaxRSC = 16,
441
+ FailedMonitorAjaxSend = 17,
442
+ FailedMonitorAjaxGetCorrelationHeader = 18,
443
+ FailedToAddHandlerForOnBeforeUnload = 19,
444
+ FailedToSendQueuedTelemetry = 20,
445
+ FailedToReportDataLoss = 21,
446
+ FlushFailed = 22,
447
+ MessageLimitPerPVExceeded = 23,
448
+ MissingRequiredFieldSpecification = 24,
449
+ NavigationTimingNotSupported = 25,
450
+ OnError = 26,
451
+ SessionRenewalDateIsZero = 27,
452
+ SenderNotInitialized = 28,
453
+ StartTrackEventFailed = 29,
454
+ StopTrackEventFailed = 30,
455
+ StartTrackFailed = 31,
456
+ StopTrackFailed = 32,
457
+ TelemetrySampledAndNotSent = 33,
458
+ TrackEventFailed = 34,
459
+ TrackExceptionFailed = 35,
460
+ TrackMetricFailed = 36,
461
+ TrackPVFailed = 37,
462
+ TrackPVFailedCalc = 38,
463
+ TrackTraceFailed = 39,
464
+ TransmissionFailed = 40,
465
+ FailedToSetStorageBuffer = 41,
466
+ FailedToRestoreStorageBuffer = 42,
467
+ InvalidBackendResponse = 43,
468
+ FailedToFixDepricatedValues = 44,
469
+ InvalidDurationValue = 45,
470
+ TelemetryEnvelopeInvalid = 46,
471
+ CreateEnvelopeError = 47,
472
+ MaxUnloadHookExceeded = 48,
473
+ CannotSerializeObject = 48,
474
+ CannotSerializeObjectNonSerializable = 49,
475
+ CircularReferenceDetected = 50,
476
+ ClearAuthContextFailed = 51,
477
+ ExceptionTruncated = 52,
478
+ IllegalCharsInName = 53,
479
+ ItemNotInArray = 54,
480
+ MaxAjaxPerPVExceeded = 55,
481
+ MessageTruncated = 56,
482
+ NameTooLong = 57,
483
+ SampleRateOutOfRange = 58,
484
+ SetAuthContextFailed = 59,
485
+ SetAuthContextFailedAccountName = 60,
486
+ StringValueTooLong = 61,
487
+ StartCalledMoreThanOnce = 62,
488
+ StopCalledWithoutStart = 63,
489
+ TelemetryInitializerFailed = 64,
490
+ TrackArgumentsNotSpecified = 65,
491
+ UrlTooLong = 66,
492
+ SessionStorageBufferFull = 67,
493
+ CannotAccessCookie = 68,
494
+ IdTooLong = 69,
495
+ InvalidEvent = 70,
496
+ FailedMonitorAjaxSetRequestHeader = 71,
497
+ SendBrowserInfoOnUserInit = 72,
498
+ PluginException = 73,
499
+ NotificationException = 74,
500
+ SnippetScriptLoadFailure = 99,
501
+ InvalidInstrumentationKey = 100,
502
+ CannotParseAiBlobValue = 101,
503
+ InvalidContentBlob = 102,
504
+ TrackPageActionEventFailed = 103,
505
+ FailedAddingCustomDefinedRequestContext = 104,
506
+ InMemoryStorageBufferFull = 105,
507
+ InstrumentationKeyDeprecation = 106,
508
+ ConfigWatcherException = 107,
509
+ DynamicConfigException = 108,
510
+ DefaultThrottleMsgKey = 109,
511
+ CdnDeprecation = 110,
512
+ SdkLdrUpdate = 111
513
+ }
514
+
515
+ const enum eLoggingSeverity {
516
+ /**
517
+ * No Logging will be enabled
518
+ */
519
+ DISABLED = 0,
520
+ /**
521
+ * Error will be sent as internal telemetry
522
+ */
523
+ CRITICAL = 1,
524
+ /**
525
+ * Error will NOT be sent as internal telemetry, and will only be shown in browser console
526
+ */
527
+ WARNING = 2,
528
+ /**
529
+ * The Error will NOT be sent as an internal telemetry, and will only be shown in the browser
530
+ * console if the logging level allows it.
531
+ */
532
+ DEBUG = 3
533
+ }
534
+
535
+ /**
536
+ * A type that identifies an enum class generated from a constant enum.
537
+ * @group Enum
538
+ * @typeParam E - The constant enum type
539
+ *
540
+ * Returned from {@link createEnum}
541
+ */
542
+ type EnumCls<E = any> = {
543
+ readonly [key in keyof E extends string | number | symbol ? keyof E : never]: key extends string ? E[key] : key;
544
+ } & {
545
+ readonly [key in keyof E]: E[key];
546
+ };
547
+
548
+ type EnumValue<E = any> = EnumCls<E>;
549
+
550
+ /**
551
+ * Defines the level of severity for the event.
552
+ */
553
+ const enum eSeverityLevel {
554
+ Verbose = 0,
555
+ Information = 1,
556
+ Warning = 2,
557
+ Error = 3,
558
+ Critical = 4
559
+ }
560
+
561
+ const enum FeatureOptInMode {
562
+ /**
563
+ * not set, completely depends on cdn cfg
564
+ */
565
+ none = 1,
566
+ /**
567
+ * try to not apply config from cdn
568
+ */
569
+ disable = 2,
570
+ /**
571
+ * try to apply config from cdn
572
+ */
573
+ enable = 3
574
+ }
575
+
576
+ /**
577
+ * This defines the handler function that is called via the finally when the promise is resolved or rejected
578
+ */
579
+ type FinallyPromiseHandler = (() => void) | undefined | null;
580
+
581
+ interface IAppInsightsCore<CfgType extends IConfiguration = IConfiguration> extends IPerfManagerProvider {
582
+ readonly config: CfgType;
583
+ /**
584
+ * The current logger instance for this instance.
585
+ */
586
+ readonly logger: IDiagnosticLogger;
587
+ /**
588
+ * An array of the installed plugins that provide a version
589
+ */
590
+ readonly pluginVersionStringArr: string[];
591
+ /**
592
+ * The formatted string of the installed plugins that contain a version number
593
+ */
594
+ readonly pluginVersionString: string;
595
+ /**
596
+ * Returns a value that indicates whether the instance has already been previously initialized.
597
+ */
598
+ isInitialized?: () => boolean;
599
+ initialize(config: CfgType, extensions: IPlugin[], logger?: IDiagnosticLogger, notificationManager?: INotificationManager): void;
600
+ getChannels(): IChannelControls[];
601
+ track(telemetryItem: ITelemetryItem): void;
602
+ /**
603
+ * Get the current notification manager
604
+ */
605
+ getNotifyMgr(): INotificationManager;
606
+ /**
607
+ * Get the current cookie manager for this instance
608
+ */
609
+ getCookieMgr(): ICookieMgr;
610
+ /**
611
+ * Set the current cookie manager for this instance
612
+ * @param cookieMgr - The manager, if set to null/undefined will cause the default to be created
613
+ */
614
+ setCookieMgr(cookieMgr: ICookieMgr): void;
615
+ /**
616
+ * Adds a notification listener. The SDK calls methods on the listener when an appropriate notification is raised.
617
+ * The added plugins must raise notifications. If the plugins do not implement the notifications, then no methods will be
618
+ * called.
619
+ * @param listener - An INotificationListener object.
620
+ */
621
+ addNotificationListener?(listener: INotificationListener): void;
622
+ /**
623
+ * Removes all instances of the listener.
624
+ * @param listener - INotificationListener to remove.
625
+ */
626
+ removeNotificationListener?(listener: INotificationListener): void;
627
+ /**
628
+ * Add a telemetry processor to decorate or drop telemetry events.
629
+ * @param telemetryInitializer - The Telemetry Initializer function
630
+ * @returns - A ITelemetryInitializerHandler to enable the initializer to be removed
631
+ */
632
+ addTelemetryInitializer(telemetryInitializer: TelemetryInitializerFunction): ITelemetryInitializerHandler;
633
+ pollInternalLogs?(eventName?: string): ITimerHandler;
634
+ stopPollingInternalLogs?(): void;
635
+ /**
636
+ * Return a new instance of the IProcessTelemetryContext for processing events
637
+ */
638
+ getProcessTelContext(): IProcessTelemetryContext;
639
+ /**
640
+ * Unload and Tear down the SDK and any initialized plugins, after calling this the SDK will be considered
641
+ * to be un-initialized and non-operational, re-initializing the SDK should only be attempted if the previous
642
+ * unload call return `true` stating that all plugins reported that they also unloaded, the recommended
643
+ * approach is to create a new instance and initialize that instance.
644
+ * This is due to possible unexpected side effects caused by plugins not supporting unload / teardown, unable
645
+ * to successfully remove any global references or they may just be completing the unload process asynchronously.
646
+ * If you pass isAsync as `true` (also the default) and DO NOT pass a callback function then an [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html)
647
+ * will be returned which will resolve once the unload is complete. The actual implementation of the `IPromise`
648
+ * will be a native Promise (if supported) or the default as supplied by [ts-async library](https://github.com/nevware21/ts-async)
649
+ * @param isAsync - Can the unload be performed asynchronously (default)
650
+ * @param unloadComplete - An optional callback that will be called once the unload has completed
651
+ * @param cbTimeout - An optional timeout to wait for any flush operations to complete before proceeding with the
652
+ * unload. Defaults to 5 seconds.
653
+ * @return Nothing or if occurring asynchronously a [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html)
654
+ * which will be resolved once the unload is complete, the [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html)
655
+ * will only be returned when no callback is provided and isAsync is true
656
+ */
657
+ unload(isAsync?: boolean, unloadComplete?: (unloadState: ITelemetryUnloadState) => void, cbTimeout?: number): void | IPromise<ITelemetryUnloadState>;
658
+ /**
659
+ * Find and return the (first) plugin with the specified identifier if present
660
+ * @param pluginIdentifier
661
+ */
662
+ getPlugin<T extends IPlugin = IPlugin>(pluginIdentifier: string): ILoadedPlugin<T>;
663
+ /**
664
+ * Add a new plugin to the installation
665
+ * @param plugin - The new plugin to add
666
+ * @param replaceExisting - should any existing plugin be replaced, default is false
667
+ * @param doAsync - Should the add be performed asynchronously
668
+ * @param addCb - [Optional] callback to call after the plugin has been added
669
+ */
670
+ addPlugin<T extends IPlugin = ITelemetryPlugin>(plugin: T, replaceExisting?: boolean, doAsync?: boolean, addCb?: (added?: boolean) => void): void;
671
+ /**
672
+ * Update the configuration used and broadcast the changes to all loaded plugins, this does NOT support updating, adding or removing
673
+ * any the plugins (extensions or channels). It will notify each plugin (if supported) that the configuration has changed but it will
674
+ * not remove or add any new plugins, you need to call addPlugin or getPlugin(identifier).remove();
675
+ * @param newConfig - The new configuration is apply
676
+ * @param mergeExisting - Should the new configuration merge with the existing or just replace it. Default is to merge.
677
+ */
678
+ updateCfg(newConfig: CfgType, mergeExisting?: boolean): void;
679
+ /**
680
+ * Returns the unique event namespace that should be used when registering events
681
+ */
682
+ evtNamespace(): string;
683
+ /**
684
+ * Add a handler that will be called when the SDK is being unloaded
685
+ * @param handler - the handler
686
+ */
687
+ addUnloadCb(handler: UnloadHandler): void;
688
+ /**
689
+ * Add this hook so that it is automatically removed during unloading
690
+ * @param hooks - The single hook or an array of IInstrumentHook objects
691
+ */
692
+ addUnloadHook(hooks: IUnloadHook | IUnloadHook[] | Iterator<IUnloadHook> | ILegacyUnloadHook | ILegacyUnloadHook[] | Iterator<ILegacyUnloadHook>): void;
693
+ /**
694
+ * Flush and send any batched / cached data immediately
695
+ * @param async - send data asynchronously when true (defaults to true)
696
+ * @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.
697
+ * If the caller doesn't return true the caller should assume that it may never be called.
698
+ * @param sendReason - specify the reason that you are calling "flush" defaults to ManualFlush (1) if not specified
699
+ * @param cbTimeout - An optional timeout to wait for any flush operations to complete before proceeding with the unload. Defaults to 5 seconds.
700
+ * @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
701
+ */
702
+ flush(isAsync?: boolean, callBack?: (flushComplete?: boolean) => void, sendReason?: SendRequestReason, cbTimeout?: number): boolean | void;
703
+ /**
704
+ * Gets the current distributed trace context for this instance if available
705
+ * @param createNew - Optional flag to create a new instance if one doesn't currently exist, defaults to true
706
+ */
707
+ getTraceCtx(createNew?: boolean): IDistributedTraceContext | null;
708
+ /**
709
+ * Sets the current distributed trace context for this instance if available
710
+ */
711
+ setTraceCtx(newTraceCtx: IDistributedTraceContext | null | undefined): void;
712
+ /**
713
+ * Watches and tracks changes for accesses to the current config, and if the accessed config changes the
714
+ * handler will be recalled.
715
+ * @param handler
716
+ * @returns A watcher handler instance that can be used to remove itself when being unloaded
717
+ */
718
+ onCfgChange(handler: WatcherFunction<CfgType>): IUnloadHook;
719
+ /**
720
+ * Function used to identify the get w parameter used to identify status bit to some channels
721
+ */
722
+ getWParam: () => number;
723
+ }
724
+
725
+ /**
726
+ * @description window.onerror function parameters
727
+ * @export
728
+ * @interface IAutoExceptionTelemetry
729
+ */
730
+ interface IAutoExceptionTelemetry {
731
+ /**
732
+ * @description error message. Available as event in HTML onerror="" handler
733
+ * @type {string}
734
+ * @memberof IAutoExceptionTelemetry
735
+ */
736
+ message: string;
737
+ /**
738
+ * @description URL of the script where the error was raised
739
+ * @type {string}
740
+ * @memberof IAutoExceptionTelemetry
741
+ */
742
+ url: string;
743
+ /**
744
+ * @description Line number where error was raised
745
+ * @type {number}
746
+ * @memberof IAutoExceptionTelemetry
747
+ */
748
+ lineNumber: number;
749
+ /**
750
+ * @description Column number for the line where the error occurred
751
+ * @type {number}
752
+ * @memberof IAutoExceptionTelemetry
753
+ */
754
+ columnNumber: number;
755
+ /**
756
+ * @description Error Object (object)
757
+ * @type {any}
758
+ * @memberof IAutoExceptionTelemetry
759
+ */
760
+ error: any;
761
+ /**
762
+ * @description The event at the time of the exception (object)
763
+ * @type {Event|string}
764
+ * @memberof IAutoExceptionTelemetry
765
+ */
766
+ evt?: Event | string;
767
+ /**
768
+ * @description The provided stack for the error
769
+ * @type {IStackDetails}
770
+ * @memberof IAutoExceptionTelemetry
771
+ */
772
+ stackDetails?: IStackDetails;
773
+ /**
774
+ * @description The calculated type of the error
775
+ * @type {string}
776
+ * @memberof IAutoExceptionTelemetry
777
+ */
778
+ typeName?: string;
779
+ /**
780
+ * @description The descriptive source of the error
781
+ * @type {string}
782
+ * @memberof IAutoExceptionTelemetry
783
+ */
784
+ errorSrc?: string;
785
+ }
786
+
787
+ interface IBackendResponse {
788
+ /**
789
+ * Number of items received by the backend
790
+ */
791
+ readonly itemsReceived: number;
792
+ /**
793
+ * Number of items succesfuly accepted by the backend
794
+ */
795
+ readonly itemsAccepted: number;
796
+ /**
797
+ * List of errors for items which were not accepted
798
+ */
799
+ readonly errors: IResponseError[];
800
+ /**
801
+ * App id returned by the backend - not necessary returned, but we don't need it with each response.
802
+ */
803
+ readonly appId?: string;
804
+ }
805
+
806
+ interface IBaseProcessingContext {
807
+ /**
808
+ * The current core instance for the request
809
+ */
810
+ core: () => IAppInsightsCore;
811
+ /**
812
+ * THe current diagnostic logger for the request
813
+ */
814
+ diagLog: () => IDiagnosticLogger;
815
+ /**
816
+ * Gets the current core config instance
817
+ */
818
+ getCfg: () => IConfiguration;
819
+ /**
820
+ * Gets the named extension config
821
+ */
822
+ getExtCfg: <T>(identifier: string, defaultValue?: IConfigDefaults<T>) => T;
823
+ /**
824
+ * Gets the named config from either the named identifier extension or core config if neither exist then the
825
+ * default value is returned
826
+ * @param identifier - The named extension identifier
827
+ * @param field - The config field name
828
+ * @param defaultValue - The default value to return if no defined config exists
829
+ */
830
+ getConfig: (identifier: string, field: string, defaultValue?: number | string | boolean | string[] | RegExp[] | Function) => number | string | boolean | string[] | RegExp[] | Function;
831
+ /**
832
+ * Helper to allow plugins to check and possibly shortcut executing code only
833
+ * required if there is a nextPlugin
834
+ */
835
+ hasNext: () => boolean;
836
+ /**
837
+ * Returns the next configured plugin proxy
838
+ */
839
+ getNext: () => ITelemetryPluginChain;
840
+ /**
841
+ * Helper to set the next plugin proxy
842
+ */
843
+ setNext: (nextCtx: ITelemetryPluginChain) => void;
844
+ /**
845
+ * Synchronously iterate over the context chain running the callback for each plugin, once
846
+ * every plugin has been executed via the callback, any associated onComplete will be called.
847
+ * @param callback - The function call for each plugin in the context chain
848
+ */
849
+ iterate: <T extends ITelemetryPlugin = ITelemetryPlugin>(callback: (plugin: T) => void) => void;
850
+ /**
851
+ * Set the function to call when the current chain has executed all processNext or unloadNext items.
852
+ * @param onComplete - The onComplete to call
853
+ * @param that - The "this" value to use for the onComplete call, if not provided or undefined defaults to the current context
854
+ * @param args - Any additional arguments to pass to the onComplete function
855
+ */
856
+ onComplete: (onComplete: () => void, that?: any, ...args: any[]) => void;
857
+ /**
858
+ * Create a new context using the core and config from the current instance, returns a new instance of the same type
859
+ * @param plugins - The execution order to process the plugins, if null or not supplied
860
+ * then the current execution order will be copied.
861
+ * @param startAt - The plugin to start processing from, if missing from the execution
862
+ * order then the next plugin will be NOT set.
863
+ */
864
+ createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IBaseProcessingContext;
865
+ }
866
+
867
+ /**
868
+ * Provides data transmission capabilities
869
+ */
870
+ interface IChannelControls extends ITelemetryPlugin {
871
+ /**
872
+ * Pause sending data
873
+ */
874
+ pause?(): void;
875
+ /**
876
+ * Resume sending data
877
+ */
878
+ resume?(): void;
879
+ /**
880
+ * Tear down the plugin and remove any hooked value, the plugin should be removed so that it is no longer initialized and
881
+ * therefore could be re-initialized after being torn down. The plugin should ensure that once this has been called any further
882
+ * processTelemetry calls are ignored and it just calls the processNext() with the provided context.
883
+ * @param unloadCtx - This is the context that should be used during unloading.
884
+ * @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.
885
+ * @returns boolean - true if the plugin has or will call processNext(), this for backward compatibility as previously teardown was synchronous and returned nothing.
886
+ */
887
+ teardown?: (unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState) => void | boolean;
888
+ /**
889
+ * Flush to send data immediately; channel should default to sending data asynchronously. If executing asynchronously and
890
+ * you DO NOT pass a callback function then a [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html)
891
+ * will be returned which will resolve once the flush is complete. The actual implementation of the `IPromise`
892
+ * will be a native Promise (if supported) or the default as supplied by [ts-async library](https://github.com/nevware21/ts-async)
893
+ * @param async - send data asynchronously when true
894
+ * @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.
895
+ * If the caller doesn't return true the caller should assume that it may never be called.
896
+ * @param sendReason - specify the reason that you are calling "flush" defaults to ManualFlush (1) if not specified
897
+ * @returns - If a callback is provided `true` to indicate that callback will be called after the flush is complete otherwise the caller
898
+ * should assume that any provided callback will never be called, Nothing or if occurring asynchronously a
899
+ * [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html) which will be resolved once the unload is complete,
900
+ * the [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html) will only be returned when no callback is provided
901
+ * and async is true.
902
+ */
903
+ flush?(async: boolean, callBack?: (flushComplete?: boolean) => void, sendReason?: SendRequestReason): boolean | void | IPromise<boolean>;
904
+ }
905
+
906
+ /**
907
+ * Configuration settings for how telemetry is sent
908
+ * @export
909
+ * @interface IConfig
910
+ */
911
+ interface IConfig {
912
+ /**
913
+ * The JSON format (normal vs line delimited). True means line delimited JSON.
914
+ */
915
+ emitLineDelimitedJson?: boolean;
916
+ /**
917
+ * An optional account id, if your app groups users into accounts. No spaces, commas, semicolons, equals, or vertical bars.
918
+ */
919
+ accountId?: string;
920
+ /**
921
+ * A session is logged if the user is inactive for this amount of time in milliseconds. Default 30 mins.
922
+ * @default 30*60*1000
923
+ */
924
+ sessionRenewalMs?: number;
925
+ /**
926
+ * A session is logged if it has continued for this amount of time in milliseconds. Default 24h.
927
+ * @default 24*60*60*1000
928
+ */
929
+ sessionExpirationMs?: number;
930
+ /**
931
+ * Max size of telemetry batch. If batch exceeds limit, it is sent and a new batch is started
932
+ * @default 100000
933
+ */
934
+ maxBatchSizeInBytes?: number;
935
+ /**
936
+ * How long to batch telemetry for before sending (milliseconds)
937
+ * @default 15 seconds
938
+ */
939
+ maxBatchInterval?: number;
940
+ /**
941
+ * If true, debugging data is thrown as an exception by the logger. Default false
942
+ * @defaultValue false
943
+ */
944
+ enableDebug?: boolean;
945
+ /**
946
+ * If true, exceptions are not autocollected. Default is false
947
+ * @defaultValue false
948
+ */
949
+ disableExceptionTracking?: boolean;
950
+ /**
951
+ * If true, telemetry is not collected or sent. Default is false
952
+ * @defaultValue false
953
+ */
954
+ disableTelemetry?: boolean;
955
+ /**
956
+ * Percentage of events that will be sent. Default is 100, meaning all events are sent.
957
+ * @defaultValue 100
958
+ */
959
+ samplingPercentage?: number;
960
+ /**
961
+ * If true, on a pageview, the previous instrumented page's view time is tracked and sent as telemetry and a new timer is started for the current pageview. It is sent as a custom metric named PageVisitTime in milliseconds and is calculated via the Date now() function (if available) and falls back to (new Date()).getTime() if now() is unavailable (IE8 or less). Default is false.
962
+ */
963
+ autoTrackPageVisitTime?: boolean;
964
+ /**
965
+ * Automatically track route changes in Single Page Applications (SPA). If true, each route change will send a new Pageview to Application Insights.
966
+ */
967
+ enableAutoRouteTracking?: boolean;
968
+ /**
969
+ * If true, Ajax calls are not autocollected. Default is false
970
+ * @defaultValue false
971
+ */
972
+ disableAjaxTracking?: boolean;
973
+ /**
974
+ * If true, Fetch requests are not autocollected. Default is false (Since 2.8.0, previously true).
975
+ * @defaultValue false
976
+ */
977
+ disableFetchTracking?: boolean;
978
+ /**
979
+ * Provide a way to exclude specific route from automatic tracking for XMLHttpRequest or Fetch request. For an ajax / fetch request that the request url matches with the regex patterns, auto tracking is turned off.
980
+ * @defaultValue undefined.
981
+ */
982
+ excludeRequestFromAutoTrackingPatterns?: string[] | RegExp[];
983
+ /**
984
+ * Provide a way to enrich dependencies logs with context at the beginning of api call.
985
+ * Default is undefined.
986
+ */
987
+ addRequestContext?: (requestContext?: IRequestContext) => ICustomProperties;
988
+ /**
989
+ * If true, default behavior of trackPageView is changed to record end of page view duration interval when trackPageView is called. If false and no custom duration is provided to trackPageView, the page view performance is calculated using the navigation timing API. Default is false
990
+ * @defaultValue false
991
+ */
992
+ overridePageViewDuration?: boolean;
993
+ /**
994
+ * Default 500 - controls how many ajax calls will be monitored per page view. Set to -1 to monitor all (unlimited) ajax calls on the page.
995
+ */
996
+ maxAjaxCallsPerView?: number;
997
+ /**
998
+ * @ignore
999
+ * If false, internal telemetry sender buffers will be checked at startup for items not yet sent. Default is true
1000
+ * @defaultValue true
1001
+ */
1002
+ disableDataLossAnalysis?: boolean;
1003
+ /**
1004
+ * If false, the SDK will add two headers ('Request-Id' and 'Request-Context') to all dependency requests to correlate them with corresponding requests on the server side. Default is false.
1005
+ * @defaultValue false
1006
+ */
1007
+ disableCorrelationHeaders?: boolean;
1008
+ /**
1009
+ * Sets the distributed tracing mode. If AI_AND_W3C mode or W3C mode is set, W3C trace context headers (traceparent/tracestate) will be generated and included in all outgoing requests.
1010
+ * AI_AND_W3C is provided for back-compatibility with any legacy Application Insights instrumented services
1011
+ * @defaultValue AI_AND_W3C
1012
+ */
1013
+ distributedTracingMode?: DistributedTracingModes;
1014
+ /**
1015
+ * Disable correlation headers for specific domain
1016
+ */
1017
+ correlationHeaderExcludedDomains?: string[];
1018
+ /**
1019
+ * Default false. If true, flush method will not be called when onBeforeUnload, onUnload, onPageHide or onVisibilityChange (hidden state) event(s) trigger.
1020
+ */
1021
+ disableFlushOnBeforeUnload?: boolean;
1022
+ /**
1023
+ * Default value of {@link #disableFlushOnBeforeUnload}. If true, flush method will not be called when onPageHide or onVisibilityChange (hidden state) event(s) trigger.
1024
+ */
1025
+ disableFlushOnUnload?: boolean;
1026
+ /**
1027
+ * If true, the buffer with all unsent telemetry is stored in session storage. The buffer is restored on page load. Default is true.
1028
+ * @defaultValue true
1029
+ */
1030
+ enableSessionStorageBuffer?: boolean;
1031
+ /**
1032
+ * If specified, overrides the storage & retrieval mechanism that is used to manage unsent telemetry.
1033
+ */
1034
+ bufferOverride?: IStorageBuffer;
1035
+ /**
1036
+ * @deprecated Use either disableCookiesUsage or specify a cookieCfg with the enabled value set.
1037
+ * If true, the SDK will not store or read any data from cookies. Default is false. As this field is being deprecated, when both
1038
+ * isCookieUseDisabled and disableCookiesUsage are used disableCookiesUsage will take precedent.
1039
+ * @defaultValue false
1040
+ */
1041
+ isCookieUseDisabled?: boolean;
1042
+ /**
1043
+ * If true, the SDK will not store or read any data from cookies. Default is false.
1044
+ * If you have also specified a cookieCfg then enabled property (if specified) will take precedent over this value.
1045
+ * @defaultValue false
1046
+ */
1047
+ disableCookiesUsage?: boolean;
1048
+ /**
1049
+ * Custom cookie domain. This is helpful if you want to share Application Insights cookies across subdomains.
1050
+ * @defaultValue ""
1051
+ */
1052
+ cookieDomain?: string;
1053
+ /**
1054
+ * Custom cookie path. This is helpful if you want to share Application Insights cookies behind an application gateway.
1055
+ * @defaultValue ""
1056
+ */
1057
+ cookiePath?: string;
1058
+ /**
1059
+ * Default false. If false, retry on 206 (partial success), 408 (timeout), 429 (too many requests), 500 (internal server error), 503 (service unavailable), and 0 (offline, only if detected)
1060
+ * @description
1061
+ * @defaultValue false
1062
+ */
1063
+ isRetryDisabled?: boolean;
1064
+ /**
1065
+ * @deprecated Used when initizialing from snippet only.
1066
+ * The url from where the JS SDK will be downloaded.
1067
+ */
1068
+ url?: string;
1069
+ /**
1070
+ * If true, the SDK will not store or read any data from local and session storage. Default is false.
1071
+ * @defaultValue false
1072
+ */
1073
+ isStorageUseDisabled?: boolean;
1074
+ /**
1075
+ * If false, the SDK will send all telemetry using the [Beacon API](https://www.w3.org/TR/beacon)
1076
+ * @defaultValue true
1077
+ */
1078
+ isBeaconApiDisabled?: boolean;
1079
+ /**
1080
+ * Don't use XMLHttpRequest or XDomainRequest (for IE < 9) by default instead attempt to use fetch() or sendBeacon.
1081
+ * If no other transport is available it will still use XMLHttpRequest
1082
+ */
1083
+ disableXhr?: boolean;
1084
+ /**
1085
+ * If fetch keepalive is supported do not use it for sending events during unload, it may still fallback to fetch() without keepalive
1086
+ */
1087
+ onunloadDisableFetch?: boolean;
1088
+ /**
1089
+ * Sets the sdk extension name. Only alphabetic characters are allowed. The extension name is added as a prefix to the 'ai.internal.sdkVersion' tag (e.g. 'ext_javascript:2.0.0'). Default is null.
1090
+ * @defaultValue null
1091
+ */
1092
+ sdkExtension?: string;
1093
+ /**
1094
+ * Default is false. If true, the SDK will track all [Browser Link](https://docs.microsoft.com/en-us/aspnet/core/client-side/using-browserlink) requests.
1095
+ * @defaultValue false
1096
+ */
1097
+ isBrowserLinkTrackingEnabled?: boolean;
1098
+ /**
1099
+ * AppId is used for the correlation between AJAX dependencies happening on the client-side with the server-side requets. When Beacon API is enabled, it cannot be used automatically, but can be set manually in the configuration. Default is null
1100
+ * @defaultValue null
1101
+ */
1102
+ appId?: string;
1103
+ /**
1104
+ * If true, the SDK will add two headers ('Request-Id' and 'Request-Context') to all CORS requests to correlate outgoing AJAX dependencies with corresponding requests on the server side. Default is false
1105
+ * @defaultValue false
1106
+ */
1107
+ enableCorsCorrelation?: boolean;
1108
+ /**
1109
+ * An optional value that will be used as name postfix for localStorage and session cookie name.
1110
+ * @defaultValue null
1111
+ */
1112
+ namePrefix?: string;
1113
+ /**
1114
+ * An optional value that will be used as name postfix for session cookie name. If undefined, namePrefix is used as name postfix for session cookie name.
1115
+ * @defaultValue null
1116
+ */
1117
+ sessionCookiePostfix?: string;
1118
+ /**
1119
+ * An optional value that will be used as name postfix for user cookie name. If undefined, no postfix is added on user cookie name.
1120
+ * @defaultValue null
1121
+ */
1122
+ userCookiePostfix?: string;
1123
+ /**
1124
+ * An optional value that will track Request Header through trackDependency function.
1125
+ * @defaultValue false
1126
+ */
1127
+ enableRequestHeaderTracking?: boolean;
1128
+ /**
1129
+ * An optional value that will track Response Header through trackDependency function.
1130
+ * @defaultValue false
1131
+ */
1132
+ enableResponseHeaderTracking?: boolean;
1133
+ /**
1134
+ * An optional value that will track Response Error data through trackDependency function.
1135
+ * @defaultValue false
1136
+ */
1137
+ enableAjaxErrorStatusText?: boolean;
1138
+ /**
1139
+ * Flag to enable looking up and including additional browser window.performance timings
1140
+ * in the reported ajax (XHR and fetch) reported metrics.
1141
+ * Defaults to false.
1142
+ */
1143
+ enableAjaxPerfTracking?: boolean;
1144
+ /**
1145
+ * The maximum number of times to look for the window.performance timings (if available), this
1146
+ * is required as not all browsers populate the window.performance before reporting the
1147
+ * end of the XHR request and for fetch requests this is added after its complete
1148
+ * Defaults to 3
1149
+ */
1150
+ maxAjaxPerfLookupAttempts?: number;
1151
+ /**
1152
+ * The amount of time to wait before re-attempting to find the windows.performance timings
1153
+ * for an ajax request, time is in milliseconds and is passed directly to setTimeout()
1154
+ * Defaults to 25.
1155
+ */
1156
+ ajaxPerfLookupDelay?: number;
1157
+ /**
1158
+ * Default false. when tab is closed, the SDK will send all remaining telemetry using the [Beacon API](https://www.w3.org/TR/beacon)
1159
+ * @defaultValue false
1160
+ */
1161
+ onunloadDisableBeacon?: boolean;
1162
+ /**
1163
+ * @ignore
1164
+ * Internal only
1165
+ */
1166
+ autoExceptionInstrumented?: boolean;
1167
+ /**
1168
+ *
1169
+ */
1170
+ correlationHeaderDomains?: string[];
1171
+ /**
1172
+ * @ignore
1173
+ * Internal only
1174
+ */
1175
+ autoUnhandledPromiseInstrumented?: boolean;
1176
+ /**
1177
+ * Default false. Define whether to track unhandled promise rejections and report as JS errors.
1178
+ * When disableExceptionTracking is enabled (dont track exceptions) this value will be false.
1179
+ * @defaultValue false
1180
+ */
1181
+ enableUnhandledPromiseRejectionTracking?: boolean;
1182
+ /**
1183
+ * Disable correlation headers using regular expressions
1184
+ */
1185
+ correlationHeaderExcludePatterns?: RegExp[];
1186
+ /**
1187
+ * The ability for the user to provide extra headers
1188
+ */
1189
+ customHeaders?: [{
1190
+ header: string;
1191
+ value: string;
1192
+ }];
1193
+ /**
1194
+ * Provide user an option to convert undefined field to user defined value.
1195
+ */
1196
+ convertUndefined?: any;
1197
+ /**
1198
+ * [Optional] The number of events that can be kept in memory before the SDK starts to drop events. By default, this is 10,000.
1199
+ */
1200
+ eventsLimitInMem?: number;
1201
+ /**
1202
+ * [Optional] Disable iKey deprecation error message.
1203
+ * @defaultValue true
1204
+ */
1205
+ disableIkeyDeprecationMessage?: boolean;
1206
+ /**
1207
+ * [Optional] Flag to indicate whether the internal looking endpoints should be automatically
1208
+ * added to the `excludeRequestFromAutoTrackingPatterns` collection. (defaults to true).
1209
+ * This flag exists as the provided regex is generic and may unexpectedly match a domain that
1210
+ * should not be excluded.
1211
+ */
1212
+ addIntEndpoints?: boolean;
1213
+ /**
1214
+ * [Optional] Sets throttle mgr configuration by key
1215
+ */
1216
+ throttleMgrCfg?: {
1217
+ [key: number]: IThrottleMgrConfig;
1218
+ };
1219
+ }
1220
+
1221
+ /**
1222
+ * The type to identify whether the default value should be applied in preference to the provided value.
1223
+ */
1224
+ type IConfigCheckFn<V> = (value: V) => boolean;
1225
+
1226
+ /**
1227
+ * The default values with a check function
1228
+ */
1229
+ interface IConfigDefaultCheck<T, V, C = IConfiguration> {
1230
+ /**
1231
+ * Callback function to check if the user-supplied value is valid, if not the default will be applied
1232
+ */
1233
+ isVal?: IConfigCheckFn<V>;
1234
+ /**
1235
+ * Optional function to allow converting and setting of the default value
1236
+ */
1237
+ set?: IConfigSetFn<T, V>;
1238
+ /**
1239
+ * The default value to apply if the user-supplied value is not valid
1240
+ */
1241
+ v?: V | IConfigDefaults<V, T>;
1242
+ /**
1243
+ * The default fallback key if the main key is not present, this is the key value from the config
1244
+ */
1245
+ fb?: keyof T | keyof C | Array<keyof T | keyof C>;
1246
+ /**
1247
+ * Use this check to determine the default fallback, default only checked whether the property isDefined,
1248
+ * therefore `null`; `""` are considered to be valid values.
1249
+ */
1250
+ dfVal?: (value: any) => boolean;
1251
+ /**
1252
+ * Specify that any provided value should have the default value(s) merged into the value rather than
1253
+ * just using either the default of user provided values. Mergeed objects will automatically be marked
1254
+ * as referenced.
1255
+ */
1256
+ mrg?: boolean;
1257
+ /**
1258
+ * Set this field of the target as referenced, which will cause any object or array instance
1259
+ * to be updated in-place rather than being entirely replaced. All other values will continue to be replaced.
1260
+ * This is required for nested default objects to avoid multiple repetitive updates to listeners
1261
+ * @returns The referenced properties current value
1262
+ */
1263
+ ref?: boolean;
1264
+ /**
1265
+ * Set this field of the target as read-only, which will block this single named property from
1266
+ * ever being changed for the target instance.
1267
+ * This does NOT freeze or seal the instance, it just stops the direct re-assignment of the named property,
1268
+ * if the value is a non-primitive (ie. an object or array) it's properties will still be mutable.
1269
+ * @returns The referenced properties current value
1270
+ */
1271
+ rdOnly?: boolean;
1272
+ /**
1273
+ * Block the value associated with this property from having it's properties / values converted into
1274
+ * dynamic properties, this is generally used to block objects or arrays provided by external libraries
1275
+ * which may be a plain object with readonly (non-configurable) or const properties.
1276
+ */
1277
+ blkVal?: boolean;
1278
+ }
1279
+
1280
+ /**
1281
+ * The Type definition to define default values to be applied to the config
1282
+ * The value may be either the direct value or a ConfigDefaultCheck definition
1283
+ */
1284
+ type IConfigDefaults<T, C = IConfiguration> = {
1285
+ [key in keyof T]: T[key] | IConfigDefaultCheck<T, T[key], C>;
1286
+ };
1287
+
1288
+ /**
1289
+ * The type which identifies the function use to validate the user supplied value
1290
+ */
1291
+ type IConfigSetFn<T, V> = (value: any, defValue: V, theConfig: T) => V;
1292
+
1293
+ /**
1294
+ * Configuration provided to SDK core
1295
+ */
1296
+ interface IConfiguration {
1297
+ /**
1298
+ * Instrumentation key of resource. Either this or connectionString must be specified.
1299
+ */
1300
+ instrumentationKey?: string;
1301
+ /**
1302
+ * Connection string of resource. Either this or instrumentationKey must be specified.
1303
+ */
1304
+ connectionString?: string;
1305
+ /**
1306
+ * Set the timer interval (in ms) for internal logging queue, this is the
1307
+ * amount of time to wait after logger.queue messages are detected to be sent.
1308
+ * Note: since 3.0.1 and 2.8.13 the diagnostic logger timer is a normal timeout timer
1309
+ * and not an interval timer. So this now represents the timer "delay" and not
1310
+ * the frequency at which the events are sent.
1311
+ */
1312
+ diagnosticLogInterval?: number;
1313
+ /**
1314
+ * Maximum number of iKey transmitted logging telemetry per page view
1315
+ */
1316
+ maxMessageLimit?: number;
1317
+ /**
1318
+ * Console logging level. All logs with a severity level higher
1319
+ * than the configured level will be printed to console. Otherwise
1320
+ * they are suppressed. ie Level 2 will print both CRITICAL and
1321
+ * WARNING logs to console, level 1 prints only CRITICAL.
1322
+ *
1323
+ * Note: Logs sent as telemetry to instrumentation key will also
1324
+ * be logged to console if their severity meets the configured loggingConsoleLevel
1325
+ *
1326
+ * 0: ALL console logging off
1327
+ * 1: logs to console: severity >= CRITICAL
1328
+ * 2: logs to console: severity >= WARNING
1329
+ */
1330
+ loggingLevelConsole?: number;
1331
+ /**
1332
+ * Telemtry logging level to instrumentation key. All logs with a severity
1333
+ * level higher than the configured level will sent as telemetry data to
1334
+ * the configured instrumentation key.
1335
+ *
1336
+ * 0: ALL iKey logging off
1337
+ * 1: logs to iKey: severity >= CRITICAL
1338
+ * 2: logs to iKey: severity >= WARNING
1339
+ */
1340
+ loggingLevelTelemetry?: number;
1341
+ /**
1342
+ * If enabled, uncaught exceptions will be thrown to help with debugging
1343
+ */
1344
+ enableDebug?: boolean;
1345
+ /**
1346
+ * Endpoint where telemetry data is sent
1347
+ */
1348
+ endpointUrl?: string;
1349
+ /**
1350
+ * Extension configs loaded in SDK
1351
+ */
1352
+ extensionConfig?: {
1353
+ [key: string]: any;
1354
+ };
1355
+ /**
1356
+ * Additional plugins that should be loaded by core at runtime
1357
+ */
1358
+ readonly extensions?: ITelemetryPlugin[];
1359
+ /**
1360
+ * Channel queues that is setup by caller in desired order.
1361
+ * If channels are provided here, core will ignore any channels that are already setup, example if there is a SKU with an initialized channel
1362
+ */
1363
+ readonly channels?: IChannelControls[][];
1364
+ /**
1365
+ * @type {boolean}
1366
+ * Flag that disables the Instrumentation Key validation.
1367
+ */
1368
+ disableInstrumentationKeyValidation?: boolean;
1369
+ /**
1370
+ * [Optional] When enabled this will create local perfEvents based on sections of the code that have been instrumented
1371
+ * to emit perfEvents (via the doPerf()) when this is enabled. This can be used to identify performance issues within
1372
+ * the SDK, the way you are using it or optionally your own instrumented code.
1373
+ * The provided IPerfManager implementation does NOT send any additional telemetry events to the server it will only fire
1374
+ * the new perfEvent() on the INotificationManager which you can listen to.
1375
+ * This also does not use the window.performance API, so it will work in environments where this API is not supported.
1376
+ */
1377
+ enablePerfMgr?: boolean;
1378
+ /**
1379
+ * [Optional] Callback function that will be called to create a the IPerfManager instance when required and ```enablePerfMgr```
1380
+ * is enabled, this enables you to override the default creation of a PerfManager() without needing to ```setPerfMgr()```
1381
+ * after initialization.
1382
+ */
1383
+ createPerfMgr?: (core: IAppInsightsCore, notificationManager: INotificationManager) => IPerfManager;
1384
+ /**
1385
+ * [Optional] Fire every single performance event not just the top level root performance event. Defaults to false.
1386
+ */
1387
+ perfEvtsSendAll?: boolean;
1388
+ /**
1389
+ * [Optional] Identifies the default length used to generate random session and user id's if non currently exists for the user / session.
1390
+ * Defaults to 22, previous default value was 5, if you need to keep the previous maximum length you should set this value to 5.
1391
+ */
1392
+ idLength?: number;
1393
+ /**
1394
+ * @description Custom cookie domain. This is helpful if you want to share Application Insights cookies across subdomains. It
1395
+ * can be set here or as part of the cookieCfg.domain, the cookieCfg takes precedence if both are specified.
1396
+ * @type {string}
1397
+ * @defaultValue ""
1398
+ */
1399
+ cookieDomain?: string;
1400
+ /**
1401
+ * @description Custom cookie path. This is helpful if you want to share Application Insights cookies behind an application
1402
+ * gateway. It can be set here or as part of the cookieCfg.domain, the cookieCfg takes precedence if both are specified.
1403
+ * @type {string}
1404
+ * @defaultValue ""
1405
+ */
1406
+ cookiePath?: string;
1407
+ /**
1408
+ * [Optional] A boolean that indicated whether to disable the use of cookies by the SDK. If true, the SDK will not store or
1409
+ * read any data from cookies. Cookie usage can be re-enabled after initialization via the core.getCookieMgr().enable().
1410
+ */
1411
+ disableCookiesUsage?: boolean;
1412
+ /**
1413
+ * [Optional] A Cookie Manager configuration which includes hooks to allow interception of the get, set and delete cookie
1414
+ * operations. If this configuration is specified any specified enabled and domain properties will take precedence over the
1415
+ * cookieDomain and disableCookiesUsage values.
1416
+ */
1417
+ cookieCfg?: ICookieMgrConfig;
1418
+ /**
1419
+ * [Optional] An array of the page unload events that you would like to be ignored, special note there must be at least one valid unload
1420
+ * event hooked, if you list all or the runtime environment only supports a listed "disabled" event it will still be hooked, if required by the SDK.
1421
+ * Unload events include "beforeunload", "unload", "visibilitychange" (with 'hidden' state) and "pagehide"
1422
+ */
1423
+ disablePageUnloadEvents?: string[];
1424
+ /**
1425
+ * [Optional] An array of page show events that you would like to be ignored, special note there must be at lease one valid show event
1426
+ * hooked, if you list all or the runtime environment only supports a listed (disabled) event it will STILL be hooked, if required by the SDK.
1427
+ * Page Show events include "pageshow" and "visibilitychange" (with 'visible' state)
1428
+ */
1429
+ disablePageShowEvents?: string[];
1430
+ /**
1431
+ * [Optional] A flag for performance optimization to disable attempting to use the Chrome Debug Extension, if disabled and the extension is installed
1432
+ * this will not send any notifications.
1433
+ */
1434
+ disableDbgExt?: boolean;
1435
+ /**
1436
+ * Add "&w=0" parameter to support UA Parsing when web-workers don't have access to Document.
1437
+ * Default is false
1438
+ */
1439
+ enableWParam?: boolean;
1440
+ /**
1441
+ * Custom optional value that will be added as a prefix for storage name.
1442
+ * @defaultValue undefined
1443
+ */
1444
+ storagePrefix?: string;
1445
+ /**
1446
+ * Custom optional value to opt in features
1447
+ * @defaultValue undefined
1448
+ */
1449
+ featureOptIn?: IFeatureOptIn;
1450
+ }
1451
+
1452
+ interface ICookieMgr {
1453
+ /**
1454
+ * Enable or Disable the usage of cookies
1455
+ */
1456
+ setEnabled(value: boolean): void;
1457
+ /**
1458
+ * Can the system use cookies, if this returns false then all cookie setting and access functions will return nothing
1459
+ */
1460
+ isEnabled(): boolean;
1461
+ /**
1462
+ * Set the named cookie with the value and optional domain and optional
1463
+ * @param name - The name of the cookie
1464
+ * @param value - The value of the cookie (Must already be encoded)
1465
+ * @param maxAgeSec - [optional] The maximum number of SECONDS that this cookie should survive
1466
+ * @param domain - [optional] The domain to set for the cookie
1467
+ * @param path - [optional] Path to set for the cookie, if not supplied will default to "/"
1468
+ * @returns - True if the cookie was set otherwise false (Because cookie usage is not enabled or available)
1469
+ */
1470
+ set(name: string, value: string, maxAgeSec?: number, domain?: string, path?: string): boolean;
1471
+ /**
1472
+ * Get the value of the named cookie
1473
+ * @param name - The name of the cookie
1474
+ */
1475
+ get(name: string): string;
1476
+ /**
1477
+ * Delete/Remove the named cookie if cookie support is available and enabled.
1478
+ * Note: Not using "delete" as the name because it's a reserved word which would cause issues on older browsers
1479
+ * @param name - The name of the cookie
1480
+ * @param path - [optional] Path to set for the cookie, if not supplied will default to "/"
1481
+ * @returns - True if the cookie was marked for deletion otherwise false (Because cookie usage is not enabled or available)
1482
+ */
1483
+ del(name: string, path?: string): boolean;
1484
+ /**
1485
+ * Purge the cookie from the system if cookie support is available, this function ignores the enabled setting of the manager
1486
+ * so any cookie will be removed.
1487
+ * Note: Not using "delete" as the name because it's a reserved word which would cause issues on older browsers
1488
+ * @param name - The name of the cookie
1489
+ * @param path - [optional] Path to set for the cookie, if not supplied will default to "/"
1490
+ * @returns - True if the cookie was marked for deletion otherwise false (Because cookie usage is not available)
1491
+ */
1492
+ purge(name: string, path?: string): boolean;
1493
+ /**
1494
+ * Optional Callback hook to allow the cookie manager to update it's configuration, not generally implemented now that
1495
+ * dynamic configuration is supported
1496
+ * @param updateState
1497
+ */
1498
+ update?(updateState: ITelemetryUpdateState): void;
1499
+ /**
1500
+ * Unload and remove any state that this ICookieMgr may be holding, this is generally called when the
1501
+ * owning SDK is being unloaded.
1502
+ * @param isAsync - Can the unload be performed asynchronously (default)
1503
+ * @return If the unload occurs synchronously then nothing should be returned, if happening asynchronously then
1504
+ * the function should return an [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html)
1505
+ * / Promise to allow any listeners to wait for the operation to complete.
1506
+ */
1507
+ unload?(isAsync?: boolean): void | IPromise<void>;
1508
+ }
1509
+
1510
+ /**
1511
+ * Configuration definition for instance based cookie management configuration
1512
+ */
1513
+ interface ICookieMgrConfig {
1514
+ /**
1515
+ * Defaults to true, A boolean that indicates whether the use of cookies by the SDK is enabled by the current instance.
1516
+ * If false, the instance of the SDK initialized by this configuration will not store or read any data from cookies
1517
+ */
1518
+ enabled?: boolean;
1519
+ /**
1520
+ * Custom cookie domain. This is helpful if you want to share Application Insights cookies across subdomains.
1521
+ */
1522
+ domain?: string;
1523
+ /**
1524
+ * Specifies the path to use for the cookie, defaults to '/'
1525
+ */
1526
+ path?: string;
1527
+ /**
1528
+ * Specify the cookie name(s) to be ignored, this will cause any matching cookie name to never be read or written.
1529
+ * They may still be explicitly purged or deleted. You do not need to repeat the name in the `blockedCookies`
1530
+ * configuration.(Since v2.8.8)
1531
+ */
1532
+ ignoreCookies?: string[];
1533
+ /**
1534
+ * Specify the cookie name(s) to never be written, this will cause any cookie name to never be created or updated,
1535
+ * they will still be read unless also included in the ignoreCookies and may still be explicitly purged or deleted.
1536
+ * If not provided defaults to the same list provided in ignoreCookies. (Since v2.8.8)
1537
+ */
1538
+ blockedCookies?: string[];
1539
+ /**
1540
+ * Hook function to fetch the named cookie value.
1541
+ * @param name - The name of the cookie
1542
+ */
1543
+ getCookie?: (name: string) => string;
1544
+ /**
1545
+ * Hook function to set the named cookie with the specified value.
1546
+ * @param name - The name of the cookie
1547
+ * @param value - The value to set for the cookie
1548
+ */
1549
+ setCookie?: (name: string, value: string) => void;
1550
+ /**
1551
+ * Hook function to delete the named cookie with the specified value, separated from
1552
+ * setCookie to avoid the need to parse the value to determine whether the cookie is being
1553
+ * added or removed.
1554
+ * @param name - The name of the cookie
1555
+ * @param cookieValue - The value to set to expire the cookie
1556
+ */
1557
+ delCookie?: (name: string, cookieValue: string) => void;
1558
+ }
1559
+
1560
+ interface ICustomProperties {
1561
+ [key: string]: any;
1562
+ }
1563
+
1564
+ /**
1565
+ * DependencyTelemetry telemetry interface
1566
+ */
1567
+ interface IDependencyTelemetry extends IPartC {
1568
+ id: string;
1569
+ name?: string;
1570
+ duration?: number;
1571
+ success?: boolean;
1572
+ startTime?: Date;
1573
+ responseCode: number;
1574
+ correlationContext?: string;
1575
+ type?: string;
1576
+ data?: string;
1577
+ target?: string;
1578
+ iKey?: string;
1579
+ }
1580
+
1581
+ interface IDiagnosticLogger {
1582
+ /**
1583
+ * 0: OFF
1584
+ * 1: only critical (default)
1585
+ * 2: critical + info
1586
+ */
1587
+ consoleLoggingLevel: () => number;
1588
+ /**
1589
+ * The internal logging queue
1590
+ */
1591
+ queue: _InternalLogMessage[];
1592
+ /**
1593
+ * This method will throw exceptions in debug mode or attempt to log the error as a console warning.
1594
+ * @param severity - The severity of the log message
1595
+ * @param message - The log message.
1596
+ */
1597
+ throwInternal(severity: LoggingSeverity, msgId: _InternalMessageId, msg: string, properties?: Object, isUserAct?: boolean): void;
1598
+ /**
1599
+ * This will write a debug message to the console if possible
1600
+ * @param message - {string} - The debug message
1601
+ */
1602
+ debugToConsole?(message: string): void;
1603
+ /**
1604
+ * This will write a warning to the console if possible
1605
+ * @param message - The warning message
1606
+ */
1607
+ warnToConsole(message: string): void;
1608
+ /**
1609
+ * This will write an error to the console if possible.
1610
+ * Provided by the default DiagnosticLogger instance, and internally the SDK will fall back to warnToConsole, however,
1611
+ * direct callers MUST check for its existence on the logger as you can provide your own IDiagnosticLogger instance.
1612
+ * @param message - The error message
1613
+ */
1614
+ errorToConsole?(message: string): void;
1615
+ /**
1616
+ * Resets the internal message count
1617
+ */
1618
+ resetInternalMessageCount(): void;
1619
+ /**
1620
+ * Logs a message to the internal queue.
1621
+ * @param severity - The severity of the log message
1622
+ * @param message - The message to log.
1623
+ */
1624
+ logInternalMessage?(severity: LoggingSeverity, message: _InternalLogMessage): void;
1625
+ /**
1626
+ * Optional Callback hook to allow the diagnostic logger to update it's configuration
1627
+ * @param updateState
1628
+ */
1629
+ update?(updateState: ITelemetryUpdateState): void;
1630
+ /**
1631
+ * Unload and remove any state that this IDiagnosticLogger may be holding, this is generally called when the
1632
+ * owning SDK is being unloaded.
1633
+ * @param isAsync - Can the unload be performed asynchronously (default)
1634
+ * @return If the unload occurs synchronously then nothing should be returned, if happening asynchronously then
1635
+ * the function should return an [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html)
1636
+ * / Promise to allow any listeners to wait for the operation to complete.
1637
+ */
1638
+ unload?(isAsync?: boolean): void | IPromise<void>;
1639
+ }
1640
+
1641
+ interface IDistributedTraceContext {
1642
+ /**
1643
+ * Returns the current name of the page
1644
+ */
1645
+ getName(): string;
1646
+ /**
1647
+ * Sets the current name of the page
1648
+ * @param pageName
1649
+ */
1650
+ setName(pageName: string): void;
1651
+ /**
1652
+ * Returns the unique identifier for a trace. All requests / spans from the same trace share the same traceId.
1653
+ * Must be read from incoming headers or generated according to the W3C TraceContext specification,
1654
+ * in a hex representation of 16-byte array. A.k.a. trace-id, TraceID or Distributed TraceID
1655
+ */
1656
+ getTraceId(): string;
1657
+ /**
1658
+ * Set the unique identifier for a trace. All requests / spans from the same trace share the same traceId.
1659
+ * Must be conform to the W3C TraceContext specification, in a hex representation of 16-byte array.
1660
+ * A.k.a. trace-id, TraceID or Distributed TraceID https://www.w3.org/TR/trace-context/#trace-id
1661
+ */
1662
+ setTraceId(newValue: string): void;
1663
+ /**
1664
+ * Self-generated 8-bytes identifier of the incoming request. Must be a hex representation of 8-byte array.
1665
+ * Also know as the parentId, used to link requests together
1666
+ */
1667
+ getSpanId(): string;
1668
+ /**
1669
+ * Self-generated 8-bytes identifier of the incoming request. Must be a hex representation of 8-byte array.
1670
+ * Also know as the parentId, used to link requests together
1671
+ * https://www.w3.org/TR/trace-context/#parent-id
1672
+ */
1673
+ setSpanId(newValue: string): void;
1674
+ /**
1675
+ * An integer representation of the W3C TraceContext trace-flags.
1676
+ */
1677
+ getTraceFlags(): number | undefined;
1678
+ /**
1679
+ * https://www.w3.org/TR/trace-context/#trace-flags
1680
+ * @param newValue
1681
+ */
1682
+ setTraceFlags(newValue?: number): void;
1683
+ }
1684
+
1685
+ interface IEnvelope extends ISerializable {
1686
+ /**
1687
+ * Envelope version. For internal use only. By assigning this the default, it will not be serialized within the payload unless changed to a value other than #1.
1688
+ */
1689
+ ver: number;
1690
+ /**
1691
+ * Type name of telemetry data item.
1692
+ */
1693
+ name: string;
1694
+ /**
1695
+ * Event date time when telemetry item was created. This is the wall clock time on the client when the event was generated. There is no guarantee that the client's time is accurate. This field must be formatted in UTC ISO 8601 format, with a trailing 'Z' character, as described publicly on https://en.wikipedia.org/wiki/ISO_8601#UTC. Note: the number of decimal seconds digits provided are variable (and unspecified). Consumers should handle this, i.e. managed code consumers should not use format 'O' for parsing as it specifies a fixed length. Example: 2009-06-15T13:45:30.0000000Z.
1696
+ */
1697
+ time: string;
1698
+ /**
1699
+ * Sampling rate used in application. This telemetry item represents 1 / sampleRate actual telemetry items.
1700
+ */
1701
+ sampleRate: number;
1702
+ /**
1703
+ * Sequence field used to track absolute order of uploaded events.
1704
+ */
1705
+ seq: string;
1706
+ /**
1707
+ * The application's instrumentation key. The key is typically represented as a GUID, but there are cases when it is not a guid. No code should rely on iKey being a GUID. Instrumentation key is case insensitive.
1708
+ */
1709
+ iKey: string;
1710
+ /**
1711
+ * Key/value collection of context properties. See ContextTagKeys for information on available properties.
1712
+ */
1713
+ tags: {
1714
+ [name: string]: any;
1715
+ };
1716
+ /**
1717
+ * Telemetry data item.
1718
+ */
1719
+ data: any;
1720
+ }
1721
+
1722
+ interface IEventTelemetry extends IPartC {
1723
+ /**
1724
+ * @description An event name string
1725
+ * @type {string}
1726
+ * @memberof IEventTelemetry
1727
+ */
1728
+ name: string;
1729
+ /**
1730
+ * @description custom defined iKey
1731
+ * @type {string}
1732
+ * @memberof IEventTelemetry
1733
+ */
1734
+ iKey?: string;
1735
+ }
1736
+
1737
+ interface IFeatureOptIn {
1738
+ [feature: string]: IFeatureOptInDetails;
1739
+ }
1740
+
1741
+ interface IFeatureOptInDetails {
1742
+ /**
1743
+ * sets feature opt-in mode
1744
+ * @default undefined
1745
+ */
1746
+ mode?: FeatureOptInMode;
1747
+ /**
1748
+ * Identifies configuration override values when given feature is enabled
1749
+ * NOTE: should use flat string for fields, for example, if you want to set value for extensionConfig.Ananlytics.disableAjaxTrackig in configurations,
1750
+ * you should use "extensionConfig.Ananlytics.disableAjaxTrackig" as field name: {["extensionConfig.Analytics.disableAjaxTrackig"]:1}
1751
+ * Default: undefined
1752
+ */
1753
+ onCfg?: {
1754
+ [field: string]: any;
1755
+ };
1756
+ /**
1757
+ * Identifies configuration override values when given feature is disabled
1758
+ * NOTE: should use flat string for fields, for example, if you want to set value for extensionConfig.Ananlytics.disableAjaxTrackig in configurations,
1759
+ * you should use "extensionConfig.Ananlytics.disableAjaxTrackig" as field name: {["extensionConfig.Analytics.disableAjaxTrackig"]:1}
1760
+ * Default: undefined
1761
+ */
1762
+ offCfg?: {
1763
+ [field: string]: any;
1764
+ };
1765
+ /**
1766
+ * define if should block any changes from cdn cfg, if set to true, cfgValue will be applied under all scenarios
1767
+ * @default false
1768
+ */
1769
+ blockCdnCfg?: boolean;
1770
+ }
1771
+
1772
+ /**
1773
+ * An alternate interface which provides automatic removal during unloading of the component
1774
+ */
1775
+ interface ILegacyUnloadHook {
1776
+ /**
1777
+ * Legacy Self remove the referenced component
1778
+ */
1779
+ remove: () => void;
1780
+ }
1781
+
1782
+ interface ILoadedPlugin<T extends IPlugin> {
1783
+ plugin: T;
1784
+ /**
1785
+ * Identifies whether the plugin is enabled and can process events. This is slightly different from isInitialized as the plugin may be initialized but disabled
1786
+ * via the setEnabled() or it may be a shared plugin which has had it's teardown function called from another instance..
1787
+ * @returns boolean = true if the plugin is in a state where it is operational.
1788
+ */
1789
+ isEnabled: () => boolean;
1790
+ /**
1791
+ * You can optionally enable / disable a plugin from processing events.
1792
+ * Setting enabled to true will not necessarily cause the `isEnabled()` to also return true
1793
+ * as the plugin must also have been successfully initialized and not had it's `teardown` method called
1794
+ * (unless it's also been re-initialized)
1795
+ */
1796
+ setEnabled: (isEnabled: boolean) => void;
1797
+ remove: (isAsync?: boolean, removeCb?: (removed?: boolean) => void) => void;
1798
+ }
1799
+
1800
+ interface IMetricTelemetry extends IPartC {
1801
+ /**
1802
+ * @description (required) - name of this metric
1803
+ * @type {string}
1804
+ * @memberof IMetricTelemetry
1805
+ */
1806
+ name: string;
1807
+ /**
1808
+ * @description (required) - Recorded value/average for this metric
1809
+ * @type {number}
1810
+ * @memberof IMetricTelemetry
1811
+ */
1812
+ average: number;
1813
+ /**
1814
+ * @description (optional) Number of samples represented by the average.
1815
+ * @type {number=}
1816
+ * @memberof IMetricTelemetry
1817
+ * @default sampleCount=1
1818
+ */
1819
+ sampleCount?: number;
1820
+ /**
1821
+ * @description (optional) The smallest measurement in the sample. Defaults to the average
1822
+ * @type {number}
1823
+ * @memberof IMetricTelemetry
1824
+ * @default min=average
1825
+ */
1826
+ min?: number;
1827
+ /**
1828
+ * @description (optional) The largest measurement in the sample. Defaults to the average.
1829
+ * @type {number}
1830
+ * @memberof IMetricTelemetry
1831
+ * @default max=average
1832
+ */
1833
+ max?: number;
1834
+ /**
1835
+ * (optional) The standard deviation measurement in the sample, Defaults to undefined which results in zero.
1836
+ */
1837
+ stdDev?: number;
1838
+ /**
1839
+ * @description custom defined iKey
1840
+ * @type {string}
1841
+ * @memberof IMetricTelemetry
1842
+ */
1843
+ iKey?: string;
1844
+ }
1845
+
1846
+ /**
1847
+ * An interface used for the notification listener.
1848
+ * @interface
1849
+ */
1850
+ interface INotificationListener {
1851
+ /**
1852
+ * [Optional] A function called when events are sent.
1853
+ * @param events - The array of events that have been sent.
1854
+ */
1855
+ eventsSent?: (events: ITelemetryItem[]) => void;
1856
+ /**
1857
+ * [Optional] A function called when events are discarded.
1858
+ * @param events - The array of events that have been discarded.
1859
+ * @param reason - The reason for discarding the events. The EventsDiscardedReason
1860
+ * constant should be used to check the different values.
1861
+ */
1862
+ eventsDiscarded?: (events: ITelemetryItem[], reason: number) => void;
1863
+ /**
1864
+ * [Optional] A function called when the events have been requested to be sent to the sever.
1865
+ * @param sendReason - The reason why the event batch is being sent.
1866
+ * @param isAsync - A flag which identifies whether the requests are being sent in an async or sync manner.
1867
+ */
1868
+ eventsSendRequest?: (sendReason: number, isAsync?: boolean) => void;
1869
+ /**
1870
+ * [Optional] This event is sent if you have enabled perf events, they are primarily used to track internal performance testing and debugging
1871
+ * the event can be displayed via the debug plugin extension.
1872
+ * @param perfEvent
1873
+ */
1874
+ perfEvent?: (perfEvent: IPerfEvent) => void;
1875
+ /**
1876
+ * Unload and remove any state that this INotificationListener may be holding, this is generally called when the
1877
+ * owning Manager is being unloaded.
1878
+ * @param isAsync - Can the unload be performed asynchronously (default)
1879
+ * @return If the unload occurs synchronously then nothing should be returned, if happening asynchronously then
1880
+ * the function should return an [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html)
1881
+ * / Promise to allow any listeners to wait for the operation to complete.
1882
+ */
1883
+ unload?(isAsync?: boolean): void | IPromise<void>;
1884
+ }
1885
+
1886
+ /**
1887
+ * Class to manage sending notifications to all the listeners.
1888
+ */
1889
+ interface INotificationManager {
1890
+ listeners: INotificationListener[];
1891
+ /**
1892
+ * Adds a notification listener.
1893
+ * @param listener - The notification listener to be added.
1894
+ */
1895
+ addNotificationListener(listener: INotificationListener): void;
1896
+ /**
1897
+ * Removes all instances of the listener.
1898
+ * @param listener - AWTNotificationListener to remove.
1899
+ */
1900
+ removeNotificationListener(listener: INotificationListener): void;
1901
+ /**
1902
+ * Notification for events sent.
1903
+ * @param events - The array of events that have been sent.
1904
+ */
1905
+ eventsSent(events: ITelemetryItem[]): void;
1906
+ /**
1907
+ * Notification for events being discarded.
1908
+ * @param events - The array of events that have been discarded by the SDK.
1909
+ * @param reason - The reason for which the SDK discarded the events. The EventsDiscardedReason
1910
+ * constant should be used to check the different values.
1911
+ */
1912
+ eventsDiscarded(events: ITelemetryItem[], reason: number): void;
1913
+ /**
1914
+ * [Optional] A function called when the events have been requested to be sent to the sever.
1915
+ * @param sendReason - The reason why the event batch is being sent.
1916
+ * @param isAsync - A flag which identifies whether the requests are being sent in an async or sync manner.
1917
+ */
1918
+ eventsSendRequest?(sendReason: number, isAsync: boolean): void;
1919
+ /**
1920
+ * [Optional] This event is sent if you have enabled perf events, they are primarily used to track internal performance testing and debugging
1921
+ * the event can be displayed via the debug plugin extension.
1922
+ * @param perfEvent - The perf event details
1923
+ */
1924
+ perfEvent?(perfEvent: IPerfEvent): void;
1925
+ /**
1926
+ * Unload and remove any state that this INotificationManager may be holding, this is generally called when the
1927
+ * owning SDK is being unloaded.
1928
+ * @param isAsync - Can the unload be performed asynchronously (default)
1929
+ * @return If the unload occurs synchronously then nothing should be returned, if happening asynchronously then
1930
+ * the function should return an [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html)
1931
+ * / Promise to allow any listeners to wait for the operation to complete.
1932
+ */
1933
+ unload?(isAsync?: boolean): void | IPromise<void>;
1934
+ }
1935
+
1936
+ class _InternalLogMessage {
1937
+ static dataType: string;
1938
+ message: string;
1939
+ messageId: _InternalMessageId;
1940
+ constructor(msgId: _InternalMessageId, msg: string, isUserAct?: boolean, properties?: Object);
1941
+ }
1942
+
1943
+ type _InternalMessageId = number | _eInternalMessageId;
1944
+
1945
+ interface IPageViewPerformanceTelemetry extends IPartC {
1946
+ /**
1947
+ * name String - The name of the page. Defaults to the document title.
1948
+ */
1949
+ name?: string;
1950
+ /**
1951
+ * url String - a relative or absolute URL that identifies the page or other item. Defaults to the window location.
1952
+ */
1953
+ uri?: string;
1954
+ /**
1955
+ * Performance total in TimeSpan 'G' (general long) format: d:hh:mm:ss.fffffff". This is total duration in timespan format.
1956
+ */
1957
+ perfTotal?: string;
1958
+ /**
1959
+ * Performance total in TimeSpan 'G' (general long) format: d:hh:mm:ss.fffffff". This represents the total page load time.
1960
+ */
1961
+ duration?: string;
1962
+ /**
1963
+ * Sent request time in TimeSpan 'G' (general long) format: d:hh:mm:ss.fffffff
1964
+ */
1965
+ networkConnect?: string;
1966
+ /**
1967
+ * Sent request time in TimeSpan 'G' (general long) format: d:hh:mm:ss.fffffff.
1968
+ */
1969
+ sentRequest?: string;
1970
+ /**
1971
+ * Received response time in TimeSpan 'G' (general long) format: d:hh:mm:ss.fffffff.
1972
+ */
1973
+ receivedResponse?: string;
1974
+ /**
1975
+ * DOM processing time in TimeSpan 'G' (general long) format: d:hh:mm:ss.fffffff
1976
+ */
1977
+ domProcessing?: string;
1978
+ }
1979
+
1980
+ /**
1981
+ * Pageview telemetry interface
1982
+ */
1983
+ interface IPageViewTelemetry extends IPartC {
1984
+ /**
1985
+ * name String - The string you used as the name in startTrackPage. Defaults to the document title.
1986
+ */
1987
+ name?: string;
1988
+ /**
1989
+ * uri String - a relative or absolute URL that identifies the page or other item. Defaults to the window location.
1990
+ */
1991
+ uri?: string;
1992
+ /**
1993
+ * refUri String - the URL of the source page where current page is loaded from
1994
+ */
1995
+ refUri?: string;
1996
+ /**
1997
+ * pageType String - page type
1998
+ */
1999
+ pageType?: string;
2000
+ /**
2001
+ * isLoggedIn - boolean is user logged in
2002
+ */
2003
+ isLoggedIn?: boolean;
2004
+ /**
2005
+ * Property bag to contain additional custom properties (Part C)
2006
+ */
2007
+ properties?: {
2008
+ /**
2009
+ * The number of milliseconds it took to load the page. Defaults to undefined. If set to default value, page load time is calculated internally.
2010
+ */
2011
+ duration?: number;
2012
+ [key: string]: any;
2013
+ };
2014
+ /**
2015
+ * iKey String - custom defined iKey.
2016
+ */
2017
+ iKey?: string;
2018
+ /**
2019
+ * Time first page view is triggered
2020
+ */
2021
+ startTime?: Date;
2022
+ }
2023
+
2024
+ /**
2025
+ * PartC telemetry interface
2026
+ */
2027
+ interface IPartC {
2028
+ /**
2029
+ * Property bag to contain additional custom properties (Part C)
2030
+ */
2031
+ properties?: {
2032
+ [key: string]: any;
2033
+ };
2034
+ /**
2035
+ * Property bag to contain additional custom measurements (Part C)
2036
+ * @deprecated -- please use properties instead
2037
+ */
2038
+ measurements?: {
2039
+ [key: string]: number;
2040
+ };
2041
+ }
2042
+
2043
+ /** IPayloadData describes interface of payload sent via POST channel */
2044
+ interface IPayloadData {
2045
+ urlString: string;
2046
+ data: Uint8Array | string;
2047
+ headers?: {
2048
+ [name: string]: string;
2049
+ };
2050
+ timeout?: number;
2051
+ disableXhrSync?: boolean;
2052
+ disableFetchKeepAlive?: boolean;
2053
+ sendReason?: SendRequestReason;
2054
+ }
2055
+
2056
+ /**
2057
+ * This interface identifies the details of an internal performance event - it does not represent an outgoing reported event
2058
+ */
2059
+ interface IPerfEvent {
2060
+ /**
2061
+ * The name of the performance event
2062
+ */
2063
+ name: string;
2064
+ /**
2065
+ * The start time of the performance event
2066
+ */
2067
+ start: number;
2068
+ /**
2069
+ * The payload (contents) of the perfEvent, may be null or only set after the event has completed depending on
2070
+ * the runtime environment.
2071
+ */
2072
+ payload: any;
2073
+ /**
2074
+ * Is this occurring from an asynchronous event
2075
+ */
2076
+ isAsync: boolean;
2077
+ /**
2078
+ * Identifies the total inclusive time spent for this event, including the time spent for child events,
2079
+ * this will be undefined until the event is completed
2080
+ */
2081
+ time?: number;
2082
+ /**
2083
+ * Identifies the exclusive time spent in for this event (not including child events),
2084
+ * this will be undefined until the event is completed.
2085
+ */
2086
+ exTime?: number;
2087
+ /**
2088
+ * The Parent event that was started before this event was created
2089
+ */
2090
+ parent?: IPerfEvent;
2091
+ /**
2092
+ * The child perf events that are contained within the total time of this event.
2093
+ */
2094
+ childEvts?: IPerfEvent[];
2095
+ /**
2096
+ * Identifies whether this event is a child event of a parent
2097
+ */
2098
+ isChildEvt: () => boolean;
2099
+ /**
2100
+ * Get the names additional context associated with this perf event
2101
+ */
2102
+ getCtx?: (key: string) => any;
2103
+ /**
2104
+ * Set the named additional context to be associated with this perf event, this will replace any existing value
2105
+ */
2106
+ setCtx?: (key: string, value: any) => void;
2107
+ /**
2108
+ * Mark this event as completed, calculating the total execution time.
2109
+ */
2110
+ complete: () => void;
2111
+ }
2112
+
2113
+ /**
2114
+ * This defines an internal performance manager for tracking and reporting the internal performance of the SDK -- It does
2115
+ * not represent or report any event to the server.
2116
+ */
2117
+ interface IPerfManager {
2118
+ /**
2119
+ * Create a new event and start timing, the manager may return null/undefined to indicate that it does not
2120
+ * want to monitor this source event.
2121
+ * @param src - The source name of the event
2122
+ * @param payloadDetails - An optional callback function to fetch the payload details for the event.
2123
+ * @param isAsync - Is the event occurring from a async event
2124
+ */
2125
+ create(src: string, payloadDetails?: () => any, isAsync?: boolean): IPerfEvent | null | undefined;
2126
+ /**
2127
+ * Complete the perfEvent and fire any notifications.
2128
+ * @param perfEvent - Fire the event which will also complete the passed event
2129
+ */
2130
+ fire(perfEvent: IPerfEvent): void;
2131
+ /**
2132
+ * Set an execution context value
2133
+ * @param key - The context key name
2134
+ * @param value - The value
2135
+ */
2136
+ setCtx(key: string, value: any): void;
2137
+ /**
2138
+ * Get the execution context value
2139
+ * @param key - The context key
2140
+ */
2141
+ getCtx(key: string): any;
2142
+ }
2143
+
2144
+ /**
2145
+ * Identifies an interface to a host that can provide an IPerfManager implementation
2146
+ */
2147
+ interface IPerfManagerProvider {
2148
+ /**
2149
+ * Get the current performance manager
2150
+ */
2151
+ getPerfMgr(): IPerfManager;
2152
+ /**
2153
+ * Set the current performance manager
2154
+ * @param perfMgr - The performance manager
2155
+ */
2156
+ setPerfMgr(perfMgr: IPerfManager): void;
2157
+ }
2158
+
2159
+ interface IPlugin {
2160
+ /**
2161
+ * Initialize plugin loaded by SDK
2162
+ * @param config - The config for the plugin to use
2163
+ * @param core - The current App Insights core to use for initializing this plugin instance
2164
+ * @param extensions - The complete set of extensions to be used for initializing the plugin
2165
+ * @param pluginChain - [Optional] specifies the current plugin chain which identifies the
2166
+ * set of plugins and the order they should be executed for the current request.
2167
+ */
2168
+ initialize: (config: IConfiguration, core: IAppInsightsCore, extensions: IPlugin[], pluginChain?: ITelemetryPluginChain) => void;
2169
+ /**
2170
+ * Returns a value that indicates whether the plugin has already been previously initialized.
2171
+ * New plugins should implement this method to avoid being initialized more than once.
2172
+ */
2173
+ isInitialized?: () => boolean;
2174
+ /**
2175
+ * Tear down the plugin and remove any hooked value, the plugin should be removed so that it is no longer initialized and
2176
+ * therefore could be re-initialized after being torn down. The plugin should ensure that once this has been called any further
2177
+ * processTelemetry calls are ignored and it just calls the processNext() with the provided context.
2178
+ * @param unloadCtx - This is the context that should be used during unloading.
2179
+ * @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.
2180
+ * @returns boolean - true if the plugin has or will call processNext(), this for backward compatibility as previously teardown was synchronous and returned nothing.
2181
+ */
2182
+ teardown?: (unloadCtx: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState) => void | boolean;
2183
+ /**
2184
+ * Extension name
2185
+ */
2186
+ readonly identifier: string;
2187
+ /**
2188
+ * Plugin version (available in data.properties.version in common schema)
2189
+ */
2190
+ readonly version?: string;
2191
+ /**
2192
+ * The App Insights core to use for backward compatibility.
2193
+ * Therefore the interface will be able to access the core without needing to cast to "any".
2194
+ * [optional] any 3rd party plugins which are already implementing this interface don't fail to compile.
2195
+ */
2196
+ core?: IAppInsightsCore;
2197
+ }
2198
+
2199
+ /**
2200
+ * The current context for the current call to processTelemetry(), used to support sharing the same plugin instance
2201
+ * between multiple AppInsights instances
2202
+ */
2203
+ interface IProcessTelemetryContext extends IBaseProcessingContext {
2204
+ /**
2205
+ * Call back for telemetry processing before it it is sent
2206
+ * @param env - This is the current event being reported
2207
+ * @returns boolean (true) if there is no more plugins to process otherwise false or undefined (void)
2208
+ */
2209
+ processNext: (env: ITelemetryItem) => boolean | void;
2210
+ /**
2211
+ * Create a new context using the core and config from the current instance, returns a new instance of the same type
2212
+ * @param plugins - The execution order to process the plugins, if null or not supplied
2213
+ * then the current execution order will be copied.
2214
+ * @param startAt - The plugin to start processing from, if missing from the execution
2215
+ * order then the next plugin will be NOT set.
2216
+ */
2217
+ createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryContext;
2218
+ }
2219
+
2220
+ /**
2221
+ * The current context for the current call to teardown() implementations, used to support when plugins are being removed
2222
+ * or the SDK is being unloaded.
2223
+ */
2224
+ interface IProcessTelemetryUnloadContext extends IBaseProcessingContext {
2225
+ /**
2226
+ * This Plugin has finished unloading, so unload the next one
2227
+ * @param uploadState - The state of the unload process
2228
+ * @returns boolean (true) if there is no more plugins to process otherwise false or undefined (void)
2229
+ */
2230
+ processNext: (unloadState: ITelemetryUnloadState) => boolean | void;
2231
+ /**
2232
+ * Create a new context using the core and config from the current instance, returns a new instance of the same type
2233
+ * @param plugins - The execution order to process the plugins, if null or not supplied
2234
+ * then the current execution order will be copied.
2235
+ * @param startAt - The plugin to start processing from, if missing from the execution
2236
+ * order then the next plugin will be NOT set.
2237
+ */
2238
+ createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryUnloadContext;
2239
+ }
2240
+
2241
+ /**
2242
+ * The current context for the current call to the plugin update() implementations, used to support the notifications
2243
+ * for when plugins are added, removed or the configuration was changed.
2244
+ */
2245
+ interface IProcessTelemetryUpdateContext extends IBaseProcessingContext {
2246
+ /**
2247
+ * This Plugin has finished unloading, so unload the next one
2248
+ * @param updateState - The update State
2249
+ * @returns boolean (true) if there is no more plugins to process otherwise false or undefined (void)
2250
+ */
2251
+ processNext: (updateState: ITelemetryUpdateState) => boolean | void;
2252
+ /**
2253
+ * Create a new context using the core and config from the current instance, returns a new instance of the same type
2254
+ * @param plugins - The execution order to process the plugins, if null or not supplied
2255
+ * then the current execution order will be copied.
2256
+ * @param startAt - The plugin to start processing from, if missing from the execution
2257
+ * order then the next plugin will be NOT set.
2258
+ */
2259
+ createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryUpdateContext;
2260
+ }
2261
+
2262
+ /**
2263
+ * Create a Promise object that represents the eventual completion (or failure) of an asynchronous operation and its resulting value.
2264
+ * This interface definition, closely mirrors the typescript / javascript PromiseLike<T> and Promise<T> definitions as well as providing
2265
+ * simular functions as that provided by jQuery deferred objects.
2266
+ *
2267
+ * The returned Promise is a proxy for a value not necessarily known when the promise is created. It allows you to associate handlers
2268
+ * with an asynchronous action's eventual success value or failure reason. This lets asynchronous methods return values like synchronous
2269
+ * methods: instead of immediately returning the final value, the asynchronous method returns a promise to supply the value at some point
2270
+ * in the future.
2271
+ *
2272
+ * A Promise is in one of these states:
2273
+ * <ul>
2274
+ * <li> pending: initial state, neither fulfilled nor rejected.
2275
+ * <li> fulfilled: meaning that the operation was completed successfully.
2276
+ * <li> rejected: meaning that the operation failed.
2277
+ * </ul>
2278
+ *
2279
+ * A pending promise can either be fulfilled with a value or rejected with a reason (error). When either of these options happens, the
2280
+ * associated handlers queued up by a promise's then method are called synchronously. If the promise has already been fulfilled or rejected
2281
+ * when a corresponding handler is attached, the handler will be called synchronously, so there is no race condition between an asynchronous
2282
+ * operation completing and its handlers being attached.
2283
+ *
2284
+ * As the `then()` and `catch()` methods return promises, they can be chained.
2285
+ * @typeParam T - Identifies the expected return type from the promise
2286
+ */
2287
+ interface IPromise<T> extends PromiseLike<T>, Promise<T> {
2288
+ /**
2289
+ * Returns a string representation of the current state of the promise. The promise can be in one of four states.
2290
+ * <ul>
2291
+ * <li> <b>"pending"</b>: The promise is not yet in a completed state (neither "rejected"; or "resolved").</li>
2292
+ * <li> <b>"resolved"</b>: The promise is in the resolved state.</li>
2293
+ * <li> <b>"rejected"</b>: The promise is in the rejected state.</li>
2294
+ * </ul>
2295
+ * @example
2296
+ * ```ts
2297
+ * let doResolve;
2298
+ * let promise: IPromise<any> = createSyncPromise((resolve) => {
2299
+ * doResolve = resolve;
2300
+ * });
2301
+ *
2302
+ * let state: string = promise.state();
2303
+ * console.log("State: " + state); // State: pending
2304
+ * doResolve(true); // Promise will resolve synchronously as it's a synchronous promise
2305
+ * console.log("State: " + state); // State: resolved
2306
+ * ```
2307
+ */
2308
+ state?: string;
2309
+ /**
2310
+ * Attaches callbacks for the resolution and/or rejection of the Promise.
2311
+ * @param onResolved The callback to execute when the Promise is resolved.
2312
+ * @param onRejected The callback to execute when the Promise is rejected.
2313
+ * @returns A Promise for the completion of which ever callback is executed.
2314
+ * @example
2315
+ * ```ts
2316
+ * const promise1 = createPromise((resolve, reject) => {
2317
+ * resolve('Success!');
2318
+ * });
2319
+ *
2320
+ * promise1.then((value) => {
2321
+ * console.log(value);
2322
+ * // expected output: "Success!"
2323
+ * });
2324
+ * ```
2325
+ */
2326
+ then<TResult1 = T, TResult2 = never>(onResolved?: ResolvedPromiseHandler<T, TResult1>, onRejected?: RejectedPromiseHandler<TResult2>): IPromise<TResult1 | TResult2>;
2327
+ /**
2328
+ * Attaches callbacks for the resolution and/or rejection of the Promise.
2329
+ * @param onResolved The callback to execute when the Promise is resolved.
2330
+ * @param onRejected The callback to execute when the Promise is rejected.
2331
+ * @returns A Promise for the completion of which ever callback is executed.
2332
+ * @example
2333
+ * ```ts
2334
+ * const promise1 = createPromise((resolve, reject) => {
2335
+ * resolve('Success!');
2336
+ * });
2337
+ *
2338
+ * promise1.then((value) => {
2339
+ * console.log(value);
2340
+ * // expected output: "Success!"
2341
+ * });
2342
+ * ```
2343
+ */
2344
+ then<TResult1 = T, TResult2 = never>(onResolved?: ResolvedPromiseHandler<T, TResult1>, onRejected?: RejectedPromiseHandler<TResult2>): PromiseLike<TResult1 | TResult2>;
2345
+ /**
2346
+ * Attaches callbacks for the resolution and/or rejection of the Promise.
2347
+ * @param onResolved The callback to execute when the Promise is resolved.
2348
+ * @param onRejected The callback to execute when the Promise is rejected.
2349
+ * @returns A Promise for the completion of which ever callback is executed.
2350
+ * @example
2351
+ * ```ts
2352
+ * const promise1 = createPromise((resolve, reject) => {
2353
+ * resolve('Success!');
2354
+ * });
2355
+ *
2356
+ * promise1.then((value) => {
2357
+ * console.log(value);
2358
+ * // expected output: "Success!"
2359
+ * });
2360
+ * ```
2361
+ */
2362
+ then<TResult1 = T, TResult2 = never>(onResolved?: ResolvedPromiseHandler<T, TResult1>, onRejected?: RejectedPromiseHandler<TResult2>): Promise<TResult1 | TResult2>;
2363
+ /**
2364
+ * Attaches a callback for only the rejection of the Promise.
2365
+ * @param onRejected The callback to execute when the Promise is rejected.
2366
+ * @returns A Promise for the completion of the callback.
2367
+ * @example
2368
+ * ```ts
2369
+ * const promise1 = createPromise((resolve, reject) => {
2370
+ * throw 'Uh-oh!';
2371
+ * });
2372
+ *
2373
+ * promise1.catch((error) => {
2374
+ * console.error(error);
2375
+ * });
2376
+ * // expected output: Uh-oh!
2377
+ * ```
2378
+ */
2379
+ catch<TResult = never>(onRejected?: ((reason: any) => TResult | IPromise<TResult>) | undefined | null): IPromise<T | TResult>;
2380
+ /**
2381
+ * Attaches a callback for only the rejection of the Promise.
2382
+ * @param onRejected The callback to execute when the Promise is rejected.
2383
+ * @returns A Promise for the completion of the callback.
2384
+ * @example
2385
+ * ```ts
2386
+ * const promise1 = createPromise((resolve, reject) => {
2387
+ * throw 'Uh-oh!';
2388
+ * });
2389
+ *
2390
+ * promise1.catch((error) => {
2391
+ * console.error(error);
2392
+ * });
2393
+ * // expected output: Uh-oh!
2394
+ * ```
2395
+ */
2396
+ catch<TResult = never>(onRejected?: ((reason: any) => TResult | IPromise<TResult>) | undefined | null): PromiseLike<T | TResult>;
2397
+ /**
2398
+ * Attaches a callback for only the rejection of the Promise.
2399
+ * @param onRejected The callback to execute when the Promise is rejected.
2400
+ * @returns A Promise for the completion of the callback.
2401
+ * @example
2402
+ * ```ts
2403
+ * const promise1 = createPromise((resolve, reject) => {
2404
+ * throw 'Uh-oh!';
2405
+ * });
2406
+ *
2407
+ * promise1.catch((error) => {
2408
+ * console.error(error);
2409
+ * });
2410
+ * // expected output: Uh-oh!
2411
+ * ```
2412
+ */
2413
+ catch<TResult = never>(onRejected?: ((reason: any) => TResult | IPromise<TResult>) | undefined | null): Promise<T | TResult>;
2414
+ /**
2415
+ * Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The
2416
+ * resolved value cannot be modified from the callback.
2417
+ * @param onfinally The callback to execute when the Promise is settled (fulfilled or rejected).
2418
+ * @returns A Promise for the completion of the callback.
2419
+ * @example
2420
+ * ```ts
2421
+ * function doFunction() {
2422
+ * return createPromise((resolve, reject) => {
2423
+ * if (Math.random() > 0.5) {
2424
+ * resolve('Function has completed');
2425
+ * } else {
2426
+ * reject(new Error('Function failed to process'));
2427
+ * }
2428
+ * });
2429
+ * }
2430
+ *
2431
+ * doFunction().then((data) => {
2432
+ * console.log(data);
2433
+ * }).catch((err) => {
2434
+ * console.error(err);
2435
+ * }).finally(() => {
2436
+ * console.log('Function processing completed');
2437
+ * });
2438
+ * ```
2439
+ */
2440
+ finally(onfinally?: FinallyPromiseHandler): IPromise<T>;
2441
+ /**
2442
+ * Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The
2443
+ * resolved value cannot be modified from the callback.
2444
+ * @param onfinally The callback to execute when the Promise is settled (fulfilled or rejected).
2445
+ * @returns A Promise for the completion of the callback.
2446
+ * @example
2447
+ * ```ts
2448
+ * function doFunction() {
2449
+ * return createPromise((resolve, reject) => {
2450
+ * if (Math.random() > 0.5) {
2451
+ * resolve('Function has completed');
2452
+ * } else {
2453
+ * reject(new Error('Function failed to process'));
2454
+ * }
2455
+ * });
2456
+ * }
2457
+ *
2458
+ * doFunction().then((data) => {
2459
+ * console.log(data);
2460
+ * }).catch((err) => {
2461
+ * console.error(err);
2462
+ * }).finally(() => {
2463
+ * console.log('Function processing completed');
2464
+ * });
2465
+ * ```
2466
+ */
2467
+ finally(onFinally?: FinallyPromiseHandler): Promise<T>;
2468
+ }
2469
+
2470
+ interface IRequestContext {
2471
+ status?: number;
2472
+ xhr?: XMLHttpRequest;
2473
+ request?: Request;
2474
+ response?: Response | string;
2475
+ }
2476
+
2477
+ interface IResponseError {
2478
+ readonly index: number;
2479
+ readonly statusCode: number;
2480
+ readonly message: string;
2481
+ }
2482
+
2483
+ interface ISample {
2484
+ /**
2485
+ * Sample rate
2486
+ */
2487
+ sampleRate: number;
2488
+ isSampledIn(envelope: ITelemetryItem): boolean;
2489
+ }
2490
+
2491
+ interface ISendBuffer {
2492
+ /**
2493
+ * Enqueue the payload
2494
+ */
2495
+ enqueue: (payload: string) => void;
2496
+ /**
2497
+ * Returns the number of elements in the buffer
2498
+ */
2499
+ count: () => number;
2500
+ /**
2501
+ * Returns the current size of the serialized buffer
2502
+ */
2503
+ size: () => number;
2504
+ /**
2505
+ * Clears the buffer
2506
+ */
2507
+ clear: () => void;
2508
+ /**
2509
+ * Returns items stored in the buffer
2510
+ */
2511
+ getItems: () => string[];
2512
+ /**
2513
+ * Build a batch of all elements in the payload array
2514
+ */
2515
+ batchPayloads: (payload: string[]) => string;
2516
+ /**
2517
+ * Moves items to the SENT_BUFFER.
2518
+ * The buffer holds items which were sent, but we haven't received any response from the backend yet.
2519
+ */
2520
+ markAsSent: (payload: string[]) => void;
2521
+ /**
2522
+ * Removes items from the SENT_BUFFER. Should be called on successful response from the backend.
2523
+ */
2524
+ clearSent: (payload: string[]) => void;
2525
+ /**
2526
+ * Copy current buffer items to a new buffer.
2527
+ * if canUseSessionStorage is undefined, it will set to false.
2528
+ * if newLogger and newConfig are undefined, current logger and empty config will be used.
2529
+ * if canUseSessionStorage is set to true, new SessionStorageSendBuffer will be returned otherwise ArraySendBuffer will be returned.
2530
+ */
2531
+ createNew: (newLogger?: IDiagnosticLogger, newConfig?: ISenderConfig, canUseSessionStorage?: boolean) => ArraySendBuffer | SessionStorageSendBuffer;
2532
+ }
2533
+
2534
+ interface ISenderConfig {
2535
+ /**
2536
+ * The url to which payloads will be sent
2537
+ */
2538
+ endpointUrl: string;
2539
+ /**
2540
+ * The JSON format (normal vs line delimited). True means line delimited JSON.
2541
+ */
2542
+ emitLineDelimitedJson: boolean;
2543
+ /**
2544
+ * The maximum size of a batch in bytes
2545
+ */
2546
+ maxBatchSizeInBytes: number;
2547
+ /**
2548
+ * The maximum interval allowed between calls to batchInvoke
2549
+ */
2550
+ maxBatchInterval: number;
2551
+ /**
2552
+ * The master off switch. Do not send any data if set to TRUE
2553
+ */
2554
+ disableTelemetry: boolean;
2555
+ /**
2556
+ * Store a copy of a send buffer in the session storage
2557
+ */
2558
+ enableSessionStorageBuffer: boolean;
2559
+ /**
2560
+ * Specify the storage buffer type implementation.
2561
+ * @since 2.8.12
2562
+ */
2563
+ bufferOverride: IStorageBuffer | false;
2564
+ /**
2565
+ * Is retry handler disabled.
2566
+ * If enabled, retry on 206 (partial success), 408 (timeout), 429 (too many requests), 500 (internal server error) and 503 (service unavailable).
2567
+ */
2568
+ isRetryDisabled: boolean;
2569
+ isBeaconApiDisabled: boolean;
2570
+ /**
2571
+ * Don't use XMLHttpRequest or XDomainRequest (for IE < 9) by default instead attempt to use fetch() or sendBeacon.
2572
+ * If no other transport is available it will still use XMLHttpRequest
2573
+ */
2574
+ disableXhr: boolean;
2575
+ /**
2576
+ * If fetch keepalive is supported do not use it for sending events during unload, it may still fallback to fetch() without keepalive
2577
+ */
2578
+ onunloadDisableFetch: boolean;
2579
+ /**
2580
+ * Is beacon disabled on page unload.
2581
+ * If enabled, flush events through beaconSender.
2582
+ */
2583
+ onunloadDisableBeacon: boolean;
2584
+ /**
2585
+ * (Optional) Override the instrumentation key that this channel instance sends to
2586
+ */
2587
+ instrumentationKey: string;
2588
+ namePrefix: string;
2589
+ samplingPercentage: number;
2590
+ /**
2591
+ * (Optional) The ability for the user to provide extra headers
2592
+ */
2593
+ customHeaders: [{
2594
+ header: string;
2595
+ value: string;
2596
+ }];
2597
+ /**
2598
+ * (Optional) Provide user an option to convert undefined field to user defined value.
2599
+ */
2600
+ convertUndefined: any;
2601
+ /**
2602
+ * (Optional) The number of events that can be kept in memory before the SDK starts to drop events. By default, this is 10,000.
2603
+ */
2604
+ eventsLimitInMem: number;
2605
+ /**
2606
+ * (Optional) Enable the sender to return a promise so that manually flushing (and general sending) can wait for the request to finish.
2607
+ * Note: Enabling this may cause unhandled promise rejection errors to occur if you do not listen and handle any rejection response,
2608
+ * this *should* only be for manual flush attempts.
2609
+ * Defaults to false
2610
+ * @since 3.0.1
2611
+ */
2612
+ enableSendPromise?: boolean;
2613
+ /**
2614
+ * [Optional] The HTTP override that should be used to send requests, as an IXHROverride object.
2615
+ * By default during the unload of a page or if the event specifies that it wants to use sendBeacon() or sync fetch (with keep-alive),
2616
+ * this override will NOT be called.
2617
+ * If alwaysUseXhrOverride configuration value is set to true, the override will always be used.
2618
+ * The payload data (first argument) now also includes any configured 'timeout' (defaults to undefined) and whether you should avoid
2619
+ * creating any synchronous XHR requests 'disableXhr' (defaults to false/undefined)
2620
+ * @since 3.0.4
2621
+ */
2622
+ httpXHROverride?: IXHROverride;
2623
+ /**
2624
+ * [Optional] By default during unload (or when you specify to use sendBeacon() or sync fetch (with keep-alive) for an event) the SDK
2625
+ * ignores any provided httpXhrOverride and attempts to use sendBeacon() or fetch(with keep-alive) when they are available.
2626
+ * When this configuration option is true any provided httpXhrOverride will always be used, so any provided httpXhrOverride will
2627
+ * also need to "handle" the synchronous unload scenario.
2628
+ * @since 3.0.4
2629
+ */
2630
+ alwaysUseXhrOverride?: boolean;
2631
+ /**
2632
+ * [Optional] Disable events splitting during sendbeacon.
2633
+ * Default: false
2634
+ * @since 3.0.6
2635
+ */
2636
+ disableSendBeaconSplit?: boolean;
2637
+ /**
2638
+ * (Optional) The specific error codes that will cause a retry of sending data to the backend.
2639
+ * @since 3.1.1
2640
+ */
2641
+ retryCodes?: number[];
2642
+ }
2643
+
2644
+ interface ISerializable {
2645
+ /**
2646
+ * The set of fields for a serializable object.
2647
+ * This defines the serialization order and a value of true/false
2648
+ * for each field defines whether the field is required or not.
2649
+ */
2650
+ aiDataContract: any;
2651
+ }
2652
+
2653
+ /**
2654
+ * Checks if the provided value is null, undefined or contains the string value of "undefined".
2655
+ * @group Type Identity
2656
+ * @group Value Check
2657
+ * @param value - The value to check
2658
+ * @returns `true` if the value is `null` or `undefined`
2659
+ * @example
2660
+ * ```ts
2661
+ * isNullOrUndefined(null); // true
2662
+ * isNullOrUndefined(undefined); // true
2663
+ * isNullOrUndefined("undefined"); // true
2664
+ *
2665
+ * let value = null;
2666
+ * isNullOrUndefined(value); // true
2667
+ * let value = undefined;
2668
+ * isNullOrUndefined(value); // true
2669
+ *
2670
+ * isNullOrUndefined(""); // false
2671
+ * isNullOrUndefined(0); // false
2672
+ * isNullOrUndefined(new Date()); // false
2673
+ * isNullOrUndefined(true); // false
2674
+ * isNullOrUndefined(false); // false
2675
+ * ```
2676
+ */
2677
+ function isNullOrUndefined(value: any): boolean;
2678
+
2679
+ interface IStackDetails {
2680
+ src: string;
2681
+ obj: string[];
2682
+ }
2683
+
2684
+ /**
2685
+ * Identifies a simple interface to allow you to override the storage mechanism used
2686
+ * to track unsent and unacknowledged events. When provided it must provide both
2687
+ * the get and set item functions.
2688
+ * @since 2.8.12
2689
+ */
2690
+ interface IStorageBuffer {
2691
+ /**
2692
+ * Retrieves the stored value for a given key
2693
+ */
2694
+ getItem(logger: IDiagnosticLogger, name: string): string;
2695
+ /**
2696
+ * Sets the stored value for a given key
2697
+ */
2698
+ setItem(logger: IDiagnosticLogger, name: string, data: string): boolean;
2699
+ }
2700
+
2701
+ interface ITelemetryInitializerHandler extends ILegacyUnloadHook {
2702
+ remove(): void;
2703
+ }
2704
+
2705
+ /**
2706
+ * Telemety item supported in Core
2707
+ */
2708
+ interface ITelemetryItem {
2709
+ /**
2710
+ * CommonSchema Version of this SDK
2711
+ */
2712
+ ver?: string;
2713
+ /**
2714
+ * Unique name of the telemetry item
2715
+ */
2716
+ name: string;
2717
+ /**
2718
+ * Timestamp when item was sent
2719
+ */
2720
+ time?: string;
2721
+ /**
2722
+ * Identifier of the resource that uniquely identifies which resource data is sent to
2723
+ */
2724
+ iKey?: string;
2725
+ /**
2726
+ * System context properties of the telemetry item, example: ip address, city etc
2727
+ */
2728
+ ext?: {
2729
+ [key: string]: any;
2730
+ };
2731
+ /**
2732
+ * System context property extensions that are not global (not in ctx)
2733
+ */
2734
+ tags?: Tags & Tags[];
2735
+ /**
2736
+ * Custom data
2737
+ */
2738
+ data?: ICustomProperties;
2739
+ /**
2740
+ * Telemetry type used for part B
2741
+ */
2742
+ baseType?: string;
2743
+ /**
2744
+ * Based on schema for part B
2745
+ */
2746
+ baseData?: {
2747
+ [key: string]: any;
2748
+ };
2749
+ }
2750
+
2751
+ /**
2752
+ * Configuration provided to SDK core
2753
+ */
2754
+ interface ITelemetryPlugin extends ITelemetryProcessor, IPlugin {
2755
+ /**
2756
+ * Set next extension for telemetry processing, this is not optional as plugins should use the
2757
+ * processNext() function of the passed IProcessTelemetryContext instead. It is being kept for
2758
+ * now for backward compatibility only.
2759
+ */
2760
+ setNextPlugin?: (next: ITelemetryPlugin | ITelemetryPluginChain) => void;
2761
+ /**
2762
+ * Priority of the extension
2763
+ */
2764
+ readonly priority: number;
2765
+ }
2766
+
2767
+ /**
2768
+ * Configuration provided to SDK core
2769
+ */
2770
+ interface ITelemetryPluginChain extends ITelemetryProcessor {
2771
+ /**
2772
+ * Returns the underlying plugin that is being proxied for the processTelemetry call
2773
+ */
2774
+ getPlugin: () => ITelemetryPlugin;
2775
+ /**
2776
+ * Returns the next plugin
2777
+ */
2778
+ getNext: () => ITelemetryPluginChain;
2779
+ /**
2780
+ * This plugin is being unloaded and should remove any hooked events and cleanup any global/scoped values, after this
2781
+ * call the plugin will be removed from the telemetry processing chain and will no longer receive any events..
2782
+ * @param unloadCtx - The unload context to use for this call.
2783
+ * @param unloadState - The details of the unload operation
2784
+ */
2785
+ unload?: (unloadCtx: IProcessTelemetryUnloadContext, unloadState: ITelemetryUnloadState) => void;
2786
+ }
2787
+
2788
+ interface ITelemetryProcessor {
2789
+ /**
2790
+ * Call back for telemetry processing before it it is sent
2791
+ * @param env - This is the current event being reported
2792
+ * @param itemCtx - This is the context for the current request, ITelemetryPlugin instances
2793
+ * can optionally use this to access the current core instance or define / pass additional information
2794
+ * to later plugins (vs appending items to the telemetry item)
2795
+ */
2796
+ processTelemetry: (env: ITelemetryItem, itemCtx?: IProcessTelemetryContext) => void;
2797
+ /**
2798
+ * The the plugin should re-evaluate configuration and update any cached configuration settings or
2799
+ * plugins. If implemented this method will be called whenever a plugin is added or removed and if
2800
+ * the configuration has bee updated.
2801
+ * @param updateCtx - This is the context that should be used during updating.
2802
+ * @param updateState - The details / state of the update process, it holds details like the current and previous configuration.
2803
+ * @returns boolean - true if the plugin has or will call updateCtx.processNext(), this allows the plugin to perform any asynchronous operations.
2804
+ */
2805
+ update?: (updateCtx: IProcessTelemetryUpdateContext, updateState: ITelemetryUpdateState) => void | boolean;
2806
+ }
2807
+
2808
+ interface ITelemetryUnloadState {
2809
+ reason: TelemetryUnloadReason;
2810
+ isAsync: boolean;
2811
+ flushComplete?: boolean;
2812
+ }
2813
+
2814
+ interface ITelemetryUpdateState {
2815
+ /**
2816
+ * Identifies the reason for the update notification, this is a bitwise numeric value
2817
+ */
2818
+ reason: TelemetryUpdateReason;
2819
+ /**
2820
+ * This is a new active configuration that should be used
2821
+ */
2822
+ cfg?: IConfiguration;
2823
+ /**
2824
+ * The detected changes
2825
+ */
2826
+ oldCfg?: IConfiguration;
2827
+ /**
2828
+ * If this is a configuration update this was the previous configuration that was used
2829
+ */
2830
+ newConfig?: IConfiguration;
2831
+ /**
2832
+ * Was the new config requested to be merged with the existing config
2833
+ */
2834
+ merge?: boolean;
2835
+ /**
2836
+ * This holds a collection of plugins that have been added (if the reason identifies that one or more plugins have been added)
2837
+ */
2838
+ added?: IPlugin[];
2839
+ /**
2840
+ * This holds a collection of plugins that have been removed (if the reason identifies that one or more plugins have been removed)
2841
+ */
2842
+ removed?: IPlugin[];
2843
+ }
2844
+
2845
+ /**
2846
+ * Identifies frequency of items sent
2847
+ * Default: send data on 28th every 3 month each year
2848
+ */
2849
+ interface IThrottleInterval {
2850
+ /**
2851
+ * Identifies month interval that items can be sent
2852
+ * For example, if it is set to 2 and start date is in Jan, items will be sent out every two months (Jan, March, May etc.)
2853
+ * If both monthInterval and dayInterval are undefined, it will be set to 3
2854
+ */
2855
+ monthInterval?: number;
2856
+ /**
2857
+ * Identifies days Interval from start date that items can be sent
2858
+ * Default: undefined
2859
+ */
2860
+ dayInterval?: number;
2861
+ /**
2862
+ * Identifies days within each month that items can be sent
2863
+ * If both monthInterval and dayInterval are undefined, it will be default to [28]
2864
+ */
2865
+ daysOfMonth?: number[];
2866
+ }
2867
+
2868
+ /**
2869
+ * Identifies limit number/percentage of items sent per time
2870
+ * If both are provided, minimum number between the two will be used
2871
+ */
2872
+ interface IThrottleLimit {
2873
+ /**
2874
+ * Identifies sampling percentage of items per time
2875
+ * The percentage is set to 4 decimal places, for example: 1 means 0.0001%
2876
+ * Default: 100 (0.01%)
2877
+ */
2878
+ samplingRate?: number;
2879
+ /**
2880
+ * Identifies limit number of items per time
2881
+ * Default: 1
2882
+ */
2883
+ maxSendNumber?: number;
2884
+ }
2885
+
2886
+ /**
2887
+ * Identifies basic config
2888
+ */
2889
+ interface IThrottleMgrConfig {
2890
+ /**
2891
+ * Identifies if throttle is disabled
2892
+ * Default: false
2893
+ */
2894
+ disabled?: boolean;
2895
+ /**
2896
+ * Identifies limit number/percentage of items sent per time
2897
+ * Default: sampling percentage 0.01% with one item sent per time
2898
+ */
2899
+ limit?: IThrottleLimit;
2900
+ /**
2901
+ * Identifies frequency of items sent
2902
+ * Default: send data on 28th every 3 month each year
2903
+ */
2904
+ interval?: IThrottleInterval;
2905
+ }
2906
+
2907
+ /**
2908
+ * A Timer handler which is returned from {@link scheduleTimeout} which contains functions to
2909
+ * cancel or restart (refresh) the timeout function.
2910
+ *
2911
+ * @since 0.4.4
2912
+ * @group Timer
2913
+ */
2914
+ interface ITimerHandler {
2915
+ /**
2916
+ * Cancels a timeout that was previously scheduled, after calling this function any previously
2917
+ * scheduled timer will not execute.
2918
+ * @example
2919
+ * ```ts
2920
+ * let theTimer = scheduleTimeout(...);
2921
+ * theTimer.cancel();
2922
+ * ```
2923
+ */
2924
+ cancel(): void;
2925
+ /**
2926
+ * Reschedules the timer to call its callback at the previously specified duration
2927
+ * adjusted to the current time. This is useful for refreshing a timer without allocating
2928
+ * a new JavaScript object.
2929
+ *
2930
+ * Using this on a timer that has already called its callback will reactivate the timer.
2931
+ * Calling on a timer that has not yet executed will just reschedule the current timer.
2932
+ * @example
2933
+ * ```ts
2934
+ * let theTimer = scheduleTimeout(...);
2935
+ * // The timer will be restarted (if already executed) or rescheduled (if it has not yet executed)
2936
+ * theTimer.refresh();
2937
+ * ```
2938
+ */
2939
+ refresh(): ITimerHandler;
2940
+ /**
2941
+ * When called, requests that the event loop not exit so long when the ITimerHandler is active.
2942
+ * Calling timer.ref() multiple times will have no effect. By default, all ITimerHandler objects
2943
+ * will create "ref'ed" instances, making it normally unnecessary to call timer.ref() unless
2944
+ * timer.unref() had been called previously.
2945
+ * @since 0.7.0
2946
+ * @returns the ITimerHandler instance
2947
+ * @example
2948
+ * ```ts
2949
+ * let theTimer = createTimeout(...);
2950
+ *
2951
+ * // Make sure the timer is referenced (the default) so that the runtime (Node) does not terminate
2952
+ * // if there is a waiting referenced timer.
2953
+ * theTimer.ref();
2954
+ * ```
2955
+ */
2956
+ ref(): this;
2957
+ /**
2958
+ * When called, the any active ITimerHandler instance will not require the event loop to remain
2959
+ * active (Node.js). If there is no other activity keeping the event loop running, the process may
2960
+ * exit before the ITimerHandler instance callback is invoked. Calling timer.unref() multiple times
2961
+ * will have no effect.
2962
+ * @since 0.7.0
2963
+ * @returns the ITimerHandler instance
2964
+ * @example
2965
+ * ```ts
2966
+ * let theTimer = createTimeout(...);
2967
+ *
2968
+ * // Unreference the timer so that the runtime (Node) may terminate if nothing else is running.
2969
+ * theTimer.unref();
2970
+ * ```
2971
+ */
2972
+ unref(): this;
2973
+ /**
2974
+ * If true, any running referenced `ITimerHandler` instance will keep the Node.js event loop active.
2975
+ * @since 0.7.0
2976
+ * @example
2977
+ * ```ts
2978
+ * let theTimer = createTimeout(...);
2979
+ *
2980
+ * // Unreference the timer so that the runtime (Node) may terminate if nothing else is running.
2981
+ * theTimer.unref();
2982
+ * let hasRef = theTimer.hasRef(); // false
2983
+ *
2984
+ * theTimer.ref();
2985
+ * hasRef = theTimer.hasRef(); // true
2986
+ * ```
2987
+ */
2988
+ hasRef(): boolean;
2989
+ /**
2990
+ * Gets or Sets a flag indicating if the underlying timer is currently enabled and running.
2991
+ * Setting the enabled flag to the same as it's current value has no effect, setting to `true`
2992
+ * when already `true` will not {@link ITimerHandler.refresh | refresh}() the timer.
2993
+ * And setting to 'false` will {@link ITimerHandler.cancel | cancel}() the timer.
2994
+ * @since 0.8.1
2995
+ * @example
2996
+ * ```ts
2997
+ * let theTimer = createTimeout(...);
2998
+ *
2999
+ * // Check if enabled
3000
+ * theTimer.enabled; // false
3001
+ *
3002
+ * // Start the timer
3003
+ * theTimer.enabled = true; // Same as calling refresh()
3004
+ * theTimer.enabled; //true
3005
+ *
3006
+ * // Has no effect as it's already running
3007
+ * theTimer.enabled = true;
3008
+ *
3009
+ * // Will refresh / restart the time
3010
+ * theTimer.refresh()
3011
+ *
3012
+ * let theTimer = scheduleTimeout(...);
3013
+ *
3014
+ * // Check if enabled
3015
+ * theTimer.enabled; // true
3016
+ * ```
3017
+ */
3018
+ enabled: boolean;
3019
+ }
3020
+
3021
+ interface ITraceTelemetry extends IPartC {
3022
+ /**
3023
+ * @description A message string
3024
+ * @type {string}
3025
+ * @memberof ITraceTelemetry
3026
+ */
3027
+ message: string;
3028
+ /**
3029
+ * @description Severity level of the logging message used for filtering in the portal
3030
+ * @type {SeverityLevel}
3031
+ * @memberof ITraceTelemetry
3032
+ */
3033
+ severityLevel?: SeverityLevel;
3034
+ /**
3035
+ * @description custom defiend iKey
3036
+ * @type {SeverityLevel}
3037
+ * @memberof ITraceTelemetry
3038
+ */
3039
+ iKey?: string;
3040
+ }
3041
+
3042
+ /**
3043
+ * An interface which provides automatic removal during unloading of the component
3044
+ */
3045
+ interface IUnloadHook {
3046
+ /**
3047
+ * Self remove the referenced component
3048
+ */
3049
+ rm: () => void;
3050
+ }
3051
+
3052
+ /**
3053
+ * Interface which identifiesAdd this hook so that it is automatically removed during unloading
3054
+ * @param hooks - The single hook or an array of IInstrumentHook objects
3055
+ */
3056
+ interface IUnloadHookContainer {
3057
+ add: (hooks: IUnloadHook | IUnloadHook[] | Iterator<IUnloadHook> | ILegacyUnloadHook | ILegacyUnloadHook[] | Iterator<ILegacyUnloadHook>) => void;
3058
+ run: (logger?: IDiagnosticLogger) => void;
3059
+ }
3060
+
3061
+ interface IWatchDetails<T = IConfiguration> {
3062
+ /**
3063
+ * The current config object
3064
+ */
3065
+ cfg: T;
3066
+ /**
3067
+ * Set the value against the provided config/name with the value, the property
3068
+ * will be converted to be dynamic (if not already) as long as the provided config
3069
+ * is already a tracked dynamic object.
3070
+ * @throws TypeError if the provided config is not a monitored dynamic config
3071
+ */
3072
+ set: <C, V>(theConfig: C, name: string, value: V) => V;
3073
+ /**
3074
+ * Set default values for the config if not present.
3075
+ * @param theConfig - The configuration object to set default on (if missing)
3076
+ * @param defaultValues - The default values to apply to the config
3077
+ */
3078
+ setDf: <C>(theConfig: C, defaultValues: IConfigDefaults<C>) => C;
3079
+ /**
3080
+ * Set this named property of the target as referenced, which will cause any object or array instance
3081
+ * to be updated in-place rather than being entirely replaced. All other values will continue to be replaced.
3082
+ * @returns The referenced properties current value
3083
+ */
3084
+ ref: <C, V = any>(target: C, name: string) => V;
3085
+ /**
3086
+ * Set this named property of the target as read-only, which will block this single named property from
3087
+ * ever being changed for the target instance.
3088
+ * This does NOT freeze or seal the instance, it just stops the direct re-assignment of the named property,
3089
+ * if the value is a non-primitive (ie. an object or array) it's properties will still be mutable.
3090
+ * @returns The referenced properties current value
3091
+ */
3092
+ rdOnly: <C, V = any>(target: C, name: string) => V;
3093
+ }
3094
+
3095
+ /**
3096
+ * The IXHROverride interface overrides the way HTTP requests are sent.
3097
+ */
3098
+ interface IXHROverride {
3099
+ sendPOST: SendPOSTFunction;
3100
+ }
3101
+
3102
+ const LoggingSeverity: EnumValue<typeof eLoggingSeverity>;
3103
+
3104
+ type LoggingSeverity = number | eLoggingSeverity;
3105
+
3106
+ type OnCompleteCallback = (status: number, headers: {
3107
+ [headerName: string]: string;
3108
+ }, response?: string) => void;
3109
+
3110
+ /**
3111
+ * Creates proxy functions on the target which internally will call the source version with all arguments passed to the target method.
3112
+ *
3113
+ * @param target - The target object to be assigned with the source properties and functions
3114
+ * @param source - The source object which will be assigned / called by setting / calling the targets proxies
3115
+ * @param functionsToProxy - An array of function names that will be proxied on the target
3116
+ * @param overwriteTarget - If false this will not replace any pre-existing name otherwise (the default) it will overwrite any existing name
3117
+ */
3118
+ function proxyFunctions<T, S>(target: T, source: S | (() => S), functionsToProxy: (keyof S)[], overwriteTarget?: boolean): T;
3119
+
3120
+ /**
3121
+ * This defines the handler function for when a promise is rejected.
3122
+ * @param value This is the value passed as part of resolving the Promise
3123
+ * @return This may return a value, another Promise or void. @see {@link IPromise.then} for how the value is handled.
3124
+ */
3125
+ type RejectedPromiseHandler<T = never> = (((reason: any) => T | IPromise<T> | PromiseLike<T>) | undefined | null);
3126
+
3127
+ /**
3128
+ * This defines the handler function for when a promise is resolved.
3129
+ * @param value This is the value passed as part of resolving the Promise
3130
+ * @return This may return a value, another Promise or void. @see {@link IPromise.then} for how the value is handled.
3131
+ */
3132
+ type ResolvedPromiseHandler<T, TResult1 = T> = (((value: T) => TResult1 | IPromise<TResult1> | PromiseLike<TResult1>) | undefined | null);
3133
+
3134
+ class Sender extends BaseTelemetryPlugin implements IChannelControls {
3135
+ static constructEnvelope(orig: ITelemetryItem, iKey: string, logger: IDiagnosticLogger, convertUndefined?: any): IEnvelope;
3136
+ readonly priority: number;
3137
+ readonly identifier: string;
3138
+ /**
3139
+ * The configuration for this sender instance
3140
+ */
3141
+ readonly _senderConfig: ISenderConfig;
3142
+ /**
3143
+ * A method which will cause data to be send to the url
3144
+ */
3145
+ _sender: SenderFunction;
3146
+ /**
3147
+ * A send buffer object
3148
+ */
3149
+ _buffer: ISendBuffer;
3150
+ /**
3151
+ * AppId of this component parsed from some backend response.
3152
+ */
3153
+ _appId: string;
3154
+ protected _sample: ISample;
3155
+ constructor();
3156
+ /**
3157
+ * Pause the sending (transmission) of events, this will cause all events to be batched only until the maximum limits are
3158
+ * hit at which point new events are dropped. Will also cause events to NOT be sent during page unload, so if Session storage
3159
+ * is disabled events will be lost.
3160
+ * SessionStorage Limit is 2000 events, In-Memory (Array) Storage is 10,000 events (can be configured via the eventsLimitInMem).
3161
+ */
3162
+ pause(): void;
3163
+ /**
3164
+ * Resume the sending (transmission) of events, this will restart the timer and any batched events will be sent using the normal
3165
+ * send interval.
3166
+ */
3167
+ resume(): void;
3168
+ /**
3169
+ * Flush to send data immediately; channel should default to sending data asynchronously. If executing asynchronously (the default) and
3170
+ * you DO NOT pass a callback function then a [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html)
3171
+ * will be returned which will resolve once the flush is complete. The actual implementation of the `IPromise`
3172
+ * will be a native Promise (if supported) or the default as supplied by [ts-async library](https://github.com/nevware21/ts-async)
3173
+ * @param async - send data asynchronously when true
3174
+ * @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.
3175
+ * If the caller doesn't return true the caller should assume that it may never be called.
3176
+ * @param sendReason - specify the reason that you are calling "flush" defaults to ManualFlush (1) if not specified
3177
+ * @returns - If a callback is provided `true` to indicate that callback will be called after the flush is complete otherwise the caller
3178
+ * should assume that any provided callback will never be called, Nothing or if occurring asynchronously a
3179
+ * [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html) which will be resolved once the unload is complete,
3180
+ * the [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html) will only be returned when no callback is provided
3181
+ * and async is true.
3182
+ */
3183
+ flush(async?: boolean, callBack?: (flushComplete?: boolean) => void): void | IPromise<boolean>;
3184
+ /**
3185
+ * Flush the batched events synchronously (if possible -- based on configuration).
3186
+ * Will not flush if the Send has been paused.
3187
+ */
3188
+ onunloadFlush(): void;
3189
+ initialize(config: IConfiguration & IConfig, core: IAppInsightsCore, extensions: IPlugin[], pluginChain?: ITelemetryPluginChain): void;
3190
+ processTelemetry(telemetryItem: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
3191
+ /**
3192
+ * xhr state changes
3193
+ * @deprecated
3194
+ */
3195
+ _xhrReadyStateChange(xhr: XMLHttpRequest, payload: string[], countOfItemsInPayload: number): void;
3196
+ /**
3197
+ * Trigger the immediate send of buffered data; If executing asynchronously (the default) this may (not required) return
3198
+ * an [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html) that will resolve once the
3199
+ * send is complete. The actual implementation of the `IPromise` will be a native Promise (if supported) or the default
3200
+ * as supplied by [ts-async library](https://github.com/nevware21/ts-async)
3201
+ * @param async - Indicates if the events should be sent asynchronously
3202
+ * @param forcedSender - {SenderFunction} - Indicates the forcedSender, undefined if not passed
3203
+ * @returns - Nothing or optionally, if occurring asynchronously a [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html)
3204
+ * which will be resolved (or reject) once the send is complete, the [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html)
3205
+ * should only be returned when async is true.
3206
+ */
3207
+ triggerSend(async?: boolean, forcedSender?: SenderFunction, sendReason?: SendRequestReason): void | IPromise<boolean>;
3208
+ /**
3209
+ * error handler
3210
+ */
3211
+ _onError(payload: string[], message: string, event?: ErrorEvent): void;
3212
+ /**
3213
+ * partial success handler
3214
+ */
3215
+ _onPartialSuccess(payload: string[], results: IBackendResponse): void;
3216
+ /**
3217
+ * success handler
3218
+ */
3219
+ _onSuccess(payload: string[], countOfItemsInPayload: number): void;
3220
+ /**
3221
+ * xdr state changes
3222
+ * @deprecated
3223
+ */
3224
+ _xdrOnLoad(xdr: XDomainRequest, payload: string[]): void;
3225
+ /**
3226
+ * Add header to request
3227
+ * @param name - Header name.
3228
+ * @param value - Header value.
3229
+ */
3230
+ addHeader(name: string, value: string): void;
3231
+ }
3232
+
3233
+ type SenderFunction = (payload: string[], isAsync: boolean) => void | IPromise<boolean>;
3234
+
3235
+ /**
3236
+ * SendPOSTFunction type defines how an HTTP POST request is sent to an ingestion server
3237
+ * @param payload - The payload object that should be sent, contains the url, bytes/string and headers for the request
3238
+ * @param oncomplete - The function to call once the request has completed whether a success, failure or timeout
3239
+ * @param sync - A boolean flag indicating whether the request should be sent as a synchronous request.
3240
+ */
3241
+ type SendPOSTFunction = (payload: IPayloadData, oncomplete: OnCompleteCallback, sync?: boolean) => void | IPromise<boolean>;
3242
+
3243
+ /**
3244
+ * The EventsDiscardedReason enumeration contains a set of values that specify the reason for discarding an event.
3245
+ */
3246
+ const enum SendRequestReason {
3247
+ /**
3248
+ * No specific reason was specified
3249
+ */
3250
+ Undefined = 0,
3251
+ /**
3252
+ * Events are being sent based on the normal event schedule / timer.
3253
+ */
3254
+ NormalSchedule = 1,
3255
+ /**
3256
+ * A manual flush request was received
3257
+ */
3258
+ ManualFlush = 1,
3259
+ /**
3260
+ * Unload event is being processed
3261
+ */
3262
+ Unload = 2,
3263
+ /**
3264
+ * The event(s) being sent are sync events
3265
+ */
3266
+ SyncEvent = 3,
3267
+ /**
3268
+ * The Channel was resumed
3269
+ */
3270
+ Resumed = 4,
3271
+ /**
3272
+ * The event(s) being sent as a retry
3273
+ */
3274
+ Retry = 5,
3275
+ /**
3276
+ * The SDK is unloading
3277
+ */
3278
+ SdkUnload = 6,
3279
+ /**
3280
+ * Maximum batch size would be exceeded
3281
+ */
3282
+ MaxBatchSize = 10,
3283
+ /**
3284
+ * The Maximum number of events have already been queued
3285
+ */
3286
+ MaxQueuedEvents = 20
3287
+ }
3288
+
3289
+ class SessionStorageSendBuffer extends BaseSendBuffer implements ISendBuffer {
3290
+ static BUFFER_KEY: string;
3291
+ static SENT_BUFFER_KEY: string;
3292
+ static MAX_BUFFER_SIZE: number;
3293
+ constructor(logger: IDiagnosticLogger, config: ISenderConfig);
3294
+ enqueue(payload: string): void;
3295
+ clear(): void;
3296
+ markAsSent(payload: string[]): void;
3297
+ clearSent(payload: string[]): void;
3298
+ createNew(newLogger?: IDiagnosticLogger, newConfig?: ISenderConfig, canUseSessionStorage?: boolean): ArraySendBuffer | SessionStorageSendBuffer;
3299
+ }
3300
+
3301
+ /**
3302
+ * Defines the level of severity for the event.
3303
+ */
3304
+ const SeverityLevel: EnumValue<typeof eSeverityLevel>;
3305
+
3306
+ type SeverityLevel = number | eSeverityLevel;
3307
+
3308
+ interface Tags {
3309
+ [key: string]: any;
3310
+ }
3311
+
3312
+ type TelemetryInitializerFunction = <T extends ITelemetryItem>(item: T) => boolean | void;
3313
+
3314
+ /**
3315
+ * The TelemetryUnloadReason enumeration contains the possible reasons for why a plugin is being unloaded / torndown().
3316
+ */
3317
+ const enum TelemetryUnloadReason {
3318
+ /**
3319
+ * Teardown has been called without any context.
3320
+ */
3321
+ ManualTeardown = 0,
3322
+ /**
3323
+ * Just this plugin is being removed
3324
+ */
3325
+ PluginUnload = 1,
3326
+ /**
3327
+ * This instance of the plugin is being removed and replaced
3328
+ */
3329
+ PluginReplace = 2,
3330
+ /**
3331
+ * The entire SDK is being unloaded
3332
+ */
3333
+ SdkUnload = 50
3334
+ }
3335
+
3336
+ /**
3337
+ * The TelemetryUpdateReason enumeration contains a set of bit-wise values that specify the reason for update request.
3338
+ */
3339
+ const enum TelemetryUpdateReason {
3340
+ /**
3341
+ * Unknown.
3342
+ */
3343
+ Unknown = 0,
3344
+ /**
3345
+ * The configuration has ben updated or changed
3346
+ */
3347
+ ConfigurationChanged = 1,
3348
+ /**
3349
+ * One or more plugins have been added
3350
+ */
3351
+ PluginAdded = 16,
3352
+ /**
3353
+ * One or more plugins have been removed
3354
+ */
3355
+ PluginRemoved = 32
3356
+ }
3357
+
3358
+ /**
3359
+ * Throw an error exception with the specified optional message
3360
+ * @group Error
3361
+ * @param message
3362
+ */
3363
+ function throwError(message?: string): never;
3364
+
3365
+ type UnloadHandler = (itemCtx: IProcessTelemetryUnloadContext, unloadState: ITelemetryUnloadState) => void;
3366
+
3367
+ type WatcherFunction<T = IConfiguration> = (details: IWatchDetails<T>) => void;
3368
+
3369
+ interface XDomainRequest extends XMLHttpRequestEventTarget {
3370
+ readonly responseText: string;
3371
+ send(payload: string): void;
3372
+ open(method: string, url: string): void;
3373
+ }
3374
+
145
3375
  }