Skip to content

fix(breadcrumb-ios): Handle non-string category in getCurrentScreen #4629

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 2 commits into from
Mar 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

- Considers the `SENTRY_DISABLE_AUTO_UPLOAD` and `SENTRY_DISABLE_NATIVE_DEBUG_UPLOAD` environment variables in the configuration of the Sentry Android Gradle Plugin for Expo plugin ([#4583](https://github.com/getsentry/sentry-react-native/pull/4583))
- Attach App Start spans to the first created not the first processed root span ([#4618](https://github.com/getsentry/sentry-react-native/pull/4618))
- Handle non-string category in getCurrentScreen on iOS ([#4629](https://github.com/getsentry/sentry-react-native/pull/4629))

### Dependencies

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ final class RNSentryBreadcrumbTests: XCTestCase {
XCTAssertNil(actual)
}

func testNullForNonStringCategory() {
let map: [String: Any] = ["category": false]
let actual = RNSentryBreadcrumb.getCurrentScreen(from: map)
XCTAssertNil(actual)
}

func testNullForNonNavigationCategory() {
let map: [String: Any] = ["category": "unknown"]
let actual = RNSentryBreadcrumb.getCurrentScreen(from: map)
Expand Down
3 changes: 2 additions & 1 deletion packages/core/ios/RNSentryBreadcrumb.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ + (SentryBreadcrumb *)from:(NSDictionary *)dict
+ (NSString *_Nullable)getCurrentScreenFrom:(NSDictionary<NSString *, id> *_Nonnull)dict
{
NSString *_Nullable maybeCategory = [dict valueForKey:@"category"];
if (![maybeCategory isEqualToString:@"navigation"]) {
if ([maybeCategory isKindOfClass:[NSString class]]
&& ![maybeCategory isEqualToString:@"navigation"]) {
return nil;
}

Expand Down
Loading