Skip to content

feat(feedback): allow error messages to be customized#20474

Open
logaretm wants to merge 5 commits intodevelopfrom
awad/js-126-allow-error-messages-to-be-customized
Open

feat(feedback): allow error messages to be customized#20474
logaretm wants to merge 5 commits intodevelopfrom
awad/js-126-allow-error-messages-to-be-customized

Conversation

@logaretm
Copy link
Copy Markdown
Member

@logaretm logaretm commented Apr 24, 2026

Adds text options to FeedbackTextConfiguration to allow customizing the widget's error messages (for i18n and other purposes).

sendFeedback now accepts optional errorMessages overrides via its hint argument, defaulting to the original English strings. The widget wraps sendFeedback to inject the configured text options before the form displays them.

Standalone sendFeedback consumers see the same English messages as before — no observable behavior change.

Closes #14687

Copilot AI review requested due to automatic review settings April 24, 2026 03:02
@logaretm logaretm requested a review from a team as a code owner April 24, 2026 03:02
@linear-code
Copy link
Copy Markdown

linear-code Bot commented Apr 24, 2026

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds customizable Feedback error messages by shifting internal error handling to stable error codes, which the UI can map to user-provided text (i18n/custom wording) while keeping defaults.

Changes:

  • Introduces FeedbackErrorCode + createFeedbackError(...) and updates sendFeedback to throw/reject with error codes.
  • Wires new error-text options through the integration defaults and into the modal Form to render customized messages.
  • Updates sendFeedback tests to assert on error codes instead of full English strings.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
packages/feedback/test/core/sendFeedback.test.ts Updates assertions to expect error-code rejections.
packages/feedback/src/util/createFeedbackError.ts Adds a typed error-code union and helper to create errors.
packages/feedback/src/modal/components/Form.tsx Maps error codes to configurable UI strings; normalizes thrown values to Error.
packages/feedback/src/core/sendFeedback.ts Reworks error messaging to use codes (throws + Promise rejections).
packages/feedback/src/core/integration.ts Adds new text options with defaults and passes them through internal options.
packages/feedback/src/constants/index.ts Defines default error-text constants for each error code.
packages/core/src/types-hoist/feedback/config.ts Extends public text configuration type with new error-text fields.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/feedback/src/core/sendFeedback.ts
Comment thread packages/feedback/src/modal/components/Form.tsx Outdated
Comment thread packages/feedback/src/core/sendFeedback.ts
Comment thread packages/feedback/src/core/sendFeedback.ts
Comment thread packages/feedback/src/constants/index.ts Outdated
Comment thread packages/feedback/src/core/sendFeedback.ts Outdated
Comment thread packages/feedback/test/core/sendFeedback.test.ts Outdated
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 24, 2026

size-limit report 📦

Path Size % Change Change
@sentry/browser 25.88 kB - -
@sentry/browser - with treeshaking flags 24.35 kB - -
@sentry/browser (incl. Tracing) 43.8 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 45.5 kB - -
@sentry/browser (incl. Tracing, Profiling) 48.73 kB - -
@sentry/browser (incl. Tracing, Replay) 82.98 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 72.5 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 87.67 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 100.28 kB +0.36% +357 B 🔺
@sentry/browser (incl. Feedback) 43.1 kB +0.95% +402 B 🔺
@sentry/browser (incl. sendFeedback) 30.68 kB +0.45% +137 B 🔺
@sentry/browser (incl. FeedbackAsync) 35.85 kB +0.83% +295 B 🔺
@sentry/browser (incl. Metrics) 27.16 kB - -
@sentry/browser (incl. Logs) 27.29 kB - -
@sentry/browser (incl. Metrics & Logs) 27.98 kB - -
@sentry/react 27.62 kB - -
@sentry/react (incl. Tracing) 46.05 kB - -
@sentry/vue 30.71 kB - -
@sentry/vue (incl. Tracing) 45.62 kB - -
@sentry/svelte 25.89 kB - -
CDN Bundle 28.57 kB - -
CDN Bundle (incl. Tracing) 46.08 kB - -
CDN Bundle (incl. Logs, Metrics) 29.95 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 47.12 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 68.92 kB - -
CDN Bundle (incl. Tracing, Replay) 83.14 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 84.17 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 88.95 kB +0.39% +338 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 90 kB +0.36% +314 B 🔺
CDN Bundle - uncompressed 83.59 kB - -
CDN Bundle (incl. Tracing) - uncompressed 137.62 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 87.73 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 141.03 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 211.31 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 255.06 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 258.46 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 268.76 kB +0.3% +789 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 272.15 kB +0.3% +789 B 🔺
@sentry/nextjs (client) 48.58 kB - -
@sentry/sveltekit (client) 44.22 kB - -
@sentry/node-core 58.35 kB +0.02% +10 B 🔺
@sentry/node 175.67 kB +0.01% +14 B 🔺
@sentry/node - without tracing 98.3 kB +0.02% +11 B 🔺
@sentry/aws-serverless 115.33 kB +0.02% +15 B 🔺

View base workflow run

Copy link
Copy Markdown
Member

@nicohrubec nicohrubec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice


await expect(
sendFeedback({ message: 'mi' }, { errorMessages: { ERROR_FORBIDDEN: 'custom forbidden text' } }),
).rejects.toMatch('custom forbidden text');
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

l: maybe it could be worth adding a case where we check that non-overriden messages keep the default?

Copy link
Copy Markdown
Member

@JPeer264 JPeer264 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Also nice that it only bumps the specific feedback bundles

@@ -1,11 +1,14 @@
/* eslint-disable max-lines */
/* eslint-disable complexity */
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

l: Could this be avoided by outsourcing wrappedSendFeedback ? Would still be nice to keep as many eslint oxlint rules as possible

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Complexity is coming from the massive destructions, extracting the inner function doesn't make the rule pass 😕

logaretm and others added 5 commits April 24, 2026 04:02
Adds five new text options (errorEmptyMessageText, errorNoClientText,
errorTimeoutText, errorForbiddenText, errorGenericText) to
FeedbackTextConfiguration so consumers can translate or reword the
widget's error messages. sendFeedback now throws/rejects with stable
codes (typed via FeedbackErrorCode) and the widget maps those codes
to the configured text.

Closes #14687

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Form: use ?? so empty-string text overrides are respected (Copilot)
- constants: grammar fix "with an empty message" (Copilot)
- sendFeedback: clean up afterSendEvent listener on timeout to avoid leak (Copilot)
- tests: cover empty-message and no-client early-return paths (Copilot)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…messages

Addresses review feedback that sendFeedback (a public API) was rejecting
with internal codes instead of human-readable strings, changing observable
behavior for non-widget consumers.

sendFeedback now accepts optional errorMessages overrides via its hint
argument, defaulting to the original English strings. The widget wraps
sendFeedback to inject its configured text options, so standalone
consumers of sendFeedback see the same strings as before.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@logaretm logaretm force-pushed the awad/js-126-allow-error-messages-to-be-customized branch from dadaa16 to 90ec385 Compare April 24, 2026 08:02
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 90ec385. Configure here.

export const HIDE_TOOL_TEXT = 'Hide';
export const REMOVE_HIGHLIGHT_TEXT = 'Remove';

export const ERROR_EMPTY_MESSAGE_TEXT = 'Unable to submit feedback with an empty message';
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error message text subtly changed for standalone consumers

Low Severity

The ERROR_EMPTY_MESSAGE_TEXT constant reads "Unable to submit feedback with an empty message" but the old inline string was "Unable to submit feedback with empty message" (no "an"). The PR description states "Standalone sendFeedback consumers see the same English messages as before — no observable behavior change," but this error text did change. Any consumer matching on the exact error message string would see different behavior.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 90ec385. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow error messages to be customized

4 participants