@microsoft/applicationinsights-core-js 2.7.5-nightly.2203-01 → 2.8.0-beta.2203-01

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 (108) hide show
  1. package/browser/applicationinsights-core-js.integrity.json +9 -9
  2. package/browser/applicationinsights-core-js.js +860 -457
  3. package/browser/applicationinsights-core-js.js.map +1 -1
  4. package/browser/applicationinsights-core-js.min.js +2 -2
  5. package/browser/applicationinsights-core-js.min.js.map +1 -1
  6. package/dist/applicationinsights-core-js.api.json +1193 -267
  7. package/dist/applicationinsights-core-js.api.md +54 -14
  8. package/dist/applicationinsights-core-js.d.ts +133 -45
  9. package/dist/applicationinsights-core-js.js +860 -457
  10. package/dist/applicationinsights-core-js.js.map +1 -1
  11. package/dist/applicationinsights-core-js.min.js +2 -2
  12. package/dist/applicationinsights-core-js.min.js.map +1 -1
  13. package/dist/applicationinsights-core-js.rollup.d.ts +133 -45
  14. package/dist-esm/JavaScriptSDK/AppInsightsCore.js +3 -69
  15. package/dist-esm/JavaScriptSDK/AppInsightsCore.js.map +1 -1
  16. package/dist-esm/JavaScriptSDK/BaseCore.js +237 -82
  17. package/dist-esm/JavaScriptSDK/BaseCore.js.map +1 -1
  18. package/dist-esm/JavaScriptSDK/BaseTelemetryPlugin.js +45 -19
  19. package/dist-esm/JavaScriptSDK/BaseTelemetryPlugin.js.map +1 -1
  20. package/dist-esm/JavaScriptSDK/ChannelController.js +155 -87
  21. package/dist-esm/JavaScriptSDK/ChannelController.js.map +1 -1
  22. package/dist-esm/JavaScriptSDK/Constants.js +1 -1
  23. package/dist-esm/JavaScriptSDK/CookieMgr.js +1 -1
  24. package/dist-esm/JavaScriptSDK/CoreUtils.js +2 -27
  25. package/dist-esm/JavaScriptSDK/CoreUtils.js.map +1 -1
  26. package/dist-esm/JavaScriptSDK/DbgExtensionUtils.js +1 -1
  27. package/dist-esm/JavaScriptSDK/DiagnosticLogger.js +1 -1
  28. package/dist-esm/JavaScriptSDK/EnvUtils.js +6 -6
  29. package/dist-esm/JavaScriptSDK/EnvUtils.js.map +1 -1
  30. package/dist-esm/JavaScriptSDK/HelperFuncs.js +51 -11
  31. package/dist-esm/JavaScriptSDK/HelperFuncs.js.map +1 -1
  32. package/dist-esm/JavaScriptSDK/InstrumentHooks.js +3 -1
  33. package/dist-esm/JavaScriptSDK/InstrumentHooks.js.map +1 -1
  34. package/dist-esm/JavaScriptSDK/NotificationManager.js +34 -36
  35. package/dist-esm/JavaScriptSDK/NotificationManager.js.map +1 -1
  36. package/dist-esm/JavaScriptSDK/PerfManager.js +1 -1
  37. package/dist-esm/JavaScriptSDK/ProcessTelemetryContext.js +289 -119
  38. package/dist-esm/JavaScriptSDK/ProcessTelemetryContext.js.map +1 -1
  39. package/dist-esm/JavaScriptSDK/RandomHelper.js +29 -4
  40. package/dist-esm/JavaScriptSDK/RandomHelper.js.map +1 -1
  41. package/dist-esm/JavaScriptSDK/TelemetryHelpers.js +2 -2
  42. package/dist-esm/JavaScriptSDK/TelemetryHelpers.js.map +1 -1
  43. package/dist-esm/JavaScriptSDK/TelemetryInitializerPlugin.js +82 -0
  44. package/dist-esm/JavaScriptSDK/TelemetryInitializerPlugin.js.map +1 -0
  45. package/dist-esm/JavaScriptSDK.Enums/EventsDiscardedReason.js +1 -1
  46. package/dist-esm/JavaScriptSDK.Enums/LoggingEnums.js +1 -1
  47. package/dist-esm/JavaScriptSDK.Enums/SendRequestReason.js +1 -1
  48. package/dist-esm/JavaScriptSDK.Interfaces/IAppInsightsCore.js +1 -2
  49. package/dist-esm/JavaScriptSDK.Interfaces/IAppInsightsCore.js.map +1 -1
  50. package/dist-esm/JavaScriptSDK.Interfaces/IChannelControls.js +1 -1
  51. package/dist-esm/JavaScriptSDK.Interfaces/IConfiguration.js +1 -1
  52. package/dist-esm/JavaScriptSDK.Interfaces/ICookieMgr.js +1 -1
  53. package/dist-esm/JavaScriptSDK.Interfaces/IDbgExtension.js +1 -1
  54. package/dist-esm/JavaScriptSDK.Interfaces/IDiagnosticLogger.js +1 -1
  55. package/dist-esm/JavaScriptSDK.Interfaces/IInstrumentHooks.js +1 -1
  56. package/dist-esm/JavaScriptSDK.Interfaces/INotificationListener.js +1 -1
  57. package/dist-esm/JavaScriptSDK.Interfaces/INotificationManager.js +1 -1
  58. package/dist-esm/JavaScriptSDK.Interfaces/IPerfEvent.js +1 -1
  59. package/dist-esm/JavaScriptSDK.Interfaces/IPerfManager.js +1 -1
  60. package/dist-esm/JavaScriptSDK.Interfaces/IProcessTelemetryContext.js +1 -1
  61. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryInitializers.js +6 -0
  62. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryInitializers.js.map +1 -0
  63. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryItem.js +1 -1
  64. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryPlugin.js +1 -1
  65. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryPluginChain.js +1 -1
  66. package/dist-esm/applicationinsights-core-js.js +4 -4
  67. package/dist-esm/applicationinsights-core-js.js.map +1 -1
  68. package/package.json +2 -2
  69. package/src/JavaScriptSDK/AppInsightsCore.ts +2 -101
  70. package/src/JavaScriptSDK/BaseCore.ts +330 -100
  71. package/src/JavaScriptSDK/BaseTelemetryPlugin.ts +69 -32
  72. package/src/JavaScriptSDK/ChannelController.ts +175 -103
  73. package/src/JavaScriptSDK/CoreUtils.ts +1 -28
  74. package/src/JavaScriptSDK/EnvUtils.ts +5 -5
  75. package/src/JavaScriptSDK/HelperFuncs.ts +57 -14
  76. package/src/JavaScriptSDK/InstrumentHooks.ts +3 -1
  77. package/src/JavaScriptSDK/NotificationManager.ts +32 -31
  78. package/src/JavaScriptSDK/PerfManager.ts +1 -1
  79. package/src/JavaScriptSDK/ProcessTelemetryContext.ts +350 -133
  80. package/src/JavaScriptSDK/RandomHelper.ts +34 -3
  81. package/src/JavaScriptSDK/TelemetryHelpers.ts +4 -6
  82. package/src/JavaScriptSDK/TelemetryInitializerPlugin.ts +119 -0
  83. package/src/JavaScriptSDK.Interfaces/IAppInsightsCore.ts +17 -1
  84. package/src/JavaScriptSDK.Interfaces/IChannelControls.ts +7 -3
  85. package/src/JavaScriptSDK.Interfaces/IInstrumentHooks.ts +5 -0
  86. package/src/JavaScriptSDK.Interfaces/IProcessTelemetryContext.ts +23 -5
  87. package/src/JavaScriptSDK.Interfaces/ITelemetryInitializers.ts +16 -0
  88. package/src/JavaScriptSDK.Interfaces/ITelemetryPlugin.ts +1 -1
  89. package/types/JavaScriptSDK/AppInsightsCore.d.ts +0 -21
  90. package/types/JavaScriptSDK/BaseCore.d.ts +30 -1
  91. package/types/JavaScriptSDK/BaseTelemetryPlugin.d.ts +13 -11
  92. package/types/JavaScriptSDK/ChannelController.d.ts +12 -17
  93. package/types/JavaScriptSDK/CoreUtils.d.ts +0 -6
  94. package/types/JavaScriptSDK/HelperFuncs.d.ts +14 -5
  95. package/types/JavaScriptSDK/ProcessTelemetryContext.d.ts +49 -3
  96. package/types/JavaScriptSDK/RandomHelper.d.ts +6 -0
  97. package/types/JavaScriptSDK/TelemetryHelpers.d.ts +3 -3
  98. package/types/JavaScriptSDK/TelemetryInitializerPlugin.d.ts +23 -0
  99. package/types/JavaScriptSDK.Interfaces/IAppInsightsCore.d.ts +15 -0
  100. package/types/JavaScriptSDK.Interfaces/IChannelControls.d.ts +7 -3
  101. package/types/JavaScriptSDK.Interfaces/IInstrumentHooks.d.ts +4 -0
  102. package/types/JavaScriptSDK.Interfaces/IProcessTelemetryContext.d.ts +18 -3
  103. package/types/JavaScriptSDK.Interfaces/ITelemetryInitializers.d.ts +13 -0
  104. package/types/applicationinsights-core-js.d.ts +5 -4
  105. package/dist-esm/JavaScriptSDK/TelemetryPluginChain.js +0 -76
  106. package/dist-esm/JavaScriptSDK/TelemetryPluginChain.js.map +0 -1
  107. package/src/JavaScriptSDK/TelemetryPluginChain.ts +0 -120
  108. package/types/JavaScriptSDK/TelemetryPluginChain.d.ts +0 -32
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Microsoft Application Insights Core Javascript SDK, 2.7.5-nightly.2203-01
2
+ * Microsoft Application Insights Core Javascript SDK, 2.8.0-beta.2203-01
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  *
5
5
  * Microsoft Application Insights Team
