Skip to content
Draft
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
1 change: 1 addition & 0 deletions Sources/Swift/Helper/SentrySDK.swift
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ import Foundation
}

#if os(iOS) && !SENTRY_NO_UIKIT
@available(*, deprecated, message: "Create an instance of SentryUserFeedbackFormController directly.")
@objc public static let feedback = {
return SentryFeedbackAPI()
}()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,34 @@ public final class SentryUserFeedbackConfiguration: NSObject {
* Configuration settings specific to the managed widget that displays the UI form.
* - note: Default: `nil` to use the default widget settings.
*/
@available(*, deprecated, message: "Create an instance of SentryUserFeedbackFormController directly.")
public var configureWidget: ((SentryUserFeedbackWidgetConfiguration) -> Void)?

@available(*, deprecated, message: "Create an instance of SentryUserFeedbackFormController directly.")
lazy var widgetConfig = SentryUserFeedbackWidgetConfiguration()

/**
* Use a shake gesture to display the form.
* - note: Default: `false`
* - note: Setting this to true does not disable the widget. In order to do so, you must set `SentryUserFeedbackWidgetConfiguration.autoInject` to `false` using the `SentryUserFeedbackConfiguration.configureWidget` config builder.
*/
@available(*, deprecated, message: "Create an instance of SentryUserFeedbackFormController directly.")
public var useShakeGesture: Bool = false

/**
* Any time a user takes a screenshot, bring up the form with the screenshot attached.
* - note: Default: `false`
* - note: Setting this to true does not disable the widget. In order to do so, you must set `SentryUserFeedbackWidgetConfiguration.autoInject` to `false` using the `SentryUserFeedbackConfiguration.configureWidget` config builder.
*/
@available(*, deprecated, message: "Create an instance of SentryUserFeedbackFormController directly.")
public var showFormForScreenshots: Bool = false

/**
* Install a hook for the specified button to show the form when it is pressed.
* - note: If this is set, `configureWidget` is ignored.
* - note: Default: `nil`
*/
@available(*, deprecated, message: "Create an instance of SentryUserFeedbackFormController directly.")
public var customButton: UIButton?

/**
Expand All @@ -62,6 +67,7 @@ public final class SentryUserFeedbackConfiguration: NSObject {
* Called when the managed feedback form is opened.
* - note: Default: `nil`
*/
@available(*, deprecated, message: "Create an instance of SentryUserFeedbackFormController directly.")
public var onFormOpen: (() -> Void)?

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public final class SentryFeedbackAPI: NSObject {
/// - warning: This is an experimental feature and may still have bugs.
/// - seealso: See `SentryOptions.configureUserFeedback` to configure the widget.
@available(iOSApplicationExtension, unavailable)
@available(*, deprecated, message: "Create an instance of SentryUserFeedbackFormController directly.")
@objc public func showWidget() {
getIntegration()?.driver.showWidget()
}
Expand All @@ -17,10 +18,12 @@ public final class SentryFeedbackAPI: NSObject {
/// - warning: This is an experimental feature and may still have bugs.
/// - seealso: See `SentryOptions.configureUserFeedback` to configure the widget.
@available(iOSApplicationExtension, unavailable)
@available(*, deprecated, message: "Create an instance of SentryUserFeedbackFormController directly.")
@objc public func hideWidget() {
getIntegration()?.driver.hideWidget()
}

@available(*, deprecated, message: "Create an instance of SentryUserFeedbackFormController directly.")
private func getIntegration() -> UserFeedbackIntegration<SentryDependencyContainer>? {
SentrySDKInternal.currentHub().getInstalledIntegration(UserFeedbackIntegration<SentryDependencyContainer>.self) as? UserFeedbackIntegration<SentryDependencyContainer>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,22 @@ protocol SentryUserFeedbackFormDelegate: NSObjectProtocol {
func finished(with feedback: SentryFeedback?)
}

final class SentryUserFeedbackFormController: UIViewController {
public final class SentryUserFeedbackFormController: UIViewController {
let config: SentryUserFeedbackConfiguration
weak var delegate: SentryUserFeedbackFormDelegate?
let screenshot: UIImage?
lazy var viewModel = SentryUserFeedbackFormViewModel(config: config, controller: self, screenshot: screenshot)

override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
public override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
config.theme.updateDefaultFonts()
config.recalculateScaleFactors()
viewModel.updateLayout()
}

public convenience init(config: SentryUserFeedbackConfiguration, screenshot: UIImage?) {
self.init(config: config, delegate: nil, screenshot: screenshot)
}

init(config: SentryUserFeedbackConfiguration, delegate: SentryUserFeedbackFormDelegate?, screenshot: UIImage?) {
self.config = config
self.delegate = delegate
Expand Down Expand Up @@ -104,19 +108,19 @@ extension SentryUserFeedbackFormController: SentryUserFeedbackFormViewModelDeleg

// MARK: UITextFieldDelegate
extension SentryUserFeedbackFormController: UITextFieldDelegate {
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
public func textFieldShouldReturn(_ textField: UITextField) -> Bool {
textField.resignFirstResponder()
return true
}

func textFieldDidChangeSelection(_ textField: UITextField) {
public func textFieldDidChangeSelection(_ textField: UITextField) {
viewModel.updateSubmitButtonAccessibilityHint()
}
}

// MARK: UITextViewDelegate
extension SentryUserFeedbackFormController: UITextViewDelegate {
func textViewDidChange(_ textView: UITextView) {
public func textViewDidChange(_ textView: UITextView) {
viewModel.messageTextViewPlaceholder.isHidden = textView.text != ""
viewModel.updateSubmitButtonAccessibilityHint()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import UIKit
* - note: The default method to show the feedback form is via a floating widget placed in the bottom trailing corner of the screen. See the configuration classes for alternative options.
*/
@available(iOSApplicationExtension, unavailable)
@available(*, deprecated, message: "Create an instance of SentryUserFeedbackFormController directly.")
final class SentryUserFeedbackIntegrationDriver: NSObject {
let configuration: SentryUserFeedbackConfiguration
private var widget: SentryUserFeedbackWidget?
Expand Down Expand Up @@ -79,6 +80,7 @@ final class SentryUserFeedbackIntegrationDriver: NSObject {

// MARK: SentryUserFeedbackFormDelegate
@available(iOSApplicationExtension, unavailable)
@available(*, deprecated, message: "Create an instance of SentryUserFeedbackFormController directly.")
extension SentryUserFeedbackIntegrationDriver: SentryUserFeedbackFormDelegate {
func finished(with feedback: SentryFeedback?) {
if let feedback = feedback {
Expand All @@ -94,6 +96,7 @@ extension SentryUserFeedbackIntegrationDriver: SentryUserFeedbackFormDelegate {

// MARK: SentryUserFeedbackWidgetDelegate
@available(iOSApplicationExtension, unavailable)
@available(*, deprecated, message: "Create an instance of SentryUserFeedbackFormController directly.")
extension SentryUserFeedbackIntegrationDriver: SentryUserFeedbackWidgetDelegate {
func showForm() {
showForm(screenshot: nil)
Expand All @@ -102,6 +105,7 @@ extension SentryUserFeedbackIntegrationDriver: SentryUserFeedbackWidgetDelegate

// MARK: UIAdaptivePresentationControllerDelegate
@available(iOSApplicationExtension, unavailable)
@available(*, deprecated, message: "Create an instance of SentryUserFeedbackFormController directly.")
extension SentryUserFeedbackIntegrationDriver: UIAdaptivePresentationControllerDelegate {
public func presentationControllerDidDismiss(_ presentationController: UIPresentationController) {
widget?.rootVC.setWidget(visible: true, animated: configuration.animations)
Expand All @@ -112,6 +116,7 @@ extension SentryUserFeedbackIntegrationDriver: UIAdaptivePresentationControllerD

// MARK: Private
@available(iOSApplicationExtension, unavailable)
@available(*, deprecated, message: "Create an instance of SentryUserFeedbackFormController directly.")
private extension SentryUserFeedbackIntegrationDriver {
func showForm(screenshot: UIImage?) {
let form = SentryUserFeedbackFormController(config: configuration, delegate: self, screenshot: screenshot)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ protocol SentryUserFeedbackWidgetDelegate: NSObjectProtocol {
}

@available(iOSApplicationExtension, unavailable)
@available(*, deprecated, message: "Create an instance of SentryUserFeedbackFormController directly.")
final class SentryUserFeedbackWidget {
private lazy var button = {
let button = SentryUserFeedbackWidgetButtonView(config: config, target: self, selector: #selector(showForm))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Foundation
@_implementationOnly import _SentryPrivate
import UIKit

@available(*, deprecated, message: "Create an instance of SentryUserFeedbackFormController directly.")
final class SentryUserFeedbackWidgetButtonView: UIView {
// MARK: Measurements
let svgSize: CGFloat = 16
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ protocol ScreenshotSourceProvider {

final class UserFeedbackIntegration<Dependencies: ScreenshotSourceProvider>: NSObject, SwiftIntegration {

@available(*, deprecated, message: "Create an instance of SentryUserFeedbackFormController directly.")
let driver: SentryUserFeedbackIntegrationDriver

@available(*, deprecated, message: "Create an instance of SentryUserFeedbackFormController directly.")
init?(with options: Options, dependencies: Dependencies) {
guard let configuration = options.userFeedbackConfiguration else {
return nil
Expand Down
Loading
Loading