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

Fix: status log when NEXT_TELEMETRY_DISABLED env is set #43948

Merged
merged 4 commits into from Dec 12, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
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