relay-sentry

Relay log function that enriches Sentry with Relay lifecycles and GraphQL data
⚙️
Install
yarn add relay-sentry
🧱
Usage
import { logFunction } from 'relay-sentry';
import { Environment } from 'relay-runtime';
const environment = new Environment({
log: logFunction(),
network,
store,
});
If you want to also include the GraphQL errors
array to the Sentry exception context. You can throw a custom Error
class that contains a property called graphqlErrors
. Internally we look for that key on the error object, and send it.
Under the hood it uses @sentry/minimal
so there is no discrepancy between Node/Browser runtimes.
TypeScript users, we export an interface to help:
import type { ErrorWithGraphQLErrors } from 'relay-sentry';
declare global {
interface Error extends ErrorWithGraphQLErrors {}
}
🎢
What does it add?
✅
Breadcrumbs
Leaves a debug/info breadcrumb trail for all intermediate life cycle events.
At this stage it doesn't filter any variables, but if there's a need for it—submit a PR
🕺
✅
Contexts
If the error was as a result of a Relay or Relay Network error, then this will include the remote errors array payload.
✅
Customisable Tag
Applies a tag when the exception was as a Result of Relay.
🔎
API
logFunction(options?: Options): LogFunction
Options
Option | Description | Default |
---|---|---|
tag?: string |
The tag key used when raising a Sentry error | "data.client" |
filterEvents?: (logEvent: LogEvent) => boolean |
Use to filter log events from creating breadcrumbs | undefined |
⁉
Help
How can I log something custom?
import { logFunction } from 'relay-sentry';
import { Environment } from 'relay-runtime';
const environment = new Environment({
log: (logEvent) => {
logFunction(logEvent);
// Do your logs
},
network,
store,
});
The error's context looks like [ [Object] ]
When you're running Sentry.init
set the normalizeDepth
to something bigger, maybe 10.
License
MIT © Marais Rossouw