Skip to content

Commit

Permalink
improve
Browse files Browse the repository at this point in the history
  • Loading branch information
lcian committed Mar 4, 2025
1 parent b8e80c6 commit 8ed6e7c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 24 deletions.
16 changes: 11 additions & 5 deletions docs/platforms/android/integrations/apollo4/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,15 @@ This feature automatically captures GraphQL client errors (like bad operations a

Sentry will group GraphQL client errors by the `operationName`, `operationType`, and `statusCode`, so that you can easily see the number of errors that happened for each.

Starting with SDK version `7.0.0`, GraphQL client error capturing is enabled by default. For prior versions of the SDK, this feature is opt-in and can be enabled by setting the `captureFailedRequests` option to `true`:
This feature is enabled by default and can be disabled by setting the `captureFailedRequests` option to `false`:

```kotlin
import com.apollographql.ApolloClient
import io.sentry.apollo4.sentryTracing

val apollo = ApolloClient.builder()
.serverUrl("https://your-api-host/")
.sentryTracing(captureFailedRequests = true)
.sentryTracing(captureFailedRequests = false)
.build()
```

Expand All @@ -156,6 +156,12 @@ val apollo = ApolloClient.builder()

By default, error events won't contain `Headers` or `Cookies`, but you can change this behavior by setting the `sendDefaultPii` option to `true`:

```kotlin
Sentry.init { options ->
options.isSendDefaultPii = true
}
```

```xml {filename:AndroidManifest.xml}
<application>
<meta-data android:name="io.sentry.send-default-pii" android:value="true" />
Expand All @@ -168,17 +174,17 @@ Alternatively, you can customize the event and scrub the data yourself.

### Customize or Drop the Error Event

To customize or drop the error event, you'll need to do a [manual initialization](/platforms/android/configuration/manual-init/#manual-initialization) of the Sentry Android SDK. The captured error event can then be customized or dropped with a `BeforeSendCallback`:
The captured error event can be customized or dropped with a `BeforeSendCallback`:

```kotlin
import io.sentry.android.core.SentryAndroid
import io.sentry.Sentry
import io.sentry.SentryOptions.BeforeSendCallback
import com.apollographql.api.http.HttpRequest
import com.apollographql.api.http.HttpResponse
import io.sentry.TypeCheckHint.APOLLO_REQUEST
import io.sentry.TypeCheckHint.APOLLO_RESPONSE

SentryAndroid.init(this) { options ->
Sentry.init { options ->
// Add a callback that will be used before the event is sent to Sentry.
// With this callback, you can modify the event or, when returning null, also discard the event.
options.beforeSend = BeforeSendCallback { event, hint ->
Expand Down
20 changes: 1 addition & 19 deletions docs/platforms/java/common/tracing/instrumentation/apollo4.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -102,25 +102,7 @@ val apollo = ApolloClient.builder()

<Alert title="Important">

Apollo Kotlin is built with Kotlin coroutines. This means that `SentryApolloInterceptor` can be used with Java using only Global Hub Mode (single Hub used by all threads), with Kotlin using single Hub mode, or with <PlatformLink to="/enriching-events/scopes/#kotlin-coroutines">Sentry's coroutines support</PlatformLink>.

</Alert>

## Using With Java

Configure Global Hub Mode:

```java
import io.sentry.Sentry;

Sentry.init(options -> {
..
}, true)
```

<Alert>

In Global Hub Mode, all threads use the same Hub.
Apollo Kotlin is built with Kotlin coroutines. This means that `SentryApolloInterceptor` can only be used with Kotlin using single Hub mode, or with <PlatformLink to="/enriching-events/scopes/#kotlin-coroutines">Sentry's coroutines support</PlatformLink>.

</Alert>

Expand Down

0 comments on commit 8ed6e7c

Please sign in to comment.