-
Notifications
You must be signed in to change notification settings - Fork 114
H-6327: Integrate Sentry feedback button into ViewportControls #8537
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
4af40a6
Integrate Sentry feedback button into ViewportControls
kube 017d7fc
Update yarn.lock for react-icons dependency
kube a67d6a7
Clean and force "use memo" for React Compiler
kube e6ac28a
Remove manual memoization in DevApp, let React Compiler handle it
kube 0d5dc37
Remove unused useCallback/useMemo imports
kube 6d6cfca
Lint
kube d8ec669
Show alert when Sentry feedback is unavailable
kube 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
46 changes: 46 additions & 0 deletions
46
apps/petrinaut-website/src/main/app/sentry-feedback-button.tsx
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,46 @@ | ||
| import type { ViewportAction } from "@hashintel/petrinaut"; | ||
| import * as Sentry from "@sentry/react"; | ||
| import { MdBugReport } from "react-icons/md"; | ||
|
|
||
| const feedbackButtonStyle: React.CSSProperties = { | ||
| backgroundColor: "#8b5cf6dd", | ||
| borderColor: "#7c3aed", | ||
| color: "#fff", | ||
| }; | ||
|
|
||
| export function useSentryFeedbackAction(): ViewportAction { | ||
| // Wouldn't be optimized by React Compiler otherwise | ||
| "use memo"; | ||
|
|
||
| return { | ||
kube marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| key: "sentry-feedback", | ||
| icon: <MdBugReport size={14} />, | ||
| label: "Give feedback", | ||
| tooltip: "Give feedback", | ||
| style: feedbackButtonStyle, | ||
| ref: (node) => { | ||
| if (!node) { | ||
| return; | ||
| } | ||
|
|
||
| const feedback = Sentry.getFeedback(); | ||
|
|
||
| if (feedback) { | ||
| return feedback.attachTo(node, { | ||
| formTitle: "Give feedback", | ||
| messagePlaceholder: "Report a bug or suggest an improvement", | ||
| submitButtonLabel: "Submit feedback", | ||
| }); | ||
| } else { | ||
| const showFeedbackUnavailable = () => | ||
| // eslint-disable-next-line no-alert -- intentional fallback when Sentry is not configured | ||
| window.alert( | ||
| "Sentry is not configured in this environment, so the feedback form is unavailable.", | ||
| ); | ||
|
|
||
| node.addEventListener("click", showFeedbackUnavailable); | ||
| return () => node.removeEventListener("click", showFeedbackUnavailable); | ||
| } | ||
| }, | ||
| }; | ||
| } | ||
cursor[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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,18 @@ | ||
| export type ViewportAction = { | ||
| /** Unique key for React rendering. */ | ||
| key: string; | ||
| /** Icon element to render inside the button. */ | ||
| icon: React.ReactNode; | ||
| /** Accessible label for the button. */ | ||
| label: string; | ||
| /** Tooltip text shown on hover. */ | ||
| tooltip: string; | ||
| /** Click handler. */ | ||
| onClick?: () => void; | ||
| /** Inline styles applied to the button element. */ | ||
| style?: React.CSSProperties; | ||
| /** CSS class name applied to the button element. */ | ||
| className?: string; | ||
| /** Ref callback to access the underlying button DOM element. */ | ||
| ref?: React.Ref<HTMLButtonElement>; | ||
| }; |
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
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.