From 8b5aca341366fb7db917496d2b4987f64c8bd786 Mon Sep 17 00:00:00 2001 From: Vidal Ortega <43078681+vidorteg@users.noreply.github.com> Date: Fri, 30 Oct 2026 10:34:45 -0700 Subject: [PATCH 1/4] Revert "Bump qs from 6.16.0 to 6.17.1 (#5079)" This reverts commit 840dba5a69a93737e42fbe0505490f219f509321. --- package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3ebe289f..78e7d539 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11660,9 +11660,9 @@ "license": "MIT" }, "node_modules/qs": { - "version": "6.17.1", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.17.1.tgz", - "integrity": "sha512-jd3COkaKVgGUW+ZHyEHCG9bH7RoaaiWuMgzsIBjUMVjLAaWGWpoUAVwljVvBHxRu/2qEHnadLGZrkutYUBPQJA==", + "version": "6.16.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.16.0.tgz", + "integrity": "sha1-wixyOiipIPOqzc6Cifq9Q+zLef0=", "dev": true, "license": "BSD-3-Clause", "dependencies": { From 306e3ecf9f65335778a3e3c8236709e5e034daf8 Mon Sep 17 00:00:00 2001 From: Vidal Ortega <43078681+vidorteg@users.noreply.github.com> Date: Fri, 30 Oct 2026 10:34:45 -0700 Subject: [PATCH 2/4] Revert "Bump undici from 6.28.0 to 6.29.1 (#5074)" This reverts commit 1745540df6134edaa92715926c5fab9ada4c40b5. --- package-lock.json | 56 +++++++++++++++++++++-------------------------- 1 file changed, 25 insertions(+), 31 deletions(-) diff --git a/package-lock.json b/package-lock.json index 78e7d539..d7fa4e52 100644 --- a/package-lock.json +++ b/package-lock.json @@ -303,6 +303,7 @@ "integrity": "sha1-gMELFySAgpaLV6hXuRZAlx8gcPc=", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@babel/code-frame": "^7.29.7", "@babel/generator": "^7.29.7", @@ -892,6 +893,7 @@ } ], "license": "MIT", + "peer": true, "engines": { "node": ">=18" }, @@ -915,6 +917,7 @@ } ], "license": "MIT", + "peer": true, "engines": { "node": ">=18" } @@ -929,31 +932,6 @@ "node": ">=14.17.0" } }, - "node_modules/@emnapi/core": { - "version": "1.11.3", - "resolved": "https://registry.npmjs.org/@emnapi/core/-/core-1.11.3.tgz", - "integrity": "sha512-zLpS5asjEb7lq8jYLq37N6XKaE41DIexlY1rF/z4/tIl3wo13Sqm28fRyfIsKZD+NZ8mM5RoKkpW/rBcuoSZSg==", - "dev": true, - "license": "MIT", - "optional": true, - "peer": true, - "dependencies": { - "@emnapi/wasi-threads": "1.2.3", - "tslib": "^2.4.0" - } - }, - "node_modules/@emnapi/runtime": { - "version": "1.11.3", - "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.11.3.tgz", - "integrity": "sha512-Xz4Tpyki7XyrpbUK1jR1AhdAdaXyhhY4lZ3neLodmhpuWfy2PAQN5B46sAiU4liOXGLkHypn/qU+jvfWSCYYLA==", - "dev": true, - "license": "MIT", - "optional": true, - "peer": true, - "dependencies": { - "tslib": "^2.4.0" - } - }, "node_modules/@emnapi/wasi-threads": { "version": "1.2.3", "resolved": "https://ms-feed-25.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@emnapi/wasi-threads/-/wasi-threads-1.2.3.tgz", @@ -961,7 +939,6 @@ "dev": true, "license": "MIT", "optional": true, - "peer": true, "dependencies": { "tslib": "^2.4.0" } @@ -3528,6 +3505,7 @@ "integrity": "sha1-ntywngsHzodueDOSLTJ0FJyJjPo=", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@types/node": "*", "@types/tough-cookie": "*", @@ -3670,6 +3648,7 @@ "integrity": "sha1-3j6tKzXlxxWA7aQIIK20/RSDTKE=", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@typescript-eslint/scope-manager": "8.69.0", "@typescript-eslint/types": "8.69.0", @@ -4771,6 +4750,7 @@ "integrity": "sha1-T68BstbTJr/u2XrqH1IiC19MGUA=", "dev": true, "license": "MIT", + "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -5375,6 +5355,7 @@ } ], "license": "MIT", + "peer": true, "dependencies": { "baseline-browser-mapping": "^2.11.12", "caniuse-lite": "^1.0.30001809", @@ -5464,6 +5445,7 @@ "integrity": "sha1-pGI1Qd0jhnYmuwigUewNLsC3ApQ=", "hasInstallScript": true, "license": "MIT", + "peer": true, "dependencies": { "node-gyp-build": "^4.3.0" }, @@ -6174,7 +6156,8 @@ "version": "0.0.1666840", "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.1666840.tgz", "integrity": "sha1-eWy8MH+CdQr8E6O0ccgpvz2hmmU=", - "license": "BSD-3-Clause" + "license": "BSD-3-Clause", + "peer": true }, "node_modules/dom-serializer": { "version": "2.0.0", @@ -6615,6 +6598,7 @@ "integrity": "sha512-XyLmROnACWqSxiGYArdef1fItQd47weqB7iwtfr9JHwRrqIXZdcFMvvEcL9xHCmL0SNsOvF0c42lWyM1U5dgig==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.8.0", "@eslint-community/regexpp": "^4.12.1", @@ -8626,6 +8610,7 @@ "integrity": "sha1-23gRRPz/i0hZ2N1aAQjUw7IXPP0=", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@jest/core": "30.5.1", "@jest/types": "30.5.1", @@ -9236,6 +9221,7 @@ "integrity": "sha1-YxM2ADTMs2s9xh7L3/eBIfkP4h8=", "dev": true, "license": "MIT", + "peer": true, "engines": { "node": ">=12" }, @@ -10137,6 +10123,7 @@ "integrity": "sha1-q18cHK/AS9h4clSQl06l6L8McrM=", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "cssstyle": "^4.2.1", "data-urls": "^5.0.0", @@ -12154,6 +12141,7 @@ "integrity": "sha1-MEs2Nq3Yi6fZNnYN1Q7OAG3qlfk=", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "fast-deep-equal": "^3.1.3", "fast-uri": "^3.0.1", @@ -13201,6 +13189,7 @@ "integrity": "sha1-YxM2ADTMs2s9xh7L3/eBIfkP4h8=", "dev": true, "license": "MIT", + "peer": true, "engines": { "node": ">=12" }, @@ -13487,7 +13476,8 @@ "node_modules/tslib": { "version": "2.7.0", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.7.0.tgz", - "integrity": "sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA==" + "integrity": "sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA==", + "peer": true }, "node_modules/tunnel": { "version": "0.0.6", @@ -13647,6 +13637,7 @@ "integrity": "sha1-kCUdwAeRbpcnhsuU100VsYVXfSE=", "dev": true, "license": "Apache-2.0", + "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -13701,9 +13692,9 @@ "license": "MIT" }, "node_modules/undici": { - "version": "6.29.1", - "resolved": "https://registry.npmjs.org/undici/-/undici-6.29.1.tgz", - "integrity": "sha512-EvRlUt/QqAEvXdQeRMYUfwOQsfzpDztykrG2owGEE/rBOBoYv9uF39ZzsNDh4lTFHhTr2XOZjKkYgueD12ZmGA==", + "version": "6.28.0", + "resolved": "https://registry.npmjs.org/undici/-/undici-6.28.0.tgz", + "integrity": "sha1-nw44V0T+9QIdZZbFvM14P2EZPBw=", "dev": true, "license": "MIT", "engines": { @@ -13858,6 +13849,7 @@ "integrity": "sha1-ioQsmxWvP2Mjo9XtXrnmHSCNjCI=", "hasInstallScript": true, "license": "MIT", + "peer": true, "dependencies": { "node-gyp-build": "^4.3.0" }, @@ -14027,6 +14019,7 @@ "integrity": "sha1-4SK2b2Imt6+PIJthAs0TI4xIE6g=", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@types/estree": "^1.0.8", "@types/json-schema": "^7.0.15", @@ -14597,6 +14590,7 @@ "integrity": "sha1-iLKiFFXzfKfczy7rM7rLQ5IyJxk=", "devOptional": true, "license": "MIT", + "peer": true, "dependencies": { "pend": "~1.2.0" }, From c7352b3cddb2847a9c185dbb234747339b941b29 Mon Sep 17 00:00:00 2001 From: Vidal Ortega <43078681+vidorteg@users.noreply.github.com> Date: Fri, 30 Oct 2026 11:07:53 -0700 Subject: [PATCH 3/4] Replacing dir scan with fileopensubscription --- src/extension.ts | 4 +- src/utils.ts | 85 +++++++++++++++++++++++++---------------- test/extension.test.ts | 6 +-- test/helpers/helpers.ts | 11 +----- test/utils.test.ts | 74 +++++++++++++++++++++++++++++++++-- 5 files changed, 129 insertions(+), 51 deletions(-) diff --git a/src/extension.ts b/src/extension.ts index bf5d1381..74f87300 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -29,7 +29,7 @@ import { SETTINGS_VIEW_NAME, getActiveDebugSessionId, getJsDebugCDPProxyWebsocketUrl, - reportFileExtensionTypes, + trackOpenedFileTypes, reportChangedExtensionSetting, reportExtensionSettings, reportUrlType, @@ -233,7 +233,7 @@ export function activate(context: vscode.ExtensionContext): void { })); void vscode.commands.executeCommand('setContext', 'titleCommandsRegistered', true); - void reportFileExtensionTypes(telemetryReporter); + context.subscriptions.push(trackOpenedFileTypes(telemetryReporter)); reportExtensionSettings(telemetryReporter); vscode.workspace.onDidChangeConfiguration(event => reportChangedExtensionSetting(event, telemetryReporter)); } diff --git a/src/utils.ts b/src/utils.ts index 38867a1c..5a996c5b 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -775,41 +775,60 @@ export function reportUrlType(url: string, telemetryReporter: Readonly): Promise { - const files = await vscode.workspace.findFiles('**/*.*', '**/node_modules/**'); - const extensionMap: Map = new Map([ - ['html', 0], - ['css', 0], - ['js', 0], - ['ts', 0], - ['jsx', 0], - ['scss', 0], - ['json', 0], - ['mjs', 0], - ['other', 0], - ]); - for (const file of files) { - const extension: string | undefined = file.path.split('.').pop(); - if (extension) { - if (extensionMap.has(extension)) { - const currentValue = extensionMap.get(extension); - if (currentValue !== undefined) { - extensionMap.set(extension, currentValue + 1); - } - } else { - const otherCount = extensionMap.get('other'); - if (otherCount !== undefined) { - extensionMap.set('other', otherCount + 1); - } - } +const TRACKED_FILE_EXTENSIONS = ['html', 'css', 'js', 'ts', 'jsx', 'scss', 'json', 'mjs']; +const TRACKED_URI_SCHEMES = ['file', 'vscode-remote']; +export const OPENED_FILE_TYPES_REPORT_DELAY_MS = 30000; + +/** + * Tracks the types of files the user opens and reports them as batched telemetry. + */ +export function trackOpenedFileTypes(telemetryReporter: Readonly): vscode.Disposable { + const seenFiles = new Set(); + let pendingCounts = new Map(); + let reportTimer: NodeJS.Timeout | undefined; + + const report = (): void => { + if (reportTimer) { + clearTimeout(reportTimer); + reportTimer = undefined; } - } - extensionMap.set('total', files.length); + if (pendingCounts.size === 0) { + return; + } + const fileTypes: {[key: string]: number} = { total: 0 }; + for (const extension of [...TRACKED_FILE_EXTENSIONS, 'other']) { + fileTypes[extension] = pendingCounts.get(extension) ?? 0; + fileTypes.total += fileTypes[extension]; + } + pendingCounts = new Map(); + sendTaxonomyEvent(telemetryReporter, { area: 'workspace', feature: 'metadata', action: 'fileOpened' }, undefined, fileTypes); + }; + + const listener = vscode.workspace.onDidOpenTextDocument(document => { + const uri = document.uri; + if (!TRACKED_URI_SCHEMES.includes(uri.scheme) || uri.path.includes('/.git/')) { + return; + } + const key = uri.toString(); + if (seenFiles.has(key)) { + return; + } + seenFiles.add(key); + + const extension = path.posix.extname(uri.path).slice(1).toLowerCase(); + const bucket = TRACKED_FILE_EXTENSIONS.includes(extension) ? extension : 'other'; + pendingCounts.set(bucket, (pendingCounts.get(bucket) ?? 0) + 1); - // Creates Object from map - const fileTypes: {[key: string]: number} = {}; - Object.assign(fileTypes, ...[...extensionMap.entries()].map(([k, v]) => ({[k]: v}))); - sendTaxonomyEvent(telemetryReporter, { area: 'workspace', feature: 'metadata', action: 'scan' }, undefined, fileTypes); + if (reportTimer) { + clearTimeout(reportTimer); + } + reportTimer = setTimeout(report, OPENED_FILE_TYPES_REPORT_DELAY_MS); + }); + + return new vscode.Disposable(() => { + listener.dispose(); + report(); + }); } (function initialize() { diff --git a/test/extension.test.ts b/test/extension.test.ts index 0e487869..a20ca707 100644 --- a/test/extension.test.ts +++ b/test/extension.test.ts @@ -44,7 +44,7 @@ describe("extension", () => { removeTrailingSlash: jest.fn(removeTrailingSlash), getJsDebugCDPProxyWebsocketUrl: jest.fn(), getActiveDebugSessionId: jest.fn(), - reportFileExtensionTypes: jest.fn(), + trackOpenedFileTypes: jest.fn(), reportChangedExtensionSetting: jest.fn(), reportExtensionSettings: jest.fn(), }; @@ -82,7 +82,7 @@ describe("extension", () => { // Activation should add the commands as subscriptions on the context newExtension.activate(context); - expect(context.subscriptions.length).toBe(19); + expect(context.subscriptions.length).toBe(20); expect(commandMock).toHaveBeenCalledTimes(18); expect(commandMock) .toHaveBeenNthCalledWith(1, `${SETTINGS_STORE_NAME}.attach`, expect.any(Function)); @@ -421,7 +421,7 @@ describe("extension", () => { reportChangedExtensionSetting: jest.fn(), reportExtensionSettings: jest.fn(), reportUrlType: jest.fn(), - reportFileExtensionTypes: jest.fn(), + trackOpenedFileTypes: jest.fn(), }; mockPanel = { diff --git a/test/helpers/helpers.ts b/test/helpers/helpers.ts index 60a08a16..96d62387 100644 --- a/test/helpers/helpers.ts +++ b/test/helpers/helpers.ts @@ -41,7 +41,7 @@ export function createFakeVSCode() { Diagnostic: jest.fn(), CallHierarchyItem: jest.fn(), CodeActionKind: jest.fn(), - Disposable: jest.fn(), + Disposable: jest.fn().mockImplementation((callOnDispose: () => void) => ({ dispose: callOnDispose })), ExtensionMode: { Production: 1 }, @@ -110,14 +110,7 @@ export function createFakeVSCode() { workspace: { isTrusted: true, createFileSystemWatcher: jest.fn(), - findFiles: jest.fn(() => { - return [ - {path: '/c:/test/main.js'}, - {path: '/c:/test/styles.css'}, - {path: '/c:/test/react/test.jsx'}, - {path: '/c:/.vscode/launch.json'} - ]; - }), + onDidOpenTextDocument: jest.fn(() => ({ dispose: jest.fn() })), getConfiguration: jest.fn(() => { return { get: (name: string) => { diff --git a/test/utils.test.ts b/test/utils.test.ts index de0a9da9..21553955 100644 --- a/test/utils.test.ts +++ b/test/utils.test.ts @@ -1037,11 +1037,77 @@ describe("utils", () => { }); }); - describe('reportFileExtensionTypes', () => { - it('correctly lists extension types in the workspace', async () => { + describe('trackOpenedFileTypes', () => { + const openDocument = (uri: string): void => { + const vscodeMock = jest.requireMock("vscode"); + const listener = vscodeMock.workspace.onDidOpenTextDocument.mock.calls[0][0]; + const [, scheme, filePath = ''] = /^([a-z-]+):\/\/[^/]*(\/.*)?$/.exec(uri) as RegExpExecArray; + listener({ uri: { scheme, path: filePath, toString: () => uri } }); + }; + + beforeEach(() => { + jest.useFakeTimers(); + }); + + afterEach(() => { + jest.useRealTimers(); + }); + + it('reports batched counts of unique opened files after a quiet period', () => { + const reporter = createFakeTelemetryReporter(); + utils.trackOpenedFileTypes(reporter); + + openDocument('file:///c:/test/main.js'); + openDocument('file:///c:/test/main.js'); + openDocument('file:///c:/test/styles.CSS'); + openDocument('vscode-remote://ssh-remote+host/home/test/react/test.jsx'); + openDocument('file:///c:/.vscode/launch.json'); + openDocument('file:///c:/test/Makefile'); + openDocument('file:///c:/test/.git/COMMIT_EDITMSG'); + openDocument('git:///c:/test/main.js'); + openDocument('output://extension-output'); + + expect(reporter.sendTelemetryEvent).not.toHaveBeenCalled(); + jest.advanceTimersByTime(utils.OPENED_FILE_TYPES_REPORT_DELAY_MS); + + expect(reporter.sendTelemetryEvent).toHaveBeenCalledTimes(1); + expect(reporter.sendTelemetryEvent).toHaveBeenCalledWith('workspace', { area: 'workspace', feature: 'metadata', action: 'fileOpened', outcome: 'success' }, {"css": 1, "html": 0, "js": 1, "json": 1, "jsx": 1, "mjs": 0, "other": 1, "scss": 0, "total": 5, "ts": 0}); + }); + + it('reports only newly opened files in subsequent batches', () => { + const reporter = createFakeTelemetryReporter(); + utils.trackOpenedFileTypes(reporter); + + openDocument('file:///c:/test/main.js'); + jest.advanceTimersByTime(utils.OPENED_FILE_TYPES_REPORT_DELAY_MS); + openDocument('file:///c:/test/main.js'); + openDocument('file:///c:/test/index.html'); + jest.advanceTimersByTime(utils.OPENED_FILE_TYPES_REPORT_DELAY_MS); + + expect(reporter.sendTelemetryEvent).toHaveBeenCalledTimes(2); + expect(reporter.sendTelemetryEvent).toHaveBeenLastCalledWith('workspace', expect.anything(), expect.objectContaining({ "html": 1, "js": 0, "total": 1 })); + }); + + it('flushes pending counts and stops listening on dispose', () => { + const reporter = createFakeTelemetryReporter(); + const disposable = utils.trackOpenedFileTypes(reporter); + const listenerDisposable = jest.requireMock("vscode").workspace.onDidOpenTextDocument.mock.results[0].value; + + openDocument('file:///c:/test/app.ts'); + disposable.dispose(); + + expect(listenerDisposable.dispose).toHaveBeenCalled(); + expect(reporter.sendTelemetryEvent).toHaveBeenCalledTimes(1); + expect(reporter.sendTelemetryEvent).toHaveBeenCalledWith('workspace', expect.anything(), expect.objectContaining({ "ts": 1, "total": 1 })); + + jest.advanceTimersByTime(utils.OPENED_FILE_TYPES_REPORT_DELAY_MS); + expect(reporter.sendTelemetryEvent).toHaveBeenCalledTimes(1); + }); + + it('does not report when no files were opened', () => { const reporter = createFakeTelemetryReporter(); - await utils.reportFileExtensionTypes(reporter); - expect(reporter.sendTelemetryEvent).toHaveBeenCalledWith('workspace', { area: 'workspace', feature: 'metadata', action: 'scan', outcome: 'success' }, {"css": 1, "html": 0, "js": 1, "json": 1, "jsx": 1, "mjs": 0, "other": 0, "scss": 0, "total": 4, "ts": 0}); + utils.trackOpenedFileTypes(reporter).dispose(); + expect(reporter.sendTelemetryEvent).not.toHaveBeenCalled(); }); }); From d52fab2040f3029524c0398d7e5587a8f9035c52 Mon Sep 17 00:00:00 2001 From: Vidal Ortega <43078681+vidorteg@users.noreply.github.com> Date: Fri, 30 Oct 2026 15:26:25 -0700 Subject: [PATCH 4/4] Addressing feedback --- package-lock.json | 6 +++--- src/extension.ts | 11 ++++++++++- test/extension.test.ts | 14 ++++++++++++++ 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9b8f292a..b52a99ba 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13700,9 +13700,9 @@ "license": "MIT" }, "node_modules/undici": { - "version": "6.28.0", - "resolved": "https://registry.npmjs.org/undici/-/undici-6.28.0.tgz", - "integrity": "sha1-nw44V0T+9QIdZZbFvM14P2EZPBw=", + "version": "6.29.1", + "resolved": "https://registry.npmjs.org/undici/-/undici-6.29.1.tgz", + "integrity": "sha512-EvRlUt/QqAEvXdQeRMYUfwOQsfzpDztykrG2owGEE/rBOBoYv9uF39ZzsNDh4lTFHhTr2XOZjKkYgueD12ZmGA==", "dev": true, "license": "MIT", "engines": { diff --git a/src/extension.ts b/src/extension.ts index 74f87300..23c480fd 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -41,6 +41,7 @@ import { ErrorReporter } from './errorReporter'; import { ErrorCodes } from './common/errorCodes'; let telemetryReporter: Readonly; +let openedFileTypesTracker: vscode.Disposable | undefined; let browserInstance: Browser; let cdpTargetsProvider: CDPTargetsProvider; @@ -233,11 +234,19 @@ export function activate(context: vscode.ExtensionContext): void { })); void vscode.commands.executeCommand('setContext', 'titleCommandsRegistered', true); - context.subscriptions.push(trackOpenedFileTypes(telemetryReporter)); + openedFileTypesTracker = trackOpenedFileTypes(telemetryReporter); + context.subscriptions.push(openedFileTypesTracker); reportExtensionSettings(telemetryReporter); vscode.workspace.onDidChangeConfiguration(event => reportChangedExtensionSetting(event, telemetryReporter)); } +export async function deactivate(): Promise { + // Report pending opened-file counts, then flush the reporter so they aren't lost on shutdown. + openedFileTypesTracker?.dispose(); + openedFileTypesTracker = undefined; + await telemetryReporter?.dispose(); +} + function ensureWorkspaceTrusted(): boolean { if (vscode.workspace.isTrusted) { return true; diff --git a/test/extension.test.ts b/test/extension.test.ts index a20ca707..b55aeed8 100644 --- a/test/extension.test.ts +++ b/test/extension.test.ts @@ -76,6 +76,20 @@ describe("extension", () => { expect(mockUtils.createTelemetryReporter).toHaveBeenCalled(); }); + it("reports pending opened file types and flushes telemetry on deactivate", async () => { + const calls: string[] = []; + const reporter = createFakeTelemetryReporter(); + reporter.dispose.mockImplementation(async () => { calls.push('reporter'); }); + mockUtils.createTelemetryReporter!.mockReturnValue(reporter); + mockUtils.trackOpenedFileTypes!.mockReturnValue({ dispose: jest.fn(() => calls.push('tracker')) }); + const newExtension = await import("../src/extension"); + + newExtension.activate(context); + await newExtension.deactivate(); + + expect(calls).toEqual(['tracker', 'reporter']); + }); + it("registers commands correctly", async () => { const newExtension = await import("../src/extension");