0.2.0 • Published 2 years ago

relay-sentry v0.2.0

Weekly downloads
75
License
MIT
Repository
github
Last release
2 years ago

relay-sentry CI downloads

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.

import type { ErrorWithGraphQLErrors } from 'relay-sentry';

declare global {
  interface Error extends ErrorWithGraphQLErrors {}
}

🎢 What does it look like?

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 🕺

🔎 API

logFunction(options?: Options): LogFunction

Options

OptionDescriptionDefault
filterEvents?: (logEvent: LogEvent) => booleanUse to filter log events from creating breadcrumbsundefined

⁉ Help

import { logFunction } from 'relay-sentry';
import { Environment } from 'relay-runtime';

const environment = new Environment({
  log: (logEvent) => {
    logFunction(logEvent);
    // Do your logs
  },
  network,
  store,
});

When you're running Sentry.init set the normalizeDepth to something bigger, maybe 10.

relay-sentry used to also manually capture an exception thorough the captureException Sentry api. However, through user feedback and further exploration we found it best to leave that to the consumer through the use of an async-boundary or alike. This avoided the double error emission (or event) for an error that would have also been emitted by those boundaries.

License

MIT © Marais Rossouw

0.3.0-alpha.1

2 years ago

0.2.0

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago

0.0.5

3 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.1

4 years ago

0.0.2

4 years ago

0.0.0

4 years ago