Skip to content

Commit

Permalink
fix(envelope): SentrySdkInfo.packages should be an array (#4626)
Browse files Browse the repository at this point in the history
  • Loading branch information
krystofwoldrich authored Dec 13, 2024
1 parent 461d953 commit a401e33
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

- Improve compiler error message for missing Swift declarations due to APPLICATION_EXTENSION_API_ONLY (#4603)

### Fixes

- `SentrySdkInfo.packages` should be an array (#4626)

## 8.42.0-beta.2

### Fixes
Expand Down
10 changes: 6 additions & 4 deletions Sources/Sentry/SentrySdkInfo.m
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,12 @@ - (nullable NSString *)getPackageName:(SentryPackageManagerOption)packageManager
if (self.packageManager != SentryPackageManagerUnkown) {
NSString *format = [self getPackageName:self.packageManager];
if (format != nil) {
sdk[@"packages"] = @{
@"name" : [NSString stringWithFormat:format, self.name],
@"version" : self.version
};
sdk[@"packages"] = @[
@{
@"name" : [NSString stringWithFormat:format, self.name],
@"version" : self.version
},
];
}
}

Expand Down
21 changes: 12 additions & 9 deletions Tests/SentryTests/Protocol/SentrySdkInfoTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ class SentrySdkInfoTests: XCTestCase {
if let sdkInfo = serialization["sdk"] as? [String: Any] {
XCTAssertEqual(3, sdkInfo.count)

let packageInfo = try XCTUnwrap(sdkInfo["packages"] as? [String: Any])
XCTAssertEqual(packageInfo["name"] as? String, "spm:getsentry/\(sdkName)")
XCTAssertEqual(packageInfo["version"] as? String, version)
let packages = try XCTUnwrap(sdkInfo["packages"] as? [[String: Any]])
XCTAssertEqual(1, packages.count)
XCTAssertEqual(packages[0]["name"] as? String, "spm:getsentry/\(sdkName)")
XCTAssertEqual(packages[0]["version"] as? String, version)
} else {
XCTFail("Serialization of SdkInfo doesn't contain sdk")
}
Expand All @@ -60,9 +61,10 @@ class SentrySdkInfoTests: XCTestCase {
if let sdkInfo = serialization["sdk"] as? [String: Any] {
XCTAssertEqual(3, sdkInfo.count)

let packageInfo = try XCTUnwrap(sdkInfo["packages"] as? [String: Any])
XCTAssertEqual(packageInfo["name"] as? String, "carthage:getsentry/\(sdkName)")
XCTAssertEqual(packageInfo["version"] as? String, version)
let packages = try XCTUnwrap(sdkInfo["packages"] as? [[String: Any]])
XCTAssertEqual(1, packages.count)
XCTAssertEqual(packages[0]["name"] as? String, "carthage:getsentry/\(sdkName)")
XCTAssertEqual(packages[0]["version"] as? String, version)
} else {
XCTFail("Serialization of SdkInfo doesn't contain sdk")
}
Expand All @@ -77,9 +79,10 @@ class SentrySdkInfoTests: XCTestCase {
if let sdkInfo = serialization["sdk"] as? [String: Any] {
XCTAssertEqual(3, sdkInfo.count)

let packageInfo = try XCTUnwrap(sdkInfo["packages"] as? [String: Any])
XCTAssertEqual(packageInfo["name"] as? String, "cocoapods:getsentry/\(sdkName)")
XCTAssertEqual(packageInfo["version"] as? String, version)
let packages = try XCTUnwrap(sdkInfo["packages"] as? [[String: Any]])
XCTAssertEqual(1, packages.count)
XCTAssertEqual(packages[0]["name"] as? String, "cocoapods:getsentry/\(sdkName)")
XCTAssertEqual(packages[0]["version"] as? String, version)
} else {
XCTFail("Serialization of SdkInfo doesn't contain sdk")
}
Expand Down

0 comments on commit a401e33

Please sign in to comment.