Skip to content

Commit d65fb40

Browse files
authored
Merge pull request #1 from ryan953/ryan953/feedback-labels
Add a new testcase for translating all the labels
2 parents 3d2aeeb + fba4cff commit d65fb40

File tree

4 files changed

+629
-470
lines changed

4 files changed

+629
-470
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"lint": "next lint"
1010
},
1111
"dependencies": {
12-
"@sentry/nextjs": "^9.30.0",
12+
"@sentry/nextjs": "10.10.0",
1313
"next": "15.3.3",
1414
"react": "^19.0.0",
1515
"react-dom": "^19.0.0"
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
"use client";
2+
3+
import {useEffect, useState} from 'react';
4+
import * as Sentry from "@sentry/nextjs";
5+
6+
type FeedbackIntegration = ReturnType<typeof Sentry.getFeedback>;
7+
8+
export default function TranslatedFeedbackForm() {
9+
const [feedback, setFeedback] = useState<FeedbackIntegration>();
10+
// Read `getFeedback` on the client only, to avoid hydration errors when server rendering
11+
useEffect(() => {
12+
setFeedback(Sentry.getFeedback());
13+
}, []);
14+
15+
// Don't render custom feedback button if Feedback integration isn't installed
16+
if (!feedback) {
17+
return null;
18+
}
19+
20+
return (
21+
<button
22+
className="hover:bg-hover px-4 py-2 rounded-md"
23+
type="button"
24+
onClick={async () => {
25+
const form = await feedback.createForm({
26+
tags: {component: 'TranslatedFeedbackForm'},
27+
28+
/**
29+
* The label for the Feedback widget button that opens the dialog
30+
*/
31+
triggerLabel: 'Lets get started',
32+
/**
33+
* The aria label for the Feedback widget button that opens the dialog
34+
*/
35+
triggerAriaLabel: 'Send it!',
36+
/**
37+
* The label for the Feedback form cancel button that closes dialog
38+
*/
39+
cancelButtonLabel: 'Nevermind',
40+
/**
41+
* The label for the Feedback form submit button that sends feedback
42+
*/
43+
submitButtonLabel: 'Send it!',
44+
/**
45+
* The label for the Screenshot editor cancel buttons
46+
*/
47+
confirmButtonLabel: 'I confirm',
48+
/**
49+
* The title of the Feedback form
50+
*/
51+
formTitle: 'Feedback Test Area',
52+
/**
53+
* Label for the email input
54+
*/
55+
emailLabel: 'Email or contact info',
56+
/**
57+
* Placeholder text for Feedback email input
58+
*/
59+
emailPlaceholder: 'you@example.com or (555) 555-5555',
60+
/**
61+
* Label for the message input
62+
*/
63+
messageLabel: "What's up?",
64+
/**
65+
* Placeholder text for Feedback message input
66+
*/
67+
messagePlaceholder: 'Tell me about it',
68+
/**
69+
* Label for the name input
70+
*/
71+
nameLabel: 'Who dis?',
72+
/**
73+
* Placeholder text for Feedback name input
74+
*/
75+
namePlaceholder: 'Name, nickname, etc.',
76+
/**
77+
* Message after feedback was sent successfully
78+
*/
79+
successMessageText: 'Thanks, we got it!',
80+
/**
81+
* Text which indicates that a field is required
82+
*/
83+
isRequiredLabel: 'critical',
84+
/**
85+
* The label for the button that adds a screenshot and renders the image editor
86+
*/
87+
addScreenshotButtonLabel: 'Add a pic',
88+
/**
89+
* The label for the button that removes a screenshot and hides the image editor
90+
*/
91+
removeScreenshotButtonLabel: 'Drop the pic',
92+
/**
93+
* The label for the button that highlights portions ofthe screenshot
94+
*/
95+
highlightToolText: 'Spotlight it',
96+
/**
97+
* The label for the button that hides portions of the screenshot
98+
*/
99+
hideToolText: 'Not this part',
100+
/**
101+
* The label for the button that removed a highlight/hidden section of the screenshot.
102+
*/
103+
removeHighlightText: 'Take it out',
104+
});
105+
form.appendToDom();
106+
form.open();
107+
}}
108+
>
109+
Give me feedback (translated)
110+
</button>
111+
);
112+
}

src/app/page.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import CreateFeedbackFromButton from "./examples/createFeedbackFormButton";
55
import MyFeedbackForm from "./examples/myFeedbackForm";
66
import CrashReportButton from "./examples/crashReportButton";
77
import ThumbsUpDownButtons from "src/app/examples/thumbsUpDownButtons";
8+
import TranslatedFeedbackForm from "src/app/examples/translatedFeedbackForm";
89

910
export default function Home() {
1011
return (
@@ -61,6 +62,12 @@ export default function Home() {
6162
<ThumbsUpDownButtons />
6263
</fieldset>
6364
</li>
65+
<li>
66+
<fieldset className="border-1 border-gray-300 rounded-md p-2">
67+
<legend>Translated Feedback Form (<a href="https://github.com/ryan953/nextjs-test-feedback/blob/main/src/app/examples/translatedFeedbackForm.tsx">source</a>)</legend>
68+
<TranslatedFeedbackForm />
69+
</fieldset>
70+
</li>
6471
</ul>
6572
</div>
6673
);

0 commit comments

Comments
 (0)