Skip to content

Commit

Permalink
Use application insights module instead of script tag, fixes microsof…
Browse files Browse the repository at this point in the history
  • Loading branch information
RMacfarlane committed Aug 9, 2019
1 parent 734c85e commit 803e140
Show file tree
Hide file tree
Showing 11 changed files with 280 additions and 68 deletions.
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -28,6 +28,7 @@
"update-distro": "node build/npm/update-distro.js"
},
"dependencies": {
"@microsoft/applicationinsights-web": "^2.1.1",
"applicationinsights": "1.0.8",
"graceful-fs": "4.1.11",
"http-proxy-agent": "^2.1.0",
Expand Down
1 change: 1 addition & 0 deletions remote/package.json
Expand Up @@ -2,6 +2,7 @@
"name": "vscode-reh",
"version": "0.0.0",
"dependencies": {
"@microsoft/applicationinsights-web": "^2.1.1",
"applicationinsights": "1.0.8",
"getmac": "1.4.1",
"graceful-fs": "4.1.11",
Expand Down
1 change: 1 addition & 0 deletions remote/web/package.json
Expand Up @@ -2,6 +2,7 @@
"name": "vscode-web",
"version": "0.0.0",
"dependencies": {
"@microsoft/applicationinsights-web": "^2.1.1",
"onigasm-umd": "^2.2.2",
"vscode-textmate": "^4.1.1",
"xterm": "3.15.0-beta67",
Expand Down
68 changes: 68 additions & 0 deletions remote/web/yarn.lock
Expand Up @@ -2,6 +2,69 @@
# yarn lockfile v1


"@microsoft/applicationinsights-analytics-js@2.1.1":
version "2.1.1"
resolved "https://registry.yarnpkg.com/@microsoft/applicationinsights-analytics-js/-/applicationinsights-analytics-js-2.1.1.tgz#6d09c1915f808026e2d45165d04802f09affed59"
integrity sha512-VKIutoFKY99CyKwxLUuj6Vnq14/QwXo9/QSQDpYnHEjo+uKn7QmLsHqWw0K9uYNfNAXt4BZimX/zDg6jZtzeXg==
dependencies:
"@microsoft/applicationinsights-common" "2.1.1"
"@microsoft/applicationinsights-core-js" "2.1.1"
tslib "^1.9.3"

"@microsoft/applicationinsights-channel-js@2.1.1":
version "2.1.1"
resolved "https://registry.yarnpkg.com/@microsoft/applicationinsights-channel-js/-/applicationinsights-channel-js-2.1.1.tgz#e205eddd93e49d17d9e0711a612b4bfc9810888f"
integrity sha512-fYr9IAqtaEr9AmaPaL3SLQVT3t3GQzl+n74gpNKyAVakDIm0nYQ/bimjdcAhJMDf1VGNSPg/xICneyuZg7Wxlg==
dependencies:
"@microsoft/applicationinsights-common" "2.1.1"
"@microsoft/applicationinsights-core-js" "2.1.1"
tslib "^1.9.3"

"@microsoft/applicationinsights-common@2.1.1":
version "2.1.1"
resolved "https://registry.yarnpkg.com/@microsoft/applicationinsights-common/-/applicationinsights-common-2.1.1.tgz#27e6074584a7a3a8ca3f11f7ff2b7ff0f395bf2d"
integrity sha512-2hkS1Ia1FmAjCuYZ5JlG20/WgObqdsKtmK5YALAFGHIB4KSQ/Za1qazS+7GsG+E0F9UJivNWL1geUIcNqg5Qjg==
dependencies:
"@microsoft/applicationinsights-core-js" "2.1.1"
tslib "^1.9.3"

"@microsoft/applicationinsights-core-js@2.1.1":
version "2.1.1"
resolved "https://registry.yarnpkg.com/@microsoft/applicationinsights-core-js/-/applicationinsights-core-js-2.1.1.tgz#30fb6a519cc1c6119c419c4811ce72c260217d9e"
integrity sha512-4t4wf6SKqIcWEQDPg/uOhm+BxtHhu/AFreyEoYZmMfcxzAu33h1FtTQRtxBNbYH1+thiNZCh80yUpnT7d9Hrlw==
dependencies:
tslib "^1.9.3"

"@microsoft/applicationinsights-dependencies-js@2.1.1":
version "2.1.1"
resolved "https://registry.yarnpkg.com/@microsoft/applicationinsights-dependencies-js/-/applicationinsights-dependencies-js-2.1.1.tgz#8154c3efcb24617d015d0bce7c2cc47797a8d3c4"
integrity sha512-yhb4EToBp+aI+qLo0h5NDNtoo3sDFV60uyIOK843YjzXqVotcXX/lRShlghTkJtYH09QhrdzDjViUHnD4sMFSQ==
dependencies:
"@microsoft/applicationinsights-common" "2.1.1"
"@microsoft/applicationinsights-core-js" "2.1.1"
tslib "^1.9.3"

"@microsoft/applicationinsights-properties-js@2.1.1":
version "2.1.1"
resolved "https://registry.yarnpkg.com/@microsoft/applicationinsights-properties-js/-/applicationinsights-properties-js-2.1.1.tgz#ca34232766eb16167b5d87693e2ae5d94f2a1559"
integrity sha512-8l+/ppw6xKTam2RL4EHZ52Lcf217olw81j6kyBNKtIcGwSnLNHrFwEeF3vBWIteG2JKzlg1GhGjrkB3oxXsV2g==
dependencies:
"@microsoft/applicationinsights-common" "2.1.1"
"@microsoft/applicationinsights-core-js" "2.1.1"
tslib "^1.9.3"

"@microsoft/applicationinsights-web@^2.1.1":
version "2.1.1"
resolved "https://registry.yarnpkg.com/@microsoft/applicationinsights-web/-/applicationinsights-web-2.1.1.tgz#1a44eddda7c244b88d9eb052dab6c855682e4f05"
integrity sha512-crvhCkNsNxkFuPWmttyWNSAA96D5FxBtKS6UA9MV9f9XHevTfchf/E3AuU9JZcsXufWMQLwLrUQ9ZiA1QJ0EWA==
dependencies:
"@microsoft/applicationinsights-analytics-js" "2.1.1"
"@microsoft/applicationinsights-channel-js" "2.1.1"
"@microsoft/applicationinsights-common" "2.1.1"
"@microsoft/applicationinsights-core-js" "2.1.1"
"@microsoft/applicationinsights-dependencies-js" "2.1.1"
"@microsoft/applicationinsights-properties-js" "2.1.1"

nan@^2.14.0:
version "2.14.0"
resolved "https://registry.yarnpkg.com/nan/-/nan-2.14.0.tgz#7818f722027b2459a86f0295d434d1fc2336c52c"
Expand All @@ -24,6 +87,11 @@ semver-umd@^5.5.3:
resolved "https://registry.yarnpkg.com/semver-umd/-/semver-umd-5.5.3.tgz#b64d7a2d4f5a717b369d56e31940a38e47e34d1e"
integrity sha512-HOnQrn2iKnVe/xlqCTzMXQdvSz3rPbD0DmQXYuQ+oK1dpptGFfPghonQrx5JHl2O7EJwDqtQnjhE7ME23q6ngw==

tslib@^1.9.3:
version "1.10.0"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.10.0.tgz#c3c19f95973fb0a62973fb09d90d961ee43e5c8a"
integrity sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==

vscode-textmate@^4.1.1:
version "4.2.2"
resolved "https://registry.yarnpkg.com/vscode-textmate/-/vscode-textmate-4.2.2.tgz#0b4dabc69a6fba79a065cb6b615f66eac07c8f4c"
Expand Down
68 changes: 68 additions & 0 deletions remote/yarn.lock
Expand Up @@ -2,6 +2,69 @@
# yarn lockfile v1


"@microsoft/applicationinsights-analytics-js@2.1.1":
version "2.1.1"
resolved "https://registry.yarnpkg.com/@microsoft/applicationinsights-analytics-js/-/applicationinsights-analytics-js-2.1.1.tgz#6d09c1915f808026e2d45165d04802f09affed59"
integrity sha512-VKIutoFKY99CyKwxLUuj6Vnq14/QwXo9/QSQDpYnHEjo+uKn7QmLsHqWw0K9uYNfNAXt4BZimX/zDg6jZtzeXg==
dependencies:
"@microsoft/applicationinsights-common" "2.1.1"
"@microsoft/applicationinsights-core-js" "2.1.1"
tslib "^1.9.3"

"@microsoft/applicationinsights-channel-js@2.1.1":
version "2.1.1"
resolved "https://registry.yarnpkg.com/@microsoft/applicationinsights-channel-js/-/applicationinsights-channel-js-2.1.1.tgz#e205eddd93e49d17d9e0711a612b4bfc9810888f"
integrity sha512-fYr9IAqtaEr9AmaPaL3SLQVT3t3GQzl+n74gpNKyAVakDIm0nYQ/bimjdcAhJMDf1VGNSPg/xICneyuZg7Wxlg==
dependencies:
"@microsoft/applicationinsights-common" "2.1.1"
"@microsoft/applicationinsights-core-js" "2.1.1"
tslib "^1.9.3"

"@microsoft/applicationinsights-common@2.1.1":
version "2.1.1"
resolved "https://registry.yarnpkg.com/@microsoft/applicationinsights-common/-/applicationinsights-common-2.1.1.tgz#27e6074584a7a3a8ca3f11f7ff2b7ff0f395bf2d"
integrity sha512-2hkS1Ia1FmAjCuYZ5JlG20/WgObqdsKtmK5YALAFGHIB4KSQ/Za1qazS+7GsG+E0F9UJivNWL1geUIcNqg5Qjg==
dependencies:
"@microsoft/applicationinsights-core-js" "2.1.1"
tslib "^1.9.3"

"@microsoft/applicationinsights-core-js@2.1.1":
version "2.1.1"
resolved "https://registry.yarnpkg.com/@microsoft/applicationinsights-core-js/-/applicationinsights-core-js-2.1.1.tgz#30fb6a519cc1c6119c419c4811ce72c260217d9e"
integrity sha512-4t4wf6SKqIcWEQDPg/uOhm+BxtHhu/AFreyEoYZmMfcxzAu33h1FtTQRtxBNbYH1+thiNZCh80yUpnT7d9Hrlw==
dependencies:
tslib "^1.9.3"

"@microsoft/applicationinsights-dependencies-js@2.1.1":
version "2.1.1"
resolved "https://registry.yarnpkg.com/@microsoft/applicationinsights-dependencies-js/-/applicationinsights-dependencies-js-2.1.1.tgz#8154c3efcb24617d015d0bce7c2cc47797a8d3c4"
integrity sha512-yhb4EToBp+aI+qLo0h5NDNtoo3sDFV60uyIOK843YjzXqVotcXX/lRShlghTkJtYH09QhrdzDjViUHnD4sMFSQ==
dependencies:
"@microsoft/applicationinsights-common" "2.1.1"
"@microsoft/applicationinsights-core-js" "2.1.1"
tslib "^1.9.3"

"@microsoft/applicationinsights-properties-js@2.1.1":
version "2.1.1"
resolved "https://registry.yarnpkg.com/@microsoft/applicationinsights-properties-js/-/applicationinsights-properties-js-2.1.1.tgz#ca34232766eb16167b5d87693e2ae5d94f2a1559"
integrity sha512-8l+/ppw6xKTam2RL4EHZ52Lcf217olw81j6kyBNKtIcGwSnLNHrFwEeF3vBWIteG2JKzlg1GhGjrkB3oxXsV2g==
dependencies:
"@microsoft/applicationinsights-common" "2.1.1"
"@microsoft/applicationinsights-core-js" "2.1.1"
tslib "^1.9.3"

"@microsoft/applicationinsights-web@^2.1.1":
version "2.1.1"
resolved "https://registry.yarnpkg.com/@microsoft/applicationinsights-web/-/applicationinsights-web-2.1.1.tgz#1a44eddda7c244b88d9eb052dab6c855682e4f05"
integrity sha512-crvhCkNsNxkFuPWmttyWNSAA96D5FxBtKS6UA9MV9f9XHevTfchf/E3AuU9JZcsXufWMQLwLrUQ9ZiA1QJ0EWA==
dependencies:
"@microsoft/applicationinsights-analytics-js" "2.1.1"
"@microsoft/applicationinsights-channel-js" "2.1.1"
"@microsoft/applicationinsights-common" "2.1.1"
"@microsoft/applicationinsights-core-js" "2.1.1"
"@microsoft/applicationinsights-dependencies-js" "2.1.1"
"@microsoft/applicationinsights-properties-js" "2.1.1"

agent-base@4, agent-base@^4.1.0:
version "4.2.0"
resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-4.2.0.tgz#9838b5c3392b962bad031e6a4c5e1024abec45ce"
Expand Down Expand Up @@ -1024,6 +1087,11 @@ to-regex@^3.0.1, to-regex@^3.0.2:
regex-not "^1.0.2"
safe-regex "^1.1.0"

tslib@^1.9.3:
version "1.10.0"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.10.0.tgz#c3c19f95973fb0a62973fb09d90d961ee43e5c8a"
integrity sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==

typechecker@^4.3.0:
version "4.7.0"
resolved "https://registry.yarnpkg.com/typechecker/-/typechecker-4.7.0.tgz#5249f427358f45b7250c4924fd4d01ed9ba435e9"
Expand Down
59 changes: 59 additions & 0 deletions src/typings/applicationinsights-web.d.ts
@@ -0,0 +1,59 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

declare module 'applicationinsights-web' {
export interface IConfig {
instrumentationKey?: string;
endpointUrl?: string;
emitLineDelimitedJson?: boolean;
accountId?: string;
sessionRenewalMs?: number;
sessionExpirationMs?: number;
maxBatchSizeInBytes?: number;
maxBatchInterval?: number;
enableDebug?: boolean;
disableExceptionTracking?: boolean;
disableTelemetry?: boolean;
verboseLogging?: boolean;
diagnosticLogInterval?: number;
samplingPercentage?: number;
autoTrackPageVisitTime?: boolean;
disableAjaxTracking?: boolean;
overridePageViewDuration?: boolean;
maxAjaxCallsPerView?: number;
disableDataLossAnalysis?: boolean;
disableCorrelationHeaders?: boolean;
correlationHeaderExcludedDomains?: string[];
disableFlushOnBeforeUnload?: boolean;
enableSessionStorageBuffer?: boolean;
isCookieUseDisabled?: boolean;
cookieDomain?: string;
isRetryDisabled?: boolean;
url?: string;
isStorageUseDisabled?: boolean;
isBeaconApiDisabled?: boolean;
sdkExtension?: string;
isBrowserLinkTrackingEnabled?: boolean;
appId?: string;
enableCorsCorrelation?: boolean;
}

export interface ISnippet {
config: IConfig;
}

export interface IEventTelemetry {
name: string;
properties?: { [key: string]: string };
measurements?: { [key: string]: number };
}

export class ApplicationInsights {
constructor(config: ISnippet);
loadAppInsights(): void;
trackEvent(data: IEventTelemetry): void;
flush(): void;
}
}
3 changes: 0 additions & 3 deletions src/vs/code/browser/workbench/workbench.html
Expand Up @@ -24,9 +24,6 @@
<body aria-label="">
</body>

<!-- Application insights telemetry library -->
<script src="https://az416426.vo.msecnd.net/scripts/a/ai.0.js"></script>

<!-- Require our AMD loader -->
<script src="./out/vs/loader.js"></script>

Expand Down
3 changes: 2 additions & 1 deletion src/vs/code/browser/workbench/workbench.js
Expand Up @@ -16,6 +16,7 @@
'xterm-addon-search': `${window.location.origin}/node_modules/xterm-addon-search/lib/xterm-addon-search.js`,
'xterm-addon-web-links': `${window.location.origin}/node_modules/xterm-addon-web-links/lib/xterm-addon-web-links.js`,
'semver-umd': `${window.location.origin}/node_modules/semver-umd/lib/semver-umd.js`,
'applicationinsights-web': `${window.location.origin}/node_modules/@microsoft/applicationinsights-web/dist/applicationinsights-web.js`,
}
});

