-
-
Notifications
You must be signed in to change notification settings - Fork 55
feat: iOS native bridge for scope sync #296
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
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
6d55e76
initial poc: tags, user, breadcrumbs
bitsandfoxes cff04ee
modified test breadcrumb for null test
bitsandfoxes 814764f
bridge now deals with nullptr
bitsandfoxes 5758e10
bridge now handles nullptr and accepts everything the observer has
bitsandfoxes cb2850e
added more debug to init
bitsandfoxes c114476
removing extra key
bitsandfoxes 80ce513
Merge branch 'main' into feat/ios-native-bridge
bitsandfoxes b26acec
replaced NSLog with SentryLog
bitsandfoxes 4095e24
expression bodies are love
bitsandfoxes 5c964d2
removed trailing dots
bitsandfoxes 51a2711
moved bridge to package/plugins/ios
bitsandfoxes dc25349
moved bridge to package/plugins/ios
bitsandfoxes e0e43b3
tweaked bridge debug output
bitsandfoxes 46313ed
fixed precompile constant to exclude running in editor
bitsandfoxes dbcd7fa
moved native scope observer into own proj
bitsandfoxes c696307
added tests, bridge cleanup, observer tweaks
bitsandfoxes c93001c
typo in CI
bitsandfoxes 785b43f
removed init debug code
bitsandfoxes a5613aa
renamed ios native support options flag
bitsandfoxes dbbe3de
updated CHANGELOG.md
bitsandfoxes 9b72c2b
updated ios native flag name in test
bitsandfoxes 22f16af
Merge branch 'main' into feat/ios-native-bridge
bruno-garcia 32657e8
Merge branch 'main' into feat/ios-native-bridge
bruno-garcia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,109 @@ | ||
#import <Sentry/Sentry.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
void SentryNativeBridgeAddBreadcrumb(const char* timestamp, const char* message, const char* type, const char* category, int level) { | ||
if (timestamp == NULL && message == NULL && type == NULL && category == NULL) { | ||
return; | ||
} | ||
|
||
[SentrySDK configureScope:^(SentryScope * scope) { | ||
SentryBreadcrumb *breadcrumb = [[SentryBreadcrumb alloc] init]; | ||
|
||
if (timestamp != NULL) { | ||
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; | ||
[dateFormatter setDateFormat:NSCalendarIdentifierISO8601]; | ||
breadcrumb.timestamp = [dateFormatter dateFromString:[NSString stringWithCString:timestamp encoding:NSUTF8StringEncoding]]; | ||
} | ||
|
||
if (message != NULL) { | ||
breadcrumb.message = [NSString stringWithCString:message encoding:NSUTF8StringEncoding]; | ||
} | ||
|
||
if (type != NULL) { | ||
breadcrumb.type = [NSString stringWithCString:type encoding:NSUTF8StringEncoding]; | ||
} | ||
|
||
if (category != NULL) { | ||
breadcrumb.category = [NSString stringWithCString:category encoding:NSUTF8StringEncoding]; | ||
} | ||
|
||
breadcrumb.level = level; | ||
|
||
[scope addBreadcrumb:breadcrumb]; | ||
}]; | ||
} | ||
|
||
void SentryNativeBridgeSetExtra(const char* key, const char* value) { | ||
if (key == NULL) { | ||
return; | ||
} | ||
|
||
[SentrySDK configureScope:^(SentryScope * scope) { | ||
if (value != NULL) { | ||
[scope setExtraValue:[NSString stringWithUTF8String:value] forKey:[NSString stringWithUTF8String:key]]; | ||
} else { | ||
[scope removeExtraForKey:[NSString stringWithUTF8String:key]]; | ||
} | ||
}]; | ||
} | ||
|
||
void SentryNativeBridgeSetTag(const char* key, const char* value) { | ||
if (key == NULL) { | ||
return; | ||
} | ||
|
||
[SentrySDK configureScope:^(SentryScope * scope) { | ||
if (value != NULL) { | ||
[scope setTagValue:[NSString stringWithUTF8String:value] forKey:[NSString stringWithUTF8String:key]]; | ||
} else { | ||
[scope removeTagForKey:[NSString stringWithUTF8String:key]]; | ||
} | ||
}]; | ||
} | ||
|
||
void SentryNativeBridgeUnsetTag(const char* key) { | ||
if (key == NULL) { | ||
return; | ||
} | ||
|
||
[SentrySDK configureScope:^(SentryScope * scope) { | ||
[scope removeTagForKey:[NSString stringWithUTF8String:key]]; | ||
}]; | ||
} | ||
|
||
void SentryNativeBridgeSetUser(const char* email, const char* userId, const char* ipAddress, const char* username) { | ||
if (email == NULL && userId == NULL && ipAddress == NULL && username == NULL) { | ||
return; | ||
} | ||
|
||
[SentrySDK configureScope:^(SentryScope * scope) { | ||
SentryUser *user = [[SentryUser alloc] init]; | ||
|
||
if (email != NULL) { | ||
user.email = [NSString stringWithCString:email encoding:NSUTF8StringEncoding]; | ||
} | ||
|
||
if (userId != NULL) { | ||
user.userId = [NSString stringWithCString:userId encoding:NSUTF8StringEncoding]; | ||
} | ||
|
||
if (ipAddress != NULL) { | ||
user.ipAddress = [NSString stringWithCString:ipAddress encoding:NSUTF8StringEncoding]; | ||
} | ||
|
||
if (username != NULL) { | ||
user.username = [NSString stringWithCString:username encoding:NSUTF8StringEncoding]; | ||
} | ||
|
||
[scope setUser:user]; | ||
}]; | ||
} | ||
|
||
void SentryNativeBridgeUnsetUser() { | ||
[SentrySDK configureScope:^(SentryScope * scope) { | ||
[scope setUser:nil]; | ||
}]; | ||
} | ||
|
||
NS_ASSUME_NONNULL_END |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
No idea if this works: