Skip to content
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

add sentry to track solve rejected error #7

Merged
merged 2 commits into from
Dec 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified bun.lockb
Binary file not shown.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"@radix-ui/react-popover": "^1.0.7",
"@radix-ui/react-slot": "^1.0.2",
"@react-oauth/google": "0.12.1",
"@sentry/react": "^8.47.0",
"@tanstack/react-query": "^5.29.2",
"@tanstack/react-router": "^1.47.5",
"@vscubing/cubing": "0.46.1-vscubing.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ import { ContestsCreateSolveInput, contestsOngoingContestSolveCreateCreate } fro
import { TOASTS_PRESETS, Toast, toast } from '@/components/ui'
import { AxiosError } from 'axios'
import { ongoingContestQuery } from '@/shared/contests'
import * as Sentry from '@sentry/browser'

export const SOLVE_REJECTED_ERROR_TEXT = 'A solve was rejected by the server'
const SOLVE_REJECTED_TOAST = {
title: 'Uh-oh! Solve rejected by the server',
description: "Under normal circumstances this shouldn't happen.",
// description: "Under normal circumstances this shouldn't happen.", // uncomment once the bug is fixed
description: 'We are working on fixing this bug, for now please take an extra.',
duration: 'infinite',
} satisfies Toast

Expand All @@ -19,6 +22,7 @@ export const usePostSolveResult = (discipline: string) =>
await contestsOngoingContestSolveCreateCreate(result, { disciplineSlug: discipline, scrambleId })
} catch (err) {
if (err instanceof AxiosError && err.response?.status === 400) {
Sentry.captureException(new Error(SOLVE_REJECTED_ERROR_TEXT))
toast(SOLVE_REJECTED_TOAST)
} else {
toast(TOASTS_PRESETS.internalError)
Expand Down
11 changes: 11 additions & 0 deletions src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@ import { CubeProvider } from './features/cube'
import { queryClient } from './lib/reactQuery'
import { router } from './router'
import { Toaster } from './components/ui'
import * as Sentry from '@sentry/react'
import { SOLVE_REJECTED_ERROR_TEXT } from './features/contests/pages/SolveContestPage/api'

Sentry.init({
dsn: 'https://ad4ae74aa3be7afcfee2ca4cf9df2c52@o4508506299564032.ingest.de.sentry.io/4508506301988944',
environment: import.meta.env.MODE,
integrations: [],
beforeSend: (error) => {
return error.exception?.values?.at(0)?.value === SOLVE_REJECTED_ERROR_TEXT ? error : null
},
})

ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
Expand Down
Loading