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

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