Skip to content

Commit

Permalink
Fix: status log when NEXT_TELEMETRY_DISABLED env is set (#43948)
Browse files Browse the repository at this point in the history
Fixes: #43947

Co-authored-by: JJ Kasper <jj@jjsweb.site>
  • Loading branch information
mattpr and ijjk committed Dec 12, 2022
1 parent c06a93a commit 655fc09
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/next/telemetry/storage.ts
Expand Up @@ -152,7 +152,11 @@ 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 => {
Expand Down
12 changes: 12 additions & 0 deletions test/integration/telemetry/test/index.test.js
Expand Up @@ -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'))
Expand Down

0 comments on commit 655fc09

Please sign in to comment.