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

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