@microsoft/applicationinsights-web-basic 3.0.1-nightly3.2304-38 → 3.0.1-nightly3.2304-41

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 (35) hide show
  1. package/browser/es5/{aib.3.0.1-nightly3.2304-38.cjs.js → aib.3.0.1-nightly3.2304-41.cjs.js} +4 -4
  2. package/browser/es5/{aib.3.0.1-nightly3.2304-38.cjs.js.map → aib.3.0.1-nightly3.2304-41.cjs.js.map} +1 -1
  3. package/browser/es5/{aib.3.0.1-nightly3.2304-38.cjs.min.js → aib.3.0.1-nightly3.2304-41.cjs.min.js} +3 -3
  4. package/browser/es5/{aib.3.0.1-nightly3.2304-38.cjs.min.js.map → aib.3.0.1-nightly3.2304-41.cjs.min.js.map} +1 -1
  5. package/browser/es5/{aib.3.0.1-nightly3.2304-38.gbl.js → aib.3.0.1-nightly3.2304-41.gbl.js} +4 -4
  6. package/browser/es5/{aib.3.0.1-nightly3.2304-38.gbl.js.map → aib.3.0.1-nightly3.2304-41.gbl.js.map} +1 -1
  7. package/browser/es5/{aib.3.0.1-nightly3.2304-38.gbl.min.js → aib.3.0.1-nightly3.2304-41.gbl.min.js} +3 -3
  8. package/browser/es5/{aib.3.0.1-nightly3.2304-38.gbl.min.js.map → aib.3.0.1-nightly3.2304-41.gbl.min.js.map} +1 -1
  9. package/browser/es5/aib.3.0.1-nightly3.2304-41.integrity.json +66 -0
  10. package/browser/es5/{aib.3.0.1-nightly3.2304-38.js → aib.3.0.1-nightly3.2304-41.js} +4 -4
  11. package/browser/es5/{aib.3.0.1-nightly3.2304-38.js.map → aib.3.0.1-nightly3.2304-41.js.map} +1 -1
  12. package/browser/es5/{aib.3.0.1-nightly3.2304-38.min.js → aib.3.0.1-nightly3.2304-41.min.js} +3 -3
  13. package/browser/es5/{aib.3.0.1-nightly3.2304-38.min.js.map → aib.3.0.1-nightly3.2304-41.min.js.map} +1 -1
  14. package/browser/es5/aib.3.cjs.js +3 -3
  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 +3 -3
  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.js +3 -3
  23. package/browser/es5/aib.3.js.map +1 -1
  24. package/browser/es5/aib.3.min.js +2 -2
  25. package/browser/es5/aib.3.min.js.map +1 -1
  26. package/dist/es5/applicationinsights-web-basic.js +3 -3
  27. package/dist/es5/applicationinsights-web-basic.js.map +1 -1
  28. package/dist/es5/applicationinsights-web-basic.min.js +2 -2
  29. package/dist/es5/applicationinsights-web-basic.min.js.map +1 -1
  30. package/dist-es5/__DynamicConstants.js +1 -1
  31. package/dist-es5/index.js +1 -1
  32. package/package.json +4 -4
  33. package/types/applicationinsights-web-basic.d.ts +50 -2554
  34. package/types/applicationinsights-web-basic.namespaced.d.ts +50 -2554
  35. package/browser/es5/aib.3.0.1-nightly3.2304-38.integrity.json +0 -66
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Microsoft.ApplicationInsights, 3.0.1-nightly3.2304-38
2
+ * Microsoft.ApplicationInsights, 3.0.1-nightly3.2304-41
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  *
5
5
  * Microsoft Application Insights Team
@@ -7,153 +7,35 @@
7
7
  */
8
8
 
9
9
  declare namespace ApplicationInsights {
10
- import { arrForEach } from '@nevware21/ts-utils';
11
- import { EnumCls } from '@nevware21/ts-utils';
12
- import { isNullOrUndefined } from '@nevware21/ts-utils';
13
- import { ITimerHandler } from '@nevware21/ts-utils';
14
- import { throwError } from '@nevware21/ts-utils';
15
-
16
- class AppInsightsCore<CfgType extends IConfiguration = IConfiguration> implements IAppInsightsCore<CfgType> {
17
- config: CfgType;
18
- logger: IDiagnosticLogger;
19
- /**
20
- * An array of the installed plugins that provide a version
21
- */
22
- readonly pluginVersionStringArr: string[];
23
- /**
24
- * The formatted string of the installed plugins that contain a version number
25
- */
26
- readonly pluginVersionString: string;
27
- /**
28
- * Returns a value that indicates whether the instance has already been previously initialized.
29
- */
30
- isInitialized: () => boolean;
31
- /**
32
- * Function used to identify the get w parameter used to identify status bit to some channels
33
- */
34
- getWParam: () => number;
35
- constructor();
36
- initialize(config: CfgType, extensions: IPlugin[], logger?: IDiagnosticLogger, notificationManager?: INotificationManager): void;
37
- getChannels(): IChannelControls[];
38
- track(telemetryItem: ITelemetryItem): void;
39
- getProcessTelContext(): IProcessTelemetryContext;
40
- getNotifyMgr(): INotificationManager;
41
- /**
42
- * Adds a notification listener. The SDK calls methods on the listener when an appropriate notification is raised.
43
- * The added plugins must raise notifications. If the plugins do not implement the notifications, then no methods will be
44
- * called.
45
- * @param listener - An INotificationListener object.
46
- */
47
- addNotificationListener(listener: INotificationListener): void;
48
- /**
49
- * Removes all instances of the listener.
50
- * @param listener - INotificationListener to remove.
51
- */
52
- removeNotificationListener(listener: INotificationListener): void;
53
- /**
54
- * Get the current cookie manager for this instance
55
- */
56
- getCookieMgr(): ICookieMgr;
57
- /**
58
- * Set the current cookie manager for this instance
59
- * @param cookieMgr - The manager, if set to null/undefined will cause the default to be created
60
- */
61
- setCookieMgr(cookieMgr: ICookieMgr): void;
62
- getPerfMgr(): IPerfManager;
63
- setPerfMgr(perfMgr: IPerfManager): void;
64
- eventCnt(): number;
65
- /**
66
- * Enable the timer that checks the logger.queue for log messages to be flushed.
67
- * Note: Since 3.0.1 and 2.8.13 this is no longer an interval timer but is a normal
68
- * timer that is only started when this function is called and then subsequently
69
- * only _if_ there are any logger.queue messages to be sent.
70
- */
71
- pollInternalLogs(eventName?: string): ITimerHandler;
72
- /**
73
- * Stop the timer that log messages from logger.queue when available
74
- */
75
- stopPollingInternalLogs(): void;
76
- /**
77
- * Add a telemetry processor to decorate or drop telemetry events.
78
- * @param telemetryInitializer - The Telemetry Initializer function
79
- * @returns - A ITelemetryInitializerHandler to enable the initializer to be removed
80
- */
81
- addTelemetryInitializer(telemetryInitializer: TelemetryInitializerFunction): ITelemetryInitializerHandler;
82
- /**
83
- * Unload and Tear down the SDK and any initialized plugins, after calling this the SDK will be considered
84
- * to be un-initialized and non-operational, re-initializing the SDK should only be attempted if the previous
85
- * unload call return `true` stating that all plugins reported that they also unloaded, the recommended
86
- * approach is to create a new instance and initialize that instance.
87
- * This is due to possible unexpected side effects caused by plugins not supporting unload / teardown, unable
88
- * to successfully remove any global references or they may just be completing the unload process asynchronously.
89
- * @param isAsync - Can the unload be performed asynchronously (default)
90
- * @param unloadComplete - An optional callback that will be called once the unload has completed
91
- * @param cbTimeout - An optional timeout to wait for any flush operations to complete before proceeding with the unload. Defaults to 5 seconds.
92
- */
93
- unload(isAsync?: boolean, unloadComplete?: (unloadState: ITelemetryUnloadState) => void, cbTimeout?: number): void;
94
- getPlugin<T extends IPlugin = IPlugin>(pluginIdentifier: string): ILoadedPlugin<T>;
95
- /**
96
- * Add a new plugin to the installation
97
- * @param plugin - The new plugin to add
98
- * @param replaceExisting - should any existing plugin be replaced, default is false
99
- * @param doAsync - Should the add be performed asynchronously
100
- * @param addCb - [Optional] callback to call after the plugin has been added
101
- */
102
- addPlugin<T extends IPlugin = ITelemetryPlugin>(plugin: T, replaceExisting?: boolean, doAsync?: boolean, addCb?: (added?: boolean) => void): void;
103
- /**
104
- * Update the configuration used and broadcast the changes to all loaded plugins
105
- * @param newConfig - The new configuration is apply
106
- * @param mergeExisting - Should the new configuration merge with the existing or just replace it. Default is to true.
107
- */
108
- updateCfg(newConfig: CfgType, mergeExisting?: boolean): void;
109
- /**
110
- * Returns the unique event namespace that should be used
111
- */
112
- evtNamespace(): string;
113
- /**
114
- * Add an unload handler that will be called when the SDK is being unloaded
115
- * @param handler - the handler
116
- */
117
- addUnloadCb(handler: UnloadHandler): void;
118
- /**
119
- * Flush and send any batched / cached data immediately
120
- * @param async - send data asynchronously when true (defaults to true)
121
- * @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.
122
- * If the caller doesn't return true the caller should assume that it may never be called.
123
- * @param sendReason - specify the reason that you are calling "flush" defaults to ManualFlush (1) if not specified
124
- * @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
125
- */
126
- flush(isAsync?: boolean, callBack?: (flushComplete?: boolean) => void, sendReason?: SendRequestReason): void;
127
- /**
128
- * Gets the current distributed trace context for this instance if available
129
- * @param createNew - Optional flag to create a new instance if one doesn't currently exist, defaults to true
130
- */
131
- getTraceCtx(createNew?: boolean): IDistributedTraceContext | null;
132
- /**
133
- * Sets the current distributed trace context for this instance if available
134
- */
135
- setTraceCtx(newTracectx: IDistributedTraceContext): void;
136
- /**
137
- * Add this hook so that it is automatically removed during unloading
138
- * @param hooks - The single hook or an array of IInstrumentHook objects
139
- */
140
- addUnloadHook(hooks: IUnloadHook | IUnloadHook[] | Iterator<IUnloadHook> | ILegacyUnloadHook | ILegacyUnloadHook[] | Iterator<ILegacyUnloadHook>): void;
141
- /**
142
- * Watches and tracks changes for accesses to the current config, and if the accessed config changes the
143
- * handler will be recalled.
144
- * @param handler
145
- * @returns A watcher handler instance that can be used to remove itself when being unloaded
146
- */
147
- onCfgChange(handler: WatcherFunction<CfgType>): IUnloadHook;
148
- protected releaseQueue(): void;
149
- /**
150
- * Hook for Core extensions to allow them to update their own configuration before updating all of the plugins.
151
- * @param updateCtx - The plugin update context
152
- * @param updateState - The Update State
153
- * @returns boolean - True means the extension class will call updateState otherwise the Core will
154
- */
155
- protected _updateHook?(updateCtx: IProcessTelemetryUpdateContext, updateState: ITelemetryUpdateState): void | boolean;
156
- }
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 { isNullOrUndefined } from '@microsoft/applicationinsights-core-js';
26
+ import { ITelemetryItem } from '@microsoft/applicationinsights-core-js';
27
+ import { ITelemetryPlugin } from '@microsoft/applicationinsights-core-js';
28
+ import { ITraceTelemetry } from '@microsoft/applicationinsights-common';
29
+ import { IUnloadHook } from '@microsoft/applicationinsights-core-js';
30
+ import { proxyFunctions } from '@microsoft/applicationinsights-core-js';
31
+ import { Sender } from '@microsoft/applicationinsights-channel-js';
32
+ import { SendRequestReason } from '@microsoft/applicationinsights-core-js';
33
+ import { SeverityLevel } from '@microsoft/applicationinsights-common';
34
+ import { throwError } from '@microsoft/applicationinsights-core-js';
35
+ import { UnloadHandler } from '@microsoft/applicationinsights-core-js';
36
+ import { WatcherFunction } from '@microsoft/applicationinsights-core-js';
37
+
38
+ export { AppInsightsCore }
157
39
 
158
40
  /**
159
41
  * @export
@@ -227,2435 +109,49 @@ declare namespace ApplicationInsights {
227
109
  onCfgChange(handler: WatcherFunction<IConfiguration>): IUnloadHook;
228
110
  }
229
111
 
230
- class ArraySendBuffer extends BaseSendBuffer implements ISendBuffer {
231
- constructor(logger: IDiagnosticLogger, config: ISenderConfig);
232
- markAsSent(payload: string[]): void;
233
- clearSent(payload: string[]): void;
234
- }
235
-
236
112
  export { arrForEach }
237
113
 
238
- abstract class BaseSendBuffer {
239
- protected _get: () => string[];
240
- protected _set: (buffer: string[]) => string[];
241
- constructor(logger: IDiagnosticLogger, config: ISenderConfig);
242
- enqueue(payload: string): void;
243
- count(): number;
244
- size(): number;
245
- clear(): void;
246
- getItems(): string[];
247
- batchPayloads(payload: string[]): string;
248
- createNew(newLogger?: IDiagnosticLogger, newConfig?: ISenderConfig, canUseSessionStorage?: boolean): ArraySendBuffer | SessionStorageSendBuffer;
249
- }
114
+ export { _eInternalMessageId }
250
115
 
251
- /**
252
- * BaseTelemetryPlugin provides a basic implementation of the ITelemetryPlugin interface so that plugins
253
- * can avoid implementation the same set of boiler plate code as well as provide a base
254
- * implementation so that new default implementations can be added without breaking all plugins.
255
- */
256
- abstract class BaseTelemetryPlugin implements ITelemetryPlugin {
257
- identifier: string;
258
- version?: string;
259
- /**
260
- * Holds the core instance that was used during initialization
261
- */
262
- core: IAppInsightsCore;
263
- priority: number;
264
- /**
265
- * Call back for telemetry processing before it it is sent
266
- * @param env - This is the current event being reported
267
- * @param itemCtx - This is the context for the current request, ITelemetryPlugin instances
268
- * can optionally use this to access the current core instance or define / pass additional information
269
- * to later plugins (vs appending items to the telemetry item)
270
- */
271
- processNext: (env: ITelemetryItem, itemCtx: IProcessTelemetryContext) => void;
272
- /**
273
- * Set next extension for telemetry processing
274
- */
275
- setNextPlugin: (next: ITelemetryPlugin | ITelemetryPluginChain) => void;
276
- /**
277
- * Returns the current diagnostic logger that can be used to log issues, if no logger is currently
278
- * assigned a new default one will be created and returned.
279
- */
280
- diagLog: (itemCtx?: IProcessTelemetryContext) => IDiagnosticLogger;
281
- /**
282
- * Returns whether the plugin has been initialized
283
- */
284
- isInitialized: () => boolean;
285
- /**
286
- * Helper to return the current IProcessTelemetryContext, if the passed argument exists this just
287
- * returns that value (helps with minification for callers), otherwise it will return the configured
288
- * context or a temporary one.
289
- * @param currentCtx - [Optional] The current execution context
290
- */
291
- protected _getTelCtx: (currentCtx?: IProcessTelemetryContext) => IProcessTelemetryContext;
292
- /**
293
- * Internal helper to allow setting of the internal initialized setting for inherited instances and unit testing
294
- */
295
- protected setInitialized: (isInitialized: boolean) => void;
296
- /**
297
- * Teardown / Unload hook to allow implementations to perform some additional unload operations before the BaseTelemetryPlugin
298
- * finishes it's removal.
299
- * @param unloadCtx - This is the context that should be used during unloading.
300
- * @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.
301
- * @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.
302
- * @returns boolean - true if the plugin has or will call asyncCallback, this allows the plugin to perform any asynchronous operations.
303
- */
304
- protected _doTeardown?: (unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState, asyncCallback?: () => void) => void | boolean;
305
- /**
306
- * Extension hook to allow implementations to perform some additional update operations before the BaseTelemetryPlugin finishes it's removal
307
- * @param updateCtx - This is the context that should be used during updating.
308
- * @param updateState - The details / state of the update process, it holds details like the current and previous configuration.
309
- * @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.
310
- * @returns boolean - true if the plugin has or will call asyncCallback, this allows the plugin to perform any asynchronous operations.
311
- */
312
- protected _doUpdate?: (updateCtx?: IProcessTelemetryUpdateContext, updateState?: ITelemetryUpdateState, asyncCallback?: () => void) => void | boolean;
313
- /**
314
- * Exposes the underlying unload hook container instance for this extension to allow it to be passed down to any sub components of the class.
315
- * 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
316
- * it's scoped as protected)
317
- */
318
- protected readonly _unloadHooks: IUnloadHookContainer;
319
- constructor();
320
- initialize(config: IConfiguration, core: IAppInsightsCore, extensions: IPlugin[], pluginChain?: ITelemetryPluginChain): void;
321
- /**
322
- * Tear down the plugin and remove any hooked value, the plugin should be removed so that it is no longer initialized and
323
- * therefore could be re-initialized after being torn down. The plugin should ensure that once this has been called any further
324
- * processTelemetry calls are ignored and it just calls the processNext() with the provided context.
325
- * @param unloadCtx - This is the context that should be used during unloading.
326
- * @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.
327
- * @returns boolean - true if the plugin has or will call processNext(), this for backward compatibility as previously teardown was synchronous and returned nothing.
328
- */
329
- teardown(unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState): void | boolean;
330
- abstract processTelemetry(env: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
331
- /**
332
- * The the plugin should re-evaluate configuration and update any cached configuration settings.
333
- * @param updateCtx - This is the context that should be used during updating.
334
- * @param updateState - The details / state of the update process, it holds details like the current and previous configuration.
335
- * @returns boolean - true if the plugin has or will call updateCtx.processNext(), this allows the plugin to perform any asynchronous operations.
336
- */
337
- update(updateCtx: IProcessTelemetryUpdateContext, updateState: ITelemetryUpdateState): void | boolean;
338
- /**
339
- * Add an unload handler that will be called when the SDK is being unloaded
340
- * @param handler - the handler
341
- */
342
- protected _addUnloadCb(handler: UnloadHandler): void;
343
- /**
344
- * Add this hook so that it is automatically removed during unloading
345
- * @param hooks - The single hook or an array of IInstrumentHook objects
346
- */
347
- protected _addHook(hooks: IUnloadHook | IUnloadHook[] | Iterator<IUnloadHook> | ILegacyUnloadHook | ILegacyUnloadHook[] | Iterator<ILegacyUnloadHook>): void;
348
- }
116
+ export { eSeverityLevel }
349
117
 
350
- const DistributedTracingModes: EnumValue<typeof eDistributedTracingModes>;
118
+ export { IAppInsightsCore }
351
119
 
352
- type DistributedTracingModes = number | eDistributedTracingModes;
120
+ export { IAutoExceptionTelemetry }
353
121
 
354
- const enum eDistributedTracingModes {
355
- /**
356
- * (Default) Send Application Insights correlation headers
357
- */
358
- AI = 0,
359
- /**
360
- * Send both W3C Trace Context headers and back-compatibility Application Insights headers
361
- */
362
- AI_AND_W3C = 1,
363
- /**
364
- * Send W3C Trace Context headers
365
- */
366
- W3C = 2
367
- }
122
+ export { IConfiguration }
368
123
 
369
- const enum _eInternalMessageId {
370
- BrowserDoesNotSupportLocalStorage = 0,
371
- BrowserCannotReadLocalStorage = 1,
372
- BrowserCannotReadSessionStorage = 2,
373
- BrowserCannotWriteLocalStorage = 3,
374
- BrowserCannotWriteSessionStorage = 4,
375
- BrowserFailedRemovalFromLocalStorage = 5,
376
- BrowserFailedRemovalFromSessionStorage = 6,
377
- CannotSendEmptyTelemetry = 7,
378
- ClientPerformanceMathError = 8,
379
- ErrorParsingAISessionCookie = 9,
380
- ErrorPVCalc = 10,
381
- ExceptionWhileLoggingError = 11,
382
- FailedAddingTelemetryToBuffer = 12,
383
- FailedMonitorAjaxAbort = 13,
384
- FailedMonitorAjaxDur = 14,
385
- FailedMonitorAjaxOpen = 15,
386
- FailedMonitorAjaxRSC = 16,
387
- FailedMonitorAjaxSend = 17,
388
- FailedMonitorAjaxGetCorrelationHeader = 18,
389
- FailedToAddHandlerForOnBeforeUnload = 19,
390
- FailedToSendQueuedTelemetry = 20,
391
- FailedToReportDataLoss = 21,
392
- FlushFailed = 22,
393
- MessageLimitPerPVExceeded = 23,
394
- MissingRequiredFieldSpecification = 24,
395
- NavigationTimingNotSupported = 25,
396
- OnError = 26,
397
- SessionRenewalDateIsZero = 27,
398
- SenderNotInitialized = 28,
399
- StartTrackEventFailed = 29,
400
- StopTrackEventFailed = 30,
401
- StartTrackFailed = 31,
402
- StopTrackFailed = 32,
403
- TelemetrySampledAndNotSent = 33,
404
- TrackEventFailed = 34,
405
- TrackExceptionFailed = 35,
406
- TrackMetricFailed = 36,
407
- TrackPVFailed = 37,
408
- TrackPVFailedCalc = 38,
409
- TrackTraceFailed = 39,
410
- TransmissionFailed = 40,
411
- FailedToSetStorageBuffer = 41,
412
- FailedToRestoreStorageBuffer = 42,
413
- InvalidBackendResponse = 43,
414
- FailedToFixDepricatedValues = 44,
415
- InvalidDurationValue = 45,
416
- TelemetryEnvelopeInvalid = 46,
417
- CreateEnvelopeError = 47,
418
- CannotSerializeObject = 48,
419
- CannotSerializeObjectNonSerializable = 49,
420
- CircularReferenceDetected = 50,
421
- ClearAuthContextFailed = 51,
422
- ExceptionTruncated = 52,
423
- IllegalCharsInName = 53,
424
- ItemNotInArray = 54,
425
- MaxAjaxPerPVExceeded = 55,
426
- MessageTruncated = 56,
427
- NameTooLong = 57,
428
- SampleRateOutOfRange = 58,
429
- SetAuthContextFailed = 59,
430
- SetAuthContextFailedAccountName = 60,
431
- StringValueTooLong = 61,
432
- StartCalledMoreThanOnce = 62,
433
- StopCalledWithoutStart = 63,
434
- TelemetryInitializerFailed = 64,
435
- TrackArgumentsNotSpecified = 65,
436
- UrlTooLong = 66,
437
- SessionStorageBufferFull = 67,
438
- CannotAccessCookie = 68,
439
- IdTooLong = 69,
440
- InvalidEvent = 70,
441
- FailedMonitorAjaxSetRequestHeader = 71,
442
- SendBrowserInfoOnUserInit = 72,
443
- PluginException = 73,
444
- NotificationException = 74,
445
- SnippetScriptLoadFailure = 99,
446
- InvalidInstrumentationKey = 100,
447
- CannotParseAiBlobValue = 101,
448
- InvalidContentBlob = 102,
449
- TrackPageActionEventFailed = 103,
450
- FailedAddingCustomDefinedRequestContext = 104,
451
- InMemoryStorageBufferFull = 105,
452
- InstrumentationKeyDeprecation = 106,
453
- ConfigWatcherException = 107,
454
- DynamicConfigException = 108
455
- }
124
+ export { IDependencyTelemetry }
456
125
 
457
- const enum eLoggingSeverity {
458
- /**
459
- * No Logging will be enabled
460
- */
461
- DISABLED = 0,
462
- /**
463
- * Error will be sent as internal telemetry
464
- */
465
- CRITICAL = 1,
466
- /**
467
- * Error will NOT be sent as internal telemetry, and will only be shown in browser console
468
- */
469
- WARNING = 2
470
- }
126
+ export { IEventTelemetry }
471
127
 
472
- type EnumValue<E = any> = EnumCls<E>;
128
+ export { ILoadedPlugin }
473
129
 
474
- /**
475
- * Defines the level of severity for the event.
476
- */
477
- const enum eSeverityLevel {
478
- Verbose = 0,
479
- Information = 1,
480
- Warning = 2,
481
- Error = 3,
482
- Critical = 4
483
- }
130
+ export { IMetricTelemetry }
484
131
 
485
- interface IAppInsightsCore<CfgType extends IConfiguration = IConfiguration> extends IPerfManagerProvider {
486
- readonly config: CfgType;
487
- /**
488
- * The current logger instance for this instance.
489
- */
490
- readonly logger: IDiagnosticLogger;
491
- /**
492
- * An array of the installed plugins that provide a version
493
- */
494
- readonly pluginVersionStringArr: string[];
495
- /**
496
- * The formatted string of the installed plugins that contain a version number
497
- */
498
- readonly pluginVersionString: string;
499
- /**
500
- * Returns a value that indicates whether the instance has already been previously initialized.
501
- */
502
- isInitialized?: () => boolean;
503
- initialize(config: CfgType, extensions: IPlugin[], logger?: IDiagnosticLogger, notificationManager?: INotificationManager): void;
504
- getChannels(): IChannelControls[];
505
- track(telemetryItem: ITelemetryItem): void;
506
- /**
507
- * Get the current notification manager
508
- */
509
- getNotifyMgr(): INotificationManager;
510
- /**
511
- * Get the current cookie manager for this instance
512
- */
513
- getCookieMgr(): ICookieMgr;
514
- /**
515
- * Set the current cookie manager for this instance
516
- * @param cookieMgr - The manager, if set to null/undefined will cause the default to be created
517
- */
518
- setCookieMgr(cookieMgr: ICookieMgr): void;
519
- /**
520
- * Adds a notification listener. The SDK calls methods on the listener when an appropriate notification is raised.
521
- * The added plugins must raise notifications. If the plugins do not implement the notifications, then no methods will be
522
- * called.
523
- * @param listener - An INotificationListener object.
524
- */
525
- addNotificationListener?(listener: INotificationListener): void;
526
- /**
527
- * Removes all instances of the listener.
528
- * @param listener - INotificationListener to remove.
529
- */
530
- removeNotificationListener?(listener: INotificationListener): void;
531
- /**
532
- * Add a telemetry processor to decorate or drop telemetry events.
533
- * @param telemetryInitializer - The Telemetry Initializer function
534
- * @returns - A ITelemetryInitializerHandler to enable the initializer to be removed
535
- */
536
- addTelemetryInitializer(telemetryInitializer: TelemetryInitializerFunction): ITelemetryInitializerHandler;
537
- pollInternalLogs?(eventName?: string): ITimerHandler;
538
- stopPollingInternalLogs?(): void;
539
- /**
540
- * Return a new instance of the IProcessTelemetryContext for processing events
541
- */
542
- getProcessTelContext(): IProcessTelemetryContext;
543
- /**
544
- * Unload and Tear down the SDK and any initialized plugins, after calling this the SDK will be considered
545
- * to be un-initialized and non-operational, re-initializing the SDK should only be attempted if the previous
546
- * unload call return `true` stating that all plugins reported that they also unloaded, the recommended
547
- * approach is to create a new instance and initialize that instance.
548
- * This is due to possible unexpected side effects caused by plugins not supporting unload / teardown, unable
549
- * to successfully remove any global references or they may just be completing the unload process asynchronously.
550
- * @param isAsync - Can the unload be performed asynchronously (default)
551
- * @param unloadComplete - An optional callback that will be called once the unload has completed
552
- * @param cbTimeout - An optional timeout to wait for any flush operations to complete before proceeding with the unload. Defaults to 5 seconds.
553
- */
554
- unload(isAsync?: boolean, unloadComplete?: (unloadState: ITelemetryUnloadState) => void, cbTimeout?: number): void;
555
- /**
556
- * Find and return the (first) plugin with the specified identifier if present
557
- * @param pluginIdentifier
558
- */
559
- getPlugin<T extends IPlugin = IPlugin>(pluginIdentifier: string): ILoadedPlugin<T>;
560
- /**
561
- * Add a new plugin to the installation
562
- * @param plugin - The new plugin to add
563
- * @param replaceExisting - should any existing plugin be replaced, default is false
564
- * @param doAsync - Should the add be performed asynchronously
565
- * @param addCb - [Optional] callback to call after the plugin has been added
566
- */
567
- addPlugin<T extends IPlugin = ITelemetryPlugin>(plugin: T, replaceExisting?: boolean, doAsync?: boolean, addCb?: (added?: boolean) => void): void;
568
- /**
569
- * Update the configuration used and broadcast the changes to all loaded plugins, this does NOT support updating, adding or removing
570
- * any the plugins (extensions or channels). It will notify each plugin (if supported) that the configuration has changed but it will
571
- * not remove or add any new plugins, you need to call addPlugin or getPlugin(identifier).remove();
572
- * @param newConfig - The new configuration is apply
573
- * @param mergeExisting - Should the new configuration merge with the existing or just replace it. Default is to merge.
574
- */
575
- updateCfg(newConfig: CfgType, mergeExisting?: boolean): void;
576
- /**
577
- * Returns the unique event namespace that should be used when registering events
578
- */
579
- evtNamespace(): string;
580
- /**
581
- * Add a handler that will be called when the SDK is being unloaded
582
- * @param handler - the handler
583
- */
584
- addUnloadCb(handler: UnloadHandler): void;
585
- /**
586
- * Add this hook so that it is automatically removed during unloading
587
- * @param hooks - The single hook or an array of IInstrumentHook objects
588
- */
589
- addUnloadHook(hooks: IUnloadHook | IUnloadHook[] | Iterator<IUnloadHook> | ILegacyUnloadHook | ILegacyUnloadHook[] | Iterator<ILegacyUnloadHook>): void;
590
- /**
591
- * Flush and send any batched / cached data immediately
592
- * @param async - send data asynchronously when true (defaults to true)
593
- * @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.
594
- * If the caller doesn't return true the caller should assume that it may never be called.
595
- * @param sendReason - specify the reason that you are calling "flush" defaults to ManualFlush (1) if not specified
596
- * @param cbTimeout - An optional timeout to wait for any flush operations to complete before proceeding with the unload. Defaults to 5 seconds.
597
- * @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
598
- */
599
- flush(isAsync?: boolean, callBack?: (flushComplete?: boolean) => void, sendReason?: SendRequestReason, cbTimeout?: number): boolean | void;
600
- /**
601
- * Gets the current distributed trace context for this instance if available
602
- * @param createNew - Optional flag to create a new instance if one doesn't currently exist, defaults to true
603
- */
604
- getTraceCtx(createNew?: boolean): IDistributedTraceContext | null;
605
- /**
606
- * Sets the current distributed trace context for this instance if available
607
- */
608
- setTraceCtx(newTraceCtx: IDistributedTraceContext | null | undefined): void;
609
- /**
610
- * Watches and tracks changes for accesses to the current config, and if the accessed config changes the
611
- * handler will be recalled.
612
- * @param handler
613
- * @returns A watcher handler instance that can be used to remove itself when being unloaded
614
- */
615
- onCfgChange(handler: WatcherFunction<CfgType>): IUnloadHook;
616
- /**
617
- * Function used to identify the get w parameter used to identify status bit to some channels
618
- */
619
- getWParam: () => number;
620
- }
132
+ export { IPageViewPerformanceTelemetry }
621
133
 
622
- /**
623
- * @description window.onerror function parameters
624
- * @export
625
- * @interface IAutoExceptionTelemetry
626
- */
627
- interface IAutoExceptionTelemetry {
628
- /**
629
- * @description error message. Available as event in HTML onerror="" handler
630
- * @type {string}
631
- * @memberof IAutoExceptionTelemetry
632
- */
633
- message: string;
634
- /**
635
- * @description URL of the script where the error was raised
636
- * @type {string}
637
- * @memberof IAutoExceptionTelemetry
638
- */
639
- url: string;
640
- /**
641
- * @description Line number where error was raised
642
- * @type {number}
643
- * @memberof IAutoExceptionTelemetry
644
- */
645
- lineNumber: number;
646
- /**
647
- * @description Column number for the line where the error occurred
648
- * @type {number}
649
- * @memberof IAutoExceptionTelemetry
650
- */
651
- columnNumber: number;
652
- /**
653
- * @description Error Object (object)
654
- * @type {any}
655
- * @memberof IAutoExceptionTelemetry
656
- */
657
- error: any;
658
- /**
659
- * @description The event at the time of the exception (object)
660
- * @type {Event|string}
661
- * @memberof IAutoExceptionTelemetry
662
- */
663
- evt?: Event | string;
664
- /**
665
- * @description The provided stack for the error
666
- * @type {IStackDetails}
667
- * @memberof IAutoExceptionTelemetry
668
- */
669
- stackDetails?: IStackDetails;
670
- /**
671
- * @description The calculated type of the error
672
- * @type {string}
673
- * @memberof IAutoExceptionTelemetry
674
- */
675
- typeName?: string;
676
- /**
677
- * @description The descriptive source of the error
678
- * @type {string}
679
- * @memberof IAutoExceptionTelemetry
680
- */
681
- errorSrc?: string;
682
- }
134
+ export { IPageViewTelemetry }
683
135
 
684
- interface IBackendResponse {
685
- /**
686
- * Number of items received by the backend
687
- */
688
- readonly itemsReceived: number;
689
- /**
690
- * Number of items succesfuly accepted by the backend
691
- */
692
- readonly itemsAccepted: number;
693
- /**
694
- * List of errors for items which were not accepted
695
- */
696
- readonly errors: IResponseError[];
697
- /**
698
- * App id returned by the backend - not necessary returned, but we don't need it with each response.
699
- */
700
- readonly appId?: string;
701
- }
136
+ export { IPlugin }
702
137
 
703
- interface IBaseProcessingContext {
704
- /**
705
- * The current core instance for the request
706
- */
707
- core: () => IAppInsightsCore;
708
- /**
709
- * THe current diagnostic logger for the request
710
- */
711
- diagLog: () => IDiagnosticLogger;
712
- /**
713
- * Gets the current core config instance
714
- */
715
- getCfg: () => IConfiguration;
716
- /**
717
- * Gets the named extension config
718
- */
719
- getExtCfg: <T>(identifier: string, defaultValue?: IConfigDefaults<T>) => T;
720
- /**
721
- * Gets the named config from either the named identifier extension or core config if neither exist then the
722
- * default value is returned
723
- * @param identifier - The named extension identifier
724
- * @param field - The config field name
725
- * @param defaultValue - The default value to return if no defined config exists
726
- */
727
- getConfig: (identifier: string, field: string, defaultValue?: number | string | boolean | string[] | RegExp[] | Function) => number | string | boolean | string[] | RegExp[] | Function;
728
- /**
729
- * Helper to allow plugins to check and possibly shortcut executing code only
730
- * required if there is a nextPlugin
731
- */
732
- hasNext: () => boolean;
733
- /**
734
- * Returns the next configured plugin proxy
735
- */
736
- getNext: () => ITelemetryPluginChain;
737
- /**
738
- * Helper to set the next plugin proxy
739
- */
740
- setNext: (nextCtx: ITelemetryPluginChain) => void;
741
- /**
742
- * Synchronously iterate over the context chain running the callback for each plugin, once
743
- * every plugin has been executed via the callback, any associated onComplete will be called.
744
- * @param callback - The function call for each plugin in the context chain
745
- */
746
- iterate: <T extends ITelemetryPlugin = ITelemetryPlugin>(callback: (plugin: T) => void) => void;
747
- /**
748
- * Set the function to call when the current chain has executed all processNext or unloadNext items.
749
- * @param onComplete - The onComplete to call
750
- * @param that - The "this" value to use for the onComplete call, if not provided or undefined defaults to the current context
751
- * @param args - Any additional arguments to pass to the onComplete function
752
- */
753
- onComplete: (onComplete: () => void, that?: any, ...args: any[]) => void;
754
- /**
755
- * Create a new context using the core and config from the current instance, returns a new instance of the same type
756
- * @param plugins - The execution order to process the plugins, if null or not supplied
757
- * then the current execution order will be copied.
758
- * @param startAt - The plugin to start processing from, if missing from the execution
759
- * order then the next plugin will be NOT set.
760
- */
761
- createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IBaseProcessingContext;
762
- }
138
+ export { isNullOrUndefined }
763
139
 
764
- /**
765
- * Provides data transmission capabilities
766
- */
767
- interface IChannelControls extends ITelemetryPlugin {
768
- /**
769
- * Pause sending data
770
- */
771
- pause?(): void;
772
- /**
773
- * Resume sending data
774
- */
775
- resume?(): void;
776
- /**
777
- * Tear down the plugin and remove any hooked value, the plugin should be removed so that it is no longer initialized and
778
- * therefore could be re-initialized after being torn down. The plugin should ensure that once this has been called any further
779
- * processTelemetry calls are ignored and it just calls the processNext() with the provided context.
780
- * @param unloadCtx - This is the context that should be used during unloading.
781
- * @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.
782
- * @returns boolean - true if the plugin has or will call processNext(), this for backward compatibility as previously teardown was synchronous and returned nothing.
783
- */
784
- teardown?: (unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState) => void | boolean;
785
- /**
786
- * Flush to send data immediately; channel should default to sending data asynchronously
787
- * @param async - send data asynchronously when true
788
- * @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.
789
- * If the caller doesn't return true the caller should assume that it may never be called.
790
- * @param sendReason - specify the reason that you are calling "flush" defaults to ManualFlush (1) if not specified
791
- * @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
792
- */
793
- flush?(async: boolean, callBack?: (flushComplete?: boolean) => void, sendReason?: SendRequestReason): boolean | void;
794
- }
140
+ export { ITelemetryItem }
795
141
 
796
- /**
797
- * Configuration settings for how telemetry is sent
798
- * @export
799
- * @interface IConfig
800
- */
801
- interface IConfig {
802
- /**
803
- * The JSON format (normal vs line delimited). True means line delimited JSON.
804
- */
805
- emitLineDelimitedJson?: boolean;
806
- /**
807
- * An optional account id, if your app groups users into accounts. No spaces, commas, semicolons, equals, or vertical bars.
808
- */
809
- accountId?: string;
810
- /**
811
- * A session is logged if the user is inactive for this amount of time in milliseconds. Default 30 mins.
812
- * @default 30*60*1000
813
- */
814
- sessionRenewalMs?: number;
815
- /**
816
- * A session is logged if it has continued for this amount of time in milliseconds. Default 24h.
817
- * @default 24*60*60*1000
818
- */
819
- sessionExpirationMs?: number;
820
- /**
821
- * Max size of telemetry batch. If batch exceeds limit, it is sent and a new batch is started
822
- * @default 100000
823
- */
824
- maxBatchSizeInBytes?: number;
825
- /**
826
- * How long to batch telemetry for before sending (milliseconds)
827
- * @default 15 seconds
828
- */
829
- maxBatchInterval?: number;
830
- /**
831
- * If true, debugging data is thrown as an exception by the logger. Default false
832
- * @defaultValue false
833
- */
834
- enableDebug?: boolean;
835
- /**
836
- * If true, exceptions are not autocollected. Default is false
837
- * @defaultValue false
838
- */
839
- disableExceptionTracking?: boolean;
840
- /**
841
- * If true, telemetry is not collected or sent. Default is false
842
- * @defaultValue false
843
- */
844
- disableTelemetry?: boolean;
845
- /**
846
- * Percentage of events that will be sent. Default is 100, meaning all events are sent.
847
- * @defaultValue 100
848
- */
849
- samplingPercentage?: number;
850
- /**
851
- * 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.
852
- */
853
- autoTrackPageVisitTime?: boolean;
854
- /**
855
- * Automatically track route changes in Single Page Applications (SPA). If true, each route change will send a new Pageview to Application Insights.
856
- */
857
- enableAutoRouteTracking?: boolean;
858
- /**
859
- * If true, Ajax calls are not autocollected. Default is false
860
- * @defaultValue false
861
- */
862
- disableAjaxTracking?: boolean;
863
- /**
864
- * If true, Fetch requests are not autocollected. Default is false (Since 2.8.0, previously true).
865
- * @defaultValue false
866
- */
867
- disableFetchTracking?: boolean;
868
- /**
869
- * 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.
870
- * @defaultValue undefined.
871
- */
872
- excludeRequestFromAutoTrackingPatterns?: string[] | RegExp[];
873
- /**
874
- * Provide a way to enrich dependencies logs with context at the beginning of api call.
875
- * Default is undefined.
876
- */
877
- addRequestContext?: (requestContext?: IRequestContext) => ICustomProperties;
878
- /**
879
- * 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
880
- * @defaultValue false
881
- */
882
- overridePageViewDuration?: boolean;
883
- /**
884
- * 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.
885
- */
886
- maxAjaxCallsPerView?: number;
887
- /**
888
- * @ignore
889
- * If false, internal telemetry sender buffers will be checked at startup for items not yet sent. Default is true
890
- * @defaultValue true
891
- */
892
- disableDataLossAnalysis?: boolean;
893
- /**
894
- * 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.
895
- * @defaultValue false
896
- */
897
- disableCorrelationHeaders?: boolean;
898
- /**
899
- * 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.
900
- * AI_AND_W3C is provided for back-compatibility with any legacy Application Insights instrumented services
901
- * @defaultValue AI_AND_W3C
902
- */
903
- distributedTracingMode?: DistributedTracingModes;
904
- /**
905
- * Disable correlation headers for specific domain
906
- */
907
- correlationHeaderExcludedDomains?: string[];
908
- /**
909
- * Default false. If true, flush method will not be called when onBeforeUnload, onUnload, onPageHide or onVisibilityChange (hidden state) event(s) trigger.
910
- */
911
- disableFlushOnBeforeUnload?: boolean;
912
- /**
913
- * Default value of {@link #disableFlushOnBeforeUnload}. If true, flush method will not be called when onPageHide or onVisibilityChange (hidden state) event(s) trigger.
914
- */
915
- disableFlushOnUnload?: boolean;
916
- /**
917
- * [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
918
- * 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.
919
- * (Some page unload functionality may be disabled via disableFlushOnBeforeUnload or disableFlushOnUnload config entries)
920
- * Unload events include "beforeunload", "unload", "visibilitychange" (with 'hidden' state) and "pagehide"
921
- */
922
- disablePageUnloadEvents?: string[];
923
- /**
924
- * [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
925
- * 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.
926
- * Page Show events include "pageshow" and "visibilitychange" (with 'visible' state)
927
- */
928
- disablePageShowEvents?: string[];
929
- /**
930
- * If true, the buffer with all unsent telemetry is stored in session storage. The buffer is restored on page load. Default is true.
931
- * @defaultValue true
932
- */
933
- enableSessionStorageBuffer?: boolean;
934
- /**
935
- * If specified, overrides the storage & retrieval mechanism that is used to manage unsent telemetry.
936
- */
937
- bufferOverride?: IStorageBuffer;
938
- /**
939
- * @deprecated Use either disableCookiesUsage or specify a cookieCfg with the enabled value set.
940
- * If true, the SDK will not store or read any data from cookies. Default is false. As this field is being deprecated, when both
941
- * isCookieUseDisabled and disableCookiesUsage are used disableCookiesUsage will take precedent.
942
- * @defaultValue false
943
- */
944
- isCookieUseDisabled?: boolean;
945
- /**
946
- * If true, the SDK will not store or read any data from cookies. Default is false.
947
- * If you have also specified a cookieCfg then enabled property (if specified) will take precedent over this value.
948
- * @defaultValue false
949
- */
950
- disableCookiesUsage?: boolean;
951
- /**
952
- * Custom cookie domain. This is helpful if you want to share Application Insights cookies across subdomains.
953
- * @defaultValue ""
954
- */
955
- cookieDomain?: string;
956
- /**
957
- * Custom cookie path. This is helpful if you want to share Application Insights cookies behind an application gateway.
958
- * @defaultValue ""
959
- */
960
- cookiePath?: string;
961
- /**
962
- * 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)
963
- * @description
964
- * @defaultValue false
965
- */
966
- isRetryDisabled?: boolean;
967
- /**
968
- * @deprecated Used when initizialing from snippet only.
969
- * The url from where the JS SDK will be downloaded.
970
- */
971
- url?: string;
972
- /**
973
- * If true, the SDK will not store or read any data from local and session storage. Default is false.
974
- * @defaultValue false
975
- */
976
- isStorageUseDisabled?: boolean;
977
- /**
978
- * If false, the SDK will send all telemetry using the [Beacon API](https://www.w3.org/TR/beacon)
979
- * @defaultValue true
980
- */
981
- isBeaconApiDisabled?: boolean;
982
- /**
983
- * Don't use XMLHttpRequest or XDomainRequest (for IE < 9) by default instead attempt to use fetch() or sendBeacon.
984
- * If no other transport is available it will still use XMLHttpRequest
985
- */
986
- disableXhr?: boolean;
987
- /**
988
- * If fetch keepalive is supported do not use it for sending events during unload, it may still fallback to fetch() without keepalive
989
- */
990
- onunloadDisableFetch?: boolean;
991
- /**
992
- * 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.
993
- * @defaultValue null
994
- */
995
- sdkExtension?: string;
996
- /**
997
- * 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.
998
- * @defaultValue false
999
- */
1000
- isBrowserLinkTrackingEnabled?: boolean;
1001
- /**
1002
- * 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
1003
- * @defaultValue null
1004
- */
1005
- appId?: string;
1006
- /**
1007
- * 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
1008
- * @defaultValue false
1009
- */
1010
- enableCorsCorrelation?: boolean;
1011
- /**
1012
- * An optional value that will be used as name postfix for localStorage and session cookie name.
1013
- * @defaultValue null
1014
- */
1015
- namePrefix?: string;
1016
- /**
1017
- * 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.
1018
- * @defaultValue null
1019
- */
1020
- sessionCookiePostfix?: string;
1021
- /**
1022
- * An optional value that will be used as name postfix for user cookie name. If undefined, no postfix is added on user cookie name.
1023
- * @defaultValue null
1024
- */
1025
- userCookiePostfix?: string;
1026
- /**
1027
- * An optional value that will track Request Header through trackDependency function.
1028
- * @defaultValue false
1029
- */
1030
- enableRequestHeaderTracking?: boolean;
1031
- /**
1032
- * An optional value that will track Response Header through trackDependency function.
1033
- * @defaultValue false
1034
- */
1035
- enableResponseHeaderTracking?: boolean;
1036
- /**
1037
- * An optional value that will track Response Error data through trackDependency function.
1038
- * @defaultValue false
1039
- */
1040
- enableAjaxErrorStatusText?: boolean;
1041
- /**
1042
- * Flag to enable looking up and including additional browser window.performance timings
1043
- * in the reported ajax (XHR and fetch) reported metrics.
1044
- * Defaults to false.
1045
- */
1046
- enableAjaxPerfTracking?: boolean;
1047
- /**
1048
- * The maximum number of times to look for the window.performance timings (if available), this
1049
- * is required as not all browsers populate the window.performance before reporting the
1050
- * end of the XHR request and for fetch requests this is added after its complete
1051
- * Defaults to 3
1052
- */
1053
- maxAjaxPerfLookupAttempts?: number;
1054
- /**
1055
- * The amount of time to wait before re-attempting to find the windows.performance timings
1056
- * for an ajax request, time is in milliseconds and is passed directly to setTimeout()
1057
- * Defaults to 25.
1058
- */
1059
- ajaxPerfLookupDelay?: number;
1060
- /**
1061
- * Default false. when tab is closed, the SDK will send all remaining telemetry using the [Beacon API](https://www.w3.org/TR/beacon)
1062
- * @defaultValue false
1063
- */
1064
- onunloadDisableBeacon?: boolean;
1065
- /**
1066
- * @ignore
1067
- * Internal only
1068
- */
1069
- autoExceptionInstrumented?: boolean;
1070
- /**
1071
- *
1072
- */
1073
- correlationHeaderDomains?: string[];
1074
- /**
1075
- * @ignore
1076
- * Internal only
1077
- */
1078
- autoUnhandledPromiseInstrumented?: boolean;
1079
- /**
1080
- * Default false. Define whether to track unhandled promise rejections and report as JS errors.
1081
- * When disableExceptionTracking is enabled (dont track exceptions) this value will be false.
1082
- * @defaultValue false
1083
- */
1084
- enableUnhandledPromiseRejectionTracking?: boolean;
1085
- /**
1086
- * Disable correlation headers using regular expressions
1087
- */
1088
- correlationHeaderExcludePatterns?: RegExp[];
1089
- /**
1090
- * The ability for the user to provide extra headers
1091
- */
1092
- customHeaders?: [{
1093
- header: string;
1094
- value: string;
1095
- }];
1096
- /**
1097
- * Provide user an option to convert undefined field to user defined value.
1098
- */
1099
- convertUndefined?: any;
1100
- /**
1101
- * [Optional] The number of events that can be kept in memory before the SDK starts to drop events. By default, this is 10,000.
1102
- */
1103
- eventsLimitInMem?: number;
1104
- /**
1105
- * [Optional] Disable iKey deprecation error message.
1106
- * @defaultValue true
1107
- */
1108
- disableIkeyDeprecationMessage?: boolean;
1109
- /**
1110
- * [Optional] Flag to indicate whether the internal looking endpoints should be automatically
1111
- * added to the `excludeRequestFromAutoTrackingPatterns` collection. (defaults to true).
1112
- * This flag exists as the provided regex is generic and may unexpectedly match a domain that
1113
- * should not be excluded.
1114
- */
1115
- addIntEndpoints?: boolean;
1116
- }
1117
-
1118
- /**
1119
- * The type to identify whether the default value should be applied in preference to the provided value.
1120
- */
1121
- type IConfigCheckFn<V> = (value: V) => boolean;
1122
-
1123
- /**
1124
- * The default values with a check function
1125
- */
1126
- interface IConfigDefaultCheck<T, V, C = IConfiguration> {
1127
- /**
1128
- * Callback function to check if the user-supplied value is valid, if not the default will be applied
1129
- */
1130
- isVal?: IConfigCheckFn<V>;
1131
- /**
1132
- * Optional function to allow converting and setting of the default value
1133
- */
1134
- set?: IConfigSetFn<T, V>;
1135
- /**
1136
- * The default value to apply if the user-supplied value is not valid
1137
- */
1138
- v?: V | IConfigDefaults<V, T>;
1139
- /**
1140
- * The default fallback key if the main key is not present, this is the key value from the config
1141
- */
1142
- fb?: keyof T | keyof C | Array<keyof T | keyof C>;
1143
- /**
1144
- * Use this check to determine the default fallback, default only checked whether the property isDefined,
1145
- * therefore `null`; `""` are considered to be valid values.
1146
- */
1147
- dfVal?: (value: any) => boolean;
1148
- /**
1149
- * Specify that any provided value should have the default value(s) merged into the value rather than
1150
- * just using either the default of user provided values. Mergeed objects will automatically be marked
1151
- * as referenced.
1152
- */
1153
- mrg?: boolean;
1154
- /**
1155
- * Set this field of the target as referenced, which will cause any object or array instance
1156
- * to be updated in-place rather than being entirely replaced. All other values will continue to be replaced.
1157
- * This is required for nested default objects to avoid multiple repetitive updates to listeners
1158
- * @returns The referenced properties current value
1159
- */
1160
- ref?: boolean;
1161
- /**
1162
- * Set this field of the target as read-only, which will block this single named property from
1163
- * ever being changed for the target instance.
1164
- * This does NOT freeze or seal the instance, it just stops the direct re-assignment of the named property,
1165
- * if the value is a non-primitive (ie. an object or array) it's properties will still be mutable.
1166
- * @returns The referenced properties current value
1167
- */
1168
- rdOnly?: boolean;
1169
- }
1170
-
1171
- /**
1172
- * The Type definition to define default values to be applied to the config
1173
- * The value may be either the direct value or a ConfigDefaultCheck definition
1174
- */
1175
- type IConfigDefaults<T, C = IConfiguration> = {
1176
- [key in keyof T]: T[key] | IConfigDefaultCheck<T, T[key], C>;
1177
- };
1178
-
1179
- /**
1180
- * The type which identifies the function use to validate the user supplied value
1181
- */
1182
- type IConfigSetFn<T, V> = (value: any, defValue: V, theConfig: T) => V;
1183
-
1184
- /**
1185
- * Configuration provided to SDK core
1186
- */
1187
- interface IConfiguration {
1188
- /**
1189
- * Instrumentation key of resource. Either this or connectionString must be specified.
1190
- */
1191
- instrumentationKey?: string;
1192
- /**
1193
- * Connection string of resource. Either this or instrumentationKey must be specified.
1194
- */
1195
- connectionString?: string;
1196
- /**
1197
- * Set the timer interval (in ms) for internal logging queue, this is the
1198
- * amount of time to wait after logger.queue messages are detected to be sent.
1199
- * Note: since 3.0.1 and 2.8.13 the diagnostic logger timer is a normal timeout timer
1200
- * and not an interval timer. So this now represents the timer "delay" and not
1201
- * the frequency at which the events are sent.
1202
- */
1203
- diagnosticLogInterval?: number;
1204
- /**
1205
- * Maximum number of iKey transmitted logging telemetry per page view
1206
- */
1207
- maxMessageLimit?: number;
1208
- /**
1209
- * Console logging level. All logs with a severity level higher
1210
- * than the configured level will be printed to console. Otherwise
1211
- * they are suppressed. ie Level 2 will print both CRITICAL and
1212
- * WARNING logs to console, level 1 prints only CRITICAL.
1213
- *
1214
- * Note: Logs sent as telemetry to instrumentation key will also
1215
- * be logged to console if their severity meets the configured loggingConsoleLevel
1216
- *
1217
- * 0: ALL console logging off
1218
- * 1: logs to console: severity >= CRITICAL
1219
- * 2: logs to console: severity >= WARNING
1220
- */
1221
- loggingLevelConsole?: number;
1222
- /**
1223
- * Telemtry logging level to instrumentation key. All logs with a severity
1224
- * level higher than the configured level will sent as telemetry data to
1225
- * the configured instrumentation key.
1226
- *
1227
- * 0: ALL iKey logging off
1228
- * 1: logs to iKey: severity >= CRITICAL
1229
- * 2: logs to iKey: severity >= WARNING
1230
- */
1231
- loggingLevelTelemetry?: number;
1232
- /**
1233
- * If enabled, uncaught exceptions will be thrown to help with debugging
1234
- */
1235
- enableDebug?: boolean;
1236
- /**
1237
- * Endpoint where telemetry data is sent
1238
- */
1239
- endpointUrl?: string;
1240
- /**
1241
- * Extension configs loaded in SDK
1242
- */
1243
- extensionConfig?: {
1244
- [key: string]: any;
1245
- };
1246
- /**
1247
- * Additional plugins that should be loaded by core at runtime
1248
- */
1249
- readonly extensions?: ITelemetryPlugin[];
1250
- /**
1251
- * Channel queues that is setup by caller in desired order.
1252
- * If channels are provided here, core will ignore any channels that are already setup, example if there is a SKU with an initialized channel
1253
- */
1254
- readonly channels?: IChannelControls[][];
1255
- /**
1256
- * @type {boolean}
1257
- * Flag that disables the Instrumentation Key validation.
1258
- */
1259
- disableInstrumentationKeyValidation?: boolean;
1260
- /**
1261
- * [Optional] When enabled this will create local perfEvents based on sections of the code that have been instrumented
1262
- * to emit perfEvents (via the doPerf()) when this is enabled. This can be used to identify performance issues within
1263
- * the SDK, the way you are using it or optionally your own instrumented code.
1264
- * The provided IPerfManager implementation does NOT send any additional telemetry events to the server it will only fire
1265
- * the new perfEvent() on the INotificationManager which you can listen to.
1266
- * This also does not use the window.performance API, so it will work in environments where this API is not supported.
1267
- */
1268
- enablePerfMgr?: boolean;
1269
- /**
1270
- * [Optional] Callback function that will be called to create a the IPerfManager instance when required and ```enablePerfMgr```
1271
- * is enabled, this enables you to override the default creation of a PerfManager() without needing to ```setPerfMgr()```
1272
- * after initialization.
1273
- */
1274
- createPerfMgr?: (core: IAppInsightsCore, notificationManager: INotificationManager) => IPerfManager;
1275
- /**
1276
- * [Optional] Fire every single performance event not just the top level root performance event. Defaults to false.
1277
- */
1278
- perfEvtsSendAll?: boolean;
1279
- /**
1280
- * [Optional] Identifies the default length used to generate random session and user id's if non currently exists for the user / session.
1281
- * Defaults to 22, previous default value was 5, if you need to keep the previous maximum length you should set this value to 5.
1282
- */
1283
- idLength?: number;
1284
- /**
1285
- * @description Custom cookie domain. This is helpful if you want to share Application Insights cookies across subdomains. It
1286
- * can be set here or as part of the cookieCfg.domain, the cookieCfg takes precedence if both are specified.
1287
- * @type {string}
1288
- * @defaultValue ""
1289
- */
1290
- cookieDomain?: string;
1291
- /**
1292
- * @description Custom cookie path. This is helpful if you want to share Application Insights cookies behind an application
1293
- * gateway. It can be set here or as part of the cookieCfg.domain, the cookieCfg takes precedence if both are specified.
1294
- * @type {string}
1295
- * @defaultValue ""
1296
- */
1297
- cookiePath?: string;
1298
- /**
1299
- * [Optional] A boolean that indicated whether to disable the use of cookies by the SDK. If true, the SDK will not store or
1300
- * read any data from cookies. Cookie usage can be re-enabled after initialization via the core.getCookieMgr().enable().
1301
- */
1302
- disableCookiesUsage?: boolean;
1303
- /**
1304
- * [Optional] A Cookie Manager configuration which includes hooks to allow interception of the get, set and delete cookie
1305
- * operations. If this configuration is specified any specified enabled and domain properties will take precedence over the
1306
- * cookieDomain and disableCookiesUsage values.
1307
- */
1308
- cookieCfg?: ICookieMgrConfig;
1309
- /**
1310
- * [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
1311
- * 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.
1312
- * Unload events include "beforeunload", "unload", "visibilitychange" (with 'hidden' state) and "pagehide"
1313
- */
1314
- disablePageUnloadEvents?: string[];
1315
- /**
1316
- * [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
1317
- * 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.
1318
- * Page Show events include "pageshow" and "visibilitychange" (with 'visible' state)
1319
- */
1320
- disablePageShowEvents?: string[];
1321
- /**
1322
- * [Optional] A flag for performance optimization to disable attempting to use the Chrome Debug Extension, if disabled and the extension is installed
1323
- * this will not send any notifications.
1324
- */
1325
- disableDbgExt?: boolean;
1326
- /**
1327
- * Add "&w=0" parameter to support UA Parsing when web-workers don't have access to Document.
1328
- * Default is false
1329
- */
1330
- enableWParam?: boolean;
1331
- }
1332
-
1333
- interface ICookieMgr {
1334
- /**
1335
- * Enable or Disable the usage of cookies
1336
- */
1337
- setEnabled(value: boolean): void;
1338
- /**
1339
- * Can the system use cookies, if this returns false then all cookie setting and access functions will return nothing
1340
- */
1341
- isEnabled(): boolean;
1342
- /**
1343
- * Set the named cookie with the value and optional domain and optional
1344
- * @param name - The name of the cookie
1345
- * @param value - The value of the cookie (Must already be encoded)
1346
- * @param maxAgeSec - [optional] The maximum number of SECONDS that this cookie should survive
1347
- * @param domain - [optional] The domain to set for the cookie
1348
- * @param path - [optional] Path to set for the cookie, if not supplied will default to "/"
1349
- * @returns - True if the cookie was set otherwise false (Because cookie usage is not enabled or available)
1350
- */
1351
- set(name: string, value: string, maxAgeSec?: number, domain?: string, path?: string): boolean;
1352
- /**
1353
- * Get the value of the named cookie
1354
- * @param name - The name of the cookie
1355
- */
1356
- get(name: string): string;
1357
- /**
1358
- * Delete/Remove the named cookie if cookie support is available and enabled.
1359
- * Note: Not using "delete" as the name because it's a reserved word which would cause issues on older browsers
1360
- * @param name - The name of the cookie
1361
- * @param path - [optional] Path to set for the cookie, if not supplied will default to "/"
1362
- * @returns - True if the cookie was marked for deletion otherwise false (Because cookie usage is not enabled or available)
1363
- */
1364
- del(name: string, path?: string): boolean;
1365
- /**
1366
- * Purge the cookie from the system if cookie support is available, this function ignores the enabled setting of the manager
1367
- * so any cookie will be removed.
1368
- * Note: Not using "delete" as the name because it's a reserved word which would cause issues on older browsers
1369
- * @param name - The name of the cookie
1370
- * @param path - [optional] Path to set for the cookie, if not supplied will default to "/"
1371
- * @returns - True if the cookie was marked for deletion otherwise false (Because cookie usage is not available)
1372
- */
1373
- purge(name: string, path?: string): boolean;
1374
- /**
1375
- * Optional Callback hook to allow the diagnostic logger to update it's configuration
1376
- * @param updateState
1377
- */
1378
- update?(updateState: ITelemetryUpdateState): void;
1379
- }
1380
-
1381
- /**
1382
- * Configuration definition for instance based cookie management configuration
1383
- */
1384
- interface ICookieMgrConfig {
1385
- /**
1386
- * Defaults to true, A boolean that indicates whether the use of cookies by the SDK is enabled by the current instance.
1387
- * If false, the instance of the SDK initialized by this configuration will not store or read any data from cookies
1388
- */
1389
- enabled?: boolean;
1390
- /**
1391
- * Custom cookie domain. This is helpful if you want to share Application Insights cookies across subdomains.
1392
- */
1393
- domain?: string;
1394
- /**
1395
- * Specifies the path to use for the cookie, defaults to '/'
1396
- */
1397
- path?: string;
1398
- /**
1399
- * Specify the cookie name(s) to be ignored, this will cause any matching cookie name to never be read or written.
1400
- * They may still be explicitly purged or deleted. You do not need to repeat the name in the `blockedCookies`
1401
- * configuration.(Since v2.8.8)
1402
- */
1403
- ignoreCookies?: string[];
1404
- /**
1405
- * Specify the cookie name(s) to never be written, this will cause any cookie name to never be created or updated,
1406
- * they will still be read unless also included in the ignoreCookies and may still be explicitly purged or deleted.
1407
- * If not provided defaults to the same list provided in ignoreCookies. (Since v2.8.8)
1408
- */
1409
- blockedCookies?: string[];
1410
- /**
1411
- * Hook function to fetch the named cookie value.
1412
- * @param name - The name of the cookie
1413
- */
1414
- getCookie?: (name: string) => string;
1415
- /**
1416
- * Hook function to set the named cookie with the specified value.
1417
- * @param name - The name of the cookie
1418
- * @param value - The value to set for the cookie
1419
- */
1420
- setCookie?: (name: string, value: string) => void;
1421
- /**
1422
- * Hook function to delete the named cookie with the specified value, separated from
1423
- * setCookie to avoid the need to parse the value to determine whether the cookie is being
1424
- * added or removed.
1425
- * @param name - The name of the cookie
1426
- * @param cookieValue - The value to set to expire the cookie
1427
- */
1428
- delCookie?: (name: string, cookieValue: string) => void;
1429
- }
1430
-
1431
- interface ICustomProperties {
1432
- [key: string]: any;
1433
- }
1434
-
1435
- /**
1436
- * DependencyTelemetry telemetry interface
1437
- */
1438
- interface IDependencyTelemetry extends IPartC {
1439
- id: string;
1440
- name?: string;
1441
- duration?: number;
1442
- success?: boolean;
1443
- startTime?: Date;
1444
- responseCode: number;
1445
- correlationContext?: string;
1446
- type?: string;
1447
- data?: string;
1448
- target?: string;
1449
- iKey?: string;
1450
- }
1451
-
1452
- interface IDiagnosticLogger {
1453
- /**
1454
- * 0: OFF
1455
- * 1: only critical (default)
1456
- * 2: critical + info
1457
- */
1458
- consoleLoggingLevel: () => number;
1459
- /**
1460
- * The internal logging queue
1461
- */
1462
- queue: _InternalLogMessage[];
1463
- /**
1464
- * This method will throw exceptions in debug mode or attempt to log the error as a console warning.
1465
- * @param severity - The severity of the log message
1466
- * @param message - The log message.
1467
- */
1468
- throwInternal(severity: LoggingSeverity, msgId: _InternalMessageId, msg: string, properties?: Object, isUserAct?: boolean): void;
1469
- /**
1470
- * This will write a warning to the console if possible
1471
- * @param message - The warning message
1472
- */
1473
- warnToConsole(message: string): void;
1474
- /**
1475
- * This will write an error to the console if possible.
1476
- * Provided by the default DiagnosticLogger instance, and internally the SDK will fall back to warnToConsole, however,
1477
- * direct callers MUST check for its existence on the logger as you can provide your own IDiagnosticLogger instance.
1478
- * @param message - The error message
1479
- */
1480
- errorToConsole?(message: string): void;
1481
- /**
1482
- * Resets the internal message count
1483
- */
1484
- resetInternalMessageCount(): void;
1485
- /**
1486
- * Logs a message to the internal queue.
1487
- * @param severity - The severity of the log message
1488
- * @param message - The message to log.
1489
- */
1490
- logInternalMessage?(severity: LoggingSeverity, message: _InternalLogMessage): void;
1491
- /**
1492
- * Optional Callback hook to allow the diagnostic logger to update it's configuration
1493
- * @param updateState
1494
- */
1495
- update?(updateState: ITelemetryUpdateState): void;
1496
- }
1497
-
1498
- interface IDistributedTraceContext {
1499
- /**
1500
- * Returns the current name of the page
1501
- */
1502
- getName(): string;
1503
- /**
1504
- * Sets the current name of the page
1505
- * @param pageName
1506
- */
1507
- setName(pageName: string): void;
1508
- /**
1509
- * Returns the unique identifier for a trace. All requests / spans from the same trace share the same traceId.
1510
- * Must be read from incoming headers or generated according to the W3C TraceContext specification,
1511
- * in a hex representation of 16-byte array. A.k.a. trace-id, TraceID or Distributed TraceID
1512
- */
1513
- getTraceId(): string;
1514
- /**
1515
- * Set the unique identifier for a trace. All requests / spans from the same trace share the same traceId.
1516
- * Must be conform to the W3C TraceContext specification, in a hex representation of 16-byte array.
1517
- * A.k.a. trace-id, TraceID or Distributed TraceID https://www.w3.org/TR/trace-context/#trace-id
1518
- */
1519
- setTraceId(newValue: string): void;
1520
- /**
1521
- * Self-generated 8-bytes identifier of the incoming request. Must be a hex representation of 8-byte array.
1522
- * Also know as the parentId, used to link requests together
1523
- */
1524
- getSpanId(): string;
1525
- /**
1526
- * Self-generated 8-bytes identifier of the incoming request. Must be a hex representation of 8-byte array.
1527
- * Also know as the parentId, used to link requests together
1528
- * https://www.w3.org/TR/trace-context/#parent-id
1529
- */
1530
- setSpanId(newValue: string): void;
1531
- /**
1532
- * An integer representation of the W3C TraceContext trace-flags.
1533
- */
1534
- getTraceFlags(): number | undefined;
1535
- /**
1536
- * https://www.w3.org/TR/trace-context/#trace-flags
1537
- * @param newValue
1538
- */
1539
- setTraceFlags(newValue?: number): void;
1540
- }
1541
-
1542
- interface IEnvelope extends ISerializable {
1543
- /**
1544
- * 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.
1545
- */
1546
- ver: number;
1547
- /**
1548
- * Type name of telemetry data item.
1549
- */
1550
- name: string;
1551
- /**
1552
- * 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.
1553
- */
1554
- time: string;
1555
- /**
1556
- * Sampling rate used in application. This telemetry item represents 1 / sampleRate actual telemetry items.
1557
- */
1558
- sampleRate: number;
1559
- /**
1560
- * Sequence field used to track absolute order of uploaded events.
1561
- */
1562
- seq: string;
1563
- /**
1564
- * 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.
1565
- */
1566
- iKey: string;
1567
- /**
1568
- * Key/value collection of context properties. See ContextTagKeys for information on available properties.
1569
- */
1570
- tags: {
1571
- [name: string]: any;
1572
- };
1573
- /**
1574
- * Telemetry data item.
1575
- */
1576
- data: any;
1577
- }
1578
-
1579
- interface IEventTelemetry extends IPartC {
1580
- /**
1581
- * @description An event name string
1582
- * @type {string}
1583
- * @memberof IEventTelemetry
1584
- */
1585
- name: string;
1586
- /**
1587
- * @description custom defined iKey
1588
- * @type {string}
1589
- * @memberof IEventTelemetry
1590
- */
1591
- iKey?: string;
1592
- }
1593
-
1594
- /**
1595
- * An alternate interface which provides automatic removal during unloading of the component
1596
- */
1597
- interface ILegacyUnloadHook {
1598
- /**
1599
- * Legacy Self remove the referenced component
1600
- */
1601
- remove: () => void;
1602
- }
1603
-
1604
- interface ILoadedPlugin<T extends IPlugin> {
1605
- plugin: T;
1606
- /**
1607
- * Identifies whether the plugin is enabled and can process events. This is slightly different from isInitialized as the plugin may be initialized but disabled
1608
- * via the setEnabled() or it may be a shared plugin which has had it's teardown function called from another instance..
1609
- * @returns boolean = true if the plugin is in a state where it is operational.
1610
- */
1611
- isEnabled: () => boolean;
1612
- /**
1613
- * You can optionally enable / disable a plugin from processing events.
1614
- * Setting enabled to true will not necessarily cause the `isEnabled()` to also return true
1615
- * as the plugin must also have been successfully initialized and not had it's `teardown` method called
1616
- * (unless it's also been re-initialized)
1617
- */
1618
- setEnabled: (isEnabled: boolean) => void;
1619
- remove: (isAsync?: boolean, removeCb?: (removed?: boolean) => void) => void;
1620
- }
1621
-
1622
- interface IMetricTelemetry extends IPartC {
1623
- /**
1624
- * @description (required) - name of this metric
1625
- * @type {string}
1626
- * @memberof IMetricTelemetry
1627
- */
1628
- name: string;
1629
- /**
1630
- * @description (required) - Recorded value/average for this metric
1631
- * @type {number}
1632
- * @memberof IMetricTelemetry
1633
- */
1634
- average: number;
1635
- /**
1636
- * @description (optional) Number of samples represented by the average.
1637
- * @type {number=}
1638
- * @memberof IMetricTelemetry
1639
- * @default sampleCount=1
1640
- */
1641
- sampleCount?: number;
1642
- /**
1643
- * @description (optional) The smallest measurement in the sample. Defaults to the average
1644
- * @type {number}
1645
- * @memberof IMetricTelemetry
1646
- * @default min=average
1647
- */
1648
- min?: number;
1649
- /**
1650
- * @description (optional) The largest measurement in the sample. Defaults to the average.
1651
- * @type {number}
1652
- * @memberof IMetricTelemetry
1653
- * @default max=average
1654
- */
1655
- max?: number;
1656
- /**
1657
- * (optional) The standard deviation measurement in the sample, Defaults to undefined which results in zero.
1658
- */
1659
- stdDev?: number;
1660
- /**
1661
- * @description custom defined iKey
1662
- * @type {string}
1663
- * @memberof IMetricTelemetry
1664
- */
1665
- iKey?: string;
1666
- }
1667
-
1668
- /**
1669
- * An interface used for the notification listener.
1670
- * @interface
1671
- */
1672
- interface INotificationListener {
1673
- /**
1674
- * [Optional] A function called when events are sent.
1675
- * @param events - The array of events that have been sent.
1676
- */
1677
- eventsSent?: (events: ITelemetryItem[]) => void;
1678
- /**
1679
- * [Optional] A function called when events are discarded.
1680
- * @param events - The array of events that have been discarded.
1681
- * @param reason - The reason for discarding the events. The EventsDiscardedReason
1682
- * constant should be used to check the different values.
1683
- */
1684
- eventsDiscarded?: (events: ITelemetryItem[], reason: number) => void;
1685
- /**
1686
- * [Optional] A function called when the events have been requested to be sent to the sever.
1687
- * @param sendReason - The reason why the event batch is being sent.
1688
- * @param isAsync - A flag which identifies whether the requests are being sent in an async or sync manner.
1689
- */
1690
- eventsSendRequest?: (sendReason: number, isAsync?: boolean) => void;
1691
- /**
1692
- * [Optional] This event is sent if you have enabled perf events, they are primarily used to track internal performance testing and debugging
1693
- * the event can be displayed via the debug plugin extension.
1694
- * @param perfEvent
1695
- */
1696
- perfEvent?: (perfEvent: IPerfEvent) => void;
1697
- }
1698
-
1699
- /**
1700
- * Class to manage sending notifications to all the listeners.
1701
- */
1702
- interface INotificationManager {
1703
- listeners: INotificationListener[];
1704
- /**
1705
- * Adds a notification listener.
1706
- * @param listener - The notification listener to be added.
1707
- */
1708
- addNotificationListener(listener: INotificationListener): void;
1709
- /**
1710
- * Removes all instances of the listener.
1711
- * @param listener - AWTNotificationListener to remove.
1712
- */
1713
- removeNotificationListener(listener: INotificationListener): void;
1714
- /**
1715
- * Notification for events sent.
1716
- * @param events - The array of events that have been sent.
1717
- */
1718
- eventsSent(events: ITelemetryItem[]): void;
1719
- /**
1720
- * Notification for events being discarded.
1721
- * @param events - The array of events that have been discarded by the SDK.
1722
- * @param reason - The reason for which the SDK discarded the events. The EventsDiscardedReason
1723
- * constant should be used to check the different values.
1724
- */
1725
- eventsDiscarded(events: ITelemetryItem[], reason: number): void;
1726
- /**
1727
- * [Optional] A function called when the events have been requested to be sent to the sever.
1728
- * @param sendReason - The reason why the event batch is being sent.
1729
- * @param isAsync - A flag which identifies whether the requests are being sent in an async or sync manner.
1730
- */
1731
- eventsSendRequest?(sendReason: number, isAsync: boolean): void;
1732
- /**
1733
- * [Optional] This event is sent if you have enabled perf events, they are primarily used to track internal performance testing and debugging
1734
- * the event can be displayed via the debug plugin extension.
1735
- * @param perfEvent - The perf event details
1736
- */
1737
- perfEvent?(perfEvent: IPerfEvent): void;
1738
- }
1739
-
1740
- class _InternalLogMessage {
1741
- static dataType: string;
1742
- message: string;
1743
- messageId: _InternalMessageId;
1744
- constructor(msgId: _InternalMessageId, msg: string, isUserAct?: boolean, properties?: Object);
1745
- }
1746
-
1747
- type _InternalMessageId = number | _eInternalMessageId;
1748
-
1749
- interface IPageViewPerformanceTelemetry extends IPartC {
1750
- /**
1751
- * name String - The name of the page. Defaults to the document title.
1752
- */
1753
- name?: string;
1754
- /**
1755
- * url String - a relative or absolute URL that identifies the page or other item. Defaults to the window location.
1756
- */
1757
- uri?: string;
1758
- /**
1759
- * Performance total in TimeSpan 'G' (general long) format: d:hh:mm:ss.fffffff". This is total duration in timespan format.
1760
- */
1761
- perfTotal?: string;
1762
- /**
1763
- * Performance total in TimeSpan 'G' (general long) format: d:hh:mm:ss.fffffff". This represents the total page load time.
1764
- */
1765
- duration?: string;
1766
- /**
1767
- * Sent request time in TimeSpan 'G' (general long) format: d:hh:mm:ss.fffffff
1768
- */
1769
- networkConnect?: string;
1770
- /**
1771
- * Sent request time in TimeSpan 'G' (general long) format: d:hh:mm:ss.fffffff.
1772
- */
1773
- sentRequest?: string;
1774
- /**
1775
- * Received response time in TimeSpan 'G' (general long) format: d:hh:mm:ss.fffffff.
1776
- */
1777
- receivedResponse?: string;
1778
- /**
1779
- * DOM processing time in TimeSpan 'G' (general long) format: d:hh:mm:ss.fffffff
1780
- */
1781
- domProcessing?: string;
1782
- }
1783
-
1784
- /**
1785
- * Pageview telemetry interface
1786
- */
1787
- interface IPageViewTelemetry extends IPartC {
1788
- /**
1789
- * name String - The string you used as the name in startTrackPage. Defaults to the document title.
1790
- */
1791
- name?: string;
1792
- /**
1793
- * uri String - a relative or absolute URL that identifies the page or other item. Defaults to the window location.
1794
- */
1795
- uri?: string;
1796
- /**
1797
- * refUri String - the URL of the source page where current page is loaded from
1798
- */
1799
- refUri?: string;
1800
- /**
1801
- * pageType String - page type
1802
- */
1803
- pageType?: string;
1804
- /**
1805
- * isLoggedIn - boolean is user logged in
1806
- */
1807
- isLoggedIn?: boolean;
1808
- /**
1809
- * Property bag to contain additional custom properties (Part C)
1810
- */
1811
- properties?: {
1812
- /**
1813
- * The number of milliseconds it took to load the page. Defaults to undefined. If set to default value, page load time is calculated internally.
1814
- */
1815
- duration?: number;
1816
- [key: string]: any;
1817
- };
1818
- /**
1819
- * iKey String - custom defined iKey.
1820
- */
1821
- iKey?: string;
1822
- }
1823
-
1824
- /**
1825
- * PartC telemetry interface
1826
- */
1827
- interface IPartC {
1828
- /**
1829
- * Property bag to contain additional custom properties (Part C)
1830
- */
1831
- properties?: {
1832
- [key: string]: any;
1833
- };
1834
- /**
1835
- * Property bag to contain additional custom measurements (Part C)
1836
- * @deprecated -- please use properties instead
1837
- */
1838
- measurements?: {
1839
- [key: string]: number;
1840
- };
1841
- }
1842
-
1843
- /**
1844
- * This interface identifies the details of an internal performance event - it does not represent an outgoing reported event
1845
- */
1846
- interface IPerfEvent {
1847
- /**
1848
- * The name of the performance event
1849
- */
1850
- name: string;
1851
- /**
1852
- * The start time of the performance event
1853
- */
1854
- start: number;
1855
- /**
1856
- * The payload (contents) of the perfEvent, may be null or only set after the event has completed depending on
1857
- * the runtime environment.
1858
- */
1859
- payload: any;
1860
- /**
1861
- * Is this occurring from an asynchronous event
1862
- */
1863
- isAsync: boolean;
1864
- /**
1865
- * Identifies the total inclusive time spent for this event, including the time spent for child events,
1866
- * this will be undefined until the event is completed
1867
- */
1868
- time?: number;
1869
- /**
1870
- * Identifies the exclusive time spent in for this event (not including child events),
1871
- * this will be undefined until the event is completed.
1872
- */
1873
- exTime?: number;
1874
- /**
1875
- * The Parent event that was started before this event was created
1876
- */
1877
- parent?: IPerfEvent;
1878
- /**
1879
- * The child perf events that are contained within the total time of this event.
1880
- */
1881
- childEvts?: IPerfEvent[];
1882
- /**
1883
- * Identifies whether this event is a child event of a parent
1884
- */
1885
- isChildEvt: () => boolean;
1886
- /**
1887
- * Get the names additional context associated with this perf event
1888
- */
1889
- getCtx?: (key: string) => any;
1890
- /**
1891
- * Set the named additional context to be associated with this perf event, this will replace any existing value
1892
- */
1893
- setCtx?: (key: string, value: any) => void;
1894
- /**
1895
- * Mark this event as completed, calculating the total execution time.
1896
- */
1897
- complete: () => void;
1898
- }
1899
-
1900
- /**
1901
- * This defines an internal performance manager for tracking and reporting the internal performance of the SDK -- It does
1902
- * not represent or report any event to the server.
1903
- */
1904
- interface IPerfManager {
1905
- /**
1906
- * Create a new event and start timing, the manager may return null/undefined to indicate that it does not
1907
- * want to monitor this source event.
1908
- * @param src - The source name of the event
1909
- * @param payloadDetails - An optional callback function to fetch the payload details for the event.
1910
- * @param isAsync - Is the event occurring from a async event
1911
- */
1912
- create(src: string, payloadDetails?: () => any, isAsync?: boolean): IPerfEvent | null | undefined;
1913
- /**
1914
- * Complete the perfEvent and fire any notifications.
1915
- * @param perfEvent - Fire the event which will also complete the passed event
1916
- */
1917
- fire(perfEvent: IPerfEvent): void;
1918
- /**
1919
- * Set an execution context value
1920
- * @param key - The context key name
1921
- * @param value - The value
1922
- */
1923
- setCtx(key: string, value: any): void;
1924
- /**
1925
- * Get the execution context value
1926
- * @param key - The context key
1927
- */
1928
- getCtx(key: string): any;
1929
- }
1930
-
1931
- /**
1932
- * Identifies an interface to a host that can provide an IPerfManager implementation
1933
- */
1934
- interface IPerfManagerProvider {
1935
- /**
1936
- * Get the current performance manager
1937
- */
1938
- getPerfMgr(): IPerfManager;
1939
- /**
1940
- * Set the current performance manager
1941
- * @param perfMgr - The performance manager
1942
- */
1943
- setPerfMgr(perfMgr: IPerfManager): void;
1944
- }
1945
-
1946
- interface IPlugin {
1947
- /**
1948
- * Initialize plugin loaded by SDK
1949
- * @param config - The config for the plugin to use
1950
- * @param core - The current App Insights core to use for initializing this plugin instance
1951
- * @param extensions - The complete set of extensions to be used for initializing the plugin
1952
- * @param pluginChain - [Optional] specifies the current plugin chain which identifies the
1953
- * set of plugins and the order they should be executed for the current request.
1954
- */
1955
- initialize: (config: IConfiguration, core: IAppInsightsCore, extensions: IPlugin[], pluginChain?: ITelemetryPluginChain) => void;
1956
- /**
1957
- * Returns a value that indicates whether the plugin has already been previously initialized.
1958
- * New plugins should implement this method to avoid being initialized more than once.
1959
- */
1960
- isInitialized?: () => boolean;
1961
- /**
1962
- * Tear down the plugin and remove any hooked value, the plugin should be removed so that it is no longer initialized and
1963
- * therefore could be re-initialized after being torn down. The plugin should ensure that once this has been called any further
1964
- * processTelemetry calls are ignored and it just calls the processNext() with the provided context.
1965
- * @param unloadCtx - This is the context that should be used during unloading.
1966
- * @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.
1967
- * @returns boolean - true if the plugin has or will call processNext(), this for backward compatibility as previously teardown was synchronous and returned nothing.
1968
- */
1969
- teardown?: (unloadCtx: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState) => void | boolean;
1970
- /**
1971
- * Extension name
1972
- */
1973
- readonly identifier: string;
1974
- /**
1975
- * Plugin version (available in data.properties.version in common schema)
1976
- */
1977
- readonly version?: string;
1978
- /**
1979
- * The App Insights core to use for backward compatibility.
1980
- * Therefore the interface will be able to access the core without needing to cast to "any".
1981
- * [optional] any 3rd party plugins which are already implementing this interface don't fail to compile.
1982
- */
1983
- core?: IAppInsightsCore;
1984
- }
1985
-
1986
- /**
1987
- * The current context for the current call to processTelemetry(), used to support sharing the same plugin instance
1988
- * between multiple AppInsights instances
1989
- */
1990
- interface IProcessTelemetryContext extends IBaseProcessingContext {
1991
- /**
1992
- * Call back for telemetry processing before it it is sent
1993
- * @param env - This is the current event being reported
1994
- * @returns boolean (true) if there is no more plugins to process otherwise false or undefined (void)
1995
- */
1996
- processNext: (env: ITelemetryItem) => boolean | void;
1997
- /**
1998
- * Create a new context using the core and config from the current instance, returns a new instance of the same type
1999
- * @param plugins - The execution order to process the plugins, if null or not supplied
2000
- * then the current execution order will be copied.
2001
- * @param startAt - The plugin to start processing from, if missing from the execution
2002
- * order then the next plugin will be NOT set.
2003
- */
2004
- createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryContext;
2005
- }
2006
-
2007
- /**
2008
- * The current context for the current call to teardown() implementations, used to support when plugins are being removed
2009
- * or the SDK is being unloaded.
2010
- */
2011
- interface IProcessTelemetryUnloadContext extends IBaseProcessingContext {
2012
- /**
2013
- * This Plugin has finished unloading, so unload the next one
2014
- * @param uploadState - The state of the unload process
2015
- * @returns boolean (true) if there is no more plugins to process otherwise false or undefined (void)
2016
- */
2017
- processNext: (unloadState: ITelemetryUnloadState) => boolean | void;
2018
- /**
2019
- * Create a new context using the core and config from the current instance, returns a new instance of the same type
2020
- * @param plugins - The execution order to process the plugins, if null or not supplied
2021
- * then the current execution order will be copied.
2022
- * @param startAt - The plugin to start processing from, if missing from the execution
2023
- * order then the next plugin will be NOT set.
2024
- */
2025
- createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryUnloadContext;
2026
- }
2027
-
2028
- /**
2029
- * The current context for the current call to the plugin update() implementations, used to support the notifications
2030
- * for when plugins are added, removed or the configuration was changed.
2031
- */
2032
- interface IProcessTelemetryUpdateContext extends IBaseProcessingContext {
2033
- /**
2034
- * This Plugin has finished unloading, so unload the next one
2035
- * @param updateState - The update State
2036
- * @returns boolean (true) if there is no more plugins to process otherwise false or undefined (void)
2037
- */
2038
- processNext: (updateState: ITelemetryUpdateState) => boolean | void;
2039
- /**
2040
- * Create a new context using the core and config from the current instance, returns a new instance of the same type
2041
- * @param plugins - The execution order to process the plugins, if null or not supplied
2042
- * then the current execution order will be copied.
2043
- * @param startAt - The plugin to start processing from, if missing from the execution
2044
- * order then the next plugin will be NOT set.
2045
- */
2046
- createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryUpdateContext;
2047
- }
2048
-
2049
- interface IRequestContext {
2050
- status?: number;
2051
- xhr?: XMLHttpRequest;
2052
- request?: Request;
2053
- response?: Response | string;
2054
- }
2055
-
2056
- interface IResponseError {
2057
- readonly index: number;
2058
- readonly statusCode: number;
2059
- readonly message: string;
2060
- }
2061
-
2062
- interface ISample {
2063
- /**
2064
- * Sample rate
2065
- */
2066
- sampleRate: number;
2067
- isSampledIn(envelope: ITelemetryItem): boolean;
2068
- }
2069
-
2070
- interface ISendBuffer {
2071
- /**
2072
- * Enqueue the payload
2073
- */
2074
- enqueue: (payload: string) => void;
2075
- /**
2076
- * Returns the number of elements in the buffer
2077
- */
2078
- count: () => number;
2079
- /**
2080
- * Returns the current size of the serialized buffer
2081
- */
2082
- size: () => number;
2083
- /**
2084
- * Clears the buffer
2085
- */
2086
- clear: () => void;
2087
- /**
2088
- * Returns items stored in the buffer
2089
- */
2090
- getItems: () => string[];
2091
- /**
2092
- * Build a batch of all elements in the payload array
2093
- */
2094
- batchPayloads: (payload: string[]) => string;
2095
- /**
2096
- * Moves items to the SENT_BUFFER.
2097
- * The buffer holds items which were sent, but we haven't received any response from the backend yet.
2098
- */
2099
- markAsSent: (payload: string[]) => void;
2100
- /**
2101
- * Removes items from the SENT_BUFFER. Should be called on successful response from the backend.
2102
- */
2103
- clearSent: (payload: string[]) => void;
2104
- /**
2105
- * Copy current buffer items to a new buffer.
2106
- * if canUseSessionStorage is undefined, it will set to false.
2107
- * if newLogger and newConfig are undefined, current logger and empty config will be used.
2108
- * if canUseSessionStorage is set to true, new SessionStorageSendBuffer will be returned otherwise ArraySendBuffer will be returned.
2109
- */
2110
- createNew: (newLogger?: IDiagnosticLogger, newConfig?: ISenderConfig, canUseSessionStorage?: boolean) => ArraySendBuffer | SessionStorageSendBuffer;
2111
- }
2112
-
2113
- interface ISenderConfig {
2114
- /**
2115
- * The url to which payloads will be sent
2116
- */
2117
- endpointUrl: string;
2118
- /**
2119
- * The JSON format (normal vs line delimited). True means line delimited JSON.
2120
- */
2121
- emitLineDelimitedJson: boolean;
2122
- /**
2123
- * The maximum size of a batch in bytes
2124
- */
2125
- maxBatchSizeInBytes: number;
2126
- /**
2127
- * The maximum interval allowed between calls to batchInvoke
2128
- */
2129
- maxBatchInterval: number;
2130
- /**
2131
- * The master off switch. Do not send any data if set to TRUE
2132
- */
2133
- disableTelemetry: boolean;
2134
- /**
2135
- * Store a copy of a send buffer in the session storage
2136
- */
2137
- enableSessionStorageBuffer: boolean;
2138
- /**
2139
- * Specify the storage buffer type implementation.
2140
- * @since 2.8.12
2141
- */
2142
- bufferOverride: IStorageBuffer | false;
2143
- /**
2144
- * Is retry handler disabled.
2145
- * If enabled, retry on 206 (partial success), 408 (timeout), 429 (too many requests), 500 (internal server error) and 503 (service unavailable).
2146
- */
2147
- isRetryDisabled: boolean;
2148
- isBeaconApiDisabled: boolean;
2149
- /**
2150
- * Don't use XMLHttpRequest or XDomainRequest (for IE < 9) by default instead attempt to use fetch() or sendBeacon.
2151
- * If no other transport is available it will still use XMLHttpRequest
2152
- */
2153
- disableXhr: boolean;
2154
- /**
2155
- * If fetch keepalive is supported do not use it for sending events during unload, it may still fallback to fetch() without keepalive
2156
- */
2157
- onunloadDisableFetch: boolean;
2158
- /**
2159
- * Is beacon disabled on page unload.
2160
- * If enabled, flush events through beaconSender.
2161
- */
2162
- onunloadDisableBeacon: boolean;
2163
- /**
2164
- * (Optional) Override the instrumentation key that this channel instance sends to
2165
- */
2166
- instrumentationKey: string;
2167
- namePrefix: string;
2168
- samplingPercentage: number;
2169
- /**
2170
- * (Optional) The ability for the user to provide extra headers
2171
- */
2172
- customHeaders: [{
2173
- header: string;
2174
- value: string;
2175
- }];
2176
- /**
2177
- * (Optional) Provide user an option to convert undefined field to user defined value.
2178
- */
2179
- convertUndefined: any;
2180
- /**
2181
- * (Optional) The number of events that can be kept in memory before the SDK starts to drop events. By default, this is 10,000.
2182
- */
2183
- eventsLimitInMem: number;
2184
- }
2185
-
2186
- interface ISerializable {
2187
- /**
2188
- * The set of fields for a serializable object.
2189
- * This defines the serialization order and a value of true/false
2190
- * for each field defines whether the field is required or not.
2191
- */
2192
- aiDataContract: any;
2193
- }
2194
-
2195
- export { isNullOrUndefined }
2196
-
2197
- interface IStackDetails {
2198
- src: string;
2199
- obj: string[];
2200
- }
2201
-
2202
- /**
2203
- * Identifies a simple interface to allow you to override the storage mechanism used
2204
- * to track unsent and unacknowledged events. When provided it must provide both
2205
- * the get and set item functions.
2206
- * @since 2.8.12
2207
- */
2208
- interface IStorageBuffer {
2209
- /**
2210
- * Retrieves the stored value for a given key
2211
- */
2212
- getItem(logger: IDiagnosticLogger, name: string): string;
2213
- /**
2214
- * Sets the stored value for a given key
2215
- */
2216
- setItem(logger: IDiagnosticLogger, name: string, data: string): boolean;
2217
- }
2218
-
2219
- interface ITelemetryInitializerHandler extends ILegacyUnloadHook {
2220
- remove(): void;
2221
- }
2222
-
2223
- /**
2224
- * Telemety item supported in Core
2225
- */
2226
- interface ITelemetryItem {
2227
- /**
2228
- * CommonSchema Version of this SDK
2229
- */
2230
- ver?: string;
2231
- /**
2232
- * Unique name of the telemetry item
2233
- */
2234
- name: string;
2235
- /**
2236
- * Timestamp when item was sent
2237
- */
2238
- time?: string;
2239
- /**
2240
- * Identifier of the resource that uniquely identifies which resource data is sent to
2241
- */
2242
- iKey?: string;
2243
- /**
2244
- * System context properties of the telemetry item, example: ip address, city etc
2245
- */
2246
- ext?: {
2247
- [key: string]: any;
2248
- };
2249
- /**
2250
- * System context property extensions that are not global (not in ctx)
2251
- */
2252
- tags?: Tags & Tags[];
2253
- /**
2254
- * Custom data
2255
- */
2256
- data?: ICustomProperties;
2257
- /**
2258
- * Telemetry type used for part B
2259
- */
2260
- baseType?: string;
2261
- /**
2262
- * Based on schema for part B
2263
- */
2264
- baseData?: {
2265
- [key: string]: any;
2266
- };
2267
- }
2268
-
2269
- /**
2270
- * Configuration provided to SDK core
2271
- */
2272
- interface ITelemetryPlugin extends ITelemetryProcessor, IPlugin {
2273
- /**
2274
- * Set next extension for telemetry processing, this is not optional as plugins should use the
2275
- * processNext() function of the passed IProcessTelemetryContext instead. It is being kept for
2276
- * now for backward compatibility only.
2277
- */
2278
- setNextPlugin?: (next: ITelemetryPlugin | ITelemetryPluginChain) => void;
2279
- /**
2280
- * Priority of the extension
2281
- */
2282
- readonly priority: number;
2283
- }
2284
-
2285
- /**
2286
- * Configuration provided to SDK core
2287
- */
2288
- interface ITelemetryPluginChain extends ITelemetryProcessor {
2289
- /**
2290
- * Returns the underlying plugin that is being proxied for the processTelemetry call
2291
- */
2292
- getPlugin: () => ITelemetryPlugin;
2293
- /**
2294
- * Returns the next plugin
2295
- */
2296
- getNext: () => ITelemetryPluginChain;
2297
- /**
2298
- * This plugin is being unloaded and should remove any hooked events and cleanup any global/scoped values, after this
2299
- * call the plugin will be removed from the telemetry processing chain and will no longer receive any events..
2300
- * @param unloadCtx - The unload context to use for this call.
2301
- * @param unloadState - The details of the unload operation
2302
- */
2303
- unload?: (unloadCtx: IProcessTelemetryUnloadContext, unloadState: ITelemetryUnloadState) => void;
2304
- }
2305
-
2306
- interface ITelemetryProcessor {
2307
- /**
2308
- * Call back for telemetry processing before it it is sent
2309
- * @param env - This is the current event being reported
2310
- * @param itemCtx - This is the context for the current request, ITelemetryPlugin instances
2311
- * can optionally use this to access the current core instance or define / pass additional information
2312
- * to later plugins (vs appending items to the telemetry item)
2313
- */
2314
- processTelemetry: (env: ITelemetryItem, itemCtx?: IProcessTelemetryContext) => void;
2315
- /**
2316
- * The the plugin should re-evaluate configuration and update any cached configuration settings or
2317
- * plugins. If implemented this method will be called whenever a plugin is added or removed and if
2318
- * the configuration has bee updated.
2319
- * @param updateCtx - This is the context that should be used during updating.
2320
- * @param updateState - The details / state of the update process, it holds details like the current and previous configuration.
2321
- * @returns boolean - true if the plugin has or will call updateCtx.processNext(), this allows the plugin to perform any asynchronous operations.
2322
- */
2323
- update?: (updateCtx: IProcessTelemetryUpdateContext, updateState: ITelemetryUpdateState) => void | boolean;
2324
- }
2325
-
2326
- interface ITelemetryUnloadState {
2327
- reason: TelemetryUnloadReason;
2328
- isAsync: boolean;
2329
- flushComplete?: boolean;
2330
- }
2331
-
2332
- interface ITelemetryUpdateState {
2333
- /**
2334
- * Identifies the reason for the update notification, this is a bitwise numeric value
2335
- */
2336
- reason: TelemetryUpdateReason;
2337
- /**
2338
- * This is a new active configuration that should be used
2339
- */
2340
- cfg?: IConfiguration;
2341
- /**
2342
- * The detected changes
2343
- */
2344
- oldCfg?: IConfiguration;
2345
- /**
2346
- * If this is a configuration update this was the previous configuration that was used
2347
- */
2348
- newConfig?: IConfiguration;
2349
- /**
2350
- * Was the new config requested to be merged with the existing config
2351
- */
2352
- merge?: boolean;
2353
- /**
2354
- * This holds a collection of plugins that have been added (if the reason identifies that one or more plugins have been added)
2355
- */
2356
- added?: IPlugin[];
2357
- /**
2358
- * This holds a collection of plugins that have been removed (if the reason identifies that one or more plugins have been removed)
2359
- */
2360
- removed?: IPlugin[];
2361
- }
2362
-
2363
- interface ITraceTelemetry extends IPartC {
2364
- /**
2365
- * @description A message string
2366
- * @type {string}
2367
- * @memberof ITraceTelemetry
2368
- */
2369
- message: string;
2370
- /**
2371
- * @description Severity level of the logging message used for filtering in the portal
2372
- * @type {SeverityLevel}
2373
- * @memberof ITraceTelemetry
2374
- */
2375
- severityLevel?: SeverityLevel;
2376
- /**
2377
- * @description custom defiend iKey
2378
- * @type {SeverityLevel}
2379
- * @memberof ITraceTelemetry
2380
- */
2381
- iKey?: string;
2382
- }
2383
-
2384
- /**
2385
- * An interface which provides automatic removal during unloading of the component
2386
- */
2387
- interface IUnloadHook {
2388
- /**
2389
- * Self remove the referenced component
2390
- */
2391
- rm: () => void;
2392
- }
2393
-
2394
- /**
2395
- * Interface which identifiesAdd this hook so that it is automatically removed during unloading
2396
- * @param hooks - The single hook or an array of IInstrumentHook objects
2397
- */
2398
- interface IUnloadHookContainer {
2399
- add: (hooks: IUnloadHook | IUnloadHook[] | Iterator<IUnloadHook> | ILegacyUnloadHook | ILegacyUnloadHook[] | Iterator<ILegacyUnloadHook>) => void;
2400
- run: (logger?: IDiagnosticLogger) => void;
2401
- }
2402
-
2403
- interface IWatchDetails<T extends IConfiguration> {
2404
- /**
2405
- * The current config object
2406
- */
2407
- cfg: T;
2408
- /**
2409
- * Set the value against the provided config/name with the value, the property
2410
- * will be converted to be dynamic (if not already) as long as the provided config
2411
- * is already a tracked dynamic object.
2412
- * @throws TypeError if the provided config is not a monitored dynamic config
2413
- */
2414
- set: <C, V>(theConfig: C, name: string, value: V) => V;
2415
- /**
2416
- * Set default values for the config if not present.
2417
- * @param theConfig - The configuration object to set default on (if missing)
2418
- * @param defaultValues - The default values to apply to the config
2419
- */
2420
- setDf: <C>(theConfig: C, defaultValues: IConfigDefaults<C>) => C;
2421
- /**
2422
- * Set this named property of the target as referenced, which will cause any object or array instance
2423
- * to be updated in-place rather than being entirely replaced. All other values will continue to be replaced.
2424
- * @returns The referenced properties current value
2425
- */
2426
- ref: <C, V = any>(target: C, name: string) => V;
2427
- /**
2428
- * Set this named property of the target as read-only, which will block this single named property from
2429
- * ever being changed for the target instance.
2430
- * This does NOT freeze or seal the instance, it just stops the direct re-assignment of the named property,
2431
- * if the value is a non-primitive (ie. an object or array) it's properties will still be mutable.
2432
- * @returns The referenced properties current value
2433
- */
2434
- rdOnly: <C, V = any>(target: C, name: string) => V;
2435
- }
2436
-
2437
- const LoggingSeverity: EnumValue<typeof eLoggingSeverity>;
2438
-
2439
- type LoggingSeverity = number | eLoggingSeverity;
2440
-
2441
- /**
2442
- * Creates proxy functions on the target which internally will call the source version with all arguments passed to the target method.
2443
- *
2444
- * @param target - The target object to be assigned with the source properties and functions
2445
- * @param source - The source object which will be assigned / called by setting / calling the targets proxies
2446
- * @param functionsToProxy - An array of function names that will be proxied on the target
2447
- * @param overwriteTarget - If false this will not replace any pre-existing name otherwise (the default) it will overwrite any existing name
2448
- */
2449
- function proxyFunctions<T, S>(target: T, source: S | (() => S), functionsToProxy: (keyof S)[], overwriteTarget?: boolean): T;
2450
-
2451
- class Sender extends BaseTelemetryPlugin implements IChannelControls {
2452
- static constructEnvelope(orig: ITelemetryItem, iKey: string, logger: IDiagnosticLogger, convertUndefined?: any): IEnvelope;
2453
- readonly priority: number;
2454
- readonly identifier: string;
2455
- /**
2456
- * The configuration for this sender instance
2457
- */
2458
- readonly _senderConfig: ISenderConfig;
2459
- /**
2460
- * A method which will cause data to be send to the url
2461
- */
2462
- _sender: SenderFunction;
2463
- /**
2464
- * A send buffer object
2465
- */
2466
- _buffer: ISendBuffer;
2467
- /**
2468
- * AppId of this component parsed from some backend response.
2469
- */
2470
- _appId: string;
2471
- protected _sample: ISample;
2472
- constructor();
2473
- /**
2474
- * Pause the sending (transmission) of events, this will cause all events to be batched only until the maximum limits are
2475
- * hit at which point new events are dropped. Will also cause events to NOT be sent during page unload, so if Session storage
2476
- * is disabled events will be lost.
2477
- * SessionStorage Limit is 2000 events, In-Memory (Array) Storage is 10,000 events (can be configured via the eventsLimitInMem).
2478
- */
2479
- pause(): void;
2480
- /**
2481
- * Resume the sending (transmission) of events, this will restart the timer and any batched events will be sent using the normal
2482
- * send interval.
2483
- */
2484
- resume(): void;
2485
- /**
2486
- * Flush the batched events immediately (not synchronously).
2487
- * Will not flush if the Sender has been paused.
2488
- */
2489
- flush(): void;
2490
- /**
2491
- * Flush the batched events synchronously (if possible -- based on configuration).
2492
- * Will not flush if the Send has been paused.
2493
- */
2494
- onunloadFlush(): void;
2495
- initialize(config: IConfiguration & IConfig, core: IAppInsightsCore, extensions: IPlugin[], pluginChain?: ITelemetryPluginChain): void;
2496
- processTelemetry(telemetryItem: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
2497
- /**
2498
- * xhr state changes
2499
- */
2500
- _xhrReadyStateChange(xhr: XMLHttpRequest, payload: string[], countOfItemsInPayload: number): void;
2501
- /**
2502
- * Immediately send buffered data
2503
- * @param async - {boolean} - Indicates if the events should be sent asynchronously
2504
- * @param forcedSender - {SenderFunction} - Indicates the forcedSender, undefined if not passed
2505
- */
2506
- triggerSend(async?: boolean, forcedSender?: SenderFunction, sendReason?: SendRequestReason): void;
2507
- /**
2508
- * error handler
2509
- */
2510
- _onError(payload: string[], message: string, event?: ErrorEvent): void;
2511
- /**
2512
- * partial success handler
2513
- */
2514
- _onPartialSuccess(payload: string[], results: IBackendResponse): void;
2515
- /**
2516
- * success handler
2517
- */
2518
- _onSuccess(payload: string[], countOfItemsInPayload: number): void;
2519
- /**
2520
- * xdr state changes
2521
- */
2522
- _xdrOnLoad(xdr: XDomainRequest, payload: string[]): void;
2523
- /**
2524
- * Add header to request
2525
- * @param name - Header name.
2526
- * @param value - Header value.
2527
- */
2528
- addHeader(name: string, value: string): void;
2529
- }
2530
-
2531
- type SenderFunction = (payload: string[], isAsync: boolean) => void;
2532
-
2533
- /**
2534
- * The EventsDiscardedReason enumeration contains a set of values that specify the reason for discarding an event.
2535
- */
2536
- const enum SendRequestReason {
2537
- /**
2538
- * No specific reason was specified
2539
- */
2540
- Undefined = 0,
2541
- /**
2542
- * Events are being sent based on the normal event schedule / timer.
2543
- */
2544
- NormalSchedule = 1,
2545
- /**
2546
- * A manual flush request was received
2547
- */
2548
- ManualFlush = 1,
2549
- /**
2550
- * Unload event is being processed
2551
- */
2552
- Unload = 2,
2553
- /**
2554
- * The event(s) being sent are sync events
2555
- */
2556
- SyncEvent = 3,
2557
- /**
2558
- * The Channel was resumed
2559
- */
2560
- Resumed = 4,
2561
- /**
2562
- * The event(s) being sent as a retry
2563
- */
2564
- Retry = 5,
2565
- /**
2566
- * The SDK is unloading
2567
- */
2568
- SdkUnload = 6,
2569
- /**
2570
- * Maximum batch size would be exceeded
2571
- */
2572
- MaxBatchSize = 10,
2573
- /**
2574
- * The Maximum number of events have already been queued
2575
- */
2576
- MaxQueuedEvents = 20
2577
- }
142
+ export { ITelemetryPlugin }
2578
143
 
2579
- class SessionStorageSendBuffer extends BaseSendBuffer implements ISendBuffer {
2580
- static BUFFER_KEY: string;
2581
- static SENT_BUFFER_KEY: string;
2582
- static MAX_BUFFER_SIZE: number;
2583
- constructor(logger: IDiagnosticLogger, config: ISenderConfig);
2584
- enqueue(payload: string): void;
2585
- clear(): void;
2586
- markAsSent(payload: string[]): void;
2587
- clearSent(payload: string[]): void;
2588
- createNew(newLogger?: IDiagnosticLogger, newConfig?: ISenderConfig, canUseSessionStorage?: boolean): ArraySendBuffer | SessionStorageSendBuffer;
2589
- }
2590
-
2591
- /**
2592
- * Defines the level of severity for the event.
2593
- */
2594
- const SeverityLevel: EnumValue<typeof eSeverityLevel>;
144
+ export { ITraceTelemetry }
2595
145
 
2596
- type SeverityLevel = number | eSeverityLevel;
146
+ export { proxyFunctions }
2597
147
 
2598
- interface Tags {
2599
- [key: string]: any;
2600
- }
2601
-
2602
- type TelemetryInitializerFunction = <T extends ITelemetryItem>(item: T) => boolean | void;
148
+ export { Sender }
2603
149
 
2604
- /**
2605
- * The TelemetryUnloadReason enumeration contains the possible reasons for why a plugin is being unloaded / torndown().
2606
- */
2607
- const enum TelemetryUnloadReason {
2608
- /**
2609
- * Teardown has been called without any context.
2610
- */
2611
- ManualTeardown = 0,
2612
- /**
2613
- * Just this plugin is being removed
2614
- */
2615
- PluginUnload = 1,
2616
- /**
2617
- * This instance of the plugin is being removed and replaced
2618
- */
2619
- PluginReplace = 2,
2620
- /**
2621
- * The entire SDK is being unloaded
2622
- */
2623
- SdkUnload = 50
2624
- }
150
+ export { SendRequestReason }
2625
151
 
2626
- /**
2627
- * The TelemetryUpdateReason enumeration contains a set of bit-wise values that specify the reason for update request.
2628
- */
2629
- const enum TelemetryUpdateReason {
2630
- /**
2631
- * Unknown.
2632
- */
2633
- Unknown = 0,
2634
- /**
2635
- * The configuration has ben updated or changed
2636
- */
2637
- ConfigurationChanged = 1,
2638
- /**
2639
- * One or more plugins have been added
2640
- */
2641
- PluginAdded = 16,
2642
- /**
2643
- * One or more plugins have been removed
2644
- */
2645
- PluginRemoved = 32
2646
- }
152
+ export { SeverityLevel }
2647
153
 
2648
154
  export { throwError }
2649
155
 
2650
- type UnloadHandler = (itemCtx: IProcessTelemetryUnloadContext, unloadState: ITelemetryUnloadState) => void;
2651
-
2652
- type WatcherFunction<T extends IConfiguration> = (details: IWatchDetails<T>) => void;
2653
-
2654
- interface XDomainRequest extends XMLHttpRequestEventTarget {
2655
- readonly responseText: string;
2656
- send(payload: string): void;
2657
- open(method: string, url: string): void;
2658
- }
2659
-
2660
156
 
2661
157
  }