@microsoft/applicationinsights-properties-js 3.1.0-nightly3.2402-09 → 3.1.1-nightly3.2402-13

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