forked from getsentry/sentry-cocoa
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Send GraphQL "operationName" in HTTP breadcrumbs
- Loading branch information
Max Chuquimia
committed
Jan 15, 2024
1 parent
42ef6ba
commit fa0b660
Showing
8 changed files
with
77 additions
and
0 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#import <Foundation/Foundation.h> | ||
|
||
@interface | ||
NSURLSessionTask (Sentry) | ||
|
||
- (nullable NSString *)sentry_graphQLOperationName; | ||
|
||
@end |
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,25 @@ | ||
#import "NSURLSessionTask+Sentry.h" | ||
|
||
|
||
@implementation | ||
NSURLSessionTask (Sentry) | ||
|
||
- (nullable NSString *)sentry_graphQLOperationName | ||
{ | ||
if (!self.originalRequest.HTTPBody) { return nil; } | ||
if (![[self.originalRequest valueForHTTPHeaderField:@"Content-Type"] isEqual: @"application/json"]) { return nil; } | ||
|
||
NSError *error = nil; | ||
id requestDictionary = [NSJSONSerialization JSONObjectWithData:self.originalRequest.HTTPBody options:0 error:&error]; | ||
|
||
if (error) { return nil; } | ||
if (![requestDictionary isKindOfClass: [NSDictionary class]]) { return nil; } // Could be an array | ||
|
||
id operationName = [requestDictionary valueForKey:@"operationName"]; | ||
if (![operationName isKindOfClass: [NSString class]]) { return nil; } | ||
if ([operationName length] == 0) { return nil; } | ||
|
||
return operationName; | ||
} | ||
|
||
@end |
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