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