Expand All @@ -24,4 +25,4 @@

api.create(document.body, options);
});
})();
})();
73 changes: 10 additions & 63 deletions src/vs/workbench/services/telemetry/browser/telemetryService.ts
Expand Up @@ -15,67 +15,10 @@ import { ClassifiedEvent, StrictPropertyCheck, GDPRClassification } from 'vs/pla
import { IStorageService } from 'vs/platform/storage/common/storage';
import { resolveWorkbenchCommonProperties } from 'vs/platform/telemetry/browser/workbenchCommonProperties';
import { IProductService } from 'vs/platform/product/common/product';

interface IConfig {
instrumentationKey?: string;
endpointUrl?: string;
emitLineDelimitedJson?: boolean;
accountId?: string;
sessionRenewalMs?: number;
sessionExpirationMs?: number;
maxBatchSizeInBytes?: number;
maxBatchInterval?: number;
enableDebug?: boolean;
disableExceptionTracking?: boolean;
disableTelemetry?: boolean;
verboseLogging?: boolean;
diagnosticLogInterval?: number;
samplingPercentage?: number;
autoTrackPageVisitTime?: boolean;
disableAjaxTracking?: boolean;
overridePageViewDuration?: boolean;
maxAjaxCallsPerView?: number;
disableDataLossAnalysis?: boolean;
disableCorrelationHeaders?: boolean;
correlationHeaderExcludedDomains?: string[];
disableFlushOnBeforeUnload?: boolean;
enableSessionStorageBuffer?: boolean;
isCookieUseDisabled?: boolean;
cookieDomain?: string;
isRetryDisabled?: boolean;
url?: string;
isStorageUseDisabled?: boolean;
isBeaconApiDisabled?: boolean;
sdkExtension?: string;
isBrowserLinkTrackingEnabled?: boolean;
appId?: string;
enableCorsCorrelation?: boolean;
}

