ref(onboarding): Convert CreateSampleEventButton to functional component#115830
Open
ryan953 wants to merge 4 commits into
Open
ref(onboarding): Convert CreateSampleEventButton to functional component#115830ryan953 wants to merge 4 commits into
ryan953 wants to merge 4 commits into
Conversation
Replace class component with function component using hooks. Replace withApi/withOrganization HOCs with useApi/useOrganization hooks. Convert api.requestPromise POST call to useMutation with fetchMutation, and the polling loop to useQuery with retry/retryDelay. Replace browserHistory with useNavigate. Switch from default export to named export. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
📊 Type Coverage Diff✅ No new type safety issues introduced. Coverage: 93.56% |
Replace the imperative api.requestPromise polling loop and useQuery bridge with queryClient.fetchQuery inside the mutation. This keeps the entire create-and-poll lifecycle in a single useMutation, using fetchQuery's built-in retry/retryDelay for polling. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move fetchQuery polling out of mutationFn into onSuccess so the mutation completes after the POST. Polling runs as a detached .then()/.catch() chain, keeping isPending tied only to the sample event creation request. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit efdf737. Configure here.
Add an AbortController to cancel the fetchQuery polling when the component unmounts or when a new sample event is created. This prevents stale navigate, toast, and analytics calls from firing after the user has left the page. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

Convert
CreateSampleEventButtonfrom a class component withwithApi/withOrganizationHOCs to a functional component using hooks. No behavior change.API modernization
Replace
api.requestPromisewith TanStack Query primitives:useMutation+fetchMutationfor the POST, andqueryClient.fetchQuerywithapiOptions,retry, andretryDelayfor polling the latest event. The manualwhile-loop withsetTimeoutis removed entirely. ReplacebrowserHistory.pushwithuseNavigate. Switch from default export to named export.Polling via fetchQuery
The create-and-poll lifecycle lives in a single
useMutation. After the POST creates the sample group,queryClient.fetchQuerypolls the latest-event endpoint using built-inretry/retryDelayoptions instead of an imperative loop. This eliminates the_isMountedguard —useMutationhandles unmount cleanup automatically.