@microsoft/applicationinsights-analytics-js 3.1.0-nightly3.2402-09 → 3.1.0

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