Merge pull request #117 from microsoft/lramos15/empirical-squid
Remove first party support of AI
This commit is contained in:
Коммит
5d778578cb
|
@ -1,22 +1,11 @@
|
|||
const esbuild = require('esbuild');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
// Removes the warning from the app insights module since we don't want it to spam the console
|
||||
function patchAppInsightsModules() {
|
||||
const nodeAppInsightsModule = fs.readFileSync(path.join(__dirname, 'node_modules/applicationinsights/out/Library/Config.js'), 'utf8');
|
||||
const fileWithRemovedWarning = nodeAppInsightsModule.replace(/Logging.warn\([^)]*invalid instrumentation key[^)]*\)/, '// Warning removed');
|
||||
fs.writeFileSync(path.join(__dirname, 'node_modules/applicationinsights/out/Library/Config.js'), fileWithRemovedWarning, 'utf8');
|
||||
}
|
||||
|
||||
patchAppInsightsModules();
|
||||
|
||||
// Build node packages and their minifed versions
|
||||
esbuild.build({
|
||||
entryPoints: ['src/node/telemetryReporter.ts'],
|
||||
tsconfig: "./src/node/tsconfig.json",
|
||||
bundle: true,
|
||||
external: ['vscode', '@microsoft/1ds-core-js', '@microsoft/1ds-post-js'],
|
||||
external: ['vscode', './node_modules/*'],
|
||||
sourcemap: true,
|
||||
platform: 'node',
|
||||
target: ['node14'],
|
||||
|
@ -28,7 +17,7 @@ esbuild.build({
|
|||
tsconfig: "./src/node/tsconfig.json",
|
||||
bundle: true,
|
||||
sourcemap: false,
|
||||
external: ['vscode', '@microsoft/1ds-core-js', '@microsoft/1ds-post-js'],
|
||||
external: ['vscode', './node_modules/*'],
|
||||
minify: true,
|
||||
platform: 'node',
|
||||
target: ['node14'],
|
||||
|
@ -42,7 +31,7 @@ esbuild.build({
|
|||
tsconfig: "./src/browser/tsconfig.json",
|
||||
bundle: true,
|
||||
sourcemap: true,
|
||||
external: ['vscode', '@microsoft/1ds-core-js', '@microsoft/1ds-post-js'],
|
||||
external: ['vscode', './node_modules/*'],
|
||||
platform: 'browser',
|
||||
target: ['es6'],
|
||||
outfile: 'lib/telemetryReporter.web.js',
|
||||
|
@ -54,7 +43,7 @@ esbuild.build({
|
|||
format: "esm",
|
||||
bundle: true,
|
||||
sourcemap: false,
|
||||
external: ['vscode', '@microsoft/1ds-core-js', '@microsoft/1ds-post-js'],
|
||||
external: ['vscode', './node_modules/*'],
|
||||
minify: true,
|
||||
platform: 'browser',
|
||||
target: ['es6'],
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -18,18 +18,18 @@
|
|||
"compile": "tsc -noEmit -p 'src/browser/tsconfig.json' && tsc -noEmit -p 'src/node/tsconfig.json' && npm run build"
|
||||
},
|
||||
"dependencies": {
|
||||
"@microsoft/1ds-core-js": "^3.2.3",
|
||||
"@microsoft/1ds-post-js": "^3.2.3"
|
||||
"@microsoft/1ds-core-js": "^3.2.4",
|
||||
"@microsoft/1ds-post-js": "^3.2.4",
|
||||
"@microsoft/applicationinsights-web": "^2.8.5",
|
||||
"applicationinsights": "2.3.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@microsoft/applicationinsights-web": "^2.6.4",
|
||||
"@types/mocha": "^9.1.1",
|
||||
"@types/node": "^16.11.32",
|
||||
"@types/sinon": "^10.0.11",
|
||||
"@types/vscode": "^1.60.0",
|
||||
"@typescript-eslint/eslint-plugin": "^5.18.0",
|
||||
"@typescript-eslint/parser": "^5.18.0",
|
||||
"applicationinsights": "2.1.4",
|
||||
"esbuild": "^0.14.32",
|
||||
"eslint": "^8.12.0",
|
||||
"mocha": "^9.2.2",
|
||||
|
|
|
@ -13,14 +13,9 @@ const webAppInsightsClientFactory = async (key: string, replacementOptions?: Rep
|
|||
let appInsightsClient: ApplicationInsights | undefined;
|
||||
try {
|
||||
const web = await import("@microsoft/applicationinsights-web");
|
||||
let endpointUrl: undefined | string;
|
||||
if (key && key.indexOf("AIF-") === 0) {
|
||||
endpointUrl = "https://vscode.vortex.data.microsoft.com/collect/v1";
|
||||
}
|
||||
appInsightsClient = new web.ApplicationInsights({
|
||||
config: {
|
||||
instrumentationKey: key,
|
||||
endpointUrl,
|
||||
disableAjaxTracking: true,
|
||||
disableExceptionTracking: true,
|
||||
disableFetchTracking: true,
|
||||
|
@ -32,11 +27,6 @@ const webAppInsightsClientFactory = async (key: string, replacementOptions?: Rep
|
|||
},
|
||||
});
|
||||
appInsightsClient.loadAppInsights();
|
||||
// If we cannot access the endpoint this most likely means it's being blocked
|
||||
// and we should not attempt to send any telemetry.
|
||||
if (endpointUrl) {
|
||||
fetch(endpointUrl).catch(() => (appInsightsClient = undefined));
|
||||
}
|
||||
} catch (e) {
|
||||
return Promise.reject(e);
|
||||
}
|
||||
|
@ -79,8 +69,12 @@ export default class TelemetryReporter extends BaseTelemetryReporter {
|
|||
}
|
||||
|
||||
const appender = new BaseTelemetryAppender(key, clientFactory);
|
||||
// If it's a specialized AIF app insights key or a 1DS key then it is first party
|
||||
if (key && (key.indexOf("AIF-") === 0 || TelemetryUtil.shouldUseOneDataSystemSDK(key))) {
|
||||
// AIF is no longer supported
|
||||
if (key && (key.indexOf("AIF") === 0)) {
|
||||
throw new Error("AIF keys are no longer supported. Please switch to 1DS keys for 1st party extensions");
|
||||
}
|
||||
// If it's a 1DS key it is first party
|
||||
if (TelemetryUtil.shouldUseOneDataSystemSDK(key)) {
|
||||
firstParty = true;
|
||||
}
|
||||
super(extensionId, extensionVersion, appender, {
|
||||
|
|
|
@ -49,10 +49,6 @@ const appInsightsClientFactory = async (key: string, replacementOptions?: Replac
|
|||
appInsightsClient.context.tags[appInsightsClient.context.keys.cloudRole] = vscode.env.appName;
|
||||
appInsightsClient.context.tags[appInsightsClient.context.keys.cloudRoleInstance] = vscode.env.appName;
|
||||
}
|
||||
//check if it's an Asimov key to change the endpoint
|
||||
if (key && key.indexOf("AIF-") === 0) {
|
||||
appInsightsClient.config.endpointUrl = "https://mobile.events.data.microsoft.com/collect/v1";
|
||||
}
|
||||
} catch (e: any) {
|
||||
return Promise.reject("Failed to initialize app insights!\n" + e.message);
|
||||
}
|
||||
|
@ -167,8 +163,11 @@ export default class TelemetryReporter extends BaseTelemetryReporter {
|
|||
}
|
||||
|
||||
const appender = new BaseTelemetryAppender(key, clientFactory);
|
||||
// If it's a specialized AIF app insights key or a 1DS key then it is first party
|
||||
if (key && (key.indexOf("AIF-") === 0 || TelemetryUtil.shouldUseOneDataSystemSDK(key))) {
|
||||
if (key && key.indexOf("AIF-") === 0) {
|
||||
throw new Error("AIF keys are no longer supported. Please switch to 1DS keys for 1st party extensions");
|
||||
}
|
||||
// 1DS is always first party
|
||||
if (TelemetryUtil.shouldUseOneDataSystemSDK(key)) {
|
||||
firstParty = true;
|
||||
}
|
||||
super(extensionId, extensionVersion, appender, {
|
||||
|
|
Загрузка…
Ссылка в новой задаче