sentry-javascript icon indicating copy to clipboard operation
sentry-javascript copied to clipboard

Add optional `graphqlClientIntegration` to `@sentry/browser`

Open mydea opened this issue 1 year ago • 0 comments

Description

Similar to https://github.com/getsentry/sentry-cocoa/pull/3931, we can add a pluggable (=not enabled by default) integration to @sentry/browser (and downstream SDKs) which allows to opt-in to get better breadcrumbs & spans when using GraphQL as a client.

This could behave like this:

Sentry.init({
  integrations: [
    Sentry.graphqlClientIntegration({
      endpoints: ['/graphql'],  
    })
  ]
})

Where any http.client span or breadcrumb created that matches endpoints will be enhanced with graphql data from the request payload:

  1. For http.client spans, we can update the span name similar to what we do here in node: https://github.com/getsentry/sentry-javascript/pull/13248
  2. For breadcrumbs, we can add the operation name to the breadcrumb data (and possibly also the query itself)

related: https://github.com/getsentry/sentry-javascript/issues/13215

mydea avatar Aug 16 '24 07:08 mydea