Repository: ueman/feedback

Issue:
Update sentry dependency to v 9.0.0
#### Description
The `sentry_flutter` and `sentry` packages were recently updated to version `9.0.0`. But updating sentry_flutter is blocked by `feedback_sentry` that still depends on sentry `8.10.0`.

#### Proposal
Update the sentry dependency to version 9.0.0




Fix patch:
diff --git a/feedback_sentry/lib/feedback_sentry.dart b/feedback_sentry/lib/feedback_sentry.dart
index 1970545b..c0c34803 100644
--- a/feedback_sentry/lib/feedback_sentry.dart
+++ b/feedback_sentry/lib/feedback_sentry.dart
@@ -26,10 +26,6 @@ extension SentryFeedbackX on FeedbackController {
   /// This method opens the feedback ui and the users feedback
   /// is uploaded to Sentry after the user submitted his feedback.
   /// [name] and [email] are optional. They are shown in the Sentry.io ui.s
-  @Deprecated(
-    'Sentry marked the underlying APIs for this method as deprecated. '
-    'Unfortunately, there is no replacement.',
-  )
   void showAndUploadToSentryWithException({
     Hub? hub,
     String? name,
@@ -59,20 +55,23 @@ OnFeedbackCallback sendToSentry({
 
   return (UserFeedback feedback) async {
     await realHub.captureFeedback(
-      SentryFeedback(
-        contactEmail: email,
-        name: name,
-        message: feedback.text,
-        unknown: feedback.extra,
-      ),
-      hint: Hint.withScreenshot(
-        SentryAttachment.fromUint8List(
-          feedback.screenshot,
-          'screenshot.png',
-          contentType: 'image/png',
+        SentryFeedback(
+          contactEmail: email,
+          name: name,
+          message: feedback.text,
         ),
-      ),
-    );
+        hint: Hint.withScreenshot(
+          SentryAttachment.fromUint8List(
+            feedback.screenshot,
+            'screenshot.png',
+            contentType: 'image/png',
+          ),
+        ), withScope: (scope) {
+      scope.setContexts(
+        "user_feedback",
+        feedback.extra,
+      );
+    });
   };
 }
 
@@ -93,6 +92,10 @@ OnFeedbackCallback sendToSentryWithException({
       exception,
       stackTrace: stackTrace,
       withScope: (scope) {
+        scope.setContexts(
+          "user_feedback",
+          feedback.extra,
+        );
         scope.addAttachment(SentryAttachment.fromUint8List(
           feedback.screenshot,
           'screenshot.png',
@@ -100,12 +103,11 @@ OnFeedbackCallback sendToSentryWithException({
         ));
       },
     );
-    // ignore: deprecated_member_use
-    await realHub.captureUserFeedback(SentryUserFeedback(
-      eventId: id,
-      email: email,
+    await realHub.captureFeedback(SentryFeedback(
+      associatedEventId: id,
+      contactEmail: email,
       name: name,
-      comments: feedback.text + '\n${feedback.extra.toString()}',
+      message: feedback.text,
     ));
   };
 }
diff --git a/feedback_sentry/pubspec.yaml b/feedback_sentry/pubspec.yaml
index d9c7cecc..afb2ec93 100644
--- a/feedback_sentry/pubspec.yaml
+++ b/feedback_sentry/pubspec.yaml
@@ -9,15 +9,16 @@ funding:
   - https://github.com/sponsors/ueman
 
 environment:
-  sdk: '>=3.0.0 <4.0.0'
-  flutter: '>=3.10.0'
+  sdk: ">=3.5.0 <4.0.0"
+  flutter: ">=3.24.0"
 
 dependencies:
   flutter:
     sdk: flutter
   feedback: ^3.0.0
-  sentry: ^8.10.0
+  sentry: ^9.0.0
 
 dev_dependencies:
   flutter_test:
-    sdk: flutter
\ No newline at end of file
+    sdk: flutter
+


Test patch:
diff --git a/feedback_sentry/test/feedback_sentry_test.dart b/feedback_sentry/test/feedback_sentry_test.dart
index a3615efb..bc3ecdf3 100644
--- a/feedback_sentry/test/feedback_sentry_test.dart
+++ b/feedback_sentry/test/feedback_sentry_test.dart
@@ -23,21 +23,20 @@ void main() {
 
     expect(completed, true);
 
-    expect(mockHub.capturedMessage, 'foo bar');
-
-    expect(mockHub.capturedFeedback?.comments, 'foo bar\n{foo: bar}');
+    expect(mockHub.capturedFeedback?.message, 'foo bar');
     expect(mockHub.capturedFeedback?.name, 'foo');
-    expect(mockHub.capturedFeedback?.email, 'bar@foo.de');
-
-    expect(mockHub.scope.attachments.length, 1);
+    expect(mockHub.scope.contexts["user_feedback"], {'foo': 'bar'});
+    expect(mockHub.capturedFeedback?.contactEmail, 'bar@foo.de');
+    expect(mockHub.captureHint?.screenshot?.filename, "screenshot.png");
   });
 }
 
 class MockHub implements Hub {
-  SentryUserFeedback? capturedFeedback;
+  SentryFeedback? capturedFeedback;
   String? capturedMessage;
   Scope scope = Scope(SentryOptions());
   Completer<bool> completer = Completer<bool>();
+  Hint? captureHint;
 
   @override
   Future<SentryId> captureMessage(
@@ -45,7 +44,7 @@ class MockHub implements Hub {
     SentryLevel? level,
     String? template,
     List? params,
-    hint,
+    Hint? hint,
     ScopeCallback? withScope,
   }) async {
     capturedMessage = message;
@@ -54,9 +53,16 @@ class MockHub implements Hub {
   }
 
   @override
-  Future<void> captureUserFeedback(SentryUserFeedback userFeedback) async {
-    capturedFeedback = userFeedback;
+  Future<SentryId> captureFeedback(
+    SentryFeedback feedback, {
+    Hint? hint,
+    ScopeCallback? withScope,
+  }) async {
+    capturedFeedback = feedback;
+    withScope?.call(scope);
+    captureHint = hint;
     completer.complete(true);
+    return SentryId.newId();
   }
 
   // Used so that unneeded methods, do not need to be overridden.