@microsoft/power-apps-cli 0.5.3 → 0.5.4

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