@@ -70,26 +70,6 @@ export declare class AppInsightsCore extends BaseCore implements IAppInsightsCor
70
70
  constructor();
71
71
  initialize(config: IConfiguration, extensions: IPlugin[], logger?: IDiagnosticLogger, notificationManager?: INotificationManager): void;
72
72
  track(telemetryItem: ITelemetryItem): void;
73
- /**
74
- * Adds a notification listener. The SDK calls methods on the listener when an appropriate notification is raised.
75
- * The added plugins must raise notifications. If the plugins do not implement the notifications, then no methods will be
76
- * called.
77
- * @param {INotificationListener} listener - An INotificationListener object.
78
- */
79
- addNotificationListener(listener: INotificationListener): void;
80
- /**
81
- * Removes all instances of the listener.
82
- * @param {INotificationListener} listener - INotificationListener to remove.
83
- */
84
- removeNotificationListener(listener: INotificationListener): void;
85
- /**
86
- * Periodically check logger.queue for
87
- */
88
- pollInternalLogs(eventName?: string): number;
89
- /**
90
- * Periodically check logger.queue for
91
- */
92
- stopPollingInternalLogs(): void;
93
73
  }
94
74
 
95
75
  export declare function areCookiesSupported(logger?: IDiagnosticLogger): any;
