Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to no bundling and let extensions decide how they would like to bundle #119

Merged
merged 7 commits into from Sep 8, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
51 changes: 0 additions & 51 deletions .esbuild.config.js

This file was deleted.

6 changes: 4 additions & 2 deletions .gitignore
Expand Up @@ -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
5 changes: 1 addition & 4 deletions .npmignore
@@ -1,10 +1,6 @@
.vscode
build
.github
lib/*.js.map
lib/*.js
lib/test
!lib/*.min.js
node_modules
src
typings_patches
Expand All @@ -16,4 +12,5 @@ tsfmt.json
.esbuild.config.js
.eslintrc.json
.eslintignore
*.tgz
*.test.ts
File renamed without changes.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 6 additions & 7 deletions 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",
"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"
"build": "npm run compile",
"test": "tsc -p 'test/tsconfig.json' && mocha dist/test/*",
"compile": "tsc -p 'src/browser/tsconfig.json' && tsc -p 'src/node/tsconfig.json'"
},
"dependencies": {
"@microsoft/1ds-core-js": "^3.2.4",
Expand All @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/browser/telemetryReporter.ts
Expand Up @@ -12,7 +12,7 @@ import { TelemetryUtil } from "../common/util";
const webAppInsightsClientFactory = async (key: string, replacementOptions?: ReplacementOption[]): Promise<BaseTelemetryClient> => {
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,
Expand Down
2 changes: 1 addition & 1 deletion src/browser/tsconfig.json
Expand Up @@ -4,7 +4,7 @@
"lib": ["ES2015","DOM"],
"module": "ES2020",
"moduleResolution": "node",
"outDir": "./lib",
"outDir": "../../dist/browser",
"typeRoots": []
},
"include": [".", "../common", "../../vscode.proposed.telemetry.d.ts"]
Expand Down
4 changes: 2 additions & 2 deletions src/common/1dsClientFactory.ts
Expand Up @@ -16,8 +16,8 @@ import { AppenderData } from "./baseTelemetryReporter";
* @returns The AI core object
*/
const getAICore = async (key: string, vscodeAPI: typeof vscode, xhrOverride?: IXHROverride): Promise<AppInsightsCore> => {
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
Expand Down
5 changes: 4 additions & 1 deletion src/common/baseTelemetryReporter.ts
Expand Up @@ -3,7 +3,7 @@
*--------------------------------------------------------*/

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";

Expand Down Expand Up @@ -148,13 +148,16 @@ 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<string, any> = {};
commonProperties["common.os"] = this.osShim.platform;
commonProperties["common.nodeArch"] = this.osShim.architecture;
commonProperties["common.platformversion"] = (this.osShim.release || "").replace(/^(\d+)(\.\d+)?(\.\d+)?(.*)/, "$1$2$3");
commonProperties["common.extname"] = this.extensionId;
commonProperties["common.extversion"] = this.extensionVersion;
// TODO @lramos15, this should be dynamic but loading JSON modules didn't play nicely
commonProperties["common.telemetryclientversion"] = "0.6.3";
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@connor4312 Any ideas on how to import a JSON file across node12, node 14, and node16. Seems node 16 gets upset that I don't use import assertions but then node12 and node14 get upset when I do. I don't really want to rely on require because I use no var requires and fs wouldn't work in a common layer

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prior to Node 16, JSON modules required a flag to be used in an ES6 import, so this is tricky.

Can the version be passed in from a higher level outside of the common layer?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could pass it in from the browser layer and node layer respectively. Not sure how that helps especially in the browser case. Normally I would use something like the bundler to compile time inject the value here but the idea is to avoid bundlers

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly the easiest way would probably be just having a npm postversion script that would update the version number in a ts file when the version gets bumped

if (this.vscodeAPI && this.vscodeAPI.env) {
commonProperties["common.vscodemachineid"] = this.vscodeAPI.env.machineId;
commonProperties["common.vscodesessionid"] = this.vscodeAPI.env.sessionId;
Expand Down
2 changes: 1 addition & 1 deletion src/node/telemetryReporter.ts
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/node/tsconfig.json
Expand Up @@ -5,7 +5,7 @@
"lib": ["ES2015", "DOM"],
"module": "CommonJS",
"moduleResolution": "node",
"outDir": "./lib",
"outDir": "../../dist/node",
"typeRoots": []
},
"include": [".", "../common", "../../vscode.proposed.telemetry.d.ts"]
Expand Down
2 changes: 1 addition & 1 deletion test/tsconfig.json
Expand Up @@ -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"]
},
Expand Down
30 changes: 0 additions & 30 deletions thirdpartynotices.txt

This file was deleted.