From bc9c0d800906d195860f8f211b10a1e4e38661bb Mon Sep 17 00:00:00 2001 From: MattPr Date: Mon, 12 Dec 2022 00:29:22 +0100 Subject: [PATCH 1/3] Fix: NEXT_TELEMETRY_DISABLED was not respected. --- packages/next/telemetry/storage.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/next/telemetry/storage.ts b/packages/next/telemetry/storage.ts index 8c2274378028619..4f3def35ad2cb49 100644 --- a/packages/next/telemetry/storage.ts +++ b/packages/next/telemetry/storage.ts @@ -152,7 +152,7 @@ export class Telemetry { } get isEnabled(): boolean { - return !!this.conf && this.conf.get(TELEMETRY_KEY_ENABLED, true) !== false + return !this.NEXT_TELEMETRY_DISABLED && !!this.conf && this.conf.get(TELEMETRY_KEY_ENABLED, true) !== false } oneWayHash = (payload: BinaryLike): string => { From 0922a8314e22af69863e16fcf187aab0a6deb967 Mon Sep 17 00:00:00 2001 From: MattPr Date: Mon, 12 Dec 2022 19:42:42 +0100 Subject: [PATCH 2/3] Add test. --- test/integration/telemetry/test/index.test.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/integration/telemetry/test/index.test.js b/test/integration/telemetry/test/index.test.js index 3558f6360ab4925..0f3abcca358831a 100644 --- a/test/integration/telemetry/test/index.test.js +++ b/test/integration/telemetry/test/index.test.js @@ -72,6 +72,18 @@ describe('Telemetry CLI', () => { expect(stdout).toMatch(/Status: Disabled/) }) + it('can disable telemetry with env NEXT_TELEMETRY_DISABLED', async () => { + // next config is not reset between tests + await runNextCommand(['telemetry', 'enable']) + const { stdout } = await runNextCommand(['telemetry', 'status'], { + stdout: true, + env: { + NEXT_TELEMETRY_DISABLED: '1', + }, + }) + expect(stdout).toMatch(/Status: Disabled/) + }) + it('detects isSrcDir dir correctly for `next build`', async () => { // must clear cache for GSSP imports to be detected correctly await fs.remove(path.join(appDir, '.next')) From 828a0ee88684652c77c03aee9875f00327ef0f63 Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Mon, 12 Dec 2022 12:54:56 -0800 Subject: [PATCH 3/3] lint-fix --- packages/next/telemetry/storage.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/next/telemetry/storage.ts b/packages/next/telemetry/storage.ts index 4f3def35ad2cb49..00ba9f9071bc53e 100644 --- a/packages/next/telemetry/storage.ts +++ b/packages/next/telemetry/storage.ts @@ -152,7 +152,11 @@ export class Telemetry { } get isEnabled(): boolean { - return !this.NEXT_TELEMETRY_DISABLED && !!this.conf && this.conf.get(TELEMETRY_KEY_ENABLED, true) !== false + return ( + !this.NEXT_TELEMETRY_DISABLED && + !!this.conf && + this.conf.get(TELEMETRY_KEY_ENABLED, true) !== false + ) } oneWayHash = (payload: BinaryLike): string => {