@@ -102,7 +82,7 @@ export declare function areCookiesSupported(logger?: IDiagnosticLogger): any;
102
82
  * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array. It can return -1 to break out of the loop
103
83
  * @param thisArg [Optional] An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
104
84
  */
105
- export declare function arrForEach<T>(arr: T[], callbackfn: (value: T, index?: number, array?: T[]) => void | number, thisArg?: any): void;
85
+ export declare function arrForEach<T = any>(arr: T[], callbackfn: (value: T, index?: number, array?: T[]) => void | number, thisArg?: any): void;
106
86
 
107
87
  /**
108
88
  * Returns the index of the first occurrence of a value in an array. This helper exists to avoid adding a polyfil for older browsers
@@ -156,6 +136,18 @@ export declare class BaseCore implements IAppInsightsCore {
156
136
  track(telemetryItem: ITelemetryItem): void;
157
137
  getProcessTelContext(): IProcessTelemetryContext;
158
138
  getNotifyMgr(): INotificationManager;
139
+ /**
140
+ * Adds a notification listener. The SDK calls methods on the listener when an appropriate notification is raised.
141
+ * The added plugins must raise notifications. If the plugins do not implement the notifications, then no methods will be
142
+ * called.
143
+ * @param {INotificationListener} listener - An INotificationListener object.
144
+ */
145
+ addNotificationListener(listener: INotificationListener): void;
146
+ /**
147
+ * Removes all instances of the listener.
148
+ * @param {INotificationListener} listener - INotificationListener to remove.
149
+ */
150
+ removeNotificationListener(listener: INotificationListener): void;
159
151
  /**
160
152
  * Get the current cookie manager for this instance
161
153
  */
@@ -168,6 +160,21 @@ export declare class BaseCore implements IAppInsightsCore {
168
160
  getPerfMgr(): IPerfManager;
169
161
  setPerfMgr(perfMgr: IPerfManager): void;
170
162
  eventCnt(): number;
163
+ /**
164
+ * Periodically check logger.queue for
165
+ */
166
+ pollInternalLogs(eventName?: string): number;
167
+ /**
168
+ * Periodically check logger.queue for
169
+ */
170
+ stopPollingInternalLogs(): void;
171
+ /**
172
+ * Add a telemetry processor to decorate or drop telemetry events.
173
+ * @param telemetryInitializer - The Telemetry Initializer function
174
+ * @returns - A ITelemetryInitializerHandler to enable the initializer to be removed
175
+ */
176
+ addTelemetryInitializer(telemetryInitializer: TelemetryInitializerFunction): ITelemetryInitializerHandler | void;
177
+ getPlugin<T extends IPlugin = IPlugin>(pluginIdentifier: string): ILoadedPlugin<T>;
171
178
  protected releaseQueue(): void;
172
179
  }
173
180
 
