@microsoft/applicationinsights-analytics-js 3.0.8 → 3.0.9

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