Skip to content

Commit

Permalink
Merge pull request #7 from vscubing/add-sentry
Browse files Browse the repository at this point in the history
add sentry to track solve rejected error
  • Loading branch information
bohdancho authored Dec 21, 2024
2 parents 741df59 + 554e268 commit 407a86c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
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,7 +5,9 @@ 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.", // uncomment once the bug is fixed
Expand All @@ -20,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

0 comments on commit 407a86c

Please sign in to comment.