@microsoft/applicationinsights-web-basic 2.7.4-nightly.2202-07 → 2.8.0-beta.2202-06

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.
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Microsoft.ApplicationInsights, 2.7.4-nightly.2202-07
2
+ * Microsoft.ApplicationInsights, 2.8.0-beta.2202-06
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  *
5
5
  * Microsoft Application Insights Team
@@ -17,26 +17,6 @@ export declare class AppInsightsCore extends BaseCore implements IAppInsightsCor
17
17
  constructor();
18
18
  initialize(config: IConfiguration, extensions: IPlugin[], logger?: IDiagnosticLogger, notificationManager?: INotificationManager): void;
19
19
  track(telemetryItem: ITelemetryItem): void;
20
- /**
21
- * Adds a notification listener. The SDK calls methods on the listener when an appropriate notification is raised.
22
- * The added plugins must raise notifications. If the plugins do not implement the notifications, then no methods will be
23
- * called.
24
- * @param {INotificationListener} listener - An INotificationListener object.
25
- */
26
- addNotificationListener(listener: INotificationListener): void;
27
- /**
28
- * Removes all instances of the listener.
29
- * @param {INotificationListener} listener - INotificationListener to remove.
30
- */
31
- removeNotificationListener(listener: INotificationListener): void;
32
- /**
33
- * Periodically check logger.queue for
34
- */
35
- pollInternalLogs(eventName?: string): number;
36
- /**
37
- * Periodically check logger.queue for
38
- */
39
- stopPollingInternalLogs(): void;
40
20
  }
41
21
 
42
22
  /**
@@ -88,6 +68,18 @@ declare class BaseCore implements IAppInsightsCore {
88
68
  track(telemetryItem: ITelemetryItem): void;
89
69
  getProcessTelContext(): IProcessTelemetryContext;
90
70
  getNotifyMgr(): INotificationManager;
71
+ /**
72
+ * Adds a notification listener. The SDK calls methods on the listener when an appropriate notification is raised.
73
+ * The added plugins must raise notifications. If the plugins do not implement the notifications, then no methods will be
74
+ * called.
75
+ * @param {INotificationListener} listener - An INotificationListener object.
76
+ */
77
+ addNotificationListener(listener: INotificationListener): void;
78
+ /**
79
+ * Removes all instances of the listener.
80
+ * @param {INotificationListener} listener - INotificationListener to remove.
81
+ */
82
+ removeNotificationListener(listener: INotificationListener): void;
91
83
  /**
92
84
  * Get the current cookie manager for this instance
93
85
  */
@@ -100,6 +92,21 @@ declare class BaseCore implements IAppInsightsCore {
100
92
  getPerfMgr(): IPerfManager;
101
93
  setPerfMgr(perfMgr: IPerfManager): void;
102
94
  eventCnt(): number;
95
+ /**
96
+ * Periodically check logger.queue for
97
+ */
98
+ pollInternalLogs(eventName?: string): number;
99
+ /**
100
+ * Periodically check logger.queue for
101
+ */
102
+ stopPollingInternalLogs(): void;
103
+ /**
104
+ * Add a telemetry processor to decorate or drop telemetry events.
105
+ * @param telemetryInitializer - The Telemetry Initializer function
106
+ * @returns - A ITelemetryInitializerHandler to enable the initializer to be removed
107
+ */
108
+ addTelemetryInitializer(telemetryInitializer: TelemetryInitializerFunction): ITelemetryInitializerHandler | void;
109
+ getPlugin<T extends IPlugin = IPlugin>(pluginIdentifier: string): ILoadedPlugin<T>;
103
110
  protected releaseQueue(): void;
104
111
  }
105
112
 
