@microsoft/applicationinsights-cfgsync-js 3.0.8 → 3.0.9

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