-
-
Notifications
You must be signed in to change notification settings - Fork 340
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
automatically get username and full user name (#4674)
- Loading branch information
1 parent
439fc9f
commit 5126088
Showing
2 changed files
with
23 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,11 +90,8 @@ struct SentrySDKWrapper { | |
|
||
let user = User(userId: "1") | ||
user.email = self.env["--io.sentry.user.email"] ?? "[email protected]" | ||
// first check if the username has been overridden in the scheme for testing purposes; then try to use the system username so each person gets an automatic way to easily filter things on the dashboard; then fall back on a hardcoded value if none of these are present | ||
let username = self.env["--io.sentry.user.username"] ?? (self.env["SIMULATOR_HOST_HOME"] as? NSString)? | ||
.lastPathComponent ?? "cocoadev" | ||
user.username = username | ||
user.name = self.env["--io.sentry.user.name"] ?? "cocoa developer" | ||
user.name = userFullName | ||
scope.setUser(user) | ||
|
||
if let path = Bundle.main.path(forResource: "Tongariro", ofType: "jpg") { | ||
|
@@ -105,6 +102,23 @@ struct SentrySDKWrapper { | |
} | ||
return scope | ||
} | ||
|
||
var userFullName: String { | ||
let name = self.env["--io.sentry.user.name"] ?? NSFullUserName() | ||
guard !name.isEmpty else { | ||
return "cocoa developer" | ||
} | ||
return name | ||
} | ||
|
||
var username: String { | ||
let username = self.env["--io.sentry.user.username"] ?? NSUserName() | ||
guard !username.isEmpty else { | ||
return (self.env["SIMULATOR_HOST_HOME"] as? NSString)? | ||
.lastPathComponent ?? "cocoadev" | ||
} | ||
return username | ||
} | ||
} | ||
|
||
// MARK: User feedback configuration | ||
|