⚠️ Capture your Apollo GraphQL exceptions into Sentry, in a meaningful way.
Apollo Sentry Helper
This package provides a new link to connect Sentry with Apollo Client, in order to automatically report GraphQL errors to Sentry in a meaningful way.
Installation
⚠️ Attention! Currently, there are two tags on the NPM package: latest
and next
.
latest
: Usesapollo-link-error
, is compatible with Apollo Client 2.next
: Uses@apollo/client/link/error
, is compatible with Apollo Client 3.
Apollo Client 3
# With npm npm install apollo-sentry-helper@next # With yarn yarn add apollo-sentry-helper@next
Apollo Client 2
# With npm npm install apollo-sentry-helper # With yarn yarn add apollo-sentry-helper
Usage
Initialize Sentry as you would normally. Then, build the error link with your settings and add it to your Apollo Client's link
array:
import ApolloLink ApolloClient InMemoryCache createHttpLink from "@apollo/client";import buildSentryErrorLink from "apollo-sentry-helper"; const httpLink = ; const sentryErrorLink = ; const link = ApolloLink; const client = cache: link;
Options
You can customize what is going to be included in the error report, and which errors should be reported.
const sentryErrorLink = ;
Be careful what you include
Please note that Sentry sets some limits to how big events can be. For instance, events greater than 200KiB are immediately dropped (pre decompression). More information on that here.
Furthermore, much of the data you are sending to Sentry can include (sensitive) personal information. This might lead you to violating the terms of the GDPR, so you'll need to be careful here.
Contributing
Pull requests are welcome! If you have any feedback, issue or suggestion, feel free to open a new issue so we can talk about it 💬.
Made possible by
License
MIT © Jungsoft