-
-
Notifications
You must be signed in to change notification settings - Fork 316
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Convert Swift extension to helper class for use by ObjC (#3973)
Resolved a crash introduced with #3931. Co-authored-by: Max Chuquimia <> Co-authored-by: Philipp Hofmann <philipp.hofmann@sentry.io>
- Loading branch information
1 parent
3912b16
commit 1ac58a6
Showing
6 changed files
with
45 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import Foundation | ||
|
||
@objcMembers | ||
class URLSessionTaskHelper: NSObject { | ||
|
||
static func getGraphQLOperationName(from task: URLSessionTask?) -> String? { | ||
guard let task = task else { return nil } | ||
guard task.originalRequest?.value(forHTTPHeaderField: "Content-Type") == "application/json" else { return nil } | ||
guard let requestBody = task.originalRequest?.httpBody else { return nil } | ||
|
||
let requestInfo = try? JSONDecoder().decode(GraphQLRequest.self, from: requestBody) | ||
|
||
return requestInfo?.operationName | ||
} | ||
|
||
} | ||
|
||
private struct GraphQLRequest: Decodable { | ||
let operationName: String | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters