@microsoft/applicationinsights-cfgsync-js 3.1.0-nightly3.2402-08 → 3.1.0-nightly3.2402-12

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