Skip to content

Commit deef7ed

Browse files
committed
Fix system name
1 parent 564fe87 commit deef7ed

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

Sources/Sentry/SentryContext.m

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ - (instancetype)init {
4141
self.osContext = [self generatedOsContext];
4242
}
4343
[serializedData setValue:self.osContext forKey:@"os"];
44-
44+
[self fixSystemName];
45+
4546
if (nil == self.appContext) {
4647
self.appContext = [self generatedAppContext];
4748
}
@@ -55,6 +56,13 @@ - (instancetype)init {
5556
return serializedData;
5657
}
5758

59+
- (void)fixSystemName {
60+
// This fixes iPhone OS to iOS because apple messed up the naming
61+
if (nil != self.osContext && [self.osContext[@"name"] isEqualToString:@"iPhone OS"]) {
62+
[self.osContext setValue:@"iOS" forKey:@"name"];
63+
}
64+
}
65+
5866
- (NSDictionary<NSString *, id> *)generatedOsContext {
5967
NSMutableDictionary *serializedData = [NSMutableDictionary new];
6068

Tests/SentryTests/SentryKSCrashReportConverterTests.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ - (void)testRawWithCrashReport {
8989
- (void)testAbort {
9090
reportPath = @"Resources/Abort";
9191
[self isValidReport];
92+
NSDictionary *rawCrash = [self getCrashReport];
93+
SentryKSCrashReportConverter *reportConverter = [[SentryKSCrashReportConverter alloc] initWithReport:rawCrash];
94+
SentryEvent *event = [reportConverter convertReportToEvent];
95+
XCTAssertEqualObjects([[event serialize] valueForKeyPath:@"contexts.os.name"], @"iOS");
9296
}
9397

9498
- (void)testMissingBinary {

0 commit comments

Comments
 (0)