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

Custom graphql operation name extraction

Open noahsmartin opened this issue 6 months ago • 0 comments

Problem Statement

The SDK supports "enableGraphQLOperationTracking" to track some fields of network requests. However, in practice this requires a field call operationName to be in the json body of the request: https://github.com/getsentry/sentry-cocoa/blob/39f4c2aab9dc651cbd05886a0aa6e8dca875a156/Sources/Swift/Core/Tools/URLSessionTaskHelper.swift#L11

It would be great if this was more flexible so clients can determine what tracking information from the request should be propagated to the SDK

More details here: https://x.com/ohwhen/status/1936503873104933199

Solution Brainstorm

SentryOptions can have a closure that apps set to process a URLRequest and turn it into a String that is attached to requests. It shouldn't be graphql specific but could be used to extract an operationName field from a graphql request

Are you willing to submit a PR?

No response

noahsmartin avatar Jun 21 '25 20:06 noahsmartin