Skip to content

Commit 803e140

Browse files
author
RMacfarlane
committed
Use application insights module instead of script tag, fixes microsoft#78475
1 parent 734c85e commit 803e140

11 files changed

Lines changed: 280 additions & 68 deletions

File tree

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"update-distro": "node build/npm/update-distro.js"
2929
},
3030
"dependencies": {
31+
"@microsoft/applicationinsights-web": "^2.1.1",
3132
"applicationinsights": "1.0.8",
3233
"graceful-fs": "4.1.11",
3334
"http-proxy-agent": "^2.1.0",

remote/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"name": "vscode-reh",
33
"version": "0.0.0",
44
"dependencies": {
5+
"@microsoft/applicationinsights-web": "^2.1.1",
56
"applicationinsights": "1.0.8",
67
"getmac": "1.4.1",
78
"graceful-fs": "4.1.11",

remote/web/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"name": "vscode-web",
33
"version": "0.0.0",
44
"dependencies": {
5+
"@microsoft/applicationinsights-web": "^2.1.1",
56
"onigasm-umd": "^2.2.2",
67
"vscode-textmate": "^4.1.1",
78
"xterm": "3.15.0-beta67",

remote/web/yarn.lock

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,69 @@
22
# yarn lockfile v1
33

44

5+
"@microsoft/applicationinsights-analytics-js@2.1.1":
6+
version "2.1.1"
7+
resolved "https://registry.yarnpkg.com/@microsoft/applicationinsights-analytics-js/-/applicationinsights-analytics-js-2.1.1.tgz#6d09c1915f808026e2d45165d04802f09affed59"
8+
integrity sha512-VKIutoFKY99CyKwxLUuj6Vnq14/QwXo9/QSQDpYnHEjo+uKn7QmLsHqWw0K9uYNfNAXt4BZimX/zDg6jZtzeXg==
9+
dependencies:
10+
"@microsoft/applicationinsights-common" "2.1.1"
11+
"@microsoft/applicationinsights-core-js" "2.1.1"
12+
tslib "^1.9.3"
13+
14+
"@microsoft/applicationinsights-channel-js@2.1.1":
15+
version "2.1.1"
16+
resolved "https://registry.yarnpkg.com/@microsoft/applicationinsights-channel-js/-/applicationinsights-channel-js-2.1.1.tgz#e205eddd93e49d17d9e0711a612b4bfc9810888f"
17+
integrity sha512-fYr9IAqtaEr9AmaPaL3SLQVT3t3GQzl+n74gpNKyAVakDIm0nYQ/bimjdcAhJMDf1VGNSPg/xICneyuZg7Wxlg==
18+
dependencies:
19+
"@microsoft/applicationinsights-common" "2.1.1"
20+
"@microsoft/applicationinsights-core-js" "2.1.1"
21+
tslib "^1.9.3"
22+
23+
"@microsoft/applicationinsights-common@2.1.1":
24+
version "2.1.1"
25+
resolved "https://registry.yarnpkg.com/@microsoft/applicationinsights-common/-/applicationinsights-common-2.1.1.tgz#27e6074584a7a3a8ca3f11f7ff2b7ff0f395bf2d"
26+
integrity sha512-2hkS1Ia1FmAjCuYZ5JlG20/WgObqdsKtmK5YALAFGHIB4KSQ/Za1qazS+7GsG+E0F9UJivNWL1geUIcNqg5Qjg==
27+
dependencies:
28+
"@microsoft/applicationinsights-core-js" "2.1.1"
29+
tslib "^1.9.3"
30+
31+
"@microsoft/applicationinsights-core-js@2.1.1":
32+
version "2.1.1"
33+
resolved "https://registry.yarnpkg.com/@microsoft/applicationinsights-core-js/-/applicationinsights-core-js-2.1.1.tgz#30fb6a519cc1c6119c419c4811ce72c260217d9e"
34+
integrity sha512-4t4wf6SKqIcWEQDPg/uOhm+BxtHhu/AFreyEoYZmMfcxzAu33h1FtTQRtxBNbYH1+thiNZCh80yUpnT7d9Hrlw==
35+
dependencies:
36+
tslib "^1.9.3"
37+
38+
"@microsoft/applicationinsights-dependencies-js@2.1.1":
39+
version "2.1.1"
40+
resolved "https://registry.yarnpkg.com/@microsoft/applicationinsights-dependencies-js/-/applicationinsights-dependencies-js-2.1.1.tgz#8154c3efcb24617d015d0bce7c2cc47797a8d3c4"
41+
integrity sha512-yhb4EToBp+aI+qLo0h5NDNtoo3sDFV60uyIOK843YjzXqVotcXX/lRShlghTkJtYH09QhrdzDjViUHnD4sMFSQ==
42+
dependencies:
43+
"@microsoft/applicationinsights-common" "2.1.1"
44+
"@microsoft/applicationinsights-core-js" "2.1.1"
45+
tslib "^1.9.3"
46+
47+
"@microsoft/applicationinsights-properties-js@2.1.1":
48+
version "2.1.1"
49+
resolved "https://registry.yarnpkg.com/@microsoft/applicationinsights-properties-js/-/applicationinsights-properties-js-2.1.1.tgz#ca34232766eb16167b5d87693e2ae5d94f2a1559"
50+
integrity sha512-8l+/ppw6xKTam2RL4EHZ52Lcf217olw81j6kyBNKtIcGwSnLNHrFwEeF3vBWIteG2JKzlg1GhGjrkB3oxXsV2g==
51+
dependencies:
52+
"@microsoft/applicationinsights-common" "2.1.1"
53+
"@microsoft/applicationinsights-core-js" "2.1.1"
54+
tslib "^1.9.3"
55+
56+
"@microsoft/applicationinsights-web@^2.1.1":
57+
version "2.1.1"
58+
resolved "https://registry.yarnpkg.com/@microsoft/applicationinsights-web/-/applicationinsights-web-2.1.1.tgz#1a44eddda7c244b88d9eb052dab6c855682e4f05"
59+
integrity sha512-crvhCkNsNxkFuPWmttyWNSAA96D5FxBtKS6UA9MV9f9XHevTfchf/E3AuU9JZcsXufWMQLwLrUQ9ZiA1QJ0EWA==
60+
dependencies:
61+
"@microsoft/applicationinsights-analytics-js" "2.1.1"
62+
"@microsoft/applicationinsights-channel-js" "2.1.1"
63+
"@microsoft/applicationinsights-common" "2.1.1"
64+
"@microsoft/applicationinsights-core-js" "2.1.1"
65+
"@microsoft/applicationinsights-dependencies-js" "2.1.1"
66+
"@microsoft/applicationinsights-properties-js" "2.1.1"
67+
568
nan@^2.14.0:
669
version "2.14.0"
770
resolved "https://registry.yarnpkg.com/nan/-/nan-2.14.0.tgz#7818f722027b2459a86f0295d434d1fc2336c52c"
@@ -24,6 +87,11 @@ semver-umd@^5.5.3:
2487
resolved "https://registry.yarnpkg.com/semver-umd/-/semver-umd-5.5.3.tgz#b64d7a2d4f5a717b369d56e31940a38e47e34d1e"
2588
integrity sha512-HOnQrn2iKnVe/xlqCTzMXQdvSz3rPbD0DmQXYuQ+oK1dpptGFfPghonQrx5JHl2O7EJwDqtQnjhE7ME23q6ngw==
2689

90+
tslib@^1.9.3:
91+
version "1.10.0"
92+
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.10.0.tgz#c3c19f95973fb0a62973fb09d90d961ee43e5c8a"
93+
integrity sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==
94+
2795
vscode-textmate@^4.1.1:
2896
version "4.2.2"
2997
resolved "https://registry.yarnpkg.com/vscode-textmate/-/vscode-textmate-4.2.2.tgz#0b4dabc69a6fba79a065cb6b615f66eac07c8f4c"

remote/yarn.lock

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,69 @@
22
# yarn lockfile v1
33

44

5+
"@microsoft/applicationinsights-analytics-js@2.1.1":
6+
version "2.1.1"
7+
resolved "https://registry.yarnpkg.com/@microsoft/applicationinsights-analytics-js/-/applicationinsights-analytics-js-2.1.1.tgz#6d09c1915f808026e2d45165d04802f09affed59"
8+
integrity sha512-VKIutoFKY99CyKwxLUuj6Vnq14/QwXo9/QSQDpYnHEjo+uKn7QmLsHqWw0K9uYNfNAXt4BZimX/zDg6jZtzeXg==
9+
dependencies:
10+
"@microsoft/applicationinsights-common" "2.1.1"
11+
"@microsoft/applicationinsights-core-js" "2.1.1"
12+
tslib "^1.9.3"
13+
14+
"@microsoft/applicationinsights-channel-js@2.1.1":
15+
version "2.1.1"
16+
resolved "https://registry.yarnpkg.com/@microsoft/applicationinsights-channel-js/-/applicationinsights-channel-js-2.1.1.tgz#e205eddd93e49d17d9e0711a612b4bfc9810888f"
17+
integrity sha512-fYr9IAqtaEr9AmaPaL3SLQVT3t3GQzl+n74gpNKyAVakDIm0nYQ/bimjdcAhJMDf1VGNSPg/xICneyuZg7Wxlg==
18+
dependencies:
19+
"@microsoft/applicationinsights-common" "2.1.1"
20+
"@microsoft/applicationinsights-core-js" "2.1.1"
21+
tslib "^1.9.3"
22+
23+
"@microsoft/applicationinsights-common@2.1.1":
24+
version "2.1.1"
25+
resolved "https://registry.yarnpkg.com/@microsoft/applicationinsights-common/-/applicationinsights-common-2.1.1.tgz#27e6074584a7a3a8ca3f11f7ff2b7ff0f395bf2d"
26+
integrity sha512-2hkS1Ia1FmAjCuYZ5JlG20/WgObqdsKtmK5YALAFGHIB4KSQ/Za1qazS+7GsG+E0F9UJivNWL1geUIcNqg5Qjg==
27+
dependencies:
28+
"@microsoft/applicationinsights-core-js" "2.1.1"
29+
tslib "^1.9.3"
30+
31+
"@microsoft/applicationinsights-core-js@2.1.1":
32+
version "2.1.1"
33+
resolved "https://registry.yarnpkg.com/@microsoft/applicationinsights-core-js/-/applicationinsights-core-js-2.1.1.tgz#30fb6a519cc1c6119c419c4811ce72c260217d9e"
34+
integrity sha512-4t4wf6SKqIcWEQDPg/uOhm+BxtHhu/AFreyEoYZmMfcxzAu33h1FtTQRtxBNbYH1+thiNZCh80yUpnT7d9Hrlw==
35+
dependencies:
36+
tslib "^1.9.3"
37+
38+
"@microsoft/applicationinsights-dependencies-js@2.1.1":
39+
version "2.1.1"
40+
resolved "https://registry.yarnpkg.com/@microsoft/applicationinsights-dependencies-js/-/applicationinsights-dependencies-js-2.1.1.tgz#8154c3efcb24617d015d0bce7c2cc47797a8d3c4"
41+
integrity sha512-yhb4EToBp+aI+qLo0h5NDNtoo3sDFV60uyIOK843YjzXqVotcXX/lRShlghTkJtYH09QhrdzDjViUHnD4sMFSQ==
42+
dependencies:
43+
"@microsoft/applicationinsights-common" "2.1.1"
44+
"@microsoft/applicationinsights-core-js" "2.1.1"
45+
tslib "^1.9.3"
46+
47+
"@microsoft/applicationinsights-properties-js@2.1.1":
48+
version "2.1.1"
49+
resolved "https://registry.yarnpkg.com/@microsoft/applicationinsights-properties-js/-/applicationinsights-properties-js-2.1.1.tgz#ca34232766eb16167b5d87693e2ae5d94f2a1559"
50+
integrity sha512-8l+/ppw6xKTam2RL4EHZ52Lcf217olw81j6kyBNKtIcGwSnLNHrFwEeF3vBWIteG2JKzlg1GhGjrkB3oxXsV2g==
51+
dependencies:
52+
"@microsoft/applicationinsights-common" "2.1.1"
53+
"@microsoft/applicationinsights-core-js" "2.1.1"
54+
tslib "^1.9.3"
55+
56+
"@microsoft/applicationinsights-web@^2.1.1":
57+
version "2.1.1"
58+
resolved "https://registry.yarnpkg.com/@microsoft/applicationinsights-web/-/applicationinsights-web-2.1.1.tgz#1a44eddda7c244b88d9eb052dab6c855682e4f05"
59+
integrity sha512-crvhCkNsNxkFuPWmttyWNSAA96D5FxBtKS6UA9MV9f9XHevTfchf/E3AuU9JZcsXufWMQLwLrUQ9ZiA1QJ0EWA==
60+
dependencies:
61+
"@microsoft/applicationinsights-analytics-js" "2.1.1"
62+
"@microsoft/applicationinsights-channel-js" "2.1.1"
63+
"@microsoft/applicationinsights-common" "2.1.1"
64+
"@microsoft/applicationinsights-core-js" "2.1.1"
65+
"@microsoft/applicationinsights-dependencies-js" "2.1.1"
66+
"@microsoft/applicationinsights-properties-js" "2.1.1"
67+
568
agent-base@4, agent-base@^4.1.0:
669
version "4.2.0"
770
resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-4.2.0.tgz#9838b5c3392b962bad031e6a4c5e1024abec45ce"
@@ -1024,6 +1087,11 @@ to-regex@^3.0.1, to-regex@^3.0.2:
10241087
regex-not "^1.0.2"
10251088
safe-regex "^1.1.0"
10261089

1090+
tslib@^1.9.3:
1091+
version "1.10.0"
1092+
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.10.0.tgz#c3c19f95973fb0a62973fb09d90d961ee43e5c8a"
1093+
integrity sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==
1094+
10271095
typechecker@^4.3.0:
10281096
version "4.7.0"
10291097
resolved "https://registry.yarnpkg.com/typechecker/-/typechecker-4.7.0.tgz#5249f427358f45b7250c4924fd4d01ed9ba435e9"
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
declare module 'applicationinsights-web' {
7+
export interface IConfig {
8+
instrumentationKey?: string;
9+
endpointUrl?: string;
10+
emitLineDelimitedJson?: boolean;
11+
accountId?: string;
12+
sessionRenewalMs?: number;
13+
sessionExpirationMs?: number;
14+
maxBatchSizeInBytes?: number;
15+
maxBatchInterval?: number;
16+
enableDebug?: boolean;
17+
disableExceptionTracking?: boolean;
18+
disableTelemetry?: boolean;
19+
verboseLogging?: boolean;
20+
diagnosticLogInterval?: number;
21+
samplingPercentage?: number;
22+
autoTrackPageVisitTime?: boolean;
23+
disableAjaxTracking?: boolean;
24+
overridePageViewDuration?: boolean;
25+
maxAjaxCallsPerView?: number;
26+
disableDataLossAnalysis?: boolean;
27+
disableCorrelationHeaders?: boolean;
28+
correlationHeaderExcludedDomains?: string[];
29+
disableFlushOnBeforeUnload?: boolean;
30+
enableSessionStorageBuffer?: boolean;
31+
isCookieUseDisabled?: boolean;
32+
cookieDomain?: string;
33+
isRetryDisabled?: boolean;
34+
url?: string;
35+
isStorageUseDisabled?: boolean;
36+
isBeaconApiDisabled?: boolean;
37+
sdkExtension?: string;
38+
isBrowserLinkTrackingEnabled?: boolean;
39+
appId?: string;
40+
enableCorsCorrelation?: boolean;
41+
}
42+
43+
export interface ISnippet {
44+
config: IConfig;
45+
}
46+
47+
export interface IEventTelemetry {
48+
name: string;
49+
properties?: { [key: string]: string };
50+
measurements?: { [key: string]: number };
51+
}
52+
53+
export class ApplicationInsights {
54+
constructor(config: ISnippet);
55+
loadAppInsights(): void;
56+
trackEvent(data: IEventTelemetry): void;
57+
flush(): void;
58+
}
59+
}

src/vs/code/browser/workbench/workbench.html

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@
2424
<body aria-label="">
2525
</body>
2626

27-
<!-- Application insights telemetry library -->
28-
<script src="https://az416426.vo.msecnd.net/scripts/a/ai.0.js"></script>
29-
3027
<!-- Require our AMD loader -->
3128
<script src="./out/vs/loader.js"></script>
3229

src/vs/code/browser/workbench/workbench.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
'xterm-addon-search': `${window.location.origin}/node_modules/xterm-addon-search/lib/xterm-addon-search.js`,
1717
'xterm-addon-web-links': `${window.location.origin}/node_modules/xterm-addon-web-links/lib/xterm-addon-web-links.js`,
1818
'semver-umd': `${window.location.origin}/node_modules/semver-umd/lib/semver-umd.js`,
19+
'applicationinsights-web': `${window.location.origin}/node_modules/@microsoft/applicationinsights-web/dist/applicationinsights-web.js`,
1920
}
2021
});
2122

