@microsoft/applicationinsights-web-basic 2.8.0-beta.2203-10 → 2.8.0-beta.2203-13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Microsoft.ApplicationInsights, 2.8.0-beta.2203-10
2
+ * Microsoft.ApplicationInsights, 2.8.0-beta.2203-13
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  *
5
5
  * Microsoft Application Insights Team
@@ -25,7 +25,6 @@ export declare class AppInsightsCore extends BaseCore implements IAppInsightsCor
25
25
  */
26
26
  export declare class ApplicationInsights {
27
27
  config: IConfiguration & IConfig;
28
- private core;
29
28
  /**
30
29
  * Creates an instance of ApplicationInsights.
31
30
  * @param {IConfiguration & IConfig} config
@@ -51,11 +50,51 @@ export declare class ApplicationInsights {
51
50
  * @memberof ApplicationInsights
52
51
  */
53
52
  flush(async?: boolean): void;
54
- private pollInternalLogs;
53
+ pollInternalLogs(): void;
55
54
  stopPollingInternalLogs(): void;
56
- private getSKUDefaults;
55
+ getSKUDefaults(): void;
56
+ /**
57
+ * Unload and Tear down the SDK and any initialized plugins, after calling this the SDK will be considered
58
+ * to be un-initialized and non-operational, re-initializing the SDK should only be attempted if the previous
59
+ * unload call return `true` stating that all plugins reported that they also unloaded, the recommended
60
+ * approach is to create a new instance and initialize that instance.
61
+ * This is due to possible unexpected side effects caused by plugins not supporting unload / teardown, unable
62
+ * to successfully remove any global references or they may just be completing the unload process asynchronously.
63
+ */
64
+ unload(isAsync?: boolean, unloadComplete?: () => void): void;
65
+ /**
66
+ * Find and return the (first) plugin with the specified identifier if present
67
+ * @param pluginIdentifier
68
+ */
69
+ getPlugin<T extends IPlugin = IPlugin>(pluginIdentifier: string): ILoadedPlugin<T>;
70
+ /**
71
+ * Add a new plugin to the installation
72
+ * @param plugin - The new plugin to add
73
+ * @param replaceExisting - should any existing plugin be replaced
74
+ * @param doAsync - Should the add be performed asynchronously
75
+ */
76
+ addPlugin<T extends IPlugin = ITelemetryPlugin>(plugin: T, replaceExisting: boolean, doAsync: boolean, addCb?: (added?: boolean) => void): void;
77
+ /**
78
+ * Returns the unique event namespace that should be used
79
+ */
80
+ evtNamespace(): string;
81
+ /**
82
+ * Add an unload handler that will be called when the SDK is being unloaded
83
+ * @param handler - the handler
84
+ */
85
+ addUnloadCb(handler: UnloadHandler): void;
57
86
  }
58
87
 
