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

Question: Possible to only attach breadcrumbs when an error occurs? #301

Closed
watadarkstar opened this issue Mar 11, 2021 · 1 comment
Closed
Labels
question Further information is requested

Comments

@watadarkstar
Copy link

watadarkstar commented Mar 11, 2021

Description

I'm wondering if there is a way to only attach the network request as a breadcrumb if there are graphQLErrors or a networkError occurs, otherwise don't attach a breadcrumb.

Context: The main reason I want this is because I think adding a ton of sentry breadcrumbs is going to be a performance hit. I might be wrong?

Code

For example, I do this inside my onErrorLink but I would love to use this library instead to attach breadcrumbs only when a network/graphql error occurs.

const onErrorLink = onError(({ graphQLErrors, networkError, operation, forward }) => {
  if (graphQLErrors) {
    graphQLErrors.forEach(({ message, locations, path }) => {
          sentryBreadcrumb(
        `[GraphQL error]: Operation: ${operation.operationName}, Message: ${message}, Location: ${locations}, Path: ${path}`
      )
    }
if (networkError) {
    sentryBreadcrumb(`[Network error]: Operation: ${operation?.operationName}`, {
      networkError,
      operation: JSON.stringify(operation),
    })
  }
}
@watadarkstar watadarkstar changed the title Question: Possible to only log when an error occurs? Question: Possible to only attach breadcrumbs when an error occurs? Mar 11, 2021
@spawnia
Copy link
Collaborator

spawnia commented Dec 17, 2021

Breadcrumbs are only sent to Sentry along with an error that occurs later.

@spawnia spawnia closed this as completed Dec 17, 2021
@spawnia spawnia added the question Further information is requested label Dec 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants