Skip to content

Commit

Permalink
Merge fc35119 into fce741e
Browse files Browse the repository at this point in the history
  • Loading branch information
armcknight authored Dec 13, 2024
2 parents fce741e + fc35119 commit 32eb9b6
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 0 deletions.
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 @@ -69,10 +69,18 @@
</BuildableReference>
</BuildableProductRunnable>
<CommandLineArguments>
<CommandLineArgument
argument = "--io.sentry.disable-everything"
isEnabled = "NO">
</CommandLineArgument>
<CommandLineArgument
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 +244,11 @@
value = ""
isEnabled = "NO">
</EnvironmentVariable>
<EnvironmentVariable
key = "--io.sentry.user.name"
value = ""
isEnabled = "NO">
</EnvironmentVariable>
</EnvironmentVariables>
</LaunchAction>
<ProfileAction
Expand Down
2 changes: 2 additions & 0 deletions Samples/iOS-Swift/iOS-Swift/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
let username = env["--io.sentry.user.username"] ?? (env["SIMULATOR_HOST_HOME"] as? NSString)?
.lastPathComponent ?? "cocoa developer"
user.username = username
user.name = env["--io.sentry.user.name"]
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 32eb9b6

Please sign in to comment.