diff --git a/.esbuild.config.js b/.esbuild.config.js deleted file mode 100644 index c9be900..0000000 --- a/.esbuild.config.js +++ /dev/null @@ -1,51 +0,0 @@ -const esbuild = require('esbuild'); - -// Build node packages and their minifed versions -esbuild.build({ - entryPoints: ['src/node/telemetryReporter.ts'], - tsconfig: "./src/node/tsconfig.json", - bundle: true, - external: ['vscode', './node_modules/*'], - sourcemap: true, - platform: 'node', - target: ['node14'], - outfile: 'lib/telemetryReporter.node.js', -}).catch(() => process.exit(1)) - -esbuild.build({ - entryPoints: ['src/node/telemetryReporter.ts'], - tsconfig: "./src/node/tsconfig.json", - bundle: true, - sourcemap: false, - external: ['vscode', './node_modules/*'], - minify: true, - platform: 'node', - target: ['node14'], - outfile: 'lib/telemetryReporter.node.min.js', -}).catch(() => process.exit(1)) - -// Build browser packages and their minified versions -esbuild.build({ - entryPoints: ['src/browser/telemetryReporter.ts'], - format: "esm", - tsconfig: "./src/browser/tsconfig.json", - bundle: true, - sourcemap: true, - external: ['vscode', './node_modules/*'], - platform: 'browser', - target: ['es6'], - outfile: 'lib/telemetryReporter.web.js', -}).catch(() => process.exit(1)) - -esbuild.build({ - entryPoints: ['src/browser/telemetryReporter.ts'], - tsconfig: "./src/browser/tsconfig.json", - format: "esm", - bundle: true, - sourcemap: false, - external: ['vscode', './node_modules/*'], - minify: true, - platform: 'browser', - target: ['es6'], - outfile: 'lib/telemetryReporter.web.min.js', -}).catch(() => process.exit(1)) diff --git a/.gitignore b/.gitignore index 7a33cf1..45f31a2 100644 --- a/.gitignore +++ b/.gitignore @@ -9,8 +9,10 @@ npm-debug.log # sourcemaps src/**/*.js.map -lib/**/*.js.map -lib/**/*.js + +# dist +dist/**/* +!dist/**/*.d.ts # Packaged node modules *.tgz \ No newline at end of file diff --git a/.npmignore b/.npmignore index 88d0e3f..53426a5 100644 --- a/.npmignore +++ b/.npmignore @@ -1,10 +1,6 @@ .vscode build .github -lib/*.js.map -lib/*.js -lib/test -!lib/*.min.js node_modules src typings_patches @@ -16,4 +12,5 @@ tsfmt.json .esbuild.config.js .eslintrc.json .eslintignore +*.tgz *.test.ts \ No newline at end of file diff --git a/lib/telemetryReporter.d.ts b/dist/telemetryReporter.d.ts similarity index 100% rename from lib/telemetryReporter.d.ts rename to dist/telemetryReporter.d.ts diff --git a/package-lock.json b/package-lock.json index 4f7866b..195a923 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@vscode/extension-telemetry", - "version": "0.6.2", + "version": "0.6.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@vscode/extension-telemetry", - "version": "0.6.2", + "version": "0.6.3", "license": "MIT", "dependencies": { "@microsoft/1ds-core-js": "^3.2.4", diff --git a/package.json b/package.json index 08018cc..953959b 100644 --- a/package.json +++ b/package.json @@ -1,21 +1,21 @@ { "name": "@vscode/extension-telemetry", "description": "A module for Visual Studio Code extensions to report consistent telemetry.", - "version": "0.6.2", + "version": "0.6.3", "author": { "name": "Microsoft Corporation" }, - "main": "./lib/telemetryReporter.node.min.js", - "browser": "./lib/telemetryReporter.web.min.js", + "main": "./dist/node/src/node/telemetryReporter.js", + "browser": "./dist/browser/src/browser/telemetryReporter.js", "types": "./lib/telemetryReporter.d.ts", "license": "MIT", "engines": { "vscode": "^1.60.0" }, "scripts": { - "build": "node .esbuild.config.js", + "build": "npm run compile", "test": "tsc -p 'test/tsconfig.json' && mocha lib/test/*", - "compile": "tsc -noEmit -p 'src/browser/tsconfig.json' && tsc -noEmit -p 'src/node/tsconfig.json' && npm run build" + "compile": "tsc -p 'src/browser/tsconfig.json' && tsc -p 'src/node/tsconfig.json'" }, "dependencies": { "@microsoft/1ds-core-js": "^3.2.4", @@ -30,7 +30,6 @@ "@types/vscode": "^1.60.0", "@typescript-eslint/eslint-plugin": "^5.18.0", "@typescript-eslint/parser": "^5.18.0", - "esbuild": "^0.14.32", "eslint": "^8.12.0", "mocha": "^9.2.2", "sinon": "^13.0.2", diff --git a/src/browser/telemetryReporter.ts b/src/browser/telemetryReporter.ts index 7fd52b6..7a964e6 100644 --- a/src/browser/telemetryReporter.ts +++ b/src/browser/telemetryReporter.ts @@ -12,7 +12,7 @@ import { TelemetryUtil } from "../common/util"; const webAppInsightsClientFactory = async (key: string, replacementOptions?: ReplacementOption[]): Promise => { let appInsightsClient: ApplicationInsights | undefined; try { - const web = await import("@microsoft/applicationinsights-web"); + const web = await import/* webpackMode: "eager" */ ("@microsoft/applicationinsights-web"); appInsightsClient = new web.ApplicationInsights({ config: { instrumentationKey: key, diff --git a/src/browser/tsconfig.json b/src/browser/tsconfig.json index fef0c26..87a6f62 100644 --- a/src/browser/tsconfig.json +++ b/src/browser/tsconfig.json @@ -4,7 +4,7 @@ "lib": ["ES2015","DOM"], "module": "ES2020", "moduleResolution": "node", - "outDir": "./lib", + "outDir": "../../dist/browser", "typeRoots": [] }, "include": [".", "../common", "../../vscode.proposed.telemetry.d.ts"] diff --git a/src/common/1dsClientFactory.ts b/src/common/1dsClientFactory.ts index b8a0c19..9c9ff92 100644 --- a/src/common/1dsClientFactory.ts +++ b/src/common/1dsClientFactory.ts @@ -16,8 +16,8 @@ import { AppenderData } from "./baseTelemetryReporter"; * @returns The AI core object */ const getAICore = async (key: string, vscodeAPI: typeof vscode, xhrOverride?: IXHROverride): Promise => { - const oneDs = await import("@microsoft/1ds-core-js"); - const postPlugin = await import("@microsoft/1ds-post-js"); + const oneDs = await import(/* webpackMode: "eager" */ "@microsoft/1ds-core-js"); + const postPlugin = await import(/* webpackMode: "eager" */ "@microsoft/1ds-post-js"); const appInsightsCore = new oneDs.AppInsightsCore(); const collectorChannelPlugin: PostChannel = new postPlugin.PostChannel(); // Configure the app insights core to send to collector++ and disable logging of debug info diff --git a/src/common/baseTelemetryReporter.ts b/src/common/baseTelemetryReporter.ts index e145737..13c6564 100644 --- a/src/common/baseTelemetryReporter.ts +++ b/src/common/baseTelemetryReporter.ts @@ -3,9 +3,10 @@ *--------------------------------------------------------*/ import type * as vscode from "vscode"; -import type { TelemetryEventMeasurements, TelemetryEventProperties, RawTelemetryEventProperties } from "../../lib/telemetryReporter"; +import type { TelemetryEventMeasurements, TelemetryEventProperties, RawTelemetryEventProperties } from "../../dist/telemetryReporter"; import { ITelemetryAppender } from "./baseTelemetryAppender"; import { TelemetryLevel, TelemetryUtil } from "./util"; +import { version } from "../../package.json"; export interface AppenderData { properties?: RawTelemetryEventProperties, @@ -148,6 +149,7 @@ export class BaseTelemetryReporter { // __GDPR__COMMON__ "common.remotename" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" } // __GDPR__COMMON__ "common.isnewappinstall" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" } // __GDPR__COMMON__ "common.product" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" } + // __GDPR__COMMON__ "common.telemetryclientversion" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" } private getCommonProperties(): TelemetryEventProperties { const commonProperties: Record = {}; commonProperties["common.os"] = this.osShim.platform; @@ -155,6 +157,8 @@ export class BaseTelemetryReporter { commonProperties["common.platformversion"] = (this.osShim.release || "").replace(/^(\d+)(\.\d+)?(\.\d+)?(.*)/, "$1$2$3"); commonProperties["common.extname"] = this.extensionId; commonProperties["common.extversion"] = this.extensionVersion; + // Reads version from package.json + commonProperties["common.telemetryclientversion"] = version; if (this.vscodeAPI && this.vscodeAPI.env) { commonProperties["common.vscodemachineid"] = this.vscodeAPI.env.machineId; commonProperties["common.vscodesessionid"] = this.vscodeAPI.env.sessionId; diff --git a/src/node/telemetryReporter.ts b/src/node/telemetryReporter.ts index c8ce245..8dcb0d5 100644 --- a/src/node/telemetryReporter.ts +++ b/src/node/telemetryReporter.ts @@ -24,7 +24,7 @@ const appInsightsClientFactory = async (key: string, replacementOptions?: Replac let appInsightsClient: TelemetryClient | undefined; try { process.env["APPLICATION_INSIGHTS_NO_DIAGNOSTIC_CHANNEL"] = "1"; - const appInsights = await import("applicationinsights"); + const appInsights = await import(/* webpackMode: "eager" */ "applicationinsights"); //check if another instance is already initialized if (appInsights.defaultClient) { appInsightsClient = new appInsights.TelemetryClient(key); diff --git a/src/node/tsconfig.json b/src/node/tsconfig.json index 5972e2a..46550e1 100644 --- a/src/node/tsconfig.json +++ b/src/node/tsconfig.json @@ -5,7 +5,7 @@ "lib": ["ES2015", "DOM"], "module": "CommonJS", "moduleResolution": "node", - "outDir": "./lib", + "outDir": "../../dist/node", "typeRoots": [] }, "include": [".", "../common", "../../vscode.proposed.telemetry.d.ts"] diff --git a/test/tsconfig.json b/test/tsconfig.json index 6457fc5..e198b7e 100644 --- a/test/tsconfig.json +++ b/test/tsconfig.json @@ -5,7 +5,7 @@ "lib": ["ES2015", "DOM"], "module": "CommonJS", "moduleResolution": "node", - "outDir": "../lib/test", + "outDir": "../dist/test", // Not sure why it cannot find them, but alas it must be pointed out where the types are "typeRoots": ["../node_modules/@types"] }, diff --git a/thirdpartynotices.txt b/thirdpartynotices.txt deleted file mode 100644 index 001d8c9..0000000 --- a/thirdpartynotices.txt +++ /dev/null @@ -1,30 +0,0 @@ - -THIRD-PARTY SOFTWARE NOTICES AND INFORMATION -For Microsoft vscode-extension-telemetry - -This project incorporates material from the projects listed below. The original copyright notice -and the license under which Microsoft received such material are set out below. Microsoft reserves -all other rights not expressly granted, whether by implication, estoppel or otherwise. - -1. DefinitelyTyped version 0.0.1 (https://github.com/borisyankov/DefinitelyTyped) - -This project is licensed under the MIT license. -Copyrights are respective of each contributor listed at the beginning of each definition file. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/tsconfig.json b/tsconfig.json index ec26faa..4bdc7de 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,6 +2,7 @@ "compilerOptions": { "noEmitOnError": false, "strict": true, + "resolveJsonModule": true, "target": "ES2020", "module": "ES2020", "esModuleInterop": true,