@@ -109,6 +116,13 @@ declare class BaseCore implements IAppInsightsCore {
109
116
  * implementation so that new default implementations can be added without breaking all plugins.
110
117
  */
111
118
  declare abstract class BaseTelemetryPlugin implements ITelemetryPlugin {
119
+ identifier: string;
120
+ version?: string;
121
+ /**
122
+ * Holds the core instance that was used during initialization
123
+ */
124
+ core: IAppInsightsCore;
125
+ priority: number;
112
126
  /**
113
127
  * Call back for telemetry processing before it it is sent
114
128
  * @param env - This is the current event being reported
@@ -130,13 +144,6 @@ declare abstract class BaseTelemetryPlugin implements ITelemetryPlugin {
130
144
  * Returns whether the plugin has been initialized
131
145
  */
132
146
  isInitialized: () => boolean;
133
- identifier: string;
134
- version?: string;
135
- /**
136
- * Holds the core instance that was used during initialization
137
- */
138
- core: IAppInsightsCore;
139
- priority: number;
140
147
  /**
141
148
  * Helper to return the current IProcessTelemetryContext, if the passed argument exists this just
142
149
  * returns that value (helps with minification for callers), otherwise it will return the configured
@@ -148,13 +155,14 @@ declare abstract class BaseTelemetryPlugin implements ITelemetryPlugin {
148
155
  * Internal helper to allow setting of the internal initialized setting for inherited instances and unit testing
149
156
  */
150
157
  protected setInitialized: (isInitialized: boolean) => void;
151
- /**
152
- * Internal helper to initialize the instance
153
- */
154
- private _baseTelInit;
155
158
  constructor();
156
159
  initialize(config: IConfiguration, core: IAppInsightsCore, extensions: IPlugin[], pluginChain?: ITelemetryPluginChain): void;
157
160
  abstract processTelemetry(env: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
161
+ /**
162
+ * Add this hook so that it is automatically removed during unloading
163
+ * @param hooks - The single hook or an array of IInstrumentHook objects
164
+ */
165
+ protected _addHook(hooks: IInstrumentHook | IInstrumentHook[]): void;
158
166
  }
159
167
 
160
168
  /**
@@ -180,6 +188,12 @@ declare enum DistributedTracingModes {
180
188
  W3C = 2
181
189
  }
182
190
 
191
+ declare const enum GetExtCfgMergeType {
192
+ None = 0,
193
+ MergeDefaultOnly = 1,
194
+ MergeDefaultFromRootOrDefault = 2
195
+ }
196
+
183
197
  export declare interface IAppInsightsCore extends IPerfManagerProvider {
184
198
  config: IConfiguration;
185
199
  logger: IDiagnosticLogger;
@@ -215,12 +229,23 @@ export declare interface IAppInsightsCore extends IPerfManagerProvider {
215
229
  * @param {INotificationListener} listener - INotificationListener to remove.
216
230
  */
217
231
  removeNotificationListener?(listener: INotificationListener): void;
232
+ /**
233
+ * Add a telemetry processor to decorate or drop telemetry events.
234
+ * @param telemetryInitializer - The Telemetry Initializer function
235
+ * @returns - A ITelemetryInitializerHandler to enable the initializer to be removed
236
+ */
237
+ addTelemetryInitializer(telemetryInitializer: TelemetryInitializerFunction): ITelemetryInitializerHandler | void;
218
238
  pollInternalLogs?(eventName?: string): number;
219
239
  stopPollingInternalLogs?(): void;
220
240
  /**
221
241
  * Return a new instance of the IProcessTelemetryContext for processing events
222
242
  */
223
243
  getProcessTelContext(): IProcessTelemetryContext;
244
+ /**
245
+ * Find and return the (first) plugin with the specified identifier if present
246
+ * @param pluginIdentifier
247
+ */
248
+ getPlugin<T extends IPlugin = IPlugin>(pluginIdentifier: string): ILoadedPlugin<T>;
224
249
  }
225
250
 
226
251
  /**
@@ -322,10 +347,13 @@ declare interface IChannelControls extends ITelemetryPlugin {
322
347
  teardown(): void;
323
348
  /**
324
349
  * Flush to send data immediately; channel should default to sending data asynchronously
325
- * @param async: send data asynchronously when true
326
- * @param callBack: if specified, notify caller when send is complete
350
+ * @param async - send data asynchronously when true
351
+ * @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.
352
+ * If the caller doesn't return true the caller should assume that it may never be called.
353
+ * @param sendReason - specify the reason that you are calling "flush" defaults to ManualFlush (1) if not specified
354
+ * @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
327
355
  */
328
- flush(async: boolean, callBack?: () => void): void;
356
+ flush(async: boolean, callBack?: (flushComplete?: boolean) => void, sendReason?: SendRequestReason): boolean | void;
329
357
  }
