@microsoft/applicationinsights-web-basic 3.1.0-nightly3.2402-09 → 3.1.0

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