@@ -177,6 +184,13 @@ export declare class BaseCore implements IAppInsightsCore {
177
184
  * implementation so that new default implementations can be added without breaking all plugins.
178
185
  */
179
186
  export declare abstract class BaseTelemetryPlugin implements ITelemetryPlugin {
187
+ identifier: string;
188
+ version?: string;
189
+ /**
190
+ * Holds the core instance that was used during initialization
191
+ */
192
+ core: IAppInsightsCore;
193
+ priority: number;
180
194
  /**
181
195
  * Call back for telemetry processing before it it is sent
182
196
  * @param env - This is the current event being reported
@@ -198,13 +212,6 @@ export declare abstract class BaseTelemetryPlugin implements ITelemetryPlugin {
198
212
  * Returns whether the plugin has been initialized
199
213
  */
200
214
  isInitialized: () => boolean;
201
- identifier: string;
202
- version?: string;
203
- /**
204
- * Holds the core instance that was used during initialization
205
- */
206
- core: IAppInsightsCore;
207
- priority: number;
208
215
  /**
209
216
  * Helper to return the current IProcessTelemetryContext, if the passed argument exists this just
210
217
  * returns that value (helps with minification for callers), otherwise it will return the configured
@@ -216,13 +223,14 @@ export declare abstract class BaseTelemetryPlugin implements ITelemetryPlugin {
216
223
  * Internal helper to allow setting of the internal initialized setting for inherited instances and unit testing
217
224
  */
218
225
  protected setInitialized: (isInitialized: boolean) => void;
219
- /**
220
- * Internal helper to initialize the instance
221
- */
222
- private _baseTelInit;
223
226
  constructor();
224
227
  initialize(config: IConfiguration, core: IAppInsightsCore, extensions: IPlugin[], pluginChain?: ITelemetryPluginChain): void;
225
228
  abstract processTelemetry(env: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
229
+ /**
230
+ * Add this hook so that it is automatically removed during unloading
231
+ * @param hooks - The single hook or an array of IInstrumentHook objects
232
+ */
233
+ protected _addHook(hooks: IInstrumentHook | IInstrumentHook[]): void;
226
234
  }
227
235
 
228
236
  /**
@@ -248,6 +256,14 @@ export declare function createClassFromInterface<T>(defaults?: T): new () => T;
248
256
 
249
257
  export declare function createCookieMgr(rootConfig?: IConfiguration, logger?: IDiagnosticLogger): ICookieMgr;
250
258
 
259
+ /**
260
+ * Creates a new Telemetry Item context with the current config, core and plugin execution chain
261
+ * @param plugins - The plugin instances that will be executed
262
+ * @param config - The current config
263
+ * @param core - The current core instance
264
+ */
265
+ export declare function createProcessTelemetryContext(telemetryChain: ITelemetryPluginChain, config: IConfiguration, core: IAppInsightsCore, startAt?: IPlugin): IProcessTelemetryContext;
266
+
251
267
  /**
252
268
  * Return the current time via the Date now() function (if available) and falls back to (new Date()).getTime() if now() is unavailable (IE8 or less)
253
269
  * https://caniuse.com/#search=Date.now
@@ -417,6 +433,12 @@ export declare function getDocument(): Document | null;
417
433
  */
418
434
  export declare function getExceptionName(object: any): string;
419
435
 
436
+ export declare const enum GetExtCfgMergeType {
437
+ None = 0,
438
+ MergeDefaultOnly = 1,
439
+ MergeDefaultFromRootOrDefault = 2
440
+ }
441
+
420
442
  /**
421
443
  * Get the current global performance manager that will be used with no performance manager is supplied.
422
444
  * @returns - The current default manager
@@ -575,12 +597,23 @@ export declare interface IAppInsightsCore extends IPerfManagerProvider {
575
597
  * @param {INotificationListener} listener - INotificationListener to remove.
576
598
  */
577
599
  removeNotificationListener?(listener: INotificationListener): void;
600
+ /**
601
+ * Add a telemetry processor to decorate or drop telemetry events.
602
+ * @param telemetryInitializer - The Telemetry Initializer function
603
+ * @returns - A ITelemetryInitializerHandler to enable the initializer to be removed
604
+ */
605
+ addTelemetryInitializer(telemetryInitializer: TelemetryInitializerFunction): ITelemetryInitializerHandler | void;
578
606
  pollInternalLogs?(eventName?: string): number;
579
607
  stopPollingInternalLogs?(): void;
580
608
  /**
581
609
  * Return a new instance of the IProcessTelemetryContext for processing events
582
610
  */
583
611
  getProcessTelContext(): IProcessTelemetryContext;
612
+ /**
613
+ * Find and return the (first) plugin with the specified identifier if present
614
+ * @param pluginIdentifier
615
+ */
616
+ getPlugin<T extends IPlugin = IPlugin>(pluginIdentifier: string): ILoadedPlugin<T>;
584
617
  }
585
618
 
586
619
  /**
@@ -601,10 +634,13 @@ export declare interface IChannelControls extends ITelemetryPlugin {
601
634
  teardown(): void;
602
635
  /**
603
636
  * Flush to send data immediately; channel should default to sending data asynchronously
604
- * @param async: send data asynchronously when true
605
- * @param callBack: if specified, notify caller when send is complete
637
+ * @param async - send data asynchronously when true
638
+ * @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.
639
+ * If the caller doesn't return true the caller should assume that it may never be called.
640
+ * @param sendReason - specify the reason that you are calling "flush" defaults to ManualFlush (1) if not specified
641
+ * @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
606
642
  */
607
- flush(async: boolean, callBack?: () => void): void;
643
+ flush(async: boolean, callBack?: (flushComplete?: boolean) => void, sendReason?: SendRequestReason): boolean | void;
608
644
  }
609
645
 
610
646
  /**
@@ -1149,6 +1185,10 @@ export declare interface IInstrumentCallDetails {
1149
1185
  * The error (exception) which occurred while executing the original method
1150
1186
  */
1151
1187
  err?: Error;
1188
+ /**
1189
+ * The Event object from (window.event) at the start of the original call
1190
+ */
1191
+ evt?: Event;
1152
1192
  }
1153
1193
 
1154
1194
  /**
@@ -1194,6 +1234,10 @@ export declare interface IInstrumentHooksCallbacks {
1194
1234
  fnErr?: InstrumentorHooksCallback;
1195
1235
  }
1196
1236
 
1237
+ declare interface ILoadedPlugin<T extends IPlugin> {
1238
+ plugin: T;
1239
+ }
1240
+
1197
1241
  /**
1198
1242
  * Initialize the queue of plugins
1199
1243
  * @param plugins - The array of plugins to initialize and setting of the next plugin
@@ -1201,7 +1245,7 @@ export declare interface IInstrumentHooksCallbacks {
1201
1245
  * @param core THe current core instance
1202
1246
  * @param extensions The extensions
1203
1247
  */
1204
- export declare function initializePlugins(processContext: ProcessTelemetryContext, extensions: IPlugin[]): void;
1248
+ export declare function initializePlugins(processContext: IProcessTelemetryContext, extensions: IPlugin[]): void;
1205
1249
 
1206
1250
  /**
1207
1251
  * An interface used for the notification listener.
@@ -1565,7 +1609,7 @@ export declare interface IProcessTelemetryContext {
1565
1609
  /**
1566
1610
  * Gets the named extension config
1567
1611
  */
1568
- getExtCfg: <T>(identifier: string, defaultValue?: T | any) => T;
1612
+ getExtCfg: <T>(identifier: string, defaultValue?: T | any, mergeDefault?: GetExtCfgMergeType) => T;
1569
1613
  /**
1570
1614
  * Gets the named config from either the named identifier extension or core config if neither exist then the
1571
1615
  * default value is returned
@@ -1573,7 +1617,7 @@ export declare interface IProcessTelemetryContext {
1573
1617
  * @param field The config field name
1574
1618
  * @param defaultValue The default value to return if no defined config exists
1575
1619
  */
