Skip to content

Commit

Permalink
test: usernames and emails in iOS-Swift scope (#4117)
Browse files Browse the repository at this point in the history
  • Loading branch information
armcknight authored Jun 26, 2024
1 parent 0d37a82 commit 60b32ed
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,16 @@
value = ""
isEnabled = "NO">
</EnvironmentVariable>
<EnvironmentVariable
key = "--io.sentry.user.username"
value = ""
isEnabled = "NO">
</EnvironmentVariable>
<EnvironmentVariable
key = "--io.sentry.user.email"
value = ""
isEnabled = "NO">
</EnvironmentVariable>
</EnvironmentVariables>
</LaunchAction>
<ProfileAction
Expand Down
6 changes: 5 additions & 1 deletion Samples/iOS-Swift/iOS-Swift/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
scope.setTag(value: "swift", key: "language")

let user = User(userId: "1")
user.email = "tony@example.com"
user.email = env["--io.sentry.user.email"] ?? "tony@example.com"
// 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 = env["--io.sentry.user.username"] ?? (env["SIMULATOR_HOST_HOME"] as? NSString)?
.lastPathComponent ?? "cocoa developer"
user.username = username
scope.setUser(user)

if let path = Bundle.main.path(forResource: "Tongariro", ofType: "jpg") {
Expand Down

0 comments on commit 60b32ed

Please sign in to comment.