@microsoft/applicationinsights-web-basic 3.0.0-beta.2211-03 → 3.0.0-beta.2212-03

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 (30) hide show
  1. package/browser/aib.2.js +1072 -1222
  2. package/browser/aib.2.js.map +1 -1
  3. package/browser/aib.2.min.js +2 -2
  4. package/browser/aib.2.min.js.map +1 -1
  5. package/browser/aib.3.0.0-beta.2212-03.integrity.json +26 -0
  6. package/browser/{aib.3.0.0-beta.2211-03.js → aib.3.0.0-beta.2212-03.js} +1073 -1223
  7. package/browser/aib.3.0.0-beta.2212-03.js.map +1 -0
  8. package/browser/aib.3.0.0-beta.2212-03.min.js +6 -0
  9. package/browser/aib.3.0.0-beta.2212-03.min.js.map +1 -0
  10. package/dist/applicationinsights-web-basic.api.json +113 -81
  11. package/dist/applicationinsights-web-basic.api.md +7 -8
  12. package/dist/applicationinsights-web-basic.d.ts +14 -8
  13. package/dist/applicationinsights-web-basic.js +1072 -1222
  14. package/dist/applicationinsights-web-basic.js.map +1 -1
  15. package/dist/applicationinsights-web-basic.min.js +2 -2
  16. package/dist/applicationinsights-web-basic.min.js.map +1 -1
  17. package/dist/applicationinsights-web-basic.rollup.d.ts +14 -8
  18. package/dist-esm/__DynamicConstants.js +3 -2
  19. package/dist-esm/__DynamicConstants.js.map +1 -1
  20. package/dist-esm/index.js +27 -17
  21. package/dist-esm/index.js.map +1 -1
  22. package/package.json +5 -5
  23. package/src/__DynamicConstants.ts +2 -1
  24. package/src/index.ts +43 -26
  25. package/types/__DynamicConstants.d.ts +2 -1
  26. package/types/index.d.ts +8 -2
  27. package/browser/aib.3.0.0-beta.2211-03.integrity.json +0 -26
  28. package/browser/aib.3.0.0-beta.2211-03.js.map +0 -1
  29. package/browser/aib.3.0.0-beta.2211-03.min.js +0 -6
  30. package/browser/aib.3.0.0-beta.2211-03.min.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Microsoft.ApplicationInsights, 3.0.0-beta.2211-03
2
+ * Microsoft.ApplicationInsights, 3.0.0-beta.2212-03
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  *
5
5
  * Microsoft Application Insights Team
