-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
feat(apple): document enableGraphQLOperationTracking option #15669
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| --- | ||
| title: GraphQL Operation Tracking | ||
| sidebar_order: 14 | ||
| description: "Enable tracking of GraphQL operation names in HTTP breadcrumbs and failed request events" | ||
| --- | ||
|
|
||
| When enabled, the SDK extracts the GraphQL operation name from HTTP requests that have `Content-Type: application/json` and contain a JSON body with an `operationName` field. The operation name is then attached to: | ||
|
|
||
| - HTTP breadcrumbs as `graphql_operation_name` (when network breadcrumbs are enabled) | ||
| - Failed request events in the context as `graphql.operation_name` (when HTTP client error capture is enabled) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| This feature is disabled by default. To enable it: | ||
|
|
||
| ```swift {tabTitle:Swift} | ||
| import Sentry | ||
|
|
||
| SentrySDK.start { options in | ||
| options.dsn = "___PUBLIC_DSN___" | ||
| options.enableGraphQLOperationTracking = true | ||
| } | ||
| ``` | ||
|
|
||
| ```objc {tabTitle:Objective-C} | ||
| @import Sentry; | ||
|
|
||
| [SentrySDK startWithConfigureOptions:^(SentryOptions *options) { | ||
| options.dsn = @"___PUBLIC_DSN___"; | ||
| options.enableGraphQLOperationTracking = YES; | ||
| }]; | ||
| ``` | ||
| ## How It Works | ||
| The SDK automatically detects GraphQL requests by checking: | ||
| 1. The HTTP request has `Content-Type: application/json` header | ||
| 2. The request body contains valid JSON | ||
| 3. The JSON body includes an `operationName` field | ||
| When these conditions are met, the SDK extracts the `operationName` value and includes it in: | ||
| - **HTTP Breadcrumbs**: When network breadcrumbs are enabled (default), the GraphQL operation name is added as `graphql_operation_name` in the breadcrumb data. This helps you identify which GraphQL operations were executed leading up to an error. | ||
| - **Failed Request Events**: When HTTP client error capture is enabled (default since version 8.0.0), the GraphQL operation name is included in the event context as `graphql.operation_name`. This makes it easier to identify which GraphQL operation failed when debugging HTTP client errors. | ||
| ## Example GraphQL Request | ||
| The SDK extracts the operation name from requests like this: | ||
| ```json | ||
| { | ||
| "operationName": "GetUserProfile", | ||
| "variables": { | ||
| "id": "1234" | ||
| }, | ||
| "query": "query GetUserProfile($id: ID!) { user(id: $id) { name email } }" | ||
| } | ||
| ``` | ||
|
|
||
| In this example, `GetUserProfile` would be extracted and attached to breadcrumbs and error events. | ||
|
|
||
| ## Related Features | ||
|
|
||
| - <PlatformLink to="/configuration/http-client-errors/">HTTP Client Errors</PlatformLink> - Learn about capturing HTTP client errors | ||
| - <PlatformLink to="/enriching-events/breadcrumbs/">Breadcrumbs</PlatformLink> - Learn about breadcrumb tracking | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -73,6 +73,30 @@ SentrySDK.start { options in | |
| }]; | ||
| ``` | ||
|
|
||
| ### GraphQL Operation Tracking | ||
|
|
||
| When `enableGraphQLOperationTracking` is enabled, the SDK extracts the GraphQL operation name from HTTP requests that have `Content-Type: application/json` and contain a JSON body with an `operationName` field. The operation name is then included in the error event's context as `graphql.operation_name`, making it easier to identify which GraphQL operation failed. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| ```swift {tabTitle:Swift} | ||
| import Sentry | ||
|
|
||
| SentrySDK.start { options in | ||
| options.dsn = "___PUBLIC_DSN___" | ||
| options.enableGraphQLOperationTracking = true | ||
| } | ||
| ``` | ||
|
|
||
| ```objc {tabTitle:Objective-C} | ||
| @import Sentry; | ||
|
|
||
| [SentrySDK startWithConfigureOptions:^(SentryOptions *options) { | ||
| options.dsn = @"___PUBLIC_DSN___"; | ||
| options.enableGraphQLOperationTracking = YES; | ||
| }]; | ||
| ``` | ||
|
|
||
| When enabled, GraphQL operation names are also added to HTTP breadcrumbs as `graphql_operation_name` (when network breadcrumbs are enabled). | ||
|
|
||
| Error events may contain PII data, such as `Headers` and `Cookies`. Sentry already does data scrubbing by default, but you can scrub any data before it is sent. Learn more in [Scrubbing Sensitive Data](/platforms/apple/guides/ios/data-management/sensitive-data/). | ||
|
|
||
| These events are searchable and you can set alerts on them if you use the `http.url` and `http.status_code` properties. Learn more in our full [Searchable Properties](/concepts/search/searchable-properties/) documentation. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
m: I would mention the exact option hereenableNetworkBreadcrumbsand link to the options doc page. I just noticed that we don't haveenableNetworkBreadcrumbson https://docs.sentry.io/platforms/apple/guides/ios/configuration/options/ 😅I think we should also mention that this is enabled by default otherwise it could be confusing.