Skip to content

Commit

Permalink
fix: profiling app release version format (#2470)
Browse files Browse the repository at this point in the history
* fix: list versions the same way they are reported elsewhere in sentry
  • Loading branch information
armcknight authored Dec 1, 2022
1 parent a745091 commit d8c347f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ This version adds a dependency on Swift.
- Increase `SentryCrashMAX_STRINGBUFFERSIZE` to reduce the instances where we're dropping a crash due to size limit (#2465)
- `SentryAppStateManager` correctly unsubscribes from `NSNotificationCenter` when closing the SDK (#2460)
- The SDK no longer reports an OOM when a crash happens after closing the SDK (#2468)
- Use the preexisting app release version format for profiles (#2470)

### Breaking Changes

Expand Down
7 changes: 1 addition & 6 deletions Sources/Sentry/SentryProfiler.mm
Original file line number Diff line number Diff line change
Expand Up @@ -548,12 +548,7 @@ - (void)captureEnvelope
profile[@"platform"] = _transactions.firstObject.platform;
profile[@"environment"] = _hub.scope.environmentString ?: _hub.getClient.options.environment;
profile[@"timestamp"] = [[SentryCurrentDate date] sentry_toIso8601String];

const auto bundle = NSBundle.mainBundle;
profile[@"release"] =
[NSString stringWithFormat:@"%@ (%@)",
[bundle objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey],
[bundle objectForInfoDictionaryKey:@"CFBundleShortVersionString"]];
profile[@"release"] = _hub.getClient.options.releaseName;

# if SENTRY_HAS_UIKIT
auto relativeFrameTimestampsNs = [NSMutableArray array];
Expand Down
7 changes: 4 additions & 3 deletions Tests/SentryTests/Profiling/SentryProfilerSwiftTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,10 @@ private extension SentryProfilerSwiftTests {

XCTAssertEqual(transactionEnvironment, profile["environment"] as! String)

let version = Bundle.main.object(forInfoDictionaryKey: kCFBundleVersionKey as String) ?? "(null)"
let build = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") ?? "(null)"
let releaseString = "\(version) (\(build))"
let bundleID = Bundle.main.object(forInfoDictionaryKey: kCFBundleIdentifierKey as String) ?? "(null)"
let version = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") ?? "(null)"
let build = Bundle.main.object(forInfoDictionaryKey: kCFBundleVersionKey as String) ?? "(null)"
let releaseString = "\(bundleID)@\(version)+\(build)"
XCTAssertEqual(profile["release"] as! String, releaseString)

XCTAssertNotEqual(SentryId.empty, SentryId(uuidString: profile["profile_id"] as! String))
Expand Down

0 comments on commit d8c347f

Please sign in to comment.