Skip to content

Commit

Permalink
Merge e04eaa3 into fce741e
Browse files Browse the repository at this point in the history
  • Loading branch information
armcknight authored Dec 13, 2024
2 parents fce741e + e04eaa3 commit a029ce3
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 1 deletion.
11 changes: 11 additions & 0 deletions Samples/iOS-Swift/iOS-Swift-UITests/UserFeedbackUITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,17 @@ class UserFeedbackUITests: BaseUITest {
XCTAssertFalse(app.staticTexts["Thy name (Required)"].exists)
}

func testPrefilledUserInformation() throws {
launchApp(args: ["--io.sentry.feedback.use-sentry-user"], env: [
"--io.sentry.user.name": "ui test user",
"--io.sentry.user.email": "[email protected]"
])

widgetButton.tap()
XCTAssertEqual(try XCTUnwrap(nameField.value as? String), "ui test user")
XCTAssertEqual(try XCTUnwrap(emailField.value as? String), "[email protected]")
}

// MARK: Tests validating happy path / successful submission

func testSubmitFullyFilledForm() throws {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@
argument = "--disable-file-io-tracing"
isEnabled = "NO">
</CommandLineArgument>
<CommandLineArgument
argument = "--io.sentry.feedback.use-sentry-user"
isEnabled = "YES">
</CommandLineArgument>
<CommandLineArgument
argument = "--io.sentry.feedback.require-name"
isEnabled = "NO">
Expand Down Expand Up @@ -236,6 +240,11 @@
value = ""
isEnabled = "NO">
</EnvironmentVariable>
<EnvironmentVariable
key = "--io.sentry.user.name"
value = ""
isEnabled = "NO">
</EnvironmentVariable>
</EnvironmentVariables>
</LaunchAction>
<ProfileAction
Expand Down
4 changes: 3 additions & 1 deletion Samples/iOS-Swift/iOS-Swift/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
user.email = 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 = env["--io.sentry.user.username"] ?? (env["SIMULATOR_HOST_HOME"] as? NSString)?
.lastPathComponent ?? "cocoa developer"
.lastPathComponent ?? "cocoadev"
user.username = username
user.name = env["--io.sentry.user.name"] ?? "cocoa developer"
scope.setUser(user)

if let path = Bundle.main.path(forResource: "Tongariro", ofType: "jpg") {
Expand All @@ -174,6 +175,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
return
}
config.animations = !args.contains("--io.sentry.feedback.no-animations")
config.useSentryUser = args.contains("--io.sentry.feedback.use-sentry-user")
config.useShakeGesture = true
config.showFormForScreenshots = true
config.configureWidget = { widget in
Expand Down
2 changes: 2 additions & 0 deletions Sources/Sentry/include/SentryPrivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#import "SentryDispatchQueueWrapper.h"
#import "SentryNSDataUtils.h"
#import "SentryRandom.h"
#import "SentrySDK+Private.h"
#import "SentryScope+Private.h"
#import "SentryTime.h"

// Headers that also import SentryDefines should be at the end of this list
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,10 @@ class SentryUserFeedbackForm: UIViewController {
field.accessibilityLabel = config.formConfig.nameTextFieldAccessibilityLabel
field.accessibilityIdentifier = "io.sentry.feedback.form.name"
field.delegate = self
field.autocapitalizationType = .words
if config.useSentryUser {
field.text = SentrySDK.currentHub().scope.userObject?.name
}
return field
}()

Expand All @@ -277,6 +281,10 @@ class SentryUserFeedbackForm: UIViewController {
field.accessibilityIdentifier = "io.sentry.feedback.form.email"
field.delegate = self
field.keyboardType = .emailAddress
field.autocapitalizationType = .none
if config.useSentryUser {
field.text = SentrySDK.currentHub().scope.userObject?.email
}
return field
}()

Expand Down

0 comments on commit a029ce3

Please sign in to comment.