Skip to content

Commit 8d2c9d8

Browse files
authored
feat(dotcom): add checkbox to include current file link in feedback (tldraw#8807)
In order to give people control over whether their current file URL is shared when they submit feedback, this PR adds a one-line "Include link to current file" checkbox to the signed-in feedback dialog. The checkbox is checked by default, preserving today's behaviour, and unchecking it sends an empty URL. Closes tldraw#8806. The submit-feedback worker now omits the `URL: ...` line in the Discord embed and Plain thread when the URL is empty, so feedback messages stay tidy when the user opts out. ### Change type - [x] `feature` ### Test plan 1. Run `yarn dev-app`, sign in, and open Help menu → Send feedback. 2. Verify the dialog shows a checkbox labeled "Include link to current file" between the textarea and the footer, checked by default. 3. Submit feedback with the checkbox checked. Confirm the Discord/Plain message includes the page URL. 4. Submit feedback with the checkbox unchecked. Confirm the Discord/Plain message does not include a `URL:` line. ### Release notes - Add an option to include or omit the current file link when submitting feedback from tldraw.com. ### Code changes | Section | LOC change | | --- | --- | | Apps | +41 / -7 |
1 parent cd78c67 commit 8d2c9d8

6 files changed

Lines changed: 46 additions & 7 deletions

File tree

apps/dotcom/client/public/tla/locales-compiled/en.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,12 @@
153153
"value": "My files"
154154
}
155155
],
156+
"2e2b3c700b": [
157+
{
158+
"type": 0,
159+
"value": "Include link to current file"
160+
}
161+
],
156162
"31246941ad": [
157163
{
158164
"type": 0,

apps/dotcom/client/public/tla/locales/en.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@
7474
"2c3ef76333": {
7575
"translation": "My files"
7676
},
77+
"2e2b3c700b": {
78+
"translation": "Include link to current file"
79+
},
7780
"31246941ad": {
7881
"translation": "You need to sign in to view this file."
7982
},

apps/dotcom/client/src/tla/components/dialogs/SubmitFeedbackDialog.tsx

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { useAuth } from '@clerk/clerk-react'
22
import { addBreadcrumb, withScope } from '@sentry/react'
33
import { SubmitFeedbackRequestBody } from '@tldraw/dotcom-shared'
4-
import { useCallback, useEffect, useRef } from 'react'
4+
import { useCallback, useEffect, useRef, useState } from 'react'
55
import {
66
TldrawUiButton,
7+
TldrawUiButtonCheck,
78
TldrawUiButtonLabel,
89
TldrawUiDialogBody,
910
TldrawUiDialogCloseButton,
@@ -74,6 +75,7 @@ function SignedOutSubmitFeedbackDialog() {
7475

7576
function SignedInSubmitFeedbackDialog({ onClose }: { onClose(): void }) {
7677
const rInput = useRef<HTMLTextAreaElement>(null)
78+
const [includeFileLink, setIncludeFileLink] = useState(true)
7779
const toasts = useToasts()
7880
const intl = useIntl()
7981
const onSubmit = useCallback(async () => {
@@ -83,7 +85,9 @@ function SignedInSubmitFeedbackDialog({ onClose }: { onClose(): void }) {
8385
body: JSON.stringify({
8486
allowContact: true,
8587
description: rInput.current.value.trim(),
86-
url: window.location.href.replace('https', 'https-please-be-mindful'),
88+
url: includeFileLink
89+
? window.location.href.replace('https', 'https-please-be-mindful')
90+
: '',
8791
} satisfies SubmitFeedbackRequestBody),
8892
})
8993
.then((r) => {
@@ -105,7 +109,7 @@ function SignedInSubmitFeedbackDialog({ onClose }: { onClose(): void }) {
105109
title: intl.formatMessage(messages.submitted),
106110
description: intl.formatMessage(messages.thanks),
107111
})
108-
}, [intl, onClose, toasts])
112+
}, [includeFileLink, intl, onClose, toasts])
109113

110114
// Focus the input when the dialog opens, select all text
111115
useEffect(() => {
@@ -163,6 +167,18 @@ function SignedInSubmitFeedbackDialog({ onClose }: { onClose(): void }) {
163167
/>
164168
</TldrawUiDialogBody>
165169
<TldrawUiDialogFooter className="tlui-dialog__footer__actions">
170+
<div className="tlui-dialog__footer__file-link-checkbox">
171+
<TldrawUiButton
172+
type="normal"
173+
onClick={() => setIncludeFileLink((v) => !v)}
174+
className={styles.feedbackDialogCheckbox}
175+
>
176+
<TldrawUiButtonCheck checked={includeFileLink} />
177+
<TldrawUiButtonLabel>
178+
<F defaultMessage="Include link to current file" />
179+
</TldrawUiButtonLabel>
180+
</TldrawUiButton>
181+
</div>
166182
<TldrawUiButton type="normal" onClick={onClose}>
167183
<TldrawUiButtonLabel>
168184
<F defaultMessage="Cancel" />

apps/dotcom/client/src/tla/components/dialogs/dialogs.module.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@
3535
color: var(--tl-color-text-3);
3636
}
3737

38+
.feedbackDialogCheckbox {
39+
margin-right: auto;
40+
}
41+
3842
/* --------------------- Cookie --------------------- */
3943

4044
.cookieConsent {

apps/dotcom/client/src/tla/styles/tla.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,3 +338,7 @@
338338
.tla-primary-button:not(.tlui-button):focus-visible {
339339
outline-offset: 0;
340340
}
341+
342+
.tlui-dialog__footer__file-link-checkbox {
343+
flex: 2;
344+
}

apps/dotcom/sync-worker/src/routes/submitFeedback.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,13 @@ export async function submitFeedback(req: IRequest, env: Environment) {
5050
}
5151
}
5252

53-
const embedDescription = plainThreadUrl
54-
? `${description}\n\nURL: ${url}\nPlain: ${plainThreadUrl}`
55-
: `${description}\n\nURL: ${url}`
53+
const extraLines = [
54+
url ? `URL: ${url}` : null,
55+
plainThreadUrl ? `Plain: ${plainThreadUrl}` : null,
56+
].filter(Boolean)
57+
const embedDescription = extraLines.length
58+
? `${description}\n\n${extraLines.join('\n')}`
59+
: description
5660

5761
const payload = {
5862
username: `Feedback (${env.WORKER_NAME ?? 'localhost'})`,
@@ -195,7 +199,9 @@ async function createPlainThread(
195199
customerIdentifier: { customerId },
196200
title: 'tldraw.com feedback',
197201
description: description.length > 200 ? description.slice(0, 200) + '…' : description,
198-
components: [{ componentText: { text: `${description}\n\nURL: ${url}` } }],
202+
components: [
203+
{ componentText: { text: url ? `${description}\n\nURL: ${url}` : description } },
204+
],
199205
...(env.PLAIN_LABEL_TYPE_ID && { labelTypeIds: [env.PLAIN_LABEL_TYPE_ID] }),
200206
},
201207
},

0 commit comments

Comments
 (0)