@microsoft/applicationinsights-properties-js 2.8.4-nightly.2205-08 → 2.8.4
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/applicationinsights-properties-js.integrity.json +9 -9
- package/browser/applicationinsights-properties-js.js +571 -499
- package/browser/applicationinsights-properties-js.js.map +1 -1
- package/browser/applicationinsights-properties-js.min.js +2 -2
- package/browser/applicationinsights-properties-js.min.js.map +1 -1
- package/dist/applicationinsights-properties-js.api.json +45 -1
- package/dist/applicationinsights-properties-js.api.md +4 -1
- package/dist/applicationinsights-properties-js.d.ts +4 -2
- package/dist/applicationinsights-properties-js.js +571 -499
- package/dist/applicationinsights-properties-js.js.map +1 -1
- package/dist/applicationinsights-properties-js.min.js +2 -2
- package/dist/applicationinsights-properties-js.min.js.map +1 -1
- package/dist/applicationinsights-properties-js.rollup.d.ts +4 -2
- package/dist-esm/Context/Application.js +1 -1
- package/dist-esm/Context/Device.js +1 -1
- package/dist-esm/Context/Internal.js +2 -2
- package/dist-esm/Context/Internal.js.map +1 -1
- package/dist-esm/Context/Location.js +1 -1
- package/dist-esm/Context/Session.js +5 -5
- package/dist-esm/Context/Session.js.map +1 -1
- package/dist-esm/Context/TelemetryTrace.js +3 -4
- package/dist-esm/Context/TelemetryTrace.js.map +1 -1
- package/dist-esm/Context/User.js +2 -2
- package/dist-esm/Context/User.js.map +1 -1
- package/dist-esm/Interfaces/IPropTelemetryContext.js +1 -1
- package/dist-esm/Interfaces/ITelemetryConfig.js +1 -1
- package/dist-esm/PropertiesPlugin.js +30 -8
- package/dist-esm/PropertiesPlugin.js.map +1 -1
- package/dist-esm/TelemetryContext.js +11 -3
- package/dist-esm/TelemetryContext.js.map +1 -1
- package/dist-esm/applicationinsights-properties-js.js +1 -1
- package/package.json +58 -61
- package/src/Context/Internal.ts +1 -1
- package/src/Context/TelemetryTrace.ts +3 -3
- package/src/PropertiesPlugin.ts +33 -7
- package/src/TelemetryContext.ts +12 -3
- package/types/Context/TelemetryTrace.d.ts +1 -0
- package/types/TelemetryContext.d.ts +2 -2
- package/types/tsdoc-metadata.json +1 -1
package/package.json
CHANGED
|
@@ -1,61 +1,58 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@microsoft/applicationinsights-properties-js",
|
|
3
|
-
"version": "2.8.4
|
|
4
|
-
"description": "Microsoft Application Insights properties (Part A) plugin",
|
|
5
|
-
"homepage": "https://github.com/microsoft/ApplicationInsights-JS#readme",
|
|
6
|
-
"author": "Microsoft Application Insights Team",
|
|
7
|
-
"main": "dist/applicationinsights-properties-js.js",
|
|
8
|
-
"module": "dist-esm/applicationinsights-properties-js.js",
|
|
9
|
-
"types": "types/applicationinsights-properties-js.d.ts",
|
|
10
|
-
"sideEffects": false,
|
|
11
|
-
"repository": {
|
|
12
|
-
"type": "git",
|
|
13
|
-
"url": "https://github.com/microsoft/ApplicationInsights-JS/tree/master/extensions/applicationinsights-properties-js"
|
|
14
|
-
},
|
|
15
|
-
"scripts": {
|
|
16
|
-
"build": "npm run build:esm && npm run build:browser && npm run sri && npm run dtsgen",
|
|
17
|
-
"build:esm": "grunt properties",
|
|
18
|
-
"build:browser": "rollup -c",
|
|
19
|
-
"rebuild": "npm run build",
|
|
20
|
-
"test": "grunt propertiestests",
|
|
21
|
-
"lint": "tslint -p tsconfig.json",
|
|
22
|
-
"dtsgen": "api-extractor run --local && node ../../scripts/dtsgen.js \"Microsoft Application Insights properties plugin\"",
|
|
23
|
-
"sri": "node ../../tools/subResourceIntegrity/generateIntegrityFile.js"
|
|
24
|
-
},
|
|
25
|
-
"devDependencies": {
|
|
26
|
-
"@microsoft/ai-test-framework": "0.0.1",
|
|
27
|
-
"@microsoft/applicationinsights-rollup-plugin-uglify3-js": "1.0.0",
|
|
28
|
-
"@microsoft/applicationinsights-rollup-es3": "1.1.3",
|
|
29
|
-
"@microsoft/api-extractor": "^7.18.1",
|
|
30
|
-
"typescript": "^4.3.4",
|
|
31
|
-
"tslib": "^2.0.0",
|
|
32
|
-
"grunt": "^1.5.3",
|
|
33
|
-
"grunt-cli": "^1.4.3",
|
|
34
|
-
"grunt-contrib-qunit": "^5.0.1",
|
|
35
|
-
"@nevware21/grunt-ts-plugin": "^0.4.3",
|
|
36
|
-
"@nevware21/grunt-eslint-ts": "^0.2.2",
|
|
37
|
-
"globby": "^11.0.0",
|
|
38
|
-
"magic-string": "^0.25.7",
|
|
39
|
-
"pako": "^2.0.3",
|
|
40
|
-
"@rollup/plugin-commonjs": "^18.0.0",
|
|
41
|
-
"@rollup/plugin-node-resolve": "^11.2.1",
|
|
42
|
-
"@rollup/plugin-replace": "^2.3.3",
|
|
43
|
-
"rollup-plugin-cleanup": "^3.2.1",
|
|
44
|
-
"rollup": "^2.32.0",
|
|
45
|
-
"qunit": "^2.11.2",
|
|
46
|
-
"sinon": "^7.3.1"
|
|
47
|
-
},
|
|
48
|
-
"peerDependencies": {
|
|
49
|
-
"tslib": "*"
|
|
50
|
-
},
|
|
51
|
-
"dependencies": {
|
|
52
|
-
"@microsoft/dynamicproto-js": "^1.1.6",
|
|
53
|
-
"@microsoft/applicationinsights-shims": "2.0.1",
|
|
54
|
-
"@microsoft/applicationinsights-core-js": "2.8.4
|
|
55
|
-
"@microsoft/applicationinsights-common": "2.8.4
|
|
56
|
-
},
|
|
57
|
-
"license": "MIT"
|
|
58
|
-
|
|
59
|
-
"tag": "nightly"
|
|
60
|
-
}
|
|
61
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@microsoft/applicationinsights-properties-js",
|
|
3
|
+
"version": "2.8.4",
|
|
4
|
+
"description": "Microsoft Application Insights properties (Part A) plugin",
|
|
5
|
+
"homepage": "https://github.com/microsoft/ApplicationInsights-JS#readme",
|
|
6
|
+
"author": "Microsoft Application Insights Team",
|
|
7
|
+
"main": "dist/applicationinsights-properties-js.js",
|
|
8
|
+
"module": "dist-esm/applicationinsights-properties-js.js",
|
|
9
|
+
"types": "types/applicationinsights-properties-js.d.ts",
|
|
10
|
+
"sideEffects": false,
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "https://github.com/microsoft/ApplicationInsights-JS/tree/master/extensions/applicationinsights-properties-js"
|
|
14
|
+
},
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "npm run build:esm && npm run build:browser && npm run sri && npm run dtsgen",
|
|
17
|
+
"build:esm": "grunt properties",
|
|
18
|
+
"build:browser": "rollup -c",
|
|
19
|
+
"rebuild": "npm run build",
|
|
20
|
+
"test": "grunt propertiestests",
|
|
21
|
+
"lint": "tslint -p tsconfig.json",
|
|
22
|
+
"dtsgen": "api-extractor run --local && node ../../scripts/dtsgen.js \"Microsoft Application Insights properties plugin\"",
|
|
23
|
+
"sri": "node ../../tools/subResourceIntegrity/generateIntegrityFile.js"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@microsoft/ai-test-framework": "0.0.1",
|
|
27
|
+
"@microsoft/applicationinsights-rollup-plugin-uglify3-js": "1.0.0",
|
|
28
|
+
"@microsoft/applicationinsights-rollup-es3": "1.1.3",
|
|
29
|
+
"@microsoft/api-extractor": "^7.18.1",
|
|
30
|
+
"typescript": "^4.3.4",
|
|
31
|
+
"tslib": "^2.0.0",
|
|
32
|
+
"grunt": "^1.5.3",
|
|
33
|
+
"grunt-cli": "^1.4.3",
|
|
34
|
+
"grunt-contrib-qunit": "^5.0.1",
|
|
35
|
+
"@nevware21/grunt-ts-plugin": "^0.4.3",
|
|
36
|
+
"@nevware21/grunt-eslint-ts": "^0.2.2",
|
|
37
|
+
"globby": "^11.0.0",
|
|
38
|
+
"magic-string": "^0.25.7",
|
|
39
|
+
"pako": "^2.0.3",
|
|
40
|
+
"@rollup/plugin-commonjs": "^18.0.0",
|
|
41
|
+
"@rollup/plugin-node-resolve": "^11.2.1",
|
|
42
|
+
"@rollup/plugin-replace": "^2.3.3",
|
|
43
|
+
"rollup-plugin-cleanup": "^3.2.1",
|
|
44
|
+
"rollup": "^2.32.0",
|
|
45
|
+
"qunit": "^2.11.2",
|
|
46
|
+
"sinon": "^7.3.1"
|
|
47
|
+
},
|
|
48
|
+
"peerDependencies": {
|
|
49
|
+
"tslib": "*"
|
|
50
|
+
},
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"@microsoft/dynamicproto-js": "^1.1.6",
|
|
53
|
+
"@microsoft/applicationinsights-shims": "2.0.1",
|
|
54
|
+
"@microsoft/applicationinsights-core-js": "2.8.4",
|
|
55
|
+
"@microsoft/applicationinsights-common": "2.8.4"
|
|
56
|
+
},
|
|
57
|
+
"license": "MIT"
|
|
58
|
+
}
|
package/src/Context/Internal.ts
CHANGED
|
@@ -9,18 +9,18 @@ export class TelemetryTrace implements ITelemetryTrace {
|
|
|
9
9
|
public traceID: string;
|
|
10
10
|
public parentID: string;
|
|
11
11
|
public traceState: ITraceState;
|
|
12
|
+
public traceFlags: number;
|
|
12
13
|
public name: string;
|
|
13
14
|
|
|
14
15
|
constructor(id?: string, parentId?: string, name?: string, logger?: IDiagnosticLogger) {
|
|
15
16
|
const _self = this;
|
|
16
17
|
_self.traceID = id || generateW3CId();
|
|
17
18
|
_self.parentID = parentId;
|
|
18
|
-
_self.name = name;
|
|
19
19
|
let location = getLocation();
|
|
20
20
|
if (!name && location && location.pathname) {
|
|
21
|
-
|
|
21
|
+
name = location.pathname;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
_self.name = dataSanitizeString(logger,
|
|
24
|
+
_self.name = dataSanitizeString(logger, name);
|
|
25
25
|
}
|
|
26
26
|
}
|
package/src/PropertiesPlugin.ts
CHANGED
|
@@ -7,10 +7,10 @@ import dynamicProto from "@microsoft/dynamicproto-js";
|
|
|
7
7
|
import {
|
|
8
8
|
BaseTelemetryPlugin, IConfiguration, isNullOrUndefined,
|
|
9
9
|
IAppInsightsCore, IPlugin, ITelemetryItem, IProcessTelemetryContext, _InternalLogMessage, eLoggingSeverity, _eInternalMessageId, getNavigator,
|
|
10
|
-
ITelemetryPluginChain, objForEachKey, getSetValue, _logInternalMessage
|
|
10
|
+
ITelemetryPluginChain, objForEachKey, getSetValue, _logInternalMessage, IProcessTelemetryUnloadContext, ITelemetryUnloadState, IDistributedTraceContext
|
|
11
11
|
} from "@microsoft/applicationinsights-core-js";
|
|
12
12
|
import { TelemetryContext } from "./TelemetryContext";
|
|
13
|
-
import { PageView, IConfig, BreezeChannelIdentifier, PropertiesPluginIdentifier, IPropertiesPlugin,
|
|
13
|
+
import { PageView, IConfig, BreezeChannelIdentifier, PropertiesPluginIdentifier, IPropertiesPlugin, createDistributedTraceContextFromTrace } from "@microsoft/applicationinsights-common";
|
|
14
14
|
import { ITelemetryConfig } from "./Interfaces/ITelemetryConfig";
|
|
15
15
|
import { IPropTelemetryContext } from "./Interfaces/IPropTelemetryContext";
|
|
16
16
|
|
|
@@ -46,11 +46,14 @@ export default class PropertiesPlugin extends BaseTelemetryPlugin implements IPr
|
|
|
46
46
|
constructor() {
|
|
47
47
|
super();
|
|
48
48
|
|
|
49
|
-
let _breezeChannel: IPlugin; // optional. If exists, grab appId from it
|
|
50
49
|
let _extensionConfig: ITelemetryConfig;
|
|
50
|
+
let _distributedTraceCtx: IDistributedTraceContext;
|
|
51
|
+
let _previousTraceCtx: IDistributedTraceContext;
|
|
51
52
|
|
|
52
53
|
dynamicProto(PropertiesPlugin, this, (_self, _base) => {
|
|
53
54
|
|
|
55
|
+
_initDefaults();
|
|
56
|
+
|
|
54
57
|
_self.initialize = (config: IConfiguration & IConfig, core: IAppInsightsCore, extensions: IPlugin[], pluginChain?:ITelemetryPluginChain) => {
|
|
55
58
|
_base.initialize(config, core, extensions, pluginChain);
|
|
56
59
|
let ctx = _self._getTelCtx();
|
|
@@ -58,12 +61,17 @@ export default class PropertiesPlugin extends BaseTelemetryPlugin implements IPr
|
|
|
58
61
|
const defaultConfig: ITelemetryConfig = PropertiesPlugin.getDefaultConfig();
|
|
59
62
|
_extensionConfig = _extensionConfig || {} as ITelemetryConfig;
|
|
60
63
|
objForEachKey(defaultConfig, (field, value) => {
|
|
61
|
-
_extensionConfig[field] = () => ctx.getConfig(identifier, field, value());
|
|
64
|
+
_extensionConfig[field] = () => ctx.getConfig(identifier, field, value() as any);
|
|
62
65
|
});
|
|
63
66
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
_self.context.
|
|
67
|
+
_previousTraceCtx = core.getTraceCtx(false);
|
|
68
|
+
_self.context = new TelemetryContext(core, _extensionConfig, _previousTraceCtx);
|
|
69
|
+
_distributedTraceCtx = createDistributedTraceContextFromTrace(_self.context.telemetryTrace, _previousTraceCtx);
|
|
70
|
+
core.setTraceCtx(_distributedTraceCtx);
|
|
71
|
+
_self.context.appId = () => {
|
|
72
|
+
let breezeChannel = core.getPlugin<IPlugin>(BreezeChannelIdentifier);
|
|
73
|
+
return breezeChannel ? breezeChannel.plugin["_appId"] : null;
|
|
74
|
+
};
|
|
67
75
|
|
|
68
76
|
// Test hook to allow accessing the internal values -- explicitly not defined as an available property on the class
|
|
69
77
|
_self["_extConfig"] = _extensionConfig;
|
|
@@ -108,7 +116,25 @@ export default class PropertiesPlugin extends BaseTelemetryPlugin implements IPr
|
|
|
108
116
|
_self.processNext(event, itemCtx);
|
|
109
117
|
}
|
|
110
118
|
};
|
|
119
|
+
|
|
120
|
+
_self._doTeardown = (unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState) => {
|
|
121
|
+
let core = (unloadCtx || {} as any).core();
|
|
122
|
+
if (core && core.getTraceCtx) {
|
|
123
|
+
let traceCtx = core.getTraceCtx(false);
|
|
124
|
+
if (traceCtx === _distributedTraceCtx) {
|
|
125
|
+
core.setTraceCtx(_previousTraceCtx);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
_initDefaults();
|
|
130
|
+
};
|
|
111
131
|
|
|
132
|
+
function _initDefaults() {
|
|
133
|
+
_extensionConfig = null;
|
|
134
|
+
_distributedTraceCtx = null;
|
|
135
|
+
_previousTraceCtx = null;
|
|
136
|
+
}
|
|
137
|
+
|
|
112
138
|
function _processTelemetryInternal(evt: ITelemetryItem, itemCtx: IProcessTelemetryContext) {
|
|
113
139
|
// Set Part A fields
|
|
114
140
|
getSetValue(evt, "tags", []);
|
package/src/TelemetryContext.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import dynamicProto from "@microsoft/dynamicproto-js";
|
|
7
|
-
import { ITelemetryItem, IProcessTelemetryContext, IAppInsightsCore, isString, objKeys, hasWindow, _InternalLogMessage, setValue, getSetValue } from "@microsoft/applicationinsights-core-js";
|
|
7
|
+
import { ITelemetryItem, IProcessTelemetryContext, IAppInsightsCore, isString, objKeys, hasWindow, _InternalLogMessage, setValue, getSetValue, IDistributedTraceContext } from "@microsoft/applicationinsights-core-js";
|
|
8
8
|
import { Session, _SessionManager } from "./Context/Session";
|
|
9
9
|
import { Extensions, IOperatingSystem, ITelemetryTrace, IWeb, CtxTagKeys, PageView, IApplication, IDevice, ILocation, IUserContext, IInternal, ISession } from "@microsoft/applicationinsights-common";
|
|
10
10
|
import { Application } from "./Context/Application";
|
|
@@ -40,7 +40,7 @@ export class TelemetryContext implements IPropTelemetryContext {
|
|
|
40
40
|
public appId: () => string;
|
|
41
41
|
public getSessionId: () => string;
|
|
42
42
|
|
|
43
|
-
constructor(core: IAppInsightsCore, defaultConfig: ITelemetryConfig) {
|
|
43
|
+
constructor(core: IAppInsightsCore, defaultConfig: ITelemetryConfig, previousTraceCtx?: IDistributedTraceContext) {
|
|
44
44
|
let logger = core.logger
|
|
45
45
|
this.appId = () => null;
|
|
46
46
|
this.getSessionId = () => null;
|
|
@@ -53,7 +53,16 @@ export class TelemetryContext implements IPropTelemetryContext {
|
|
|
53
53
|
_self.device = new Device();
|
|
54
54
|
_self.location = new Location();
|
|
55
55
|
_self.user = new User(defaultConfig, core);
|
|
56
|
-
|
|
56
|
+
|
|
57
|
+
let traceId: string;
|
|
58
|
+
let parentId: string;
|
|
59
|
+
let name: string;
|
|
60
|
+
if (previousTraceCtx) {
|
|
61
|
+
traceId = previousTraceCtx.getTraceId();
|
|
62
|
+
parentId = previousTraceCtx.getSpanId();
|
|
63
|
+
name = previousTraceCtx.getName();
|
|
64
|
+
}
|
|
65
|
+
_self.telemetryTrace = new TelemetryTrace(traceId, parentId, name, logger);
|
|
57
66
|
_self.session = new Session();
|
|
58
67
|
}
|
|
59
68
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* TelemetryContext.ts
|
|
3
3
|
* @copyright Microsoft 2018
|
|
4
4
|
*/
|
|
5
|
-
import { ITelemetryItem, IProcessTelemetryContext, IAppInsightsCore } from "@microsoft/applicationinsights-core-js";
|
|
5
|
+
import { ITelemetryItem, IProcessTelemetryContext, IAppInsightsCore, IDistributedTraceContext } from "@microsoft/applicationinsights-core-js";
|
|
6
6
|
import { _SessionManager } from "./Context/Session";
|
|
7
7
|
import { IOperatingSystem, ITelemetryTrace, IWeb, IApplication, IDevice, ILocation, IUserContext, IInternal, ISession } from "@microsoft/applicationinsights-common";
|
|
8
8
|
import { ITelemetryConfig } from "./Interfaces/ITelemetryConfig";
|
|
@@ -20,7 +20,7 @@ export declare class TelemetryContext implements IPropTelemetryContext {
|
|
|
20
20
|
web: IWeb;
|
|
21
21
|
appId: () => string;
|
|
22
22
|
getSessionId: () => string;
|
|
23
|
-
constructor(core: IAppInsightsCore, defaultConfig: ITelemetryConfig);
|
|
23
|
+
constructor(core: IAppInsightsCore, defaultConfig: ITelemetryConfig, previousTraceCtx?: IDistributedTraceContext);
|
|
24
24
|
applySessionContext(evt: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
|
|
25
25
|
applyOperatingSystemContxt(event: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
|
|
26
26
|
applyApplicationContext(event: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
|