@@ -41,7 +41,7 @@ export declare class AppInsightsCore implements IAppInsightsCore {
41
41
  getWParam: () => number;
42
42
  constructor();
43
43
  initialize(config: IConfiguration, extensions: IPlugin[], logger?: IDiagnosticLogger, notificationManager?: INotificationManager): void;
44
- getTransmissionControls(): IChannelControls[][];
44
+ getChannels(): IChannelControls[];
45
45
  track(telemetryItem: ITelemetryItem): void;
46
46
  getProcessTelContext(): IProcessTelemetryContext;
47
47
  getNotifyMgr(): INotificationManager;
@@ -192,7 +192,6 @@ export declare class ApplicationInsights {
192
192
  flush(async?: boolean): void;
193
193
  pollInternalLogs(): void;
194
194
  stopPollingInternalLogs(): void;
195
- getSKUDefaults(): void;
196
195
  /**
197
196
  * Unload and Tear down the SDK and any initialized plugins, after calling this the SDK will be considered
198
197
  * to be un-initialized and non-operational, re-initializing the SDK should only be attempted if the previous
@@ -223,6 +222,13 @@ export declare class ApplicationInsights {
223
222
  * @param handler - the handler
224
223
  */
225
224
  addUnloadCb(handler: UnloadHandler): void;
225
+ /**
226
+ * Watches and tracks changes for accesses to the current config, and if the accessed config changes the
227
+ * handler will be recalled.
228
+ * @param handler
229
+ * @returns A watcher handler instance that can be used to remove itself when being unloaded
230
+ */
231
+ onCfgChange(handler: WatcherFunction<IConfiguration>): IUnloadHook;
226
232
  }
227
233
 
228
234
  export { arrForEach }
@@ -471,7 +477,7 @@ export declare interface IAppInsightsCore extends IPerfManagerProvider {
471
477
  */
472
478
  isInitialized?: () => boolean;
473
479
  initialize(config: IConfiguration, extensions: IPlugin[], logger?: IDiagnosticLogger, notificationManager?: INotificationManager): void;
474
- getTransmissionControls(): IChannelControls[][];
480
+ getChannels(): IChannelControls[];
475
481
  track(telemetryItem: ITelemetryItem): void;
476
482
  /**
477
483
  * Get the current notification manager
@@ -738,11 +744,11 @@ declare interface IChannelControls extends ITelemetryPlugin {
738
744
  /**
739
745
  * Pause sending data
740
746
  */
741
- pause(): void;
747
+ pause?(): void;
742
748
  /**
743
749
  * Resume sending data
744
750
  */
745
- resume(): void;
751
+ resume?(): void;
746
752
  /**
747
753
  * Tear down the plugin and remove any hooked value, the plugin should be removed so that it is no longer initialized and
748
754
  * therefore could be re-initialized after being torn down. The plugin should ensure that once this has been called any further
@@ -751,7 +757,7 @@ declare interface IChannelControls extends ITelemetryPlugin {
751
757
  * @param unloadState - The details / state of the unload process, it holds details like whether it should be unloaded synchronously or asynchronously and the reason for the unload.
752
758
  * @returns boolean - true if the plugin has or will call processNext(), this for backward compatibility as previously teardown was synchronous and returned nothing.
753
759
  */
754
- teardown: (unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState) => void | boolean;
760
+ teardown?: (unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState) => void | boolean;
755
761
  /**
756
762
  * Flush to send data immediately; channel should default to sending data asynchronously
757
763
  * @param async - send data asynchronously when true
@@ -760,7 +766,7 @@ declare interface IChannelControls extends ITelemetryPlugin {
760
766
  * @param sendReason - specify the reason that you are calling "flush" defaults to ManualFlush (1) if not specified
761
767
  * @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
762
768
  */
763
- flush(async: boolean, callBack?: (flushComplete?: boolean) => void, sendReason?: SendRequestReason): boolean | void;
769
+ flush?(async: boolean, callBack?: (flushComplete?: boolean) => void, sendReason?: SendRequestReason): boolean | void;
764
770
  }
765
771
 
766
772
  declare interface IChannelControlsAI extends IChannelControls {
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Application Insights JavaScript Web SDK - Basic, 3.0.0-beta.2211-03
2
+ * Application Insights JavaScript Web SDK - Basic, 3.0.0-beta.2212-03
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
@@ -11,5 +11,6 @@
11
11
  // ###########################################################################################################################################
12
12
  // Note: DON'T Export these const from the package as we are still targeting IE this will export a mutable variables that someone could change
13
13
  // ###########################################################################################################################################
14
- export var _DYN_DIAGNOSTIC_LOG_INTER0 = "diagnosticLogInterval"; // Count: 4
14
+ export var _DYN_CONNECTION_STRING = "connectionString"; // Count: 2
15
+ export var _DYN_INSTRUMENTATION_KEY = "instrumentationKey"; // Count: 2
15
16
  //# sourceMappingURL=__DynamicConstants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"__DynamicConstants.js.map","sources":["__DynamicConstants.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\n// @skip-file-minify\r\n// ##############################################################\r\n// AUTO GENERATED FILE: This file is Auto Generated during build.\r\n// ##############################################################\r\n// ###########################################################################################################################################\r\n// Note: DON'T Export these const from the package as we are still targeting IE this will export a mutable variables that someone could change\r\n// ###########################################################################################################################################\r\nexport var _DYN_DIAGNOSTIC_LOG_INTER0 = \"diagnosticLogInterval\"; // Count: 4\r\n//# sourceMappingURL=__DynamicConstants.js.map"],"names":[],"mappings":";;;;AAA4D;AAC1B;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
1
+ {"version":3,"file":"__DynamicConstants.js.map","sources":["__DynamicConstants.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\n// @skip-file-minify\r\n// ##############################################################\r\n// AUTO GENERATED FILE: This file is Auto Generated during build.\r\n// ##############################################################\r\n// ###########################################################################################################################################\r\n// Note: DON'T Export these const from the package as we are still targeting IE this will export a mutable variables that someone could change\r\n// ###########################################################################################################################################\r\nexport var _DYN_CONNECTION_STRING = \"connectionString\"; // Count: 2\r\nexport var _DYN_INSTRUMENTATION_KEY = \"instrumentationKey\"; // Count: 2\r\n//# sourceMappingURL=__DynamicConstants.js.map"],"names":[],"mappings":";;;;AAA4D;AAC1B;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
package/dist-esm/index.js CHANGED
@@ -1,14 +1,22 @@
1
1
  /*
2
- * Application Insights JavaScript Web SDK - Basic, 3.0.0-beta.2211-03
2
+ * Application Insights JavaScript Web SDK - Basic, 3.0.0-beta.2212-03
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
6
6
 
7
7
  import dynamicProto from "@microsoft/dynamicproto-js";
8
8
  import { Sender } from "@microsoft/applicationinsights-channel-js";
9
- import { AppInsightsCore, isNullOrUndefined, proxyFunctions, throwError } from "@microsoft/applicationinsights-core-js";
9
+ import { DEFAULT_BREEZE_PATH, parseConnectionString } from "@microsoft/applicationinsights-common";
10
+ import { AppInsightsCore, createDynamicConfig, onConfigChange, proxyFunctions } from "@microsoft/applicationinsights-core-js";
10
11
  import { objDefineProp } from "@nevware21/ts-utils";
11
- import { _DYN_DIAGNOSTIC_LOG_INTER0 } from "./__DynamicConstants";
12
+ import { _DYN_CONNECTION_STRING, _DYN_INSTRUMENTATION_KEY } from "./__DynamicConstants";
13
+ var defaultConfigValues = {
14
+ diagnosticLogInterval: { isVal: _chkDiagLevel, v: 10000 }
15
+ };
16
+ function _chkDiagLevel(value) {
17
+ // Make sure we have a value > 0
18
+ return value && value > 0;
19
+ }
12
20
  /**
13
21
  * @export
14
22
  * @class ApplicationInsights
@@ -21,25 +29,16 @@ var ApplicationInsights = /** @class */ (function () {
21
29
  */
22
30
  function ApplicationInsights(config) {
23
31
  var core = new AppInsightsCore();
24
- // initialize the queue and config in case they are undefined
25
- if (isNullOrUndefined(config) ||
26
- isNullOrUndefined(config.instrumentationKey)) {
27
- throwError("Invalid input configuration");
28
- }
32
+ var _config;
29
33
  dynamicProto(ApplicationInsights, this, function (_self) {
30
34
  // Define _self.config
31
35
  objDefineProp(_self, "config", {
32
36
  configurable: true,
33
37
  enumerable: true,
34
- get: function () { return config; }
38
+ get: function () { return _config; }
35
39
  });
36
40
  _initialize();
37
41
  _self.initialize = _initialize;
38
- _self.getSKUDefaults = function () {
39
- _self.config[_DYN_DIAGNOSTIC_LOG_INTER0 /* @min:%2ediagnosticLogInterval */] =
40
- _self.config[_DYN_DIAGNOSTIC_LOG_INTER0 /* @min:%2ediagnosticLogInterval */] && _self.config[_DYN_DIAGNOSTIC_LOG_INTER0 /* @min:%2ediagnosticLogInterval */] > 0 ? _self.config[_DYN_DIAGNOSTIC_LOG_INTER0 /* @min:%2ediagnosticLogInterval */] : 10000;
41
- };
42
- _self.getSKUDefaults();
43
42
  proxyFunctions(_self, core, [
44
43
  "track",
45
44
  "flush",
@@ -49,11 +48,22 @@ var ApplicationInsights = /** @class */ (function () {
49
48
  "getPlugin",
50
49
  "addPlugin",
51
50
  "evtNamespace",
52
- "addUnloadCb"
51
+ "addUnloadCb",
52
+ "onCfgChange"
53
53
  ]);
54
54
  function _initialize() {
55
+ var cfgHandler = createDynamicConfig(config || {}, defaultConfigValues);
56
+ _config = cfgHandler.cfg;
57
+ core.addUnloadHook(onConfigChange(cfgHandler, function () {
58
+ if (_config[_DYN_CONNECTION_STRING /* @min:%2econnectionString */]) {
59
+ var cs = parseConnectionString(_config[_DYN_CONNECTION_STRING /* @min:%2econnectionString */]);
60
+ var ingest = cs.ingestionendpoint;
61
+ _config.endpointUrl = ingest ? (ingest + DEFAULT_BREEZE_PATH) : _config.endpointUrl; // only add /v2/track when from connectionstring
62
+ _config[_DYN_INSTRUMENTATION_KEY /* @min:%2einstrumentationKey */] = cs.instrumentationkey || _config[_DYN_INSTRUMENTATION_KEY /* @min:%2einstrumentationKey */];
63
+ }
64
+ }));
55
65
  // initialize core
56
- core.initialize(_self.config, [new Sender()]);
66
+ core.initialize(_config, [new Sender()]);
57
67
  }
58
68
  });
59
69
  }
@@ -62,12 +72,12 @@ var ApplicationInsights = /** @class */ (function () {
62
72
  // Removed Stub for ApplicationInsights.prototype.flush.
63
73
  // Removed Stub for ApplicationInsights.prototype.pollInternalLogs.
64
74
  // Removed Stub for ApplicationInsights.prototype.stopPollingInternalLogs.
65
- // Removed Stub for ApplicationInsights.prototype.getSKUDefaults.
66
75
  // Removed Stub for ApplicationInsights.prototype.unload.
67
76
  // Removed Stub for ApplicationInsights.prototype.getPlugin.
68
77
  // Removed Stub for ApplicationInsights.prototype.addPlugin.
69
78
  // Removed Stub for ApplicationInsights.prototype.evtNamespace.
70
79
  // Removed Stub for ApplicationInsights.prototype.addUnloadCb.
80
+ // Removed Stub for ApplicationInsights.prototype.onCfgChange.
71
81
  // This is a workaround for an IE bug when using dynamicProto() with classes that don't have any
72
82
  // non-dynamic functions or static properties/functions when using uglify-js to minify the resulting code.
73
83
  ApplicationInsights.__ieDyn=1;
@@ -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 dynamicProto from \"@microsoft/dynamicproto-js\";\r\nimport { Sender } from \"@microsoft/applicationinsights-channel-js\";\r\nimport { AppInsightsCore, isNullOrUndefined, proxyFunctions, throwError } from \"@microsoft/applicationinsights-core-js\";\r\nimport { objDefineProp } from \"@nevware21/ts-utils\";\r\nimport { _DYN_DIAGNOSTIC_LOG_INTER0 } from \"./__DynamicConstants\";\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 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 // Define _self.config\r\n objDefineProp(_self, \"config\", {\r\n configurable: true,\r\n enumerable: true,\r\n get: function () { return config; }\r\n });\r\n _initialize();\r\n _self.initialize = _initialize;\r\n _self.getSKUDefaults = function () {\r\n _self.config[_DYN_DIAGNOSTIC_LOG_INTER0 /* @min:%2ediagnosticLogInterval */] =\r\n _self.config[_DYN_DIAGNOSTIC_LOG_INTER0 /* @min:%2ediagnosticLogInterval */] && _self.config[_DYN_DIAGNOSTIC_LOG_INTER0 /* @min:%2ediagnosticLogInterval */] > 0 ? _self.config[_DYN_DIAGNOSTIC_LOG_INTER0 /* @min:%2ediagnosticLogInterval */] : 10000;\r\n };\r\n _self.getSKUDefaults();\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 // initialize core\r\n core.initialize(_self.config, [new Sender()]);\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 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 [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, arrForEach, 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;AACA;;;;;;;;;;8DA6EM,CAAC;;;;;+BACwB;AAC/B;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 { Sender } from \"@microsoft/applicationinsights-channel-js\";\r\nimport { DEFAULT_BREEZE_PATH, parseConnectionString } from \"@microsoft/applicationinsights-common\";\r\nimport { AppInsightsCore, createDynamicConfig, onConfigChange, proxyFunctions } from \"@microsoft/applicationinsights-core-js\";\r\nimport { objDefineProp } from \"@nevware21/ts-utils\";\r\nimport { _DYN_CONNECTION_STRING, _DYN_INSTRUMENTATION_KEY } from \"./__DynamicConstants\";\r\nvar defaultConfigValues = {\r\n diagnosticLogInterval: { isVal: _chkDiagLevel, v: 10000 }\r\n};\r\nfunction _chkDiagLevel(value) {\r\n // Make sure we have a value > 0\r\n return value && value > 0;\r\n}\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 config\r\n * @memberof ApplicationInsights\r\n */\r\n function ApplicationInsights(config) {\r\n var core = new AppInsightsCore();\r\n var _config;\r\n dynamicProto(ApplicationInsights, this, function (_self) {\r\n // Define _self.config\r\n objDefineProp(_self, \"config\", {\r\n configurable: true,\r\n enumerable: true,\r\n get: function () { return _config; }\r\n });\r\n _initialize();\r\n _self.initialize = _initialize;\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 \"onCfgChange\"\r\n ]);\r\n function _initialize() {\r\n var cfgHandler = createDynamicConfig(config || {}, defaultConfigValues);\r\n _config = cfgHandler.cfg;\r\n core.addUnloadHook(onConfigChange(cfgHandler, function () {\r\n if (_config[_DYN_CONNECTION_STRING /* @min:%2econnectionString */]) {\r\n var cs = parseConnectionString(_config[_DYN_CONNECTION_STRING /* @min:%2econnectionString */]);\r\n var ingest = cs.ingestionendpoint;\r\n _config.endpointUrl = ingest ? (ingest + DEFAULT_BREEZE_PATH) : _config.endpointUrl; // only add /v2/track when from connectionstring\r\n _config[_DYN_INSTRUMENTATION_KEY /* @min:%2einstrumentationKey */] = cs.instrumentationkey || _config[_DYN_INSTRUMENTATION_KEY /* @min:%2einstrumentationKey */];\r\n }\r\n }));\r\n // initialize core\r\n core.initialize(_config, [new Sender()]);\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 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 [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 /**\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 /**\r\n * Watches and tracks changes for accesses to the current config, and if the accessed config changes the\r\n * handler will be recalled.\r\n * @param handler\r\n * @returns A watcher handler instance that can be used to remove itself when being unloaded\r\n */\r\n ApplicationInsights.prototype.onCfgChange = function (handler) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n return null;\r\n };\r\n return ApplicationInsights;\r\n}());\r\nexport { ApplicationInsights };\r\nexport { AppInsightsCore, arrForEach, 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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;8DAoFM,CAAC;;;;;+BACwB;AAC/B;AACA;AACA;AACA;AACA;AACA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microsoft/applicationinsights-web-basic",
3
- "version": "3.0.0-beta.2211-03",
3
+ "version": "3.0.0-beta.2212-03",
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",
@@ -53,10 +53,10 @@
53
53
  "dependencies": {
54
54
  "@microsoft/dynamicproto-js": "^1.1.7",
55
55
  "@microsoft/applicationinsights-shims": "2.0.2",
56
- "@microsoft/applicationinsights-common": "3.0.0-beta.2211-03",
57
- "@microsoft/applicationinsights-channel-js": "3.0.0-beta.2211-03",
58
- "@microsoft/applicationinsights-core-js": "3.0.0-beta.2211-03",
59
- "@nevware21/ts-utils": "^0.5.0"
56
+ "@microsoft/applicationinsights-common": "3.0.0-beta.2212-03",
57
+ "@microsoft/applicationinsights-channel-js": "3.0.0-beta.2212-03",
58
+ "@microsoft/applicationinsights-core-js": "3.0.0-beta.2212-03",
59
+ "@nevware21/ts-utils": "^0.6.0"
60
60
  },
61
61
  "license": "MIT",
62
62
  "publishConfig": {
@@ -10,4 +10,5 @@
10
10
  // Note: DON'T Export these const from the package as we are still targeting IE this will export a mutable variables that someone could change
11
11
  // ###########################################################################################################################################
12
12
 
13
- export const _DYN_DIAGNOSTIC_LOG_INTER0 = "diagnosticLogInterval"; // Count: 4
13
+ export const _DYN_CONNECTION_STRING = "connectionString"; // Count: 2
14
+ export const _DYN_INSTRUMENTATION_KEY = "instrumentationKey"; // Count: 2
package/src/index.ts CHANGED
@@ -3,13 +3,22 @@
3
3
 
4
4
  import dynamicProto from "@microsoft/dynamicproto-js";
5
5
  import { Sender } from "@microsoft/applicationinsights-channel-js";
6
- import { IConfig } from "@microsoft/applicationinsights-common";
6
+ import { DEFAULT_BREEZE_PATH, IConfig, parseConnectionString } from "@microsoft/applicationinsights-common";
7
7
  import {
8
- AppInsightsCore, IConfiguration, ILoadedPlugin, IPlugin, ITelemetryItem, ITelemetryPlugin, UnloadHandler, _eInternalMessageId,
9
- isNullOrUndefined, proxyFunctions, throwError
8
+ AppInsightsCore, IConfigDefaults, IConfiguration, IDynamicConfigHandler, ILoadedPlugin, IPlugin, ITelemetryItem, ITelemetryPlugin,
9
+ IUnloadHook, UnloadHandler, WatcherFunction, createDynamicConfig, onConfigChange, proxyFunctions
10
10
  } from "@microsoft/applicationinsights-core-js";
11
11
  import { objDefineProp } from "@nevware21/ts-utils";
12
12
 
13
+ const defaultConfigValues: IConfigDefaults<IConfiguration> = {
14
+ diagnosticLogInterval: { isVal: _chkDiagLevel, v: 10000 }
15
+ };
16
+
17
+ function _chkDiagLevel(value: number) {
18
+ // Make sure we have a value > 0
19
+ return value && value > 0;
20
+ }
21
+
13
22
  /**
14
23
  * @export
15
24
  * @class ApplicationInsights
@@ -24,14 +33,7 @@ export class ApplicationInsights {
24
33
  */
25
34
  constructor(config: IConfiguration & IConfig) {
26
35
  let core = new AppInsightsCore();
27
-
28
- // initialize the queue and config in case they are undefined
29
- if (
30
- isNullOrUndefined(config) ||
31
- isNullOrUndefined(config.instrumentationKey)
32
- ) {
33
- throwError("Invalid input configuration");
34
- }
36
+ let _config: IConfiguration & IConfig;
35
37
 
36
38
  dynamicProto(ApplicationInsights, this, (_self) => {
37
39
 
@@ -39,18 +41,12 @@ export class ApplicationInsights {
39
41
  objDefineProp(_self, "config", {
40
42
  configurable: true,
41
43
  enumerable: true,
42
- get: () => config
44
+ get: () => _config
43
45
  });
44
-
46
+
45
47
  _initialize();
46
-
48
+
47
49
  _self.initialize = _initialize;
48
-
49
- _self.getSKUDefaults = () => {
50
- _self.config.diagnosticLogInterval =
51
- _self.config.diagnosticLogInterval && _self.config.diagnosticLogInterval > 0 ? _self.config.diagnosticLogInterval : 10000;
52
- };
53
- _self.getSKUDefaults();
54
50
 
55
51
  proxyFunctions(_self, core, [
56
52
  "track",
@@ -61,12 +57,25 @@ export class ApplicationInsights {
61
57
  "getPlugin",
62
58
  "addPlugin",
63
59
  "evtNamespace",
64
- "addUnloadCb"
60
+ "addUnloadCb",
61
+ "onCfgChange"
65
62
  ]);
66
63
 
67
64
  function _initialize(): void {
65
+ let cfgHandler: IDynamicConfigHandler<IConfiguration & IConfig> = createDynamicConfig(config || ({} as any), defaultConfigValues);
66
+ _config = cfgHandler.cfg;
67
+
68
+ core.addUnloadHook(onConfigChange(cfgHandler, () => {
69
+ if (_config.connectionString) {
70
+ const cs = parseConnectionString(_config.connectionString);
71
+ const ingest = cs.ingestionendpoint;
72
+ _config.endpointUrl = ingest ? (ingest + DEFAULT_BREEZE_PATH) : _config.endpointUrl; // only add /v2/track when from connectionstring
73
+ _config.instrumentationKey = cs.instrumentationkey || _config.instrumentationKey;
74
+ }
75
+ }));
76
+
68
77
  // initialize core
69
- core.initialize(_self.config, [new Sender()]);
78
+ core.initialize(_config, [new Sender()]);
70
79
  }
71
80
  });
72
81
  }
@@ -107,10 +116,6 @@ export class ApplicationInsights {
107
116
  // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
108
117
  }
109
118
 
110
- public getSKUDefaults() {
111
- // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
112
- }
113
-
114
119
  /**
115
120
  * Unload and Tear down the SDK and any initialized plugins, after calling this the SDK will be considered
116
121
  * to be un-initialized and non-operational, re-initializing the SDK should only be attempted if the previous
@@ -158,6 +163,18 @@ export class ApplicationInsights {
158
163
  public addUnloadCb(handler: UnloadHandler): void {
159
164
  // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
160
165
  }
166
+
167
+ /**
168
+ * Watches and tracks changes for accesses to the current config, and if the accessed config changes the
169
+ * handler will be recalled.
170
+ * @param handler
171
+ * @returns A watcher handler instance that can be used to remove itself when being unloaded
172
+ */
173
+ public onCfgChange(handler: WatcherFunction<IConfiguration>): IUnloadHook {
174
+ // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
175
+ return null;
176
+ }
177
+
161
178
  }
162
179
 
163
180
  export {
@@ -1 +1,2 @@
1
- export declare const _DYN_DIAGNOSTIC_LOG_INTER0 = "diagnosticLogInterval";
1
+ export declare const _DYN_CONNECTION_STRING = "connectionString";
2
+ export declare const _DYN_INSTRUMENTATION_KEY = "instrumentationKey";
package/types/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { IConfig } from "@microsoft/applicationinsights-common";
2
- import { IConfiguration, ILoadedPlugin, IPlugin, ITelemetryItem, ITelemetryPlugin, UnloadHandler } from "@microsoft/applicationinsights-core-js";
2
+ import { IConfiguration, ILoadedPlugin, IPlugin, ITelemetryItem, ITelemetryPlugin, IUnloadHook, UnloadHandler, WatcherFunction } from "@microsoft/applicationinsights-core-js";
3
3
  /**
4
4
  * @export
5
5
  * @class ApplicationInsights
@@ -33,7 +33,6 @@ export declare class ApplicationInsights {
33
33
  flush(async?: boolean): void;
34
34
  pollInternalLogs(): void;
35
35
  stopPollingInternalLogs(): void;
36
- getSKUDefaults(): void;
37
36
  /**
38
37
  * Unload and Tear down the SDK and any initialized plugins, after calling this the SDK will be considered
39
38
  * to be un-initialized and non-operational, re-initializing the SDK should only be attempted if the previous
@@ -64,6 +63,13 @@ export declare class ApplicationInsights {
64
63
  * @param handler - the handler
65
64
  */
66
65
  addUnloadCb(handler: UnloadHandler): void;
66
+ /**
67
+ * Watches and tracks changes for accesses to the current config, and if the accessed config changes the
68
+ * handler will be recalled.
69
+ * @param handler
70
+ * @returns A watcher handler instance that can be used to remove itself when being unloaded
71
+ */
72
+ onCfgChange(handler: WatcherFunction<IConfiguration>): IUnloadHook;
67
73
  }
68
74
  export { IConfiguration, AppInsightsCore, IAppInsightsCore, ITelemetryItem, ILoadedPlugin, arrForEach, SendRequestReason, _eInternalMessageId, isNullOrUndefined, throwError, proxyFunctions, IPlugin, ITelemetryPlugin } from "@microsoft/applicationinsights-core-js";
69
75
  export { SeverityLevel, eSeverityLevel, IPageViewTelemetry, IDependencyTelemetry, IAutoExceptionTelemetry, IEventTelemetry, IMetricTelemetry, IPageViewPerformanceTelemetry, ITraceTelemetry } from "@microsoft/applicationinsights-common";
@@ -1,26 +0,0 @@
1
- {
2
- "name": "aib",
3
- "version": "3.0.0-beta.2211-03",
4
- "ext": {
5
- "@js": {
6
- "file": "aib.3.0.0-beta.2211-03.js",
7
- "type": "text/javascript; charset=utf-8",
8
- "integrity": "sha256-RKZPQzoiQarNNDgxSpFKdBpRu4ppSgVJQhaib6bEdRM= sha384-nopCpukIXp1vskjq/jO339yXj5qgDjphe5pvGvDHhjsAD46Qug1I0db15R7BDthe sha512-XhjlwLuHOUf6uNnQgd4636SCw++fW35mFr87hEHKCmU9RRw8/sYxxdlw4dp39BiyBJ2rUFM9vNYWYiC10/smYw==",
9
- "hashes": {
10
- "sha256": "RKZPQzoiQarNNDgxSpFKdBpRu4ppSgVJQhaib6bEdRM=",
11
- "sha384": "nopCpukIXp1vskjq/jO339yXj5qgDjphe5pvGvDHhjsAD46Qug1I0db15R7BDthe",
12
- "sha512": "XhjlwLuHOUf6uNnQgd4636SCw++fW35mFr87hEHKCmU9RRw8/sYxxdlw4dp39BiyBJ2rUFM9vNYWYiC10/smYw=="
13
- }
14
- },
15
- "@min.js": {
16
- "file": "aib.3.0.0-beta.2211-03.min.js",
17
- "type": "text/javascript; charset=utf-8",
18
- "integrity": "sha256-zmKTeHSD04LXPjh8ea7tNzBebXLL3ckTz3nqhq1senU= sha384-gilJl0JC3Ttkgn7M88KrsNrPJXBv9WpTSIR4CtcL5EB/wRrZ9sCjBi3GLYzztTeE sha512-AzCKUFKb2aU10FxxE5+7LJhFwFixKzFPy+wcLunGHvQ5i13yCrb5XLGoths6zirJ7li8lUK1/fTW2YLScTzlDg==",
19
- "hashes": {
20
- "sha256": "zmKTeHSD04LXPjh8ea7tNzBebXLL3ckTz3nqhq1senU=",
21
- "sha384": "gilJl0JC3Ttkgn7M88KrsNrPJXBv9WpTSIR4CtcL5EB/wRrZ9sCjBi3GLYzztTeE",
22
- "sha512": "AzCKUFKb2aU10FxxE5+7LJhFwFixKzFPy+wcLunGHvQ5i13yCrb5XLGoths6zirJ7li8lUK1/fTW2YLScTzlDg=="
23
- }
24
- }
25
- }
26
- }