Unverified Commit 3cb7adb9 authored by Matt Probert's avatar Matt Probert Committed by GitHub

Fix: status log when NEXT_TELEMETRY_DISABLED env is set (#43948)

Fixes: https://github.com/vercel/next.js/discussions/43947Co-authored-by: 's avatarJJ Kasper <jj@jjsweb.site>
parent 4df6804c
......@@ -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 => {
......
......@@ -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'))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment