@pointblankdev/apollo-plugin-sentry
v0.0.6
Published
An Apollo Plugin for Sentry Monitoring π
Downloads
3
Readme
Apollo-Plugin-Sentry
An Apollo Plugin for Sentry Monitoring π
Tracking Errors in Apollo GraphQL with Sentry
How it works
Apollo server uses lifecycle events, enabling us to easily instrument an app for sentry integration.
Here's a visual diagram of the flow of lifecycle events. Learn more at the Apollo Plugin Docs π
Install
# yarn
yarn add @pointblankdev/apollo-plugin-sentry
# npm
npm install @pointblankdev/apollo-plugin-sentry
Usage
- To get started, you need to have a Sentry DSN which you can get here. This value should be assigned to the
SENTRY_DSN
environment variable. - Make sure you have the
ENV
variable set so Sentry knows which environment to use for tracking your errors
Pre 0.0.6
Import the package and pass an array containing the variable to the plugin options of your Apollo Server and you're good to go π
const { sentryPlugin, } = require('@pointblankdev/apollo-plugin-sentry');
const server = new ApolloServer({ ..., plugins: [sentryPlugin], });
>= 0.0.6
Import the package, initialize it by calling it with an optional service name, pass the result to the plugin options of your Apollo Server and you're good to go
const { sentryPlugin, } = require('@pointblankdev/apollo-plugin-sentry'); const plugin = sentryPlugin('my-repo');
const server = new ApolloServer({ ..., plugins: [plugin], });
The service name is added as a
service_name
tag in your error reporting, therefore making it much easier to identify individual services at first glance when you have a project that serves multiple services.