Skip to content

Commit d4689a4

Browse files
authored
Merge 373eded into 77e097d
2 parents 77e097d + 373eded commit d4689a4

File tree

12 files changed

+170
-38
lines changed

12 files changed

+170
-38
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
### Features
6+
7+
- Apps can now manually show and hide the included feedback widget button (#5236)
8+
39
## 8.50.2
410

511
### Fixes

Samples/SentrySampleShared/SentrySampleShared/SentrySDKOverrides.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,7 @@ public enum SentrySDKOverrides {
5858

5959
public var boolValue: Bool {
6060
get {
61-
switch self {
62-
case .disableAutoInject: return getBoolOverride(for: rawValue)
63-
default: return getBoolOverride(for: rawValue)
64-
}
61+
return getBoolOverride(for: rawValue)
6562
}
6663
set(newValue) {
6764
setBoolOverride(for: rawValue, value: newValue)

Samples/iOS-Swift/iOS-Swift-UITests/UserFeedbackUITests.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,8 @@ extension UserFeedbackUITests {
489489
XCTAssertEqual(try dictionaryFromSuccessHookFile(), ["name": testName, "message": "UITest user feedback", "email": testContactEmail])
490490
}
491491

492+
// MARK: Alternative widget control
493+
492494
func testFormShowsAndDismissesProperlyWithCustomButton() {
493495
launchApp(args: ["--io.sentry.feedback.use-custom-feedback-button"])
494496

@@ -512,6 +514,16 @@ extension UserFeedbackUITests {
512514
XCTAssert(customButton.isHittable)
513515
XCTAssertFalse(widgetButton.isHittable)
514516
}
517+
518+
func testManuallyDisplayingWidget() {
519+
launchApp(args: ["--io.sentry.feedback.no-auto-inject-widget"])
520+
XCTAssertFalse(widgetButton.isHittable)
521+
extrasAreaTabBarButton.tap()
522+
app.buttons["io.sentry.ui-test.button.show-widget"].tap()
523+
XCTAssert(widgetButton.isHittable)
524+
app.buttons["io.sentry.ui-test.button.hide-widget"].tap()
525+
XCTAssertFalse(widgetButton.isHittable)
526+
}
515527
}
516528

517529
// MARK: UI Element access

Samples/iOS-Swift/iOS-Swift/Base.lproj/Main.storyboard

Lines changed: 59 additions & 31 deletions
Large diffs are not rendered by default.

Samples/iOS-Swift/iOS-Swift/ExtraViewController.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,4 +348,20 @@ class ExtraViewController: UIViewController {
348348
result["item_header_type"] = json["type"]
349349
}
350350
}
351+
352+
@IBAction func showFeedbackWidget(_ sender: Any) {
353+
if #available(iOS 13.0, *) {
354+
SentrySDK.showFeedbackWidget()
355+
} else {
356+
showToast(in: self, type: .warning, message: "Feedback widget only available in iOS 13 or later.")
357+
}
358+
}
359+
360+
@IBAction func hideFeedbackWidget(_ sender: Any) {
361+
if #available(iOS 13.0, *) {
362+
SentrySDK.hideFeedbackWidget()
363+
} else {
364+
showToast(in: self, type: .warning, message: "Feedback widget only available in iOS 13 or later.")
365+
}
366+
}
351367
}

