Skip to content

Commit

Permalink
Merge 1322a1e into 56c9730
Browse files Browse the repository at this point in the history
  • Loading branch information
brustolin authored Nov 21, 2022
2 parents 56c9730 + 1322a1e commit 5135d78
Show file tree
Hide file tree
Showing 16 changed files with 41 additions and 38 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

This version introduces a dependency on Swift, which only impacts you if you don't use Swift. If your project uses Swift already, this change will not affect you.

### Breaking Changes

- Renaming Client to SentryClient for Swift (#2403)
- Renaming User to SentryUser for Swift (#2403)

### Features

- Properly demangle Swift class name (#2162)
Expand Down
4 changes: 2 additions & 2 deletions Samples/iOS-Swift/iOS-Swift/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ViewController: UIViewController {
scope.setTag(value: "swift", key: "language")
scope.setExtra(value: String(describing: self), key: "currentViewController")

let user = Sentry.User(userId: "1")
let user = SentryUser(userId: "1")
user.email = "tony@example.com"
scope.setUser(user)

Expand All @@ -33,7 +33,7 @@ class ViewController: UIViewController {
}

// Also works
let user = Sentry.User(userId: "1")
let user = SentryUser(userId: "1")
user.email = "tony1@example.com"
SentrySDK.setUser(user)

Expand Down
1 change: 0 additions & 1 deletion Sources/Sentry/Public/SentryClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

NS_ASSUME_NONNULL_BEGIN

NS_SWIFT_NAME(Client)
@interface SentryClient : NSObject
SENTRY_NO_INIT

Expand Down
1 change: 0 additions & 1 deletion Sources/Sentry/Public/SentryUser.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

NS_ASSUME_NONNULL_BEGIN

NS_SWIFT_NAME(User)
@interface SentryUser : NSObject <SentrySerializable, NSCopying>

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class SentrySystemEventBreadcrumbsTest: XCTestCase {
}

func getSut(scope: Scope, currentDevice: UIDevice? = UIDevice.current) -> SentrySystemEventBreadcrumbs {
let client = Client(options: self.options)
let client = SentryClient(options: self.options)
let hub = SentryHub(client: client, andScope: scope)
SentrySDK.setCurrentHub(hub)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class SentryCrashIntegrationTests: NotificationCenterTestCase {
options.dsn = SentryCrashIntegrationTests.dsnAsString
options.releaseName = TestData.appState.releaseName

let client = Client(options: options, permissionsObserver: TestSentryPermissionsObserver())
let client = SentryClient(options: options, permissionsObserver: TestSentryPermissionsObserver())
hub = TestHub(client: client, andScope: nil)
}

Expand Down Expand Up @@ -277,7 +277,7 @@ class SentryCrashIntegrationTests: NotificationCenterTestCase {
api?.pointee.setEnabled(true)

let transport = TestTransport()
let client = Client(options: fixture.options)
let client = SentryClient(options: fixture.options)
Dynamic(client).transportAdapter = TestTransportAdapter(transport: transport, options: fixture.options)
hub.bindClient(client)

Expand Down
16 changes: 8 additions & 8 deletions Tests/SentryTests/Protocol/SentryUserTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import XCTest
class SentryUserTests: XCTestCase {

func testSerializationWithAllProperties() {
let user = TestData.user.copy() as! User
let user = TestData.user.copy() as! SentryUser
let actual = user.serialize()

// Changing the original doesn't modify the serialized
Expand All @@ -23,15 +23,15 @@ class SentryUserTests: XCTestCase {
}

func testSerializationWithOnlyId() {
let user = User(userId: "someid")
let user = SentryUser(userId: "someid")
let actual = user.serialize()

XCTAssertEqual(user.userId, actual["id"] as? String)
XCTAssertEqual(1, actual.count)
}

func testSerializationWithoutId() {
let user = User()
let user = SentryUser()
let actual = user.serialize()

XCTAssertNil(actual["id"] as? String)
Expand All @@ -55,7 +55,7 @@ class SentryUserTests: XCTestCase {
}

func testIsEqualToCopy() {
XCTAssertEqual(TestData.user, TestData.user.copy() as! User)
XCTAssertEqual(TestData.user, TestData.user.copy() as! SentryUser)
}

func testNotIsEqual() {
Expand All @@ -67,15 +67,15 @@ class SentryUserTests: XCTestCase {
testIsNotEqual { user in user.data?.removeAll() }
}

func testIsNotEqual(block: (User) -> Void ) {
let user = TestData.user.copy() as! User
func testIsNotEqual(block: (SentryUser) -> Void ) {
let user = TestData.user.copy() as! SentryUser
block(user)
XCTAssertNotEqual(TestData.user, user)
}

func testCopyWithZone_CopiesDeepCopy() {
let user = TestData.user
let copiedUser = user.copy() as! User
let copiedUser = user.copy() as! SentryUser

// Modifying the original does not change the copy
user.userId = ""
Expand All @@ -98,7 +98,7 @@ class SentryUserTests: XCTestCase {
let queue = DispatchQueue(label: "SentryScopeTests", qos: .userInteractive, attributes: [.concurrent, .initiallyInactive])
let group = DispatchGroup()

let user = TestData.user.copy() as! User
let user = TestData.user.copy() as! SentryUser

for i in 0...20 {
group.enter()
Expand Down
4 changes: 2 additions & 2 deletions Tests/SentryTests/Protocol/TestData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ class TestData {
return event
}

static var user: User {
let user = User(userId: "id")
static var user: SentryUser {
let user = SentryUser(userId: "id")
user.email = "user@sentry.io"
user.username = "user123"
user.ipAddress = "127.0.0.1"
Expand Down
18 changes: 9 additions & 9 deletions Tests/SentryTests/SentryClientTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class SentryClientTest: XCTestCase {
let messageAsString = "message"
let message: SentryMessage

let user: User
let user: SentryUser
let fileManager: SentryFileManager
let random = TestRandom(value: 1.0)

Expand All @@ -43,7 +43,7 @@ class SentryClientTest: XCTestCase {
event = Event()
event.message = message

user = User()
user = SentryUser()
user.email = "someone@sentry.io"
user.ipAddress = "127.0.0.1"

Expand All @@ -57,15 +57,15 @@ class SentryClientTest: XCTestCase {
transportAdapter = TestTransportAdapter(transport: transport, options: options)
}

func getSut(configureOptions: (Options) -> Void = { _ in }) -> Client {
var client: Client!
func getSut(configureOptions: (Options) -> Void = { _ in }) -> SentryClient {
var client: SentryClient!
do {
let options = try Options(dict: [
"dsn": SentryClientTest.dsn
])
configureOptions(options)

client = Client(
client = SentryClient(
options: options,
transportAdapter: transportAdapter,
fileManager: fileManager,
Expand All @@ -84,13 +84,13 @@ class SentryClientTest: XCTestCase {
return client
}

func getSutWithNoDsn() -> Client {
func getSutWithNoDsn() -> SentryClient {
getSut(configureOptions: { options in
options.parsedDsn = nil
})
}

func getSutDisabledSdk() -> Client {
func getSutDisabledSdk() -> SentryClient {
getSut(configureOptions: { options in
options.enabled = false
})
Expand Down Expand Up @@ -1108,7 +1108,7 @@ class SentryClientTest: XCTestCase {

let options = Options()
options.dsn = SentryClientTest.dsn
let client = Client(options: options, permissionsObserver: TestSentryPermissionsObserver())
let client = SentryClient(options: options, permissionsObserver: TestSentryPermissionsObserver())

XCTAssertNil(client)

Expand Down Expand Up @@ -1345,7 +1345,7 @@ class SentryClientTest: XCTestCase {
return event
}

private func beforeSendReturnsNil(capture: (Client) -> Void) {
private func beforeSendReturnsNil(capture: (SentryClient) -> Void) {
capture(fixture.getSut(configureOptions: { options in
options.beforeSend = { _ in
nil
Expand Down
4 changes: 2 additions & 2 deletions Tests/SentryTests/SentryHubTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,10 @@ class SentryHubTests: XCTestCase {
}

func testAddUserToTheScope() {
let client = Client(options: fixture.options)
let client = SentryClient(options: fixture.options)
let hub = SentryHub(client: client, andScope: Scope())

let user = User()
let user = SentryUser()
user.userId = "123"
hub.setUser(user)

Expand Down
2 changes: 1 addition & 1 deletion Tests/SentryTests/SentrySDKTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ class SentrySDKTests: XCTestCase {
}

let transport = TestTransport()
let client = Client(options: fixture.options)
let client = SentryClient(options: fixture.options)
Dynamic(client).transportAdapter = TestTransportAdapter(transport: transport, options: fixture.options)
SentrySDK.currentHub().bindClient(client)

Expand Down
10 changes: 5 additions & 5 deletions Tests/SentryTests/SentryScopeSwiftTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import XCTest
class SentryScopeSwiftTests: XCTestCase {

private class Fixture {
let user: User
let user: SentryUser
let breadcrumb: Breadcrumb
let scope: Scope
let date: Date
Expand All @@ -25,7 +25,7 @@ class SentryScopeSwiftTests: XCTestCase {
init() {
date = Date(timeIntervalSince1970: 10)

user = User(userId: "id")
user = SentryUser(userId: "id")
user.email = "user@sentry.io"
user.username = "user123"
user.ipAddress = ipAddress
Expand Down Expand Up @@ -85,7 +85,7 @@ class SentryScopeSwiftTests: XCTestCase {
scope.setTag(value: "another", key: "another")
scope.setExtra(value: "another", key: "another")
scope.setContext(value: ["": 1], key: "another")
scope.setUser(User())
scope.setUser(SentryUser())
scope.setDist("")
scope.setEnvironment("")
scope.setFingerprint([])
Expand Down Expand Up @@ -563,8 +563,8 @@ class SentryScopeSwiftTests: XCTestCase {
clearInvocations += 1
}

var user: User?
func setUser(_ user: User?) {
var user: SentryUser?
func setUser(_ user: SentryUser?) {
self.user = user
}
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/SentryTests/SentrySessionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class SentrySessionTestsSwift: XCTestCase {
}

func testCopySession() {
let user = User()
let user = SentryUser()
user.email = "someone@sentry.io"

let session = SentrySession(releaseName: "1.0.0")
Expand Down
2 changes: 1 addition & 1 deletion Tests/SentryTests/TestClient.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Foundation

class TestClient: Client {
class TestClient: SentryClient {
let sentryFileManager: SentryFileManager
let queue = DispatchQueue(label: "TestClient", attributes: .concurrent)

Expand Down
2 changes: 1 addition & 1 deletion Tests/SentryTests/Transaction/SentrySpanTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class SentrySpanTests: XCTestCase {
return getSut(client: TestClient(options: options)!)
}

func getSut(client: Client) -> Span {
func getSut(client: SentryClient) -> Span {
let hub = SentryHub(client: client, andScope: nil, andCrashWrapper: TestSentryCrashWrapper.sharedInstance(), andCurrentDateProvider: currentDateProvider)
return hub.startTransaction(name: someTransaction, operation: someOperation)
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/SentryTests/Transaction/SentryTraceStateTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class SentryTraceContextTests: XCTestCase {
tracer = SentryTracer(transactionContext: TransactionContext(name: transactionName, operation: transactionOperation), hub: nil)

scope = Scope()
scope.setUser(User(userId: userId))
scope.setUser(SentryUser(userId: userId))
scope.userObject?.segment = userSegment
scope.span = tracer

Expand Down

0 comments on commit 5135d78

Please sign in to comment.