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