330
358
 
331
359
  declare interface IChannelControlsAI extends IChannelControls {
@@ -1160,6 +1188,77 @@ export declare interface IEventTelemetry extends IPartC {
1160
1188
  iKey?: string;
1161
1189
  }
1162
1190
 
1191
+ declare interface IInstrumentCallDetails {
1192
+ name: string;
1193
+ inst: any;
1194
+ /**
1195
+ * This returns an object that the hook function can use to store hook specific
1196
+ * context, it it not shared with any other hook instances and is unique for the
1197
+ * current call.
1198
+ * A hook implementation can use this to pass / share context between different
1199
+ * hook callbacks eg. request/response requst/hookErrors etc.
1200
+ */
1201
+ ctx: () => any;
1202
+ /**
1203
+ * Allows the hook functions to replace the original arguments
1204
+ * @param idx - The argument index (0 based)
1205
+ * @param value - The new value for the argument
1206
+ */
1207
+ set: (idx: number, value: any) => void;
1208
+ /**
1209
+ * The result of the original method, only populated after the original method has returned
1210
+ */
1211
+ rslt?: any;
1212
+ /**
1213
+ * The error (exception) which occurred while executing the original method
1214
+ */
1215
+ err?: Error;
1216
+ /**
1217
+ * The Event object from (window.event) at the start of the original call
1218
+ */
1219
+ evt?: Event;
1220
+ }
1221
+
1222
+ /**
1223
+ * The holder of the specific instance callback
1224
+ */
1225
+ declare interface IInstrumentHook {
1226
+ /** Unique Id for this callback on the hooked method */
1227
+ id: number;
1228
+ /** Holds the callbacks */
1229
+ cbks: IInstrumentHooksCallbacks;
1230
+ /** Remove this hook from the function */
1231
+ rm: () => void;
1232
+ }
1233
+
1234
+ /**
1235
+ * The callbacks to call for the instrumented function, you must provide at least the request and/or response callbacks, both are not required.
1236
+ * You must always supply the error callback
1237
+ */
1238
+ declare interface IInstrumentHooksCallbacks {
1239
+ /**
1240
+ * The hook callback to call before the original function is called
1241
+ */
1242
+ req?: InstrumentorHooksCallback;
1243
+ /**
1244
+ * The hook callback to call after the original function was called
1245
+ */
1246
+ rsp?: InstrumentorHooksCallback;
1247
+ /**
1248
+ * The callback to call if the hook function causes an exception
1249
+ */
1250
+ hkErr?: InstrumentorHooksCallback;
1251
+ /**
1252
+ * The callback to call if the original function causes an exception, even if you
1253
+ * supply a callback the original exception will still be thrown
1254
+ */
1255
+ fnErr?: InstrumentorHooksCallback;
1256
+ }
1257
+
1258
+ declare interface ILoadedPlugin<T extends IPlugin> {
1259
+ plugin: T;
1260
+ }
1261
+
1163
1262
  export declare interface IMetricTelemetry extends IPartC {
1164
1263
  /**
1165
1264
  * @description (required) - name of this metric
@@ -1278,6 +1377,12 @@ declare interface INotificationManager {
1278
1377
  perfEvent?(perfEvent: IPerfEvent): void;
1279
1378
  }
1280
1379
 
1380
+ /**
1381
+ * A callback function that will be called for the wrapped instrumentation function
1382
+ * before the original function is executed.
1383
+ */
1384
+ declare type InstrumentorHooksCallback = (funcArgs: IInstrumentCallDetails, ...orgArgs: any[]) => void;
1385
+
1281
1386
  declare class _InternalLogMessage {
1282
1387
  static dataType: string;
1283
1388
  message: string;
@@ -1622,7 +1727,7 @@ declare interface IProcessTelemetryContext {
1622
1727
  /**
1623
1728
  * Gets the named extension config
1624
1729
  */
1625
- getExtCfg: <T>(identifier: string, defaultValue?: T | any) => T;
1730
+ getExtCfg: <T>(identifier: string, defaultValue?: T | any, mergeDefault?: GetExtCfgMergeType) => T;
1626
1731
  /**
1627
1732
  * Gets the named config from either the named identifier extension or core config if neither exist then the
1628
1733
  * default value is returned
@@ -1630,7 +1735,7 @@ declare interface IProcessTelemetryContext {
1630
1735
  * @param field The config field name
1631
1736
  * @param defaultValue The default value to return if no defined config exists
1632
1737
  */
1633
- getConfig: (identifier: string, field: string, defaultValue?: number | string | boolean) => number | string | boolean;
1738
+ getConfig: (identifier: string, field: string, defaultValue?: number | string | boolean | string[] | RegExp[] | Function) => number | string | boolean | string[] | RegExp[] | Function;
1634
1739
  /**
1635
1740
  * Helper to allow plugins to check and possibly shortcut executing code only
1636
1741
  * required if there is a nextPlugin
@@ -1649,6 +1754,12 @@ declare interface IProcessTelemetryContext {
1649
1754
  * @param env - This is the current event being reported
1650
1755
  */
1651
1756
  processNext: (env: ITelemetryItem) => void;
1757
+ /**
1758
+ * Synchronously iterate over the context chain running the callback for each plugin, once
1759
+ * every plugin has been executed via the callback, any associated onComplete will be called.
1760
+ * @param callback - The function call for each plugin in the context chain
1761
+ */
1762
+ iterate: <T extends ITelemetryPlugin = ITelemetryPlugin>(callback: (plugin: T) => void) => void;
1652
1763
  /**
1653
1764
  * Create a new context using the core and config from the current instance
1654
1765
  * @param plugins - The execution order to process the plugins, if null or not supplied
@@ -1657,6 +1768,10 @@ declare interface IProcessTelemetryContext {
1657
1768
  * order then the next plugin will be NOT set.
1658
1769
  */
1659
1770
  createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryContext;
1771
+ /**
1772
+ * Set the function to call when the current chain has executed all processNext or unloadNext items.
1773
+ */
1774
+ onComplete: (onComplete: () => void) => void;
1660
1775
  }
1661
1776
 
1662
1777
  declare interface IRequestContext {
@@ -1798,6 +1913,10 @@ declare interface IStackDetails {
1798
1913
  obj: string[];
1799
1914
  }
1800
1915
 
1916
+ declare interface ITelemetryInitializerHandler {
1917
+ remove(): void;
1918
+ }
1919
+
1801
1920
  /**
1802
1921
  * Telemety item supported in Core
1803
1922
  */
@@ -2062,6 +2181,8 @@ declare interface Tags {
2062
2181
  [key: string]: any;
2063
2182
  }
2064
2183
 
2184
+ declare type TelemetryInitializerFunction = <T extends ITelemetryItem>(item: T) => boolean | void;
2185
+
2065
2186
  declare interface XDomainRequest extends XMLHttpRequestEventTarget {
2066
2187
  readonly responseText: string;
2067
2188
  send(payload: string): void;
package/dist-esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript Web SDK - Basic, 2.7.4-nightly.2202-07
2
+ * Application Insights JavaScript Web SDK - Basic, 2.8.0-beta.2202-06
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microsoft/applicationinsights-web-basic",
3
- "version": "2.7.4-nightly.2202-07",
3
+ "version": "2.8.0-beta.2202-06",
4
4
  "description": "Microsoft Application Insights Javascript SDK core and channel",
5
5
  "homepage": "https://github.com/microsoft/ApplicationInsights-JS#readme",
6
6
  "author": "Microsoft Application Insights Team",
@@ -49,12 +49,12 @@
49
49
  "dependencies": {
50
50
  "@microsoft/dynamicproto-js": "^1.1.4",
51
51
  "@microsoft/applicationinsights-shims": "2.0.1",
52
- "@microsoft/applicationinsights-common": "2.7.4-nightly.2202-07",
53
- "@microsoft/applicationinsights-channel-js": "2.7.4-nightly.2202-07",
54
- "@microsoft/applicationinsights-core-js": "2.7.4-nightly.2202-07"
52
+ "@microsoft/applicationinsights-common": "2.8.0-beta.2202-06",
53
+ "@microsoft/applicationinsights-channel-js": "2.8.0-beta.2202-06",
54
+ "@microsoft/applicationinsights-core-js": "2.8.0-beta.2202-06"
55
55
  },
56
56
  "license": "MIT",
57
57
  "publishConfig": {
58
- "tag": "nightly"
58
+ "tag": "beta"
59
59
  }
60
60
  }
@@ -1,26 +0,0 @@
1
- {
2
- "name": "aib",
3
- "version": "2.7.4-nightly.2202-07",
4
- "ext": {
5
- "@js": {
6
- "file": "aib.2.7.4-nightly.2202-07.js",
7
- "type": "text/javascript; charset=utf-8",
8
- "integrity": "sha256-uZFixkFKDfp/yuASr5NCtxq+rADpKYtGz5+huJm8ioc= sha384-dsMjf5qDTsV5XktzwRip1XFM8v7vsrh+A5/+8yNvxZuRDaD34Ql8dYTa+XjZzACK sha512-msqcJ+9A4Wf2xQX/jsryL8c0JVlAjJ6jm5MEijsCzlUjjoiWsKS6fGdumhIj6QTYeAZSYW1kDSc71mDvTX7xAA==",
9
- "hashes": {
10
- "sha256": "uZFixkFKDfp/yuASr5NCtxq+rADpKYtGz5+huJm8ioc=",
11
- "sha384": "dsMjf5qDTsV5XktzwRip1XFM8v7vsrh+A5/+8yNvxZuRDaD34Ql8dYTa+XjZzACK",
12
- "sha512": "msqcJ+9A4Wf2xQX/jsryL8c0JVlAjJ6jm5MEijsCzlUjjoiWsKS6fGdumhIj6QTYeAZSYW1kDSc71mDvTX7xAA=="
13
- }
14
- },
15
- "@min.js": {
16
- "file": "aib.2.7.4-nightly.2202-07.min.js",
17
- "type": "text/javascript; charset=utf-8",
18
- "integrity": "sha256-3dUQEYCzw6rQG5padGI0LD4l84Ic66jVd9Re3DNDcf0= sha384-T6ikJZeqWP02OurjtHaGKXKcJOuQmSIbwaR996nWtNK8sPATArtmEPQMme420UpM sha512-3Fcha/TeduvnP20SXmUPxqYepiNDsvvUz3rCsxPN/VOQpefohTDCBib/ehAHjFOkc48sUkrlPicPJ2+pLDk7lw==",
19
- "hashes": {
20
- "sha256": "3dUQEYCzw6rQG5padGI0LD4l84Ic66jVd9Re3DNDcf0=",
21
- "sha384": "T6ikJZeqWP02OurjtHaGKXKcJOuQmSIbwaR996nWtNK8sPATArtmEPQMme420UpM",
22
- "sha512": "3Fcha/TeduvnP20SXmUPxqYepiNDsvvUz3rCsxPN/VOQpefohTDCBib/ehAHjFOkc48sUkrlPicPJ2+pLDk7lw=="
23
- }
24
- }
25
- }
26
- }