-
-
Notifications
You must be signed in to change notification settings - Fork 226
Support sending User Feedback without errors/exceptions #3981
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
Merged
Merged
Changes from 24 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
0ab7219
Create SentryFeedback.cs
jamescrosswell 965de12
Update CHANGELOG.md
jamescrosswell adb7c04
Added feedback to SentryContexts
jamescrosswell 486f65c
Verify files
jamescrosswell dd5e7eb
Merge branch 'main' into feedback
jamescrosswell 48c364c
Format code
getsentry-bot 8abc13e
Implemented envelopes and client/hub API
jamescrosswell 56f45e6
Merge branches 'feedback' and 'feedback' of github.com:getsentry/sent…
jamescrosswell c55b742
CollectionExtensionsTests
jamescrosswell 03eddf8
Verify tests
jamescrosswell f92258e
Update HubTests.cs
jamescrosswell b3d1c7d
EnvelopeTests
jamescrosswell a70f78c
SentryClient tests
jamescrosswell db85039
Format code
getsentry-bot 327b1fa
Marked UserFeedback APIs obsolete
jamescrosswell 81ae494
Merge branch 'feedback' of github.com:getsentry/sentry-dotnet into fe…
jamescrosswell 1ecedf7
Added to Maui Sample
jamescrosswell bd50e63
Allow attachments with feedback in Maui Sample
jamescrosswell 750bf37
Verify tests
jamescrosswell e21588f
Format code
getsentry-bot 79dd55b
Updated Console.Customized sample
jamescrosswell 498dd04
Merge branch 'feedback' of github.com:getsentry/sentry-dotnet into fe…
jamescrosswell 39ca97f
Added Feedback to ASP.NET Core MVC sample
jamescrosswell 68a9976
Merge branch 'main' into feedback
jamescrosswell d618ae9
Review feedback
jamescrosswell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
samples/Sentry.Samples.AspNetCore.Mvc/Models/FeedbackModel.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| using System.ComponentModel.DataAnnotations; | ||
|
|
||
| namespace Samples.AspNetCore.Mvc.Models; | ||
|
|
||
| public class FeedbackModel | ||
| { | ||
| [Required] | ||
| public string? Message { get; set; } | ||
|
|
||
| [EmailAddress] | ||
| public string? ContactEmail { get; set; } | ||
|
|
||
| public string? Name { get; set; } | ||
|
|
||
| public IFormFile? Screenshot { get; set; } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
samples/Sentry.Samples.AspNetCore.Mvc/Views/Home/Feedback.cshtml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| @model Samples.AspNetCore.Mvc.Models.FeedbackModel | ||
|
|
||
| @{ | ||
| ViewData["Title"] = "Submit Feedback"; | ||
| } | ||
|
|
||
| <h2>Submit Feedback</h2> | ||
|
|
||
| @if (ViewBag.Message != null) | ||
| { | ||
| <div class="alert alert-success">@ViewBag.Message</div> | ||
| } | ||
|
|
||
| <form asp-action="SubmitFeedback" method="post" enctype="multipart/form-data"> | ||
| <div class="form-group"> | ||
| <label asp-for="Message"></label> | ||
| <textarea asp-for="Message" class="form-control"></textarea> | ||
| <span asp-validation-for="Message" class="text-danger"></span> | ||
| </div> | ||
| <div class="form-group"> | ||
| <label asp-for="ContactEmail"></label> | ||
| <input asp-for="ContactEmail" class="form-control" /> | ||
| <span asp-validation-for="ContactEmail" class="text-danger"></span> | ||
| </div> | ||
| <div class="form-group"> | ||
| <label asp-for="Name"></label> | ||
| <input asp-for="Name" class="form-control" /> | ||
| <span asp-validation-for="Name" class="text-danger"></span> | ||
| </div> | ||
| <div class="form-group"> | ||
| <label asp-for="Screenshot">Attach Screenshot</label> | ||
| <input asp-for="Screenshot" type="file" class="form-control" /> | ||
| <span asp-validation-for="Screenshot" class="text-danger"></span> | ||
| </div> | ||
| <button type="submit" class="btn btn-primary">Submit</button> | ||
| </form> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
|
|
||
| <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
| xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
| x:Class="Sentry.Samples.Maui.SubmitFeedback"> | ||
| <ContentPage.Content> | ||
| <StackLayout Padding="20"> | ||
| <Label Text="Message" /> | ||
| <Editor x:Name="MessageEditor" Placeholder="Enter your feedback message" /> | ||
|
|
||
| <Label Text="Contact Email" Margin="0,20,0,0" /> | ||
| <Entry x:Name="ContactEmailEntry" Placeholder="Enter your contact email" /> | ||
|
|
||
| <Label Text="Name" Margin="0,20,0,0" /> | ||
| <Entry x:Name="NameEntry" Placeholder="Enter your name" /> | ||
|
|
||
| <Button Text="Attach Screenshot" Clicked="OnAttachScreenshotClicked" Margin="0,20,0,0" /> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice, we can use this to create a built-in Widget like @armcknight built for iOS Or use bindings to use the native one. But with a MAUI implementation means we have it also on Windows and macOS |
||
|
|
||
| <StackLayout Orientation="Horizontal" HorizontalOptions="EndAndExpand" Margin="0,20,0,0" Spacing="10"> | ||
| <Button Text="Cancel" Clicked="OnCancelClicked" BackgroundColor="Red" TextColor="White" /> | ||
| <Button Text="Submit" Clicked="OnSubmitClicked" BackgroundColor="Green" TextColor="White" /> | ||
| </StackLayout> | ||
| </StackLayout> | ||
| </ContentPage.Content> | ||
| </ContentPage> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Linq; | ||
| using System.Text; | ||
| using System.Text.RegularExpressions; | ||
| using System.Threading.Tasks; | ||
|
|
||
| namespace Sentry.Samples.Maui; | ||
|
|
||
| public partial class SubmitFeedback : ContentPage | ||
| { | ||
| [GeneratedRegex(@"^[^@\s]+@[^@\s]+\.[^@\s]+$")] | ||
| private static partial Regex EmailPattern(); | ||
|
|
||
| private string _screenshotPath; | ||
|
|
||
| private bool IsValidEmail(string email) => string.IsNullOrWhiteSpace(email) || EmailPattern().IsMatch(email); | ||
|
|
||
| public SubmitFeedback() | ||
| { | ||
| InitializeComponent(); | ||
| } | ||
|
|
||
| private async void OnSubmitClicked(object sender, EventArgs e) | ||
| { | ||
| var message = MessageEditor.Text; | ||
| var contactEmail = ContactEmailEntry.Text; | ||
| var name = NameEntry.Text; | ||
|
|
||
| if (string.IsNullOrWhiteSpace(message)) | ||
| { | ||
| await DisplayAlert("Validation Error", "Message is required.", "OK"); | ||
| return; | ||
| } | ||
|
|
||
| if (!IsValidEmail(contactEmail)) | ||
| { | ||
| await DisplayAlert("Validation Error", "Please enter a valid email address.", "OK"); | ||
| return; | ||
| } | ||
|
|
||
| SentryHint hint = null; | ||
| if (!string.IsNullOrEmpty(_screenshotPath)) | ||
| { | ||
| hint = new SentryHint(); | ||
| hint.AddAttachment(_screenshotPath, AttachmentType.Default, "image/png"); | ||
| } | ||
|
|
||
| // Handle the feedback submission logic here | ||
| var feedback = new SentryFeedback(message, contactEmail, name); | ||
| SentrySdk.CaptureFeedback(feedback, hint: hint); | ||
|
|
||
| await DisplayAlert("Feedback Submitted", "Thank you for your feedback!", "OK"); | ||
| await Navigation.PopModalAsync(); | ||
| } | ||
|
|
||
| private async void OnCancelClicked(object sender, EventArgs e) | ||
| { | ||
| await Navigation.PopModalAsync(); | ||
| } | ||
|
|
||
| private async void OnAttachScreenshotClicked(object sender, EventArgs e) | ||
| { | ||
| try | ||
| { | ||
| var result = await FilePicker.PickAsync(new PickOptions | ||
| { | ||
| FileTypes = FilePickerFileType.Images, | ||
| PickerTitle = "Select a screenshot" | ||
| }); | ||
|
|
||
| if (result != null) | ||
| { | ||
| _screenshotPath = result.FullPath; | ||
| await DisplayAlert("Screenshot Attached", "Screenshot has been attached successfully.", "OK"); | ||
| } | ||
| } | ||
| catch (Exception ex) | ||
| { | ||
| await DisplayAlert("Error", $"An error occurred while selecting the screenshot: {ex.Message}", "OK"); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.