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

[dev-overlay] Disable error feedback in UI if NEXT_TELEMETRY_DISABLED is set #76423

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/next/src/build/webpack/plugins/define-env-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,9 @@ export function getDefineEnv({
'process.env.__NEXT_ASSET_PREFIX': config.assetPrefix,
'process.env.__NEXT_EXPERIMENTAL_AUTH_INTERRUPTS':
!!config.experimental.authInterrupts,
'process.env.__NEXT_TELEMETRY_DISABLED': Boolean(
process.env.NEXT_TELEMETRY_DISABLED
),
...(isNodeOrEdgeCompilation
? {
// Fix bad-actors in the npm ecosystem (e.g. `node-formidable`)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export function ErrorFeedback({ errorCode, className }: ErrorFeedbackProps) {
const [votedMap, setVotedMap] = useState<Record<string, boolean>>({})
const voted = votedMap[errorCode]
const hasVoted = voted !== undefined
const disabled = process.env.__NEXT_TELEMETRY_DISABLED

const handleFeedback = useCallback(
async (wasHelpful: boolean) => {
Expand Down Expand Up @@ -63,16 +64,26 @@ export function ErrorFeedback({ errorCode, className }: ErrorFeedbackProps) {
</a>
</p>
<button
aria-label="Mark as helpful"
onClick={() => handleFeedback(true)}
aria-disabled={disabled ? 'true' : undefined}
aria-label={
disabled
? 'Feedback disabled due to setting NEXT_TELEMETRY_DISABLED'
: 'Mark as helpful'
}
onClick={disabled ? undefined : () => handleFeedback(true)}
className={cx('feedback-button', voted === true && 'voted')}
type="button"
>
<ThumbsUp aria-hidden="true" />
</button>
<button
aria-label="Mark as not helpful"
onClick={() => handleFeedback(false)}
aria-disabled={disabled ? 'true' : undefined}
aria-label={
disabled
? 'Feedback disabled due to setting NEXT_TELEMETRY_DISABLED'
: 'Mark as not helpful'
}
onClick={disabled ? undefined : () => handleFeedback(false)}
className={cx('feedback-button', voted === false && 'voted')}
type="button"
>
Expand Down Expand Up @@ -130,7 +141,7 @@ export const styles = `
}
}

.feedback-button:disabled {
.feedback-button[aria-disabled='true'] {
opacity: 0.7;
cursor: not-allowed;
}
Expand Down
Loading