-
Notifications
You must be signed in to change notification settings - Fork 50
feat: add report issue button #216
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
Open
vojtabohm
wants to merge
10
commits into
main
Choose a base branch
from
feat/add-report-issue-button
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
5f66df8
feat: add report issue button (ui only)
vojtabohm bd6b388
feat: add provisional reportIssue server action
vojtabohm a73206c
feat: change tooltip copy
vojtabohm 7805144
feat: add report issue popover
vojtabohm a134f26
feat: tweak and match feedback popover ui
vojtabohm a4a36e3
feat: add plain SDK, connect to API
vojtabohm da7c98b
feat: add mentions of plain integration in appropriate places
vojtabohm 1304419
feat: add analytics to report issue popover
vojtabohm 10981b8
feat: make plain api key private, expose only UI gate
vojtabohm bee1f2a
fix: bad state management
vojtabohm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,130 @@ | ||
| 'use client' | ||
|
|
||
| import { reportIssueAction } from '@/server/support/support-actions' | ||
| import { Button } from '@/ui/primitives/button' | ||
| import { | ||
| CardContent, | ||
| CardDescription, | ||
| CardHeader, | ||
| CardTitle, | ||
| } from '@/ui/primitives/card' | ||
| import { Input } from '@/ui/primitives/input' | ||
| import { Popover, PopoverContent, PopoverTrigger } from '@/ui/primitives/popover' | ||
| import { Textarea } from '@/ui/primitives/textarea' | ||
| import { usePostHog } from 'posthog-js/react' | ||
| import { useState } from 'react' | ||
| import { toast } from 'sonner' | ||
|
|
||
| interface ReportIssuePopoverProps { | ||
| trigger: React.ReactNode | ||
| } | ||
|
|
||
| export default function ReportIssuePopover({ | ||
| trigger, | ||
| }: ReportIssuePopoverProps) { | ||
| const posthog = usePostHog() | ||
| const [isOpen, setIsOpen] = useState(false) | ||
| const [sandboxId, setSandboxId] = useState('') | ||
| const [description, setDescription] = useState('') | ||
| const [isSubmitting, setIsSubmitting] = useState(false) | ||
| const [wasSubmitted, setWasSubmitted] = useState(false) | ||
|
|
||
| const handleSubmit = async (e: React.FormEvent) => { | ||
| e.preventDefault() | ||
|
|
||
| if (!sandboxId.trim() || !description.trim()) { | ||
| toast.error('Please fill in all fields') | ||
| return | ||
| } | ||
|
|
||
| setIsSubmitting(true) | ||
|
|
||
| try { | ||
| const result = await reportIssueAction({ | ||
| sandboxId: sandboxId.trim(), | ||
| description: description.trim(), | ||
| }) | ||
|
|
||
| if (result?.data?.success) { | ||
| posthog.capture('issue_reported', { | ||
| sandbox_id: sandboxId.trim(), | ||
| thread_id: result.data.threadId, | ||
| }) | ||
| setWasSubmitted(true) | ||
| toast.success('Issue reported successfully. Our team will review it shortly.') | ||
| setIsOpen(false) | ||
| // reset state | ||
| setSandboxId('') | ||
| setDescription('') | ||
| setTimeout(() => { | ||
| setWasSubmitted(false) | ||
| }, 100) | ||
| } else { | ||
| toast.error('Failed to report issue. Please try again.') | ||
| } | ||
| } catch (error) { | ||
| console.error('Error reporting issue:', error) | ||
| toast.error('Failed to report issue. Please try again.') | ||
| } finally { | ||
| setIsSubmitting(false) | ||
| } | ||
| } | ||
|
|
||
| return ( | ||
| <Popover | ||
| open={isOpen} | ||
| onOpenChange={(open) => { | ||
| if (open) { | ||
| posthog.capture('issue_report_shown') | ||
| } | ||
| if (!open && !wasSubmitted) { | ||
| posthog.capture('issue_report_dismissed') | ||
| } | ||
| setIsOpen(open) | ||
| }} | ||
| > | ||
| <PopoverTrigger asChild>{trigger}</PopoverTrigger> | ||
|
|
||
| <PopoverContent | ||
| className="w-[400px]" | ||
| collisionPadding={12} | ||
| sideOffset={12} | ||
| > | ||
| <CardHeader> | ||
| <CardTitle>Report Issue</CardTitle> | ||
| <CardDescription> | ||
| Our team will get back to you shortly | ||
| </CardDescription> | ||
| </CardHeader> | ||
| <CardContent className="pt-1"> | ||
| <form onSubmit={handleSubmit} className="flex flex-col gap-1"> | ||
| <Input | ||
| id="sandboxId" | ||
| placeholder="Enter sandbox ID" | ||
| aria-label="Sandbox ID" | ||
| value={sandboxId} | ||
| onChange={(e) => setSandboxId(e.target.value)} | ||
| disabled={isSubmitting} | ||
| /> | ||
| <Textarea | ||
| id="description" | ||
| placeholder="Describe the issue you're experiencing..." | ||
| aria-label="Issue description" | ||
| value={description} | ||
| onChange={(e) => setDescription(e.target.value)} | ||
| className="min-h-28" | ||
| disabled={isSubmitting} | ||
| /> | ||
| <Button | ||
| type="submit" | ||
| className="w-full mt-2" | ||
| disabled={isSubmitting || !sandboxId.trim() || !description.trim()} | ||
| > | ||
| {isSubmitting ? 'Submitting...' : 'Submit'} | ||
| </Button> | ||
| </form> | ||
| </CardContent> | ||
| </PopoverContent> | ||
| </Popover> | ||
| ) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.