@microsoft/applicationinsights-web-basic 3.0.0-beta.2211-04 → 3.0.0-beta.2212-04
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.
- package/browser/aib.2.js +171 -150
- package/browser/aib.2.js.map +1 -1
- package/browser/aib.2.min.js +2 -2
- package/browser/aib.2.min.js.map +1 -1
- package/browser/aib.3.0.0-beta.2212-04.integrity.json +26 -0
- package/browser/{aib.3.0.0-beta.2211-04.js → aib.3.0.0-beta.2212-04.js} +172 -151
- package/browser/aib.3.0.0-beta.2212-04.js.map +1 -0
- package/browser/aib.3.0.0-beta.2212-04.min.js +6 -0
- package/browser/aib.3.0.0-beta.2212-04.min.js.map +1 -0
- package/dist/applicationinsights-web-basic.api.json +44 -12
- package/dist/applicationinsights-web-basic.api.md +1 -2
- package/dist/applicationinsights-web-basic.d.ts +8 -2
- package/dist/applicationinsights-web-basic.js +171 -150
- package/dist/applicationinsights-web-basic.js.map +1 -1
- package/dist/applicationinsights-web-basic.min.js +2 -2
- package/dist/applicationinsights-web-basic.min.js.map +1 -1
- package/dist/applicationinsights-web-basic.rollup.d.ts +8 -2
- package/dist-esm/__DynamicConstants.js +3 -2
- package/dist-esm/__DynamicConstants.js.map +1 -1
- package/dist-esm/index.js +27 -17
- package/dist-esm/index.js.map +1 -1
- package/package.json +5 -5
- package/src/__DynamicConstants.ts +2 -1
- package/src/index.ts +43 -26
- package/types/__DynamicConstants.d.ts +2 -1
- package/types/index.d.ts +8 -2
- package/browser/aib.3.0.0-beta.2211-04.integrity.json +0 -26
- package/browser/aib.3.0.0-beta.2211-04.js.map +0 -1
- package/browser/aib.3.0.0-beta.2211-04.min.js +0 -6
- package/browser/aib.3.0.0-beta.2211-04.min.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Microsoft.ApplicationInsights, 3.0.0-beta.
|
|
2
|
+
* Microsoft.ApplicationInsights, 3.0.0-beta.2212-04
|
|
3
3
|
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* Microsoft Application Insights Team
|
|
@@ -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 }
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Application Insights JavaScript Web SDK - Basic, 3.0.0-beta.
|
|
2
|
+
* Application Insights JavaScript Web SDK - Basic, 3.0.0-beta.2212-04
|
|
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
|
|
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
|
|
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.
|
|
2
|
+
* Application Insights JavaScript Web SDK - Basic, 3.0.0-beta.2212-04
|
|
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 {
|
|
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 {
|
|
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
|
-
|
|
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
|
|
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(
|
|
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;
|
package/dist-esm/index.js.map
CHANGED
|
@@ -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,
|
|
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.
|
|
3
|
+
"version": "3.0.0-beta.2212-04",
|
|
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.
|
|
57
|
-
"@microsoft/applicationinsights-channel-js": "3.0.0-beta.
|
|
58
|
-
"@microsoft/applicationinsights-core-js": "3.0.0-beta.
|
|
59
|
-
"@nevware21/ts-utils": "^0.
|
|
56
|
+
"@microsoft/applicationinsights-common": "3.0.0-beta.2212-04",
|
|
57
|
+
"@microsoft/applicationinsights-channel-js": "3.0.0-beta.2212-04",
|
|
58
|
+
"@microsoft/applicationinsights-core-js": "3.0.0-beta.2212-04",
|
|
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
|
|
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,
|
|
9
|
-
|
|
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: () =>
|
|
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(
|
|
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
|
|
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-04",
|
|
4
|
-
"ext": {
|
|
5
|
-
"@js": {
|
|
6
|
-
"file": "aib.3.0.0-beta.2211-04.js",
|
|
7
|
-
"type": "text/javascript; charset=utf-8",
|
|
8
|
-
"integrity": "sha256-1N6J/U9x20WZlT7ySjj5GDs9n84gNc/rPclFE/pM5y0= sha384-9FFuoEC6z7F2xVNvqg3rpT0PWdi19jhrd/4Y5T4AApfbh+a/8Wa3IiiDLDKnyl0o sha512-Q4sCcLTn0ntVDB7Z3uiEo3ESIKD/ij3JmskXOZmBQaJHwX7CY8LCMdwMC8cFdizapkSLmqFbml7ljESLZbpS0Q==",
|
|
9
|
-
"hashes": {
|
|
10
|
-
"sha256": "1N6J/U9x20WZlT7ySjj5GDs9n84gNc/rPclFE/pM5y0=",
|
|
11
|
-
"sha384": "9FFuoEC6z7F2xVNvqg3rpT0PWdi19jhrd/4Y5T4AApfbh+a/8Wa3IiiDLDKnyl0o",
|
|
12
|
-
"sha512": "Q4sCcLTn0ntVDB7Z3uiEo3ESIKD/ij3JmskXOZmBQaJHwX7CY8LCMdwMC8cFdizapkSLmqFbml7ljESLZbpS0Q=="
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
"@min.js": {
|
|
16
|
-
"file": "aib.3.0.0-beta.2211-04.min.js",
|
|
17
|
-
"type": "text/javascript; charset=utf-8",
|
|
18
|
-
"integrity": "sha256-G4xxbQLkfioKNS83jN4+juoD5LQI+njHUbfPod0oY3Y= sha384-e55ssudRjVZNn4+IYy0QtkNiJIRnNEH0/maUn/FfnIkYnsEoUAxyPjPKtoCt5PHF sha512-O3kD6Hm3D4XHx3xOCdQPVxXHDMwhP92OJ95vTiEqSWipoB+KHbi1xx9zLA1Rf5Rr7hIYw8yYiWY2Clj9Gxw8Nw==",
|
|
19
|
-
"hashes": {
|
|
20
|
-
"sha256": "G4xxbQLkfioKNS83jN4+juoD5LQI+njHUbfPod0oY3Y=",
|
|
21
|
-
"sha384": "e55ssudRjVZNn4+IYy0QtkNiJIRnNEH0/maUn/FfnIkYnsEoUAxyPjPKtoCt5PHF",
|
|
22
|
-
"sha512": "O3kD6Hm3D4XHx3xOCdQPVxXHDMwhP92OJ95vTiEqSWipoB+KHbi1xx9zLA1Rf5Rr7hIYw8yYiWY2Clj9Gxw8Nw=="
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|