Skip to content

Commit

Permalink
⚠️ Omit all handled apollo errors (#4739)
Browse files Browse the repository at this point in the history
* Omit all handled apollo errors

* Omit unauthorized reqs
  • Loading branch information
WRadoslaw authored Aug 24, 2023
1 parent 911f279 commit 6f9abaa
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/atlas/src/utils/logs/sentry.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ApolloError } from '@apollo/client'
import { ApolloError, isApolloError } from '@apollo/client'
import * as Sentry from '@sentry/react'
import { Replay, Severity, SeverityLevel } from '@sentry/react'

Expand Down Expand Up @@ -36,9 +36,12 @@ class _SentryLogger {
replaysSessionSampleRate: 0,
replaysOnErrorSampleRate: 0,
beforeSend: (event, hint) => {
if ('message' in (hint.originalException as ApolloError)) {
const error = hint.originalException as ApolloError
return error.message.includes('code 400') ? null : event
if (isApolloError(hint.originalException as Error)) {
// json.stringify should we replace for a code check as soon as Orion releases patch
return event.exception?.values?.some((exception) => !exception.mechanism?.handled) &&
!JSON.stringify((hint.originalException as ApolloError).networkError).includes('Unauthorized')
? event
: null
}
return event
},
Expand Down

0 comments on commit 6f9abaa

Please sign in to comment.