Skip to content

fix(feedback): update docs with SwiftUI notes #14227

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ The following options can be configured for the integration in `SentryUserFeedba
| Option | Type | Default | Description |
| ---------------- | ------------------------- | --------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `location` | `[NSDirectionalRectEdge]` | `[.bottom, .trailing]` | The location of the widget on the screen. |
| `autoInject` | `Bool` | `true` | Injects the Feedback widget into the application when the integration is added. Set `autoInject: false` if you want to call `feedback.attachTo()` or `feedback.openDialog()` directly, or only want to show the widget on certain views. |
| `autoInject` | `Bool` | `true` | Injects the Feedback widget into the application when the integration is added. Set `autoInject: false` if you want to call `SentrySDK.feedback.showWidget()` directly, e.g. to show the widget on certain views. |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SentrySDK.feedback.showWidget() seems to be breaking the formatting on this page, I wonder if there's a way to reformat this table so that things fit?

Screenshot 2025-07-07 at 2 31 26 PM

| `windowLevel` | `UIWindow.Level` | `UIWindow.Level.normal + 1` | The window level of the widget. |
| `showIcon` | `Bool` | `true` | Whether to show the widget icon. |
| `labelText` | `String?` | `"Report a Bug"` | The text of the widget label. If `nil`, then only the icon is shown. It is an error to set both `labelText` to `nil` and `showIcon` to `false`. |
Expand Down
86 changes: 86 additions & 0 deletions docs/platforms/apple/common/user-feedback/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,92 @@ To start using the User Feedback widget in your Cocoa application, provide a fee

This setup will insert the widget into your app's view hierarchy. By default, it appears in the bottom trailing corner of the screen, but you can fully customize its appearance and behavior.

#### SwiftUI

SwiftUI apps cannot currently use automatic injection of the widget upon SDK start. Several options exist to display the feedback form:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
SwiftUI apps cannot currently use automatic injection of the widget upon SDK start. Several options exist to display the feedback form:
SwiftUI apps don’t currently support automatic widget injection when the SDK starts. Several options exist to display the feedback form:


##### Use your own button

Place a `UIButton` somewhere in your app, then provide the reference to the feedback configuration in the options provided on SDK start:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a UIButton to your app, then provide the reference to the feedback configuration in the SDK start options:


```swift
import Sentry
import SwiftUI
import UIKit

@main
struct SwiftUIApp: App {
// a button displayed somewhere in your app
public let feedbackButton = {
let button = UIButton(type: .custom)
button.setTitle("BYOB Feedback", for: .normal)
return button
}()

init() {
// start the SentrySDK as usual, as early as possible in your app's launch sequence
SentrySDK.start { options in
options.configureFeedback { config in
config.customButton = feedbackButton
}

// your other SDK options
}
}
}
```

##### Manually display the widget from a connected `UIWindowSceneDelegate`

You must set up a `UIApplicationDelegateAdaptor`, connect a `UIScene` to your app, and manually call `SentrySDK.feedback.showWidget()`:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
You must set up a `UIApplicationDelegateAdaptor`, connect a `UIScene` to your app, and manually call `SentrySDK.feedback.showWidget()`:
You can set up a `UIApplicationDelegateAdaptor`, connect a `UIScene` to your app, and manually call `SentrySDK.feedback.showWidget()`:


```swift
import Sentry
import SwiftUI

@main
struct SwiftUIApp: App {
@UIApplicationDelegateAdaptor private var appDelegate: MyAppDelegate

init() {
// start the SentrySDK as usual, as early as possible in your app's launch sequence
SentrySDK.start { options in
// configure feedback and any other SDK options
}
}

var body: some Scene {
WindowGroup {
ContentView()
}
}
}

class MyAppDelegate: NSObject, UIApplicationDelegate, ObservableObject {
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
let configuration = UISceneConfiguration(
name: nil,
sessionRole: connectingSceneSession.role)
if connectingSceneSession.role == .windowApplication {
configuration.delegateClass = MySceneDelegate.self
}
return configuration
}
}

class MySceneDelegate: NSObject, UIWindowSceneDelegate, ObservableObject {
var initializedSentry = false
func sceneDidBecomeActive(_ scene: UIScene) {
guard !initializedSentry else { return }

// display the feedback widget
SentrySDK.feedback.showWidget()

initializedSentry = true
}
}
```

### Session Replay

The User Feedback widget integrates seamlessly with Session Replay. When the widget is opened, the Replay SDK buffers up to 30 seconds of the user's session. If feedback is submitted, this replay is sent along with the feedback, allowing you to view both the feedback and the user's actions leading up to the feedback submission.
Expand Down
Loading