Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

revert: Rename of User to SentryUser #2462

Merged
merged 1 commit into from
Nov 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ This version adds a dependency on Swift.
- Rename `SentryScope.add(_ crumb:)` to `SentryScope.addBreadcrumb(_ crumb:)` (#2416)
- Rename `SentryScope.add(_ attachment:)` to `SentryScope.addAttachment(_ attachment:)` (#2416)
- Rename `Client` to `SentryClient` (#2403)
- Rename `User` to `SentryUser` (#2403)
- Remove public APIs
- Remove `SentryScope.apply(to:)` (#2416)
- Remove `SentryScope.apply(to:maxBreadcrumb:)` (#2416)
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 = SentryUser(userId: "1")
let user = User(userId: "1")
user.email = "tony@example.com"
scope.setUser(user)

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

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

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

NS_ASSUME_NONNULL_BEGIN

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

/**
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! SentryUser
let user = TestData.user.copy() as! User
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 = SentryUser(userId: "someid")
let user = User(userId: "someid")
let actual = user.serialize()

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

func testSerializationWithoutId() {
let user = SentryUser()
let user = User()
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! SentryUser)
XCTAssertEqual(TestData.user, TestData.user.copy() as! User)
}

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

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

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

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

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

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: SentryUser {
let user = SentryUser(userId: "id")
static var user: User {
let user = User(userId: "id")
user.email = "user@sentry.io"
user.username = "user123"
user.ipAddress = "127.0.0.1"
Expand Down
4 changes: 2 additions & 2 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: SentryUser
let user: User
let fileManager: SentryFileManager
let random = TestRandom(value: 1.0)

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

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

Expand Down
2 changes: 1 addition & 1 deletion Tests/SentryTests/SentryHubTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ class SentryHubTests: XCTestCase {
let client = SentryClient(options: fixture.options)
let hub = SentryHub(client: client, andScope: Scope())

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

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: SentryUser
let user: User
let breadcrumb: Breadcrumb
let scope: Scope
let date: Date
Expand All @@ -25,7 +25,7 @@ class SentryScopeSwiftTests: XCTestCase {
init() {
date = Date(timeIntervalSince1970: 10)

user = SentryUser(userId: "id")
user = User(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(SentryUser())
scope.setUser(User())
scope.setDist("")
scope.setEnvironment("")
scope.setFingerprint([])
Expand Down Expand Up @@ -558,8 +558,8 @@ class SentryScopeSwiftTests: XCTestCase {
clearInvocations += 1
}

var user: SentryUser?
func setUser(_ user: SentryUser?) {
var user: User?
func setUser(_ user: User?) {
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 = SentryUser()
let user = User()
user.email = "someone@sentry.io"

let session = SentrySession(releaseName: "1.0.0")
Expand Down
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(SentryUser(userId: userId))
scope.setUser(User(userId: userId))
scope.userObject?.segment = userSegment
scope.span = tracer

Expand Down