@@ -24,4 +25,4 @@
2425

2526
api.create(document.body, options);
2627
});
27-
})();
28+
})();

src/vs/workbench/services/telemetry/browser/telemetryService.ts

Lines changed: 10 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -15,67 +15,10 @@ import { ClassifiedEvent, StrictPropertyCheck, GDPRClassification } from 'vs/pla
1515
import { IStorageService } from 'vs/platform/storage/common/storage';
1616
import { resolveWorkbenchCommonProperties } from 'vs/platform/telemetry/browser/workbenchCommonProperties';
1717
import { IProductService } from 'vs/platform/product/common/product';
18-
19-
interface IConfig {
20-
instrumentationKey?: string;
21-
endpointUrl?: string;
22-
emitLineDelimitedJson?: boolean;
23-
accountId?: string;
24-
sessionRenewalMs?: number;
25-
sessionExpirationMs?: number;
26-
maxBatchSizeInBytes?: number;
27-
maxBatchInterval?: number;
28-
enableDebug?: boolean;
29-
disableExceptionTracking?: boolean;
30-
disableTelemetry?: boolean;
31-
verboseLogging?: boolean;
32-
diagnosticLogInterval?: number;
33-
samplingPercentage?: number;
34-
autoTrackPageVisitTime?: boolean;
35-
disableAjaxTracking?: boolean;
36-
overridePageViewDuration?: boolean;
37-
maxAjaxCallsPerView?: number;
38-
disableDataLossAnalysis?: boolean;
39-
disableCorrelationHeaders?: boolean;
40-
correlationHeaderExcludedDomains?: string[];
41-
disableFlushOnBeforeUnload?: boolean;
42-
enableSessionStorageBuffer?: boolean;
43-
isCookieUseDisabled?: boolean;
44-
cookieDomain?: string;
45-
isRetryDisabled?: boolean;
46-
url?: string;
47-
isStorageUseDisabled?: boolean;
48-
isBeaconApiDisabled?: boolean;
49-
sdkExtension?: string;
50-
isBrowserLinkTrackingEnabled?: boolean;
51-
appId?: string;
52-
enableCorsCorrelation?: boolean;
53-
}
54-
55-
declare class Microsoft {
56-
public static ApplicationInsights: {
57-
Initialization: {
58-
new(init: { config: IConfig }): AppInsights;
59-
}
60-
};
61-
}
62-
63-
declare interface IAppInsightsClient {
64-
config: IConfig;
65-
66-
/** Log a user action or other occurrence. */
67-
trackEvent: (name: string, properties?: { [key: string]: string }, measurements?: { [key: string]: number }) => void;
68-
69-
/** Immediately send all queued telemetry. Synchronous. */
70-
flush(): void;
71-
}
72-
73-
interface AppInsights {
74-
loadAppInsights: () => IAppInsightsClient;
75-
}
18+
import { ApplicationInsights } from 'applicationinsights-web';
7619

