An open API service indexing awesome lists of open source software.

https://github.com/pointblankdev/apollo-plugin-sentry

TBD
https://github.com/pointblankdev/apollo-plugin-sentry

Last synced: 2 months ago
JSON representation

TBD

Awesome Lists containing this project

README

          

# Apollo-Plugin-Sentry

[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)

Gitmoji


An Apollo Plugin for Sentry Monitoring 🔍

[Tracking Errors in Apollo GraphQL with Sentry](https://medium.com/@mahyor.sam/tracking-errors-in-apollo-graphql-with-sentry-549ae52c0c76)


## 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 📚](https://www.apollographql.com/docs/apollo-server/integrations/plugins/)

![Lifecycle Events Diagram](apollo-hooks-diagram.png)


## Install

```bash
# 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](https://sentry,io). 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');
```

```bash
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

```bash
const {
sentryPlugin,
} = require('@pointblankdev/apollo-plugin-sentry');

const plugin = sentryPlugin('my-repo');
```

```bash
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.