declare class Microsoft {
public static ApplicationInsights: {
Initialization: {
new(init: { config: IConfig }): AppInsights;
}
};
}

declare interface IAppInsightsClient {
config: IConfig;

/** Log a user action or other occurrence. */
trackEvent: (name: string, properties?: { [key: string]: string }, measurements?: { [key: string]: number }) => void;

/** Immediately send all queued telemetry. Synchronous. */
flush(): void;
}

interface AppInsights {
loadAppInsights: () => IAppInsightsClient;
}
import { ApplicationInsights } from 'applicationinsights-web';

export class WebTelemetryAppender implements ITelemetryAppender {
private _aiClient?: IAppInsightsClient;
private _aiClient?: ApplicationInsights;

constructor(aiKey: string, private _logService: ILogService) {
const initConfig = {
Expand All @@ -89,8 +32,8 @@ export class WebTelemetryAppender implements ITelemetryAppender {
}
};

const appInsights = new Microsoft.ApplicationInsights.Initialization(initConfig);
this._aiClient = appInsights.loadAppInsights();
this._aiClient = new ApplicationInsights(initConfig);
this._aiClient.loadAppInsights();
}

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

this._aiClient.trackEvent('monacoworkbench/' + eventName, data.properties, data.measurements);
this._aiClient.trackEvent({
name: 'monacoworkbench/' + eventName,
properties: data.properties,
measurements: data.measurements
});
}

flush(): Promise<void> {
Expand Down Expand Up @@ -167,4 +114,4 @@ export class TelemetryService extends Disposable implements ITelemetryService {
}
}

registerSingleton(ITelemetryService, TelemetryService);
registerSingleton(ITelemetryService, TelemetryService);
3 changes: 2 additions & 1 deletion tslint.json
Expand Up @@ -446,7 +446,8 @@
"**/vs/workbench/{common,browser}/**",
"**/vs/workbench/services/**/{common,browser}/**",
"vscode-textmate",
"onigasm-umd"
"onigasm-umd",
"applicationinsights-web"
]
},
{
Expand Down

0 comments on commit 803e140

Please sign in to comment.