Sources/Sentry/Public/SentryOptions.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -798,6 +798,7 @@ typedef void (^SentryProfilingConfigurationBlock)(SentryProfileOptions *_Nonnull
798798
* either this block to configure a widget and UI form to gather feedback, or directly submits
799799
* feedback you've gathered using your own UI by calling the method @c SentrySDK.captureFeedback
800800
* (se https://docs.sentry.io/platforms/apple/user-feedback/configuration/).
801+
* @note User feedback widget is only available for iOS 13 or later.
801802
*/
802803
@property (nonatomic, copy, nullable)
803804
SentryUserFeedbackConfigurationBlock configureUserFeedback API_AVAILABLE(ios(13.0));

Sources/Sentry/Public/SentrySDK.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,13 +263,34 @@ SENTRY_NO_INIT
263263

264264
/**
265265
* Captures user feedback that was manually gathered and sends it to Sentry.
266+
* @warning This is an experimental feature and may still have bugs.
266267
* @param feedback The feedback to send to Sentry.
267268
* @note If you'd prefer not to have to build the UI required to gather the feedback from the user,
268269
* see @c SentryOptions.configureUserFeedback to customize a fully managed integration. See
269270
* https://docs.sentry.io/platforms/apple/user-feedback/ for more information.
270271
*/
271272
+ (void)captureFeedback:(SentryFeedback *)feedback NS_SWIFT_NAME(capture(feedback:));
272273

274+
#if TARGET_OS_IOS && SENTRY_HAS_UIKIT
275+
276+
/**
277+
* Show the feedback widget button.
278+
* @warning This is an experimental feature and may still have bugs.
279+
* @seealso See @c SentryOptions.configureUserFeedback to configure the widget.
280+
* @note User feedback widget is only available for iOS 13 or later.
281+
*/
282+
+ (void)showFeedbackWidget API_AVAILABLE(ios(13.0));
283+
284+
/**
285+
* Hide the feedback widget button.
286+
* @warning This is an experimental feature and may still have bugs.
287+
* @seealso See @c SentryOptions.configureUserFeedback to configure the widget.
288+
* @note User feedback widget is only available for iOS 13 or later.
289+
*/
290+
+ (void)hideFeedbackWidget API_AVAILABLE(ios(13.0));
291+
292+
#endif // TARGET_OS_IOS && SENTRY_HAS_UIKIT
293+
273294
/**
274295
* Adds a Breadcrumb to the current Scope of the current Hub. If the total number of breadcrumbs
275296
* exceeds the @c SentryOptions.maxBreadcrumbs the SDK removes the oldest breadcrumb.

Sources/Sentry/SentrySDK.m

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#import "SentrySerialization.h"
2727
#import "SentrySwift.h"
2828
#import "SentryTransactionContext.h"
29+
#import "SentryUserFeedbackIntegration.h"
2930

3031
#if TARGET_OS_OSX
3132
# import "SentryCrashExceptionApplication.h"
@@ -431,6 +432,32 @@ + (void)captureFeedback:(SentryFeedback *)feedback
431432
[SentrySDK.currentHub captureFeedback:feedback];
432433
}
433434

435+
#if TARGET_OS_IOS && SENTRY_HAS_UIKIT
436+
437+
+ (void)showFeedbackWidget
438+
{
439+
if (@available(iOS 13.0, *)) {
440+
SentryUserFeedbackIntegration *feedback =
441+
[currentHub getInstalledIntegration:[SentryUserFeedbackIntegration class]];
442+
[feedback showWidget];
443+
} else {
444+
SENTRY_LOG_WARN(@"Sentry User Feedback is only available on iOS 13 or later.");
445+
}
446+
}
447+
448+
+ (void)hideFeedbackWidget
449+
{
450+
if (@available(iOS 13.0, *)) {
451+
SentryUserFeedbackIntegration *feedback =
452+
[currentHub getInstalledIntegration:[SentryUserFeedbackIntegration class]];
453+
[feedback hideWidget];
454+
} else {
455+
SENTRY_LOG_WARN(@"Sentry User Feedback is only available on iOS 13 or later.");
456+
}
457+
}
458+
459+
#endif // TARGET_OS_IOS && SENTRY_HAS_UIKIT
460+
434461
+ (void)addBreadcrumb:(SentryBreadcrumb *)crumb
435462
{
436463
[SentrySDK.currentHub addBreadcrumb:crumb];

Sources/Sentry/SentryUserFeedbackIntegration.m

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,16 @@ - (BOOL)installWithOptions:(SentryOptions *)options
2727
return YES;
2828
}
2929

30+
- (void)showWidget
31+
{
32+
[_driver showWidget];
33+
}
34+
35+
- (void)hideWidget
36+
{
37+
[_driver hideWidget];
38+
}
39+
3040
// MARK: SentryUserFeedbackIntegrationDriverDelegate
3141

3242
- (void)captureWithFeedback:(SentryFeedback *)feedback

Sources/Sentry/include/SentryUserFeedbackIntegration.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ NS_ASSUME_NONNULL_BEGIN
88

99
API_AVAILABLE(ios(13.0))
1010
@interface SentryUserFeedbackIntegration : SentryBaseIntegration
11-
11+
- (void)showWidget;
12+
- (void)hideWidget;
1213
@end
1314

1415
NS_ASSUME_NONNULL_END

0 commit comments

Comments
 (0)