88
+ /**
89
+ * Performs the specified action for each element in an array. This helper exists to avoid adding a polyfil for older browsers
90
+ * that do not define Array.prototype.xxxx (eg. ES3 only, IE8) just in case any page checks for presence/absence of the prototype
91
+ * implementation. Note: For consistency this will not use the Array.prototype.xxxx implementation if it exists as this would
92
+ * cause a testing requirement to test with and without the implementations
93
+ * @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
94
+ * @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.
95
+ */
96
+ export declare function arrForEach<T = any>(arr: T[], callbackfn: (value: T, index?: number, array?: T[]) => undefined | void | number, thisArg?: any): void;
97
+
59
98
  declare class BaseCore implements IAppInsightsCore {
60
99
  static defaultConfig: IConfiguration;
61
100
  config: IConfiguration;
@@ -279,7 +318,7 @@ declare const enum eDistributedTracingModes {
279
318
  W3C = 2
280
319
  }
281
320
 
282
- declare const enum _eInternalMessageId {
321
+ export declare const enum _eInternalMessageId {
283
322
  BrowserDoesNotSupportLocalStorage = 0,
284
323
  BrowserCannotReadLocalStorage = 1,
285
324
  BrowserCannotReadSessionStorage = 2,
@@ -605,7 +644,7 @@ declare interface IBaseProcessingContext {
605
644
  * @param that - The "this" value to use for the onComplete call, if not provided or undefined defaults to the current context
606
645
  * @param args - Any additional arguments to pass to the onComplete function
607
646
  */
608
- onComplete: (onComplete: Function, that?: any, ...args: any[]) => void;
647
+ onComplete: (onComplete: () => void, that?: any, ...args: any[]) => void;
609
648
  /**
610
649
  * Create a new context using the core and config from the current instance, returns a new instance of the same type
611
650
  * @param plugins - The execution order to process the plugins, if null or not supplied
@@ -1552,7 +1591,7 @@ declare interface IInstrumentHooksCallbacks {
1552
1591
  fnErr?: InstrumentorHooksCallback;
1553
1592
  }
1554
1593
 
1555
- declare interface ILoadedPlugin<T extends IPlugin> {
1594
+ export declare interface ILoadedPlugin<T extends IPlugin> {
1556
1595
  plugin: T;
1557
1596
  /**
1558
1597
  * Identifies whether the plugin is enabled and can process events. This is slightly different from isInitialized as the plugin may be initialized but disabled
@@ -1704,7 +1743,7 @@ declare class _InternalLogMessage {
1704
1743
  /**
1705
1744
  * Internal message ID. Please create a new one for every conceptually different message. Please keep alphabetically ordered
1706
1745
  */
1707
- declare const _InternalMessageId: {
1746
+ export declare const _InternalMessageId: {
1708
1747
  BrowserDoesNotSupportLocalStorage: number;
1709
1748
  BrowserCannotReadLocalStorage: number;
1710
1749
  BrowserCannotReadSessionStorage: number;
@@ -1789,7 +1828,7 @@ declare const _InternalMessageId: {
1789
1828
  InMemoryStorageBufferFull: number;
1790
1829
  };
1791
1830
 
1792
- declare type _InternalMessageId = number | _eInternalMessageId;
1831
+ export declare type _InternalMessageId = number | _eInternalMessageId;
1793
1832
 
1794
1833
  export declare interface IPageViewPerformanceTelemetry extends IPartC {
1795
1834
  /**
@@ -1988,7 +2027,7 @@ declare interface IPerfManagerProvider {
1988
2027
  setPerfMgr(perfMgr: IPerfManager): void;
1989
2028
  }
1990
2029
 
1991
- declare interface IPlugin {
2030
+ export declare interface IPlugin {
1992
2031
  /**
1993
2032
  * Initialize plugin loaded by SDK
1994
2033
  * @param config - The config for the plugin to use
@@ -2219,6 +2258,8 @@ declare interface ISerializable {
2219
2258
  aiDataContract: any;
2220
2259
  }
2221
2260
 
2261
+ export declare function isNullOrUndefined(value: any): value is null | undefined;
2262
+
2222
2263
  declare interface IStackDetails {
2223
2264
  src: string;
2224
2265
  obj: string[];
@@ -2277,7 +2318,7 @@ export declare interface ITelemetryItem {
2277
2318
  /**
2278
2319
  * Configuration provided to SDK core
2279
2320
  */
2280
- declare interface ITelemetryPlugin extends ITelemetryProcessor, IPlugin {
2321
+ export declare interface ITelemetryPlugin extends ITelemetryProcessor, IPlugin {
2281
2322
  /**
2282
2323
  * Set next extension for telemetry processing, this is not optional as plugins should use the
2283
2324
  * processNext() function of the passed IProcessTelemetryContext instead. It is being kept for
@@ -2386,6 +2427,15 @@ declare const LoggingSeverity: {
2386
2427
 
2387
2428
  declare type LoggingSeverity = number | eLoggingSeverity;
2388
2429
 
2430
+ /**
2431
+ * Creates proxy functions on the target which internally will call the source version with all arguments passed to the target method.
2432
+ *
2433
+ * @param target - The target object to be assigned with the source properties and functions
2434
+ * @param source - The source object which will be assigned / called by setting / calling the targets proxies
2435
+ * @param functionsToProxy - An array of function names that will be proxied on the target
2436
+ */
2437
+ export declare function proxyFunctions<T, S>(target: T, source: S | (() => S), functionsToProxy: (keyof S)[], overwriteTarget?: boolean): T;
2438
+
2389
2439
  export declare class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
2390
2440
  static constructEnvelope(orig: ITelemetryItem, iKey: string, logger: IDiagnosticLogger, convertUndefined?: any): IEnvelope;
2391
2441
  readonly priority: number;
@@ -2430,7 +2480,6 @@ export declare class Sender extends BaseTelemetryPlugin implements IChannelContr
2430
2480
  * Will not flush if the Send has been paused.
2431
2481
  */
2432
2482
  onunloadFlush(): void;
2433
- teardown(): void;
2434
2483
  initialize(config: IConfiguration & IConfig, core: IAppInsightsCore, extensions: IPlugin[], pluginChain?: ITelemetryPluginChain): void;
2435
2484
  processTelemetry(telemetryItem: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
2436
2485
  /**
@@ -2472,7 +2521,7 @@ declare type SenderFunction = (payload: string[], isAsync: boolean) => void;
2472
2521
  /**
2473
2522
  * The EventsDiscardedReason enumeration contains a set of values that specify the reason for discarding an event.
2474
2523
  */
2475
- declare const enum SendRequestReason {
2524
+ export declare const enum SendRequestReason {
2476
2525
  /**
2477
2526
  * No specific reason was specified
2478
2527
  */
@@ -2575,6 +2624,8 @@ declare const enum TelemetryUpdateReason {
2575
2624
  PluginRemoved = 32
2576
2625
  }
2577
2626
 
2627
+ export declare function throwError(message: string): never;
2628
+
2578
2629
  declare type UnloadHandler = (itemCtx: IProcessTelemetryUnloadContext, unloadState: ITelemetryUnloadState) => void;
2579
2630
 
2580
2631
  declare interface XDomainRequest extends XMLHttpRequestEventTarget {
package/dist-esm/index.js CHANGED
@@ -1,12 +1,12 @@
1
1
  /*
2
- * Application Insights JavaScript Web SDK - Basic, 2.8.0-beta.2203-10
2
+ * Application Insights JavaScript Web SDK - Basic, 2.8.0-beta.2203-13
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
6
6
 
7
- import { AppInsightsCore, isNullOrUndefined, arrForEach, throwError } from "@microsoft/applicationinsights-core-js";
7
+ import dynamicProto from "@microsoft/dynamicproto-js";
8
+ import { AppInsightsCore, isNullOrUndefined, throwError, proxyFunctions } from "@microsoft/applicationinsights-core-js";
8
9
  import { Sender } from "@microsoft/applicationinsights-channel-js";
9
- "use strict";
10
10
  /**
11
11
  * @export
12
12
  * @class ApplicationInsights
@@ -18,69 +18,59 @@ var ApplicationInsights = /** @class */ (function () {
18
18
  * @memberof ApplicationInsights
19
19
  */
20
20
  function ApplicationInsights(config) {
21
+ var core = new AppInsightsCore();
21
22
  // initialize the queue and config in case they are undefined
22
23
  if (isNullOrUndefined(config) ||
23
24
  isNullOrUndefined(config.instrumentationKey)) {
24
25
  throwError("Invalid input configuration");
25
26
  }
26
- this.config = config;
27
- this.getSKUDefaults();
28
- this.initialize();
29
- }
30
- /**
31
- * Initialize this instance of ApplicationInsights
32
- *
33
- * @memberof ApplicationInsights
34
- */
35
- ApplicationInsights.prototype.initialize = function () {
36
- this.core = new AppInsightsCore();
37
- var extensions = [];
38
- var appInsightsChannel = new Sender();
39
- extensions.push(appInsightsChannel);
40
- // initialize core
41
- this.core.initialize(this.config, extensions);
42
- // initialize extensions
43
- appInsightsChannel.initialize(this.config, this.core, extensions);
44
- this.pollInternalLogs();
45
- };
46
- /**
47
- * Send a manually constructed custom event
48
- *
49
- * @param {ITelemetryItem} item
50
- * @memberof ApplicationInsights
51
- */
52
- ApplicationInsights.prototype.track = function (item) {
53
- this.core.track(item);
54
- };
55
- /**
56
- * Immediately send all batched telemetry
57
- * @param {boolean} [async=true]
58
- * @memberof ApplicationInsights
59
- */
60
- ApplicationInsights.prototype.flush = function (async) {
61
- if (async === void 0) { async = true; }
62
- arrForEach(this.core.getTransmissionControls(), function (controls) {
63
- arrForEach(controls, function (plugin) {
64
- async
65
- ? plugin.flush()
66
- : plugin.triggerSend(async, null, 1 /* ManualFlush */);
67
- });
27
+ dynamicProto(ApplicationInsights, this, function (_self) {
28
+ _self.config = config;
29
+ _self.getSKUDefaults();
30
+ _initialize();
31
+ _self.initialize = _initialize;
32
+ _self.getSKUDefaults = function () {
33
+ _self.config.diagnosticLogInterval =
34
+ _self.config.diagnosticLogInterval && _self.config.diagnosticLogInterval > 0 ? _self.config.diagnosticLogInterval : 10000;
35
+ };
36
+ proxyFunctions(_self, core, [
37
+ "track",
38
+ "flush",
39
+ "pollInternalLogs",
40
+ "stopPollingInternalLogs",
41
+ "unload",
42
+ "getPlugin",
43
+ "addPlugin",
44
+ "evtNamespace",
45
+ "addUnloadCb"
46
+ ]);
47
+ function _initialize() {
48
+ var extensions = [];
49
+ var appInsightsChannel = new Sender();
50
+ extensions.push(appInsightsChannel);
51
+ // initialize core
52
+ core.initialize(this.config, extensions);
53
+ // initialize extensions
54
+ appInsightsChannel.initialize(this.config, core, extensions);
55
+ core.pollInternalLogs();
56
+ }
68
57
  });
69
- };
70
- ApplicationInsights.prototype.pollInternalLogs = function () {
71
- this.core.pollInternalLogs();
72
- };
73
- ApplicationInsights.prototype.stopPollingInternalLogs = function () {
74
- this.core.stopPollingInternalLogs();
75
- };
76
- ApplicationInsights.prototype.getSKUDefaults = function () {
77
- this.config.diagnosticLogInterval =
78
- this.config.diagnosticLogInterval && this.config.diagnosticLogInterval > 0 ? this.config.diagnosticLogInterval : 10000;
79
- };
58
+ }
59
+ // Removed Stub for ApplicationInsights.prototype.initialize.
60
+ // Removed Stub for ApplicationInsights.prototype.track.
61
+ // Removed Stub for ApplicationInsights.prototype.flush.
62
+ // Removed Stub for ApplicationInsights.prototype.pollInternalLogs.
63
+ // Removed Stub for ApplicationInsights.prototype.stopPollingInternalLogs.
64
+ // Removed Stub for ApplicationInsights.prototype.getSKUDefaults.
65
+ // Removed Stub for ApplicationInsights.prototype.unload.
66
+ // Removed Stub for ApplicationInsights.prototype.getPlugin.
67
+ // Removed Stub for ApplicationInsights.prototype.addPlugin.
68
+ // Removed Stub for ApplicationInsights.prototype.evtNamespace.
69
+ // Removed Stub for ApplicationInsights.prototype.addUnloadCb.
80
70
  return ApplicationInsights;
81
71
  }());
82
72
  export { ApplicationInsights };
83
- export { AppInsightsCore, CoreUtils } from "@microsoft/applicationinsights-core-js";
73
+ export { AppInsightsCore, CoreUtils, arrForEach, _InternalMessageId, isNullOrUndefined, throwError, proxyFunctions } from "@microsoft/applicationinsights-core-js";
84
74
  export { SeverityLevel } from "@microsoft/applicationinsights-common";
85
75
  export { Sender } from "@microsoft/applicationinsights-channel-js";
86
76
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js.map","sources":["index.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\nimport { AppInsightsCore, isNullOrUndefined, arrForEach, throwError } from \"@microsoft/applicationinsights-core-js\";\r\nimport { Sender } from \"@microsoft/applicationinsights-channel-js\";\r\n\"use strict\";\r\n/**\r\n * @export\r\n * @class ApplicationInsights\r\n */\r\nvar ApplicationInsights = /** @class */ (function () {\r\n /**\r\n * Creates an instance of ApplicationInsights.\r\n * @param {IConfiguration & IConfig} config\r\n * @memberof ApplicationInsights\r\n */\r\n function ApplicationInsights(config) {\r\n // initialize the queue and config in case they are undefined\r\n if (isNullOrUndefined(config) ||\r\n isNullOrUndefined(config.instrumentationKey)) {\r\n throwError(\"Invalid input configuration\");\r\n }\r\n this.config = config;\r\n this.getSKUDefaults();\r\n this.initialize();\r\n }\r\n /**\r\n * Initialize this instance of ApplicationInsights\r\n *\r\n * @memberof ApplicationInsights\r\n */\r\n ApplicationInsights.prototype.initialize = function () {\r\n this.core = new AppInsightsCore();\r\n var extensions = [];\r\n var appInsightsChannel = new Sender();\r\n extensions.push(appInsightsChannel);\r\n // initialize core\r\n this.core.initialize(this.config, extensions);\r\n // initialize extensions\r\n appInsightsChannel.initialize(this.config, this.core, extensions);\r\n this.pollInternalLogs();\r\n };\r\n /**\r\n * Send a manually constructed custom event\r\n *\r\n * @param {ITelemetryItem} item\r\n * @memberof ApplicationInsights\r\n */\r\n ApplicationInsights.prototype.track = function (item) {\r\n this.core.track(item);\r\n };\r\n /**\r\n * Immediately send all batched telemetry\r\n * @param {boolean} [async=true]\r\n * @memberof ApplicationInsights\r\n */\r\n ApplicationInsights.prototype.flush = function (async) {\r\n if (async === void 0) { async = true; }\r\n arrForEach(this.core.getTransmissionControls(), function (controls) {\r\n arrForEach(controls, function (plugin) {\r\n async\r\n ? plugin.flush()\r\n : plugin.triggerSend(async, null, 1 /* ManualFlush */);\r\n });\r\n });\r\n };\r\n ApplicationInsights.prototype.pollInternalLogs = function () {\r\n this.core.pollInternalLogs();\r\n };\r\n ApplicationInsights.prototype.stopPollingInternalLogs = function () {\r\n this.core.stopPollingInternalLogs();\r\n };\r\n ApplicationInsights.prototype.getSKUDefaults = function () {\r\n this.config.diagnosticLogInterval =\r\n this.config.diagnosticLogInterval && this.config.diagnosticLogInterval > 0 ? this.config.diagnosticLogInterval : 10000;\r\n };\r\n return ApplicationInsights;\r\n}());\r\nexport { ApplicationInsights };\r\nexport { AppInsightsCore, CoreUtils } from \"@microsoft/applicationinsights-core-js\";\r\nexport { SeverityLevel } from \"@microsoft/applicationinsights-common\";\r\nexport { Sender } from \"@microsoft/applicationinsights-channel-js\";\r\n//# sourceMappingURL=index.js.map"],"names":[],"mappings":";;;;AAA4D;AAC1B;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"}
1
+ {"version":3,"file":"index.js.map","sources":["index.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\nimport dynamicProto from \"@microsoft/dynamicproto-js\";\r\nimport { AppInsightsCore, isNullOrUndefined, throwError, proxyFunctions } from \"@microsoft/applicationinsights-core-js\";\r\nimport { Sender } from \"@microsoft/applicationinsights-channel-js\";\r\n/**\r\n * @export\r\n * @class ApplicationInsights\r\n */\r\nvar ApplicationInsights = /** @class */ (function () {\r\n /**\r\n * Creates an instance of ApplicationInsights.\r\n * @param {IConfiguration & IConfig} config\r\n * @memberof ApplicationInsights\r\n */\r\n function ApplicationInsights(config) {\r\n var core = new AppInsightsCore();\r\n // initialize the queue and config in case they are undefined\r\n if (isNullOrUndefined(config) ||\r\n isNullOrUndefined(config.instrumentationKey)) {\r\n throwError(\"Invalid input configuration\");\r\n }\r\n dynamicProto(ApplicationInsights, this, function (_self) {\r\n _self.config = config;\r\n _self.getSKUDefaults();\r\n _initialize();\r\n _self.initialize = _initialize;\r\n _self.getSKUDefaults = function () {\r\n _self.config.diagnosticLogInterval =\r\n _self.config.diagnosticLogInterval && _self.config.diagnosticLogInterval > 0 ? _self.config.diagnosticLogInterval : 10000;\r\n };\r\n proxyFunctions(_self, core, [\r\n \"track\",\r\n \"flush\",\r\n \"pollInternalLogs\",\r\n \"stopPollingInternalLogs\",\r\n \"unload\",\r\n \"getPlugin\",\r\n \"addPlugin\",\r\n \"evtNamespace\",\r\n \"addUnloadCb\"\r\n ]);\r\n function _initialize() {\r\n var extensions = [];\r\n var appInsightsChannel = new Sender();\r\n extensions.push(appInsightsChannel);\r\n // initialize core\r\n core.initialize(this.config, extensions);\r\n // initialize extensions\r\n appInsightsChannel.initialize(this.config, core, extensions);\r\n core.pollInternalLogs();\r\n }\r\n });\r\n }\r\n /**\r\n * Initialize this instance of ApplicationInsights\r\n *\r\n * @memberof ApplicationInsights\r\n */\r\n ApplicationInsights.prototype.initialize = function () {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n /**\r\n * Send a manually constructed custom event\r\n *\r\n * @param {ITelemetryItem} item\r\n * @memberof ApplicationInsights\r\n */\r\n ApplicationInsights.prototype.track = function (item) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n /**\r\n * Immediately send all batched telemetry\r\n * @param {boolean} [async=true]\r\n * @memberof ApplicationInsights\r\n */\r\n ApplicationInsights.prototype.flush = function (async) {\r\n if (async === void 0) { async = true; }\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n ApplicationInsights.prototype.pollInternalLogs = function () {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n ApplicationInsights.prototype.stopPollingInternalLogs = function () {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n ApplicationInsights.prototype.getSKUDefaults = function () {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n /**\r\n * Unload and Tear down the SDK and any initialized plugins, after calling this the SDK will be considered\r\n * to be un-initialized and non-operational, re-initializing the SDK should only be attempted if the previous\r\n * unload call return `true` stating that all plugins reported that they also unloaded, the recommended\r\n * approach is to create a new instance and initialize that instance.\r\n * This is due to possible unexpected side effects caused by plugins not supporting unload / teardown, unable\r\n * to successfully remove any global references or they may just be completing the unload process asynchronously.\r\n */\r\n ApplicationInsights.prototype.unload = function (isAsync, unloadComplete) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n return null;\r\n };\r\n /**\r\n * Find and return the (first) plugin with the specified identifier if present\r\n * @param pluginIdentifier\r\n */\r\n ApplicationInsights.prototype.getPlugin = function (pluginIdentifier) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n return null;\r\n };\r\n /**\r\n * Add a new plugin to the installation\r\n * @param plugin - The new plugin to add\r\n * @param replaceExisting - should any existing plugin be replaced\r\n * @param doAsync - Should the add be performed asynchronously\r\n */\r\n ApplicationInsights.prototype.addPlugin = function (plugin, replaceExisting, doAsync, addCb) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n /**\r\n * Returns the unique event namespace that should be used\r\n */\r\n ApplicationInsights.prototype.evtNamespace = function () {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n return null;\r\n };\r\n /**\r\n * Add an unload handler that will be called when the SDK is being unloaded\r\n * @param handler - the handler\r\n */\r\n ApplicationInsights.prototype.addUnloadCb = function (handler) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n return ApplicationInsights;\r\n}());\r\nexport { ApplicationInsights };\r\nexport { AppInsightsCore, CoreUtils, arrForEach, _InternalMessageId, isNullOrUndefined, throwError, proxyFunctions } from \"@microsoft/applicationinsights-core-js\";\r\nexport { SeverityLevel } from \"@microsoft/applicationinsights-common\";\r\nexport { Sender } from \"@microsoft/applicationinsights-channel-js\";\r\n//# sourceMappingURL=index.js.map"],"names":[],"mappings":";;;;AAA4D;AAC1B;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;;;;;;;;;;8DA6EM;AACN;AACA;AACA;AACA;AACA;AACA;AACA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microsoft/applicationinsights-web-basic",
3
- "version": "2.8.0-beta.2203-10",
3
+ "version": "2.8.0-beta.2203-13",
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",
@@ -13,7 +13,7 @@
13
13
  "build:esm": "grunt aiskulite",
14
14
  "build:browser": "rollup -c rollup.config.js",
15
15
  "rebuild": "npm run build",
16
- "test": "echo 'No tests'",
16
+ "test": "grunt aiskuliteunittests",
17
17
  "lint": "tslint -p tsconfig.json",
18
18
  "dtsgen": "api-extractor run --local && node ../scripts/dtsgen.js 'Microsoft.ApplicationInsights'",
19
19
  "sri": "node ../tools/subResourceIntegrity/generateIntegrityFile.js"
@@ -24,6 +24,7 @@
24
24
  "directory": "AISKULight"
25
25
  },
26
26
  "devDependencies": {
27
+ "@microsoft/ai-test-framework": "0.0.1",
27
28
  "@microsoft/applicationinsights-rollup-plugin-uglify3-js": "1.0.0",
28
29
  "@microsoft/applicationinsights-rollup-es3": "1.1.3",
29
30
  "@microsoft/api-extractor": "^7.18.1",
@@ -34,10 +35,11 @@
34
35
  "@nevware21/grunt-eslint-ts": "^0.2.2",
35
36
  "globby": "^11.0.0",
36
37
  "magic-string": "^0.25.7",
38
+ "pako": "^2.0.3",
37
39
  "@rollup/plugin-commonjs": "^18.0.0",
38
40
  "@rollup/plugin-node-resolve": "^11.2.1",
39
41
  "@rollup/plugin-replace": "^2.3.3",
40
- "rollup-plugin-cleanup": "3.2.1",
42
+ "rollup-plugin-cleanup": "^3.2.1",
41
43
  "rollup": "^2.32.0",
42
44
  "source-map-loader": "^0.2.3",
43
45
  "typescript": "^4.3.4",
@@ -49,9 +51,9 @@
49
51
  "dependencies": {
50
52
  "@microsoft/dynamicproto-js": "^1.1.4",
51
53
  "@microsoft/applicationinsights-shims": "2.0.1",
52
- "@microsoft/applicationinsights-common": "2.8.0-beta.2203-10",
53
- "@microsoft/applicationinsights-channel-js": "2.8.0-beta.2203-10",
54
- "@microsoft/applicationinsights-core-js": "2.8.0-beta.2203-10"
54
+ "@microsoft/applicationinsights-common": "2.8.0-beta.2203-13",
55
+ "@microsoft/applicationinsights-channel-js": "2.8.0-beta.2203-13",
56
+ "@microsoft/applicationinsights-core-js": "2.8.0-beta.2203-13"
55
57
  },
56
58
  "license": "MIT",
57
59
  "publishConfig": {
package/src/index.ts ADDED
@@ -0,0 +1,203 @@
1
+ // Copyright (c) Microsoft Corporation. All rights reserved.
2
+ // Licensed under the MIT License.
3
+
4
+ import dynamicProto from "@microsoft/dynamicproto-js";
5
+ import {
6
+ IConfiguration,
7
+ AppInsightsCore,
8
+ _InternalMessageId,
9
+ isNullOrUndefined,
10
+ ITelemetryItem,
11
+ throwError,
12
+ proxyFunctions,
13
+ UnloadHandler,
14
+ IPlugin,
15
+ ITelemetryPlugin,
16
+ ILoadedPlugin
17
+ } from "@microsoft/applicationinsights-core-js";
18
+ import { IConfig } from "@microsoft/applicationinsights-common";
19
+ import { Sender } from "@microsoft/applicationinsights-channel-js";
20
+
21
+ /**
22
+ * @export
23
+ * @class ApplicationInsights
24
+ */
25
+ export class ApplicationInsights {
26
+ public config: IConfiguration & IConfig;
27
+
28
+ /**
29
+ * Creates an instance of ApplicationInsights.
30
+ * @param {IConfiguration & IConfig} config
31
+ * @memberof ApplicationInsights
32
+ */
33
+ constructor(config: IConfiguration & IConfig) {
34
+ let core = new AppInsightsCore();
35
+
36
+ // initialize the queue and config in case they are undefined
37
+ if (
38
+ isNullOrUndefined(config) ||
39
+ isNullOrUndefined(config.instrumentationKey)
40
+ ) {
41
+ throwError("Invalid input configuration");
42
+ }
43
+
44
+ dynamicProto(ApplicationInsights, this, (_self) => {
45
+ _self.config = config;
46
+ _self.getSKUDefaults();
47
+
48
+ _initialize();
49
+
50
+ _self.initialize = _initialize;
51
+
52
+ _self.getSKUDefaults = () => {
53
+ _self.config.diagnosticLogInterval =
54
+ _self.config.diagnosticLogInterval && _self.config.diagnosticLogInterval > 0 ? _self.config.diagnosticLogInterval : 10000;
55
+ };
56
+
57
+ proxyFunctions(_self, core, [
58
+ "track",
59
+ "flush",
60
+ "pollInternalLogs",
61
+ "stopPollingInternalLogs",
62
+ "unload",
63
+ "getPlugin",
64
+ "addPlugin",
65
+ "evtNamespace",
66
+ "addUnloadCb"
67
+ ]);
68
+
69
+ function _initialize(): void {
70
+ const extensions = [];
71
+ const appInsightsChannel: Sender = new Sender();
72
+
73
+ extensions.push(appInsightsChannel);
74
+
75
+ // initialize core
76
+ core.initialize(this.config, extensions);
77
+
78
+ // initialize extensions
79
+ appInsightsChannel.initialize(this.config, core, extensions);
80
+
81
+ core.pollInternalLogs();
82
+ }
83
+ });
84
+ }
85
+
86
+ /**
87
+ * Initialize this instance of ApplicationInsights
88
+ *
89
+ * @memberof ApplicationInsights
90
+ */
91
+ public initialize(): void {
92
+ // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
93
+ }
94
+
95
+ /**
96
+ * Send a manually constructed custom event
97
+ *
98
+ * @param {ITelemetryItem} item
99
+ * @memberof ApplicationInsights
100
+ */
101
+ public track(item: ITelemetryItem) {
102
+ // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
103
+ }
104
+
105
+ /**
106
+ * Immediately send all batched telemetry
107
+ * @param {boolean} [async=true]
108
+ * @memberof ApplicationInsights
109
+ */
110
+ public flush(async: boolean = true) {
111
+ // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
112
+ }
113
+
114
+ public pollInternalLogs(): void {
115
+ // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
116
+ }
117
+
118
+ public stopPollingInternalLogs(): void {
119
+ // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
120
+ }
121
+
122
+ public getSKUDefaults() {
123
+ // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
124
+ }
125
+
126
+ /**
127
+ * Unload and Tear down the SDK and any initialized plugins, after calling this the SDK will be considered
128
+ * to be un-initialized and non-operational, re-initializing the SDK should only be attempted if the previous
129
+ * unload call return `true` stating that all plugins reported that they also unloaded, the recommended
130
+ * approach is to create a new instance and initialize that instance.
131
+ * This is due to possible unexpected side effects caused by plugins not supporting unload / teardown, unable
132
+ * to successfully remove any global references or they may just be completing the unload process asynchronously.
133
+ */
134
+ public unload(isAsync?: boolean, unloadComplete?: () => void): void {
135
+ // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
136
+ return null;
137
+ }
138
+
139
+ /**
140
+ * Find and return the (first) plugin with the specified identifier if present
141
+ * @param pluginIdentifier
142
+ */
143
+ public getPlugin<T extends IPlugin = IPlugin>(pluginIdentifier: string): ILoadedPlugin<T> {
144
+ // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
145
+ return null;
146
+ }
147
+
148
+ /**
149
+ * Add a new plugin to the installation
150
+ * @param plugin - The new plugin to add
151
+ * @param replaceExisting - should any existing plugin be replaced
152
+ * @param doAsync - Should the add be performed asynchronously
153
+ */
154
+ public addPlugin<T extends IPlugin = ITelemetryPlugin>(plugin: T, replaceExisting: boolean, doAsync: boolean, addCb?: (added?: boolean) => void): void {
155
+ // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
156
+ }
157
+
158
+ /**
159
+ * Returns the unique event namespace that should be used
160
+ */
161
+ public evtNamespace(): string {
162
+ // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
163
+ return null;
164
+ }
165
+
166
+ /**
167
+ * Add an unload handler that will be called when the SDK is being unloaded
168
+ * @param handler - the handler
169
+ */
170
+ public addUnloadCb(handler: UnloadHandler): void {
171
+ // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
172
+ }
173
+ }
174
+
175
+ export {
176
+ IConfiguration,
177
+ AppInsightsCore,
178
+ IAppInsightsCore,
179
+ CoreUtils,
180
+ ITelemetryItem,
181
+ ILoadedPlugin,
182
+ arrForEach,
183
+ SendRequestReason,
184
+ _eInternalMessageId,
185
+ _InternalMessageId,
186
+ isNullOrUndefined,
187
+ throwError,
188
+ proxyFunctions,
189
+ IPlugin,
190
+ ITelemetryPlugin
191
+
192
+ } from "@microsoft/applicationinsights-core-js";
193
+ export {
194
+ SeverityLevel,
195
+ IPageViewTelemetry,
196
+ IDependencyTelemetry,
197
+ IAutoExceptionTelemetry,
198
+ IEventTelemetry,
199
+ IMetricTelemetry,
200
+ IPageViewPerformanceTelemetry,
201
+ ITraceTelemetry
202
+ } from "@microsoft/applicationinsights-common";
203
+ export { Sender } from "@microsoft/applicationinsights-channel-js";
package/tsconfig.json CHANGED
@@ -16,8 +16,12 @@
16
16
  "declaration": true,
17
17
  "declarationDir": "AISKULight/types",
18
18
  "outDir": "dist-esm",
19
- "rootDir": "AISKULight"
19
+ "rootDir": "./AISKULight/src"
20
20
  },
21
- "include": ["index.ts"],
22
- "exclude": ["node_modules"]
21
+ "include": [
22
+ "src/**/*"
23
+ ],
24
+ "exclude": [
25
+ "node_modules"
26
+ ]
23
27
  }