1576
- getConfig: (identifier: string, field: string, defaultValue?: number | string | boolean) => number | string | boolean;
1620
+ getConfig: (identifier: string, field: string, defaultValue?: number | string | boolean | string[] | RegExp[] | Function) => number | string | boolean | string[] | RegExp[] | Function;
1577
1621
  /**
1578
1622
  * Helper to allow plugins to check and possibly shortcut executing code only
1579
1623
  * required if there is a nextPlugin
@@ -1592,6 +1636,12 @@ export declare interface IProcessTelemetryContext {
1592
1636
  * @param env - This is the current event being reported
1593
1637
  */
1594
1638
  processNext: (env: ITelemetryItem) => void;
1639
+ /**
1640
+ * Synchronously iterate over the context chain running the callback for each plugin, once
1641
+ * every plugin has been executed via the callback, any associated onComplete will be called.
1642
+ * @param callback - The function call for each plugin in the context chain
1643
+ */
1644
+ iterate: <T extends ITelemetryPlugin = ITelemetryPlugin>(callback: (plugin: T) => void) => void;
1595
1645
  /**
1596
1646
  * Create a new context using the core and config from the current instance
1597
1647
  * @param plugins - The execution order to process the plugins, if null or not supplied
@@ -1600,10 +1650,15 @@ export declare interface IProcessTelemetryContext {
1600
1650
  * order then the next plugin will be NOT set.
1601
1651
  */
1602
1652
  createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryContext;
1653
+ /**
1654
+ * Set the function to call when the current chain has executed all processNext or unloadNext items.
1655
+ */
1656
+ onComplete: (onComplete: () => void) => void;
1603
1657
  }
1604
1658
 
1605
1659
  /**
1606
- * Check if an object is of type Array
1660
+ * Check if an object is of type Array with optional generic T, the generic type is not validated
1661
+ * and exists to help with TypeScript validation only.
1607
1662
  */
1608
1663
  export declare let isArray: <T = any>(obj: any) => obj is Array<T>;
1609
1664
 
@@ -1695,6 +1750,19 @@ export declare function isUndefined(value: any): boolean;
1695
1750
  */
1696
1751
  export declare function isXhrSupported(): boolean;
1697
1752
 
1753
+ export declare interface ITelemetryInitializerContainer {
1754
+ /**
1755
+ * Add a telemetry processor to decorate or drop telemetry events.
1756
+ * @param telemetryInitializer - The Telemetry Initializer function
1757
+ * @returns - A ITelemetryInitializerHandler to enable the initializer to be removed
1758
+ */
1759
+ addTelemetryInitializer(telemetryInitializer: TelemetryInitializerFunction): ITelemetryInitializerHandler | void;
1760
+ }
1761
+
1762
+ export declare interface ITelemetryInitializerHandler {
1763
+ remove(): void;
1764
+ }
1765
+
1698
1766
  /**
1699
1767
  * Telemety item supported in Core
1700
1768
  */
@@ -1906,7 +1974,7 @@ export declare function objDefineAccessors<T>(target: any, prop: string, getProp
1906
1974
  * @param target The target object to find and process the keys
1907
1975
  * @param callbackfn The function to call with the details
1908
1976
  */
1909
- export declare function objForEachKey(target: any, callbackfn: (name: string, value: any) => void): void;
1977
+ export declare function objForEachKey<T = any>(target: T, callbackfn: (name: string, value: T[keyof T]) => void): void;
1910
1978
 
1911
1979
  export declare const objFreeze: <T>(value: T) => T;
1912
1980
 
@@ -2008,6 +2076,10 @@ export declare class PerfManager implements IPerfManager {
2008
2076
  */
2009
2077
  export declare function perfNow(): number;
2010
2078
 
2079
+ /**
2080
+ * This class will be removed!
2081
+ * @deprecated use createProcessTelemetryContext() instead
2082
+ */
2011
2083
  export declare class ProcessTelemetryContext implements IProcessTelemetryContext {
2012
2084
  /**
2013
2085
  * Gets the current core config instance
@@ -2045,16 +2117,31 @@ export declare class ProcessTelemetryContext implements IProcessTelemetryContext
2045
2117
  */
2046
2118
  processNext: (env: ITelemetryItem) => void;
2047
2119
  /**
2120
+ * Synchronously iterate over the context chain running the callback for each plugin, once
2121
+ * every plugin has been executed via the callback, any associated onComplete will be called.
2122
+ * @param callback - The function call for each plugin in the context chain
2123
+ */
2124
+ iterate: <T extends ITelemetryPlugin = ITelemetryPlugin>(callback: (plugin: T) => void) => void;
2125
+ /**
2126
+ /**
2048
2127
  * Create a new context using the core and config from the current instance
2128
+ * @param plugins - The execution order to process the plugins, if null or not supplied
2129
+ * then the current execution order will be copied.
2130
+ * @param startAt - The plugin to start processing from, if missing from the execution
2131
+ * order then the next plugin will be NOT set.
2049
2132
  */
2050
2133
  createNew: (plugins?: IPlugin[] | ITelemetryPluginChain, startAt?: IPlugin) => IProcessTelemetryContext;
2134
+ /**
2135
+ * Set the function to call when the current chain has executed all processNext or unloadNext items.
2136
+ */
2137
+ onComplete: (onComplete: () => void) => void;
2051
2138
  /**
2052
2139
  * Creates a new Telemetry Item context with the current config, core and plugin execution chain
2053
2140
  * @param plugins - The plugin instances that will be executed
2054
2141
  * @param config - The current config
2055
2142
  * @param core - The current core instance
2056
2143
  */
2057
- constructor(plugins: IPlugin[] | ITelemetryPluginChain, config: IConfiguration, core: IAppInsightsCore, startAt?: IPlugin);
2144
+ constructor(pluginChain: ITelemetryPluginChain, config: IConfiguration, core: IAppInsightsCore, startAt?: IPlugin);
2058
2145
  }
2059
2146
 
2060
2147
  /**
@@ -2071,9 +2158,8 @@ export declare class ProcessTelemetryContext implements IProcessTelemetryContext
2071
2158
  * @param target - The target object to be assigned with the source properties and functions
2072
2159
  * @param source - The source object which will be assigned / called by setting / calling the targets proxies
2073
2160
  * @param chkSet - An optional callback to determine whether a specific property/function should be proxied
2074
- * @memberof Initialization
2075
2161
  */
2076
- export declare function proxyAssign(target: any, source: any, chkSet?: (name: string, isFunc?: boolean, source?: any, target?: any) => boolean): any;
2162
+ export declare function proxyAssign<T, S>(target: T, source: S, chkSet?: (name: string, isFunc?: boolean, source?: S, target?: T) => boolean): T;
2077
2163
 
2078
2164
  /**
2079
2165
  * generate a random 32-bit number (0x000000..0xFFFFFFFF) or (-0x80000000..0x7FFFFFFF), defaults un-unsigned.
@@ -2171,7 +2257,7 @@ export declare function setGblPerfMgr(perfManager: IPerfManager): void;
2171
2257
  */
2172
2258
  export declare function setValue<T, K extends keyof T>(target: T, field: K, value: T[K], valChk?: (value: T[K]) => boolean, srcChk?: (value: T[K]) => boolean): T[K];
2173
2259
 
2174
- export declare function sortPlugins(plugins: IPlugin[]): IPlugin[];
2260
+ export declare function sortPlugins<T = IPlugin>(plugins: T[]): T[];
2175
2261
 
2176
2262
  /**
2177
2263
  * A simple wrapper (for minification support) to check if the value contains the search string.
@@ -2217,6 +2303,8 @@ export declare interface Tags {
2217
2303
  [key: string]: any;
2218
2304
  }
2219
2305
 
2306
+ export declare type TelemetryInitializerFunction = <T extends ITelemetryItem>(item: T) => boolean | void;
2307
+
2220
2308
  export declare function throwError(message: string): never;
2221
2309
 
2222
2310
  /**
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Core, 2.7.5-nightly.2203-01
2
+ * Application Insights JavaScript SDK - Core, 2.8.0-beta.2203-01
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
  import { __extendsFn as __extends } from "@microsoft/applicationinsights-shims";
@@ -7,18 +7,14 @@ import { BaseCore } from "./BaseCore";
7
7
  import { EventsDiscardedReason } from "../JavaScriptSDK.Enums/EventsDiscardedReason";
8
8
  import { NotificationManager } from "./NotificationManager";
9
9
  import { doPerf } from "./PerfManager";
10
- import { _InternalLogMessage, DiagnosticLogger } from "./DiagnosticLogger";
10
+ import { DiagnosticLogger } from "./DiagnosticLogger";
11
11
  import dynamicProto from "@microsoft/dynamicproto-js";
12
- import { arrForEach, isNullOrUndefined, toISOString, throwError } from "./HelperFuncs";
12
+ import { isNullOrUndefined, throwError } from "./HelperFuncs";
13
13
  "use strict";
14
14
  var AppInsightsCore = /** @class */ (function (_super) {
15
15
  __extends(AppInsightsCore, _super);
16
16
  function AppInsightsCore() {
17
17
  var _this = _super.call(this) || this;
18
- /**
19
- * Internal log poller
20
- */
21
- var _internalLogPoller = 0;
22
18
  dynamicProto(AppInsightsCore, _this, function (_self, _base) {
23
19
  _self.initialize = function (config, extensions, logger, notificationManager) {
24
20
  _base.initialize(config, extensions, logger || new DiagnosticLogger(config), notificationManager || new NotificationManager(config));
@@ -35,64 +31,6 @@ var AppInsightsCore = /** @class */ (function (_super) {
35
31
  _base.track(telemetryItem);
36
32
  }, function () { return ({ item: telemetryItem }); }, !(telemetryItem.sync));
37
33
  };
38
- /**
39
- * Adds a notification listener. The SDK calls methods on the listener when an appropriate notification is raised.
40
- * The added plugins must raise notifications. If the plugins do not implement the notifications, then no methods will be
41
- * called.
42
- * @param {INotificationListener} listener - An INotificationListener object.
43
- */
44
- _self.addNotificationListener = function (listener) {
45
- var manager = _self.getNotifyMgr();
46
- if (manager) {
47
- manager.addNotificationListener(listener);
48
- }
49
- };
50
- /**
51
- * Removes all instances of the listener.
52
- * @param {INotificationListener} listener - INotificationListener to remove.
53
- */
54
- _self.removeNotificationListener = function (listener) {
55
- var manager = _self.getNotifyMgr();
56
- if (manager) {
57
- manager.removeNotificationListener(listener);
58
- }
59
- };
60
- /**
61
- * Periodically check logger.queue for log messages to be flushed
62
- */
63
- _self.pollInternalLogs = function (eventName) {
64
- var interval = _self.config.diagnosticLogInterval;
65
- if (!interval || !(interval > 0)) {
66
- interval = 10000;
67
- }
68
- if (_internalLogPoller) {
69
- _self.stopPollingInternalLogs();
70
- }
71
- _internalLogPoller = setInterval(function () {
72
- var queue = _self.logger ? _self.logger.queue : [];
73
- arrForEach(queue, function (logMessage) {
74
- var item = {
75
- name: eventName ? eventName : "InternalMessageId: " + logMessage.messageId,
76
- iKey: _self.config.instrumentationKey,
77
- time: toISOString(new Date()),
78
- baseType: _InternalLogMessage.dataType,
79
- baseData: { message: logMessage.message }
80
- };
81
- _self.track(item);
82
- });
83
- queue.length = 0;
84
- }, interval);
85
- return _internalLogPoller;
86
- };
87
- /**
88
- * Stop polling log messages from logger.queue
89
- */
90
- _self.stopPollingInternalLogs = function () {
91
- if (!_internalLogPoller)
92
- return;
93
- clearInterval(_internalLogPoller);
94
- _internalLogPoller = 0;
95
- };
96
34
  function _validateTelemetryItem(telemetryItem) {
97
35
  if (isNullOrUndefined(telemetryItem.name)) {
98
36
  _notifyInvalidEvent(telemetryItem);
@@ -110,10 +48,6 @@ var AppInsightsCore = /** @class */ (function (_super) {
110
48
  }
111
49
  // Removed Stub for AppInsightsCore.prototype.initialize.
112
50
  // Removed Stub for AppInsightsCore.prototype.track.
113
- // Removed Stub for AppInsightsCore.prototype.addNotificationListener.
114
- // Removed Stub for AppInsightsCore.prototype.removeNotificationListener.
115
- // Removed Stub for AppInsightsCore.prototype.pollInternalLogs.
116
- // Removed Stub for AppInsightsCore.prototype.stopPollingInternalLogs.
117
51
  return AppInsightsCore;
118
52
  }(BaseCore));
119
53
  export { AppInsightsCore };
@@ -1 +1 @@
1
- {"version":3,"file":"AppInsightsCore.js.map","sources":["AppInsightsCore.js"],"sourcesContent":["import { __extends } from \"tslib\";\r\nimport { BaseCore } from \"./BaseCore\";\r\nimport { EventsDiscardedReason } from \"../JavaScriptSDK.Enums/EventsDiscardedReason\";\r\nimport { NotificationManager } from \"./NotificationManager\";\r\nimport { doPerf } from \"./PerfManager\";\r\nimport { _InternalLogMessage, DiagnosticLogger } from \"./DiagnosticLogger\";\r\nimport dynamicProto from \"@microsoft/dynamicproto-js\";\r\nimport { arrForEach, isNullOrUndefined, toISOString, throwError } from \"./HelperFuncs\";\r\n\"use strict\";\r\nvar AppInsightsCore = /** @class */ (function (_super) {\r\n __extends(AppInsightsCore, _super);\r\n function AppInsightsCore() {\r\n var _this = _super.call(this) || this;\r\n /**\r\n * Internal log poller\r\n */\r\n var _internalLogPoller = 0;\r\n dynamicProto(AppInsightsCore, _this, function (_self, _base) {\r\n _self.initialize = function (config, extensions, logger, notificationManager) {\r\n _base.initialize(config, extensions, logger || new DiagnosticLogger(config), notificationManager || new NotificationManager(config));\r\n };\r\n _self.track = function (telemetryItem) {\r\n doPerf(_self.getPerfMgr(), function () { return \"AppInsightsCore:track\"; }, function () {\r\n if (telemetryItem === null) {\r\n _notifyInvalidEvent(telemetryItem);\r\n // throw error\r\n throwError(\"Invalid telemetry item\");\r\n }\r\n // do basic validation before sending it through the pipeline\r\n _validateTelemetryItem(telemetryItem);\r\n _base.track(telemetryItem);\r\n }, function () { return ({ item: telemetryItem }); }, !(telemetryItem.sync));\r\n };\r\n /**\r\n * Adds a notification listener. The SDK calls methods on the listener when an appropriate notification is raised.\r\n * The added plugins must raise notifications. If the plugins do not implement the notifications, then no methods will be\r\n * called.\r\n * @param {INotificationListener} listener - An INotificationListener object.\r\n */\r\n _self.addNotificationListener = function (listener) {\r\n var manager = _self.getNotifyMgr();\r\n if (manager) {\r\n manager.addNotificationListener(listener);\r\n }\r\n };\r\n /**\r\n * Removes all instances of the listener.\r\n * @param {INotificationListener} listener - INotificationListener to remove.\r\n */\r\n _self.removeNotificationListener = function (listener) {\r\n var manager = _self.getNotifyMgr();\r\n if (manager) {\r\n manager.removeNotificationListener(listener);\r\n }\r\n };\r\n /**\r\n * Periodically check logger.queue for log messages to be flushed\r\n */\r\n _self.pollInternalLogs = function (eventName) {\r\n var interval = _self.config.diagnosticLogInterval;\r\n if (!interval || !(interval > 0)) {\r\n interval = 10000;\r\n }\r\n if (_internalLogPoller) {\r\n _self.stopPollingInternalLogs();\r\n }\r\n _internalLogPoller = setInterval(function () {\r\n var queue = _self.logger ? _self.logger.queue : [];\r\n arrForEach(queue, function (logMessage) {\r\n var item = {\r\n name: eventName ? eventName : \"InternalMessageId: \" + logMessage.messageId,\r\n iKey: _self.config.instrumentationKey,\r\n time: toISOString(new Date()),\r\n baseType: _InternalLogMessage.dataType,\r\n baseData: { message: logMessage.message }\r\n };\r\n _self.track(item);\r\n });\r\n queue.length = 0;\r\n }, interval);\r\n return _internalLogPoller;\r\n };\r\n /**\r\n * Stop polling log messages from logger.queue\r\n */\r\n _self.stopPollingInternalLogs = function () {\r\n if (!_internalLogPoller)\r\n return;\r\n clearInterval(_internalLogPoller);\r\n _internalLogPoller = 0;\r\n };\r\n function _validateTelemetryItem(telemetryItem) {\r\n if (isNullOrUndefined(telemetryItem.name)) {\r\n _notifyInvalidEvent(telemetryItem);\r\n throw Error(\"telemetry name required\");\r\n }\r\n }\r\n function _notifyInvalidEvent(telemetryItem) {\r\n var manager = _self.getNotifyMgr();\r\n if (manager) {\r\n manager.eventsDiscarded([telemetryItem], EventsDiscardedReason.InvalidEvent);\r\n }\r\n }\r\n });\r\n return _this;\r\n }\r\n AppInsightsCore.prototype.initialize = function (config, extensions, logger, notificationManager) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n AppInsightsCore.prototype.track = function (telemetryItem) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n /**\r\n * Adds a notification listener. The SDK calls methods on the listener when an appropriate notification is raised.\r\n * The added plugins must raise notifications. If the plugins do not implement the notifications, then no methods will be\r\n * called.\r\n * @param {INotificationListener} listener - An INotificationListener object.\r\n */\r\n AppInsightsCore.prototype.addNotificationListener = function (listener) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n /**\r\n * Removes all instances of the listener.\r\n * @param {INotificationListener} listener - INotificationListener to remove.\r\n */\r\n AppInsightsCore.prototype.removeNotificationListener = function (listener) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n /**\r\n * Periodically check logger.queue for\r\n */\r\n AppInsightsCore.prototype.pollInternalLogs = function (eventName) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n return 0;\r\n };\r\n /**\r\n * Periodically check logger.queue for\r\n */\r\n AppInsightsCore.prototype.stopPollingInternalLogs = function () {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n return AppInsightsCore;\r\n}(BaseCore));\r\nexport { AppInsightsCore };\r\n//# sourceMappingURL=AppInsightsCore.js.map"],"names":[],"mappings":";;;;AAAA,gFAAkC;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;sEAkCM;AACN;AACA;AACA;AACA"}
1
+ {"version":3,"file":"AppInsightsCore.js.map","sources":["AppInsightsCore.js"],"sourcesContent":["import { __extends } from \"tslib\";\r\nimport { BaseCore } from \"./BaseCore\";\r\nimport { EventsDiscardedReason } from \"../JavaScriptSDK.Enums/EventsDiscardedReason\";\r\nimport { NotificationManager } from \"./NotificationManager\";\r\nimport { doPerf } from \"./PerfManager\";\r\nimport { DiagnosticLogger } from \"./DiagnosticLogger\";\r\nimport dynamicProto from \"@microsoft/dynamicproto-js\";\r\nimport { isNullOrUndefined, throwError } from \"./HelperFuncs\";\r\n\"use strict\";\r\nvar AppInsightsCore = /** @class */ (function (_super) {\r\n __extends(AppInsightsCore, _super);\r\n function AppInsightsCore() {\r\n var _this = _super.call(this) || this;\r\n dynamicProto(AppInsightsCore, _this, function (_self, _base) {\r\n _self.initialize = function (config, extensions, logger, notificationManager) {\r\n _base.initialize(config, extensions, logger || new DiagnosticLogger(config), notificationManager || new NotificationManager(config));\r\n };\r\n _self.track = function (telemetryItem) {\r\n doPerf(_self.getPerfMgr(), function () { return \"AppInsightsCore:track\"; }, function () {\r\n if (telemetryItem === null) {\r\n _notifyInvalidEvent(telemetryItem);\r\n // throw error\r\n throwError(\"Invalid telemetry item\");\r\n }\r\n // do basic validation before sending it through the pipeline\r\n _validateTelemetryItem(telemetryItem);\r\n _base.track(telemetryItem);\r\n }, function () { return ({ item: telemetryItem }); }, !(telemetryItem.sync));\r\n };\r\n function _validateTelemetryItem(telemetryItem) {\r\n if (isNullOrUndefined(telemetryItem.name)) {\r\n _notifyInvalidEvent(telemetryItem);\r\n throw Error(\"telemetry name required\");\r\n }\r\n }\r\n function _notifyInvalidEvent(telemetryItem) {\r\n var manager = _self.getNotifyMgr();\r\n if (manager) {\r\n manager.eventsDiscarded([telemetryItem], EventsDiscardedReason.InvalidEvent);\r\n }\r\n }\r\n });\r\n return _this;\r\n }\r\n AppInsightsCore.prototype.initialize = function (config, extensions, logger, notificationManager) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n AppInsightsCore.prototype.track = function (telemetryItem) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n return AppInsightsCore;\r\n}(BaseCore));\r\nexport { AppInsightsCore };\r\n//# sourceMappingURL=AppInsightsCore.js.map"],"names":[],"mappings":";;;;AAAA,gFAAkC;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;oDAKM;AACN;AACA;AACA;AACA"}