Skip to content

Commit

Permalink
feat(feedback): more iteration on UI form and tests (#4600)
Browse files Browse the repository at this point in the history
  • Loading branch information
armcknight authored Dec 7, 2024
1 parent eba61d3 commit 12e65d0
Show file tree
Hide file tree
Showing 7 changed files with 329 additions and 120 deletions.
128 changes: 65 additions & 63 deletions Samples/iOS-ObjectiveC/iOS-ObjectiveC/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,75 +40,77 @@ - (BOOL)application:(UIApplication *)application
return scope;
};

options.configureUserFeedback = ^(SentryUserFeedbackConfiguration *_Nonnull config) {
UIOffset layoutOffset = UIOffsetMake(25, 75);
if ([args containsObject:@"--io.sentry.iOS-Swift.user-feedback.all-defaults"]) {
config.configureWidget = ^(SentryUserFeedbackWidgetConfiguration *widget) {
widget.layoutUIOffset = layoutOffset;
};
return;
}
config.useShakeGesture = YES;
config.showFormForScreenshots = YES;
config.configureWidget = ^(SentryUserFeedbackWidgetConfiguration *_Nonnull widget) {
if ([args
containsObject:@"--io.sentry.iOS-Swift.auto-inject-user-feedback-widget"]) {
widget.labelText = @"Report Jank";
widget.widgetAccessibilityLabel = @"io.sentry.iOS-Swift.button.report-jank";
widget.layoutUIOffset = layoutOffset;
} else {
widget.autoInject = NO;
if (@available(iOS 13.0, *)) {
options.configureUserFeedback = ^(SentryUserFeedbackConfiguration *_Nonnull config) {
UIOffset layoutOffset = UIOffsetMake(25, 75);
if ([args containsObject:@"--io.sentry.feedback.all-defaults"]) {
config.configureWidget = ^(SentryUserFeedbackWidgetConfiguration *widget) {
widget.layoutUIOffset = layoutOffset;
};
return;
}
config.useShakeGesture = YES;
config.showFormForScreenshots = YES;
config.configureWidget = ^(SentryUserFeedbackWidgetConfiguration *_Nonnull widget) {
if ([args containsObject:@"--io.sentry.feedback.auto-inject-widget"]) {
widget.labelText = @"Report Jank";
widget.widgetAccessibilityLabel = @"io.sentry.iOS-Swift.button.report-jank";
widget.layoutUIOffset = layoutOffset;
} else {
widget.autoInject = NO;
}

if ([args containsObject:@"--io.sentry.iOS-Swift.user-feedback.no-widget-text"]) {
widget.labelText = nil;
}
if ([args containsObject:@"--io.sentry.iOS-Swift.user-feedback.no-widget-icon"]) {
widget.showIcon = NO;
}
};
config.configureForm = ^(SentryUserFeedbackFormConfiguration *_Nonnull uiForm) {
uiForm.formTitle = @"Jank Report";
uiForm.submitButtonLabel = @"Report that jank";
uiForm.addScreenshotButtonLabel = @"Show us the jank";
uiForm.messagePlaceholder
= @"Describe the nature of the jank. Its essence, if you will.";
};
config.configureTheme = ^(SentryUserFeedbackThemeConfiguration *_Nonnull theme) {
theme.font = [UIFont fontWithName:@"ChalkboardSE-Regular" size:25];
};
config.onSubmitSuccess = ^(NSDictionary<NSString *, id> *_Nonnull info) {
NSString *name = info[@"name"] ?: @"$shakespearean_insult_name";
UIAlertController *alert = [UIAlertController
alertControllerWithTitle:@"Thanks?"
message:[NSString stringWithFormat:
@"We have enough jank of our own, we "
@"really didn't need yours too, %@",
name]
preferredStyle:UIAlertControllerStyleAlert];
[alert addAction:[UIAlertAction actionWithTitle:@"Derp"
style:UIAlertActionStyleDefault
handler:nil]];
[self.window.rootViewController presentViewController:alert
animated:YES
completion:nil];
};
config.onSubmitError = ^(NSError *_Nonnull error) {
UIAlertController *alert = [UIAlertController
alertControllerWithTitle:@"D'oh"
message:[NSString stringWithFormat:
if ([args containsObject:@"--io.sentry.feedback.no-widget-text"]) {
widget.labelText = nil;
}
if ([args containsObject:@"--io.sentry.feedback.no-widget-icon"]) {
widget.showIcon = NO;
}
};
config.configureForm = ^(SentryUserFeedbackFormConfiguration *_Nonnull uiForm) {
uiForm.formTitle = @"Jank Report";
uiForm.submitButtonLabel = @"Report that jank";
uiForm.addScreenshotButtonLabel = @"Show us the jank";
uiForm.messagePlaceholder
= @"Describe the nature of the jank. Its essence, if you will.";
};
config.configureTheme = ^(SentryUserFeedbackThemeConfiguration *_Nonnull theme) {
theme.font = [UIFont fontWithName:@"ChalkboardSE-Regular" size:25];
};
config.onSubmitSuccess = ^(NSDictionary<NSString *, id> *_Nonnull info) {
NSString *name = info[@"name"] ?: @"$shakespearean_insult_name";
UIAlertController *alert = [UIAlertController
alertControllerWithTitle:@"Thanks?"
message:[NSString stringWithFormat:
@"We have enough jank of our own, we "
@"really didn't need yours too, %@",
name]
preferredStyle:UIAlertControllerStyleAlert];
[alert addAction:[UIAlertAction actionWithTitle:@"Derp"
style:UIAlertActionStyleDefault
handler:nil]];
[self.window.rootViewController presentViewController:alert
animated:YES
completion:nil];
};
config.onSubmitError = ^(NSError *_Nonnull error) {
UIAlertController *alert = [UIAlertController
alertControllerWithTitle:@"D'oh"
message:
[NSString stringWithFormat:
@"You tried to report jank, and encountered "
@"more jank. The jank has you now: %@",
error]
preferredStyle:UIAlertControllerStyleAlert];
[alert addAction:[UIAlertAction actionWithTitle:@"Derp"
style:UIAlertActionStyleDefault
handler:nil]];
[self.window.rootViewController presentViewController:alert
animated:YES
completion:nil];
preferredStyle:UIAlertControllerStyleAlert];
[alert addAction:[UIAlertAction actionWithTitle:@"Derp"
style:UIAlertActionStyleDefault
handler:nil]];
[self.window.rootViewController presentViewController:alert
animated:YES
completion:nil];
};
};
};
}
}];

return YES;
Expand Down
6 changes: 5 additions & 1 deletion Samples/iOS-Swift/iOS-Swift-UITests/BaseUITest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ extension BaseUITest {
return app
}

func launchApp() {
func launchApp(args: [String] = [], env: [String: String] = [:]) {
app.launchArguments.append(contentsOf: args)
for (k, v) in env {
app.launchEnvironment[k] = v
}
app.launch()
waitForExistenceOfMainScreen()
}
Expand Down
Loading

0 comments on commit 12e65d0

Please sign in to comment.