Skip to content

Commit

Permalink
Merge f22f97a into bdb8eb1
Browse files Browse the repository at this point in the history
  • Loading branch information
brustolin committed May 5, 2023
2 parents bdb8eb1 + f22f97a commit f7b52e9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ This change has no impact on grouping of the issues in Sentry.
### Fixes

- Propagate span when copying scope (#2952)
- Remove "/" from crash report file name (#3005)

## 8.6.0

Expand Down
12 changes: 10 additions & 2 deletions Sources/SentryCrash/Recording/SentryCrash.m
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,18 @@
static NSString *
getBundleName(void)
{
NSString *bundleName = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"];
static NSString *bundleName = nil;

if (bundleName == nil) {
bundleName = @"Unknown";
#if TEST
bundleName = @"Sentry/Test";
#else
bundleName = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"] ?: @"Unknown";
#endif
//bundleName is only used for file name, therefore '/' is not allowed.
bundleName = [bundleName stringByReplacingOccurrencesOfString:@"/" withString:@"-"];
}

return bundleName;
}

Expand Down
9 changes: 9 additions & 0 deletions Tests/SentryTests/SentryCrash/SentryCrashTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ @interface SentryCrashTests : FileBasedTestCase
@end

@interface SentryCrash (private)

@property (nonatomic, readwrite, retain) NSString *bundleName;

- (NSArray *)getAttachmentPaths:(int64_t)reportID;

@end

@implementation SentryCrashTests
Expand Down Expand Up @@ -43,6 +47,11 @@ - (void)test_getScreenshots_TwoFiles
XCTAssertEqual(files.count, 2);
}

- (void)test_cleanBundleName {
SentryCrash *sentryCrash = [[SentryCrash alloc] init];
XCTAssertEqualObjects(sentryCrash.bundleName, @"Sentry-Test");
}

- (void)test_getScreenshots_NoFiles
{
[self initReport:12 withScreenshots:0];
Expand Down

0 comments on commit f7b52e9

Please sign in to comment.