7720
export class WebTelemetryAppender implements ITelemetryAppender {
78-
private _aiClient?: IAppInsightsClient;
21+
private _aiClient?: ApplicationInsights;
7922

8023
constructor(aiKey: string, private _logService: ILogService) {
8124
const initConfig = {
@@ -89,8 +32,8 @@ export class WebTelemetryAppender implements ITelemetryAppender {
8932
}
9033
};
9134

92-
const appInsights = new Microsoft.ApplicationInsights.Initialization(initConfig);
93-
this._aiClient = appInsights.loadAppInsights();
35+
this._aiClient = new ApplicationInsights(initConfig);
36+
this._aiClient.loadAppInsights();
9437
}
9538

9639
log(eventName: string, data: any): void {
@@ -101,7 +44,11 @@ export class WebTelemetryAppender implements ITelemetryAppender {
10144
data = validateTelemetryData(data);
10245
this._logService.trace(`telemetry/${eventName}`, data);
10346

104-
this._aiClient.trackEvent('monacoworkbench/' + eventName, data.properties, data.measurements);
47+
this._aiClient.trackEvent({
48+
name: 'monacoworkbench/' + eventName,
49+
properties: data.properties,
50+
measurements: data.measurements
51+
});
10552
}
10653

10754
flush(): Promise<void> {
@@ -167,4 +114,4 @@ export class TelemetryService extends Disposable implements ITelemetryService {
167114
}
168115
}
169116

170-
registerSingleton(ITelemetryService, TelemetryService);
117+
registerSingleton(ITelemetryService, TelemetryService);

tslint.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,8 @@
446446
"**/vs/workbench/{common,browser}/**",
447447
"**/vs/workbench/services/**/{common,browser}/**",
448448
"vscode-textmate",
449-
"onigasm-umd"
449+
"onigasm-umd",
450+
"applicationinsights-web"
450451
]
451452
},
452453
{

0 commit comments

Comments
 (0)