@microsoft/applicationinsights-web-basic 2.8.13-nightly.2304-34 → 2.8.13-nightly.2304-40

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