diff --git a/dart/lib/src/hub_adapter.dart b/dart/lib/src/hub_adapter.dart index ad195c525c..40684cf3c9 100644 --- a/dart/lib/src/hub_adapter.dart +++ b/dart/lib/src/hub_adapter.dart @@ -1,8 +1,8 @@ import 'dart:async'; import 'package:meta/meta.dart'; -import 'hint.dart'; +import 'hint.dart'; import 'hub.dart'; import 'metrics/metric.dart'; import 'metrics/metrics_aggregator.dart'; @@ -13,8 +13,8 @@ import 'protocol/sentry_feedback.dart'; import 'scope.dart'; import 'sentry.dart'; import 'sentry_client.dart'; -import 'sentry_user_feedback.dart'; import 'sentry_options.dart'; +import 'sentry_user_feedback.dart'; import 'tracing.dart'; /// Hub adapter to make Integrations testable @@ -118,7 +118,9 @@ class HubAdapter implements Hub { ISentrySpan? getSpan() => Sentry.currentHub.getSpan(); @override + // ignore: deprecated_member_use_from_same_package Future captureUserFeedback(SentryUserFeedback userFeedback) => + // ignore: deprecated_member_use_from_same_package Sentry.captureUserFeedback(userFeedback); @override diff --git a/dart/lib/src/noop_hub.dart b/dart/lib/src/noop_hub.dart index e7b79ec936..10f34a6d42 100644 --- a/dart/lib/src/noop_hub.dart +++ b/dart/lib/src/noop_hub.dart @@ -97,6 +97,7 @@ class NoOpHub implements Hub { SentryId.empty(); @override + // ignore: deprecated_member_use_from_same_package Future captureUserFeedback(SentryUserFeedback userFeedback) async {} @override diff --git a/dart/lib/src/noop_sentry_client.dart b/dart/lib/src/noop_sentry_client.dart index 4c80946ab9..f2854f4f7e 100644 --- a/dart/lib/src/noop_sentry_client.dart +++ b/dart/lib/src/noop_sentry_client.dart @@ -56,6 +56,7 @@ class NoOpSentryClient implements SentryClient { SentryId.empty(); @override + // ignore: deprecated_member_use_from_same_package Future captureUserFeedback(SentryUserFeedback userFeedback) async {} @override diff --git a/dart/lib/src/sentry_envelope_item.dart b/dart/lib/src/sentry_envelope_item.dart index 88ca36e930..3f7ed19d32 100644 --- a/dart/lib/src/sentry_envelope_item.dart +++ b/dart/lib/src/sentry_envelope_item.dart @@ -4,11 +4,11 @@ import 'dart:convert'; import 'client_reports/client_report.dart'; import 'metrics/metric.dart'; import 'protocol.dart'; -import 'utils.dart'; import 'sentry_attachment/sentry_attachment.dart'; -import 'sentry_item_type.dart'; import 'sentry_envelope_item_header.dart'; +import 'sentry_item_type.dart'; import 'sentry_user_feedback.dart'; +import 'utils.dart'; /// Item holding header information and JSON encoded data. class SentryEnvelopeItem { @@ -46,6 +46,7 @@ class SentryEnvelopeItem { } /// Create a [SentryEnvelopeItem] which sends [SentryUserFeedback]. + @Deprecated('Will be removed in a future version.') factory SentryEnvelopeItem.fromUserFeedback(SentryUserFeedback feedback) { final cachedItem = _CachedItem(() async => utf8JsonEncoder.convert(feedback.toJson())); diff --git a/dart/test/mocks/mock_hub.dart b/dart/test/mocks/mock_hub.dart index c076251736..2bdec695a2 100644 --- a/dart/test/mocks/mock_hub.dart +++ b/dart/test/mocks/mock_hub.dart @@ -13,6 +13,8 @@ class MockHub with NoSuchMethodProvider implements Hub { List captureMessageCalls = []; List addBreadcrumbCalls = []; List bindClientCalls = []; + + // ignore: deprecated_member_use_from_same_package List userFeedbackCalls = []; List captureTransactionCalls = []; List captureMetricsCalls = []; @@ -133,6 +135,7 @@ class MockHub with NoSuchMethodProvider implements Hub { } @override + // ignore: deprecated_member_use_from_same_package Future captureUserFeedback(SentryUserFeedback userFeedback) async { userFeedbackCalls.add(userFeedback); } diff --git a/dart/test/mocks/mock_sentry_client.dart b/dart/test/mocks/mock_sentry_client.dart index c9d221b25f..c0e4ba9ffe 100644 --- a/dart/test/mocks/mock_sentry_client.dart +++ b/dart/test/mocks/mock_sentry_client.dart @@ -9,6 +9,8 @@ class MockSentryClient with NoSuchMethodProvider implements SentryClient { List captureMessageCalls = []; List captureEnvelopeCalls = []; List captureTransactionCalls = []; + + // ignore: deprecated_member_use_from_same_package List userFeedbackCalls = []; List captureFeedbackCalls = []; List>> captureMetricsCalls = []; @@ -73,6 +75,7 @@ class MockSentryClient with NoSuchMethodProvider implements SentryClient { } @override + // ignore: deprecated_member_use_from_same_package Future captureUserFeedback(SentryUserFeedback userFeedback) async { userFeedbackCalls.add(userFeedback); } diff --git a/dart/test/sentry_client_test.dart b/dart/test/sentry_client_test.dart index 233f628930..f928d5413d 100644 --- a/dart/test/sentry_client_test.dart +++ b/dart/test/sentry_client_test.dart @@ -1655,12 +1655,14 @@ void main() { final client = fixture.getSut(eventProcessor: DropAllEventProcessor()); final id = SentryId.newId(); + // ignore: deprecated_member_use_from_same_package final feedback = SentryUserFeedback( eventId: id, comments: 'this is awesome', email: 'sentry@example.com', name: 'Rockstar Developer', ); + // ignore: deprecated_member_use_from_same_package await client.captureUserFeedback(feedback); expect(fixture.recorder.flushCalled, true); @@ -1676,12 +1678,14 @@ void main() { final client = fixture.getSut(eventProcessor: DropAllEventProcessor()); final id = SentryId.newId(); + // ignore: deprecated_member_use_from_same_package final feedback = SentryUserFeedback( eventId: id, comments: 'this is awesome', email: 'sentry@example.com', name: 'Rockstar Developer', ); + // ignore: deprecated_member_use_from_same_package await client.captureUserFeedback(feedback); final envelope = fixture.transport.envelopes.first; @@ -1844,10 +1848,12 @@ void main() { test('user feedback envelope contains dsn', () async { final client = fixture.getSut(); final event = SentryEvent(); + // ignore: deprecated_member_use_from_same_package final feedback = SentryUserFeedback( eventId: event.eventId, name: 'test', ); + // ignore: deprecated_member_use_from_same_package await client.captureUserFeedback(feedback); final capturedEnvelope = (fixture.transport).envelopes.first; diff --git a/dart/test/sentry_envelope_item_test.dart b/dart/test/sentry_envelope_item_test.dart index 3f1bad3ee0..9074ee712c 100644 --- a/dart/test/sentry_envelope_item_test.dart +++ b/dart/test/sentry_envelope_item_test.dart @@ -139,11 +139,13 @@ void main() { }); test('fromUserFeedback', () async { + // ignore: deprecated_member_use_from_same_package final userFeedback = SentryUserFeedback( eventId: SentryId.newId(), name: 'name', comments: 'comments', email: 'email'); + // ignore: deprecated_member_use_from_same_package final sut = SentryEnvelopeItem.fromUserFeedback(userFeedback); final expectedData = utf8.encode(jsonEncode( diff --git a/dart/test/sentry_envelope_test.dart b/dart/test/sentry_envelope_test.dart index a24cab20c7..303d3cab63 100644 --- a/dart/test/sentry_envelope_test.dart +++ b/dart/test/sentry_envelope_test.dart @@ -132,10 +132,12 @@ void main() { test('fromUserFeedback', () async { final eventId = SentryId.newId(); + // ignore: deprecated_member_use_from_same_package final userFeedback = SentryUserFeedback( eventId: eventId, name: 'name', email: 'email', comments: 'comments'); final sdkVersion = SdkVersion(name: 'fixture-name', version: 'fixture-version'); + // ignore: deprecated_member_use_from_same_package final sut = SentryEnvelope.fromUserFeedback( userFeedback, sdkVersion, @@ -143,6 +145,7 @@ void main() { ); final expectedEnvelopeItem = + // ignore: deprecated_member_use_from_same_package SentryEnvelopeItem.fromUserFeedback(userFeedback); expect(sut.header.eventId, eventId); diff --git a/dart/test/sentry_user_feedback_test.dart b/dart/test/sentry_user_feedback_test.dart index cb406f65b1..9c5c0c711d 100644 --- a/dart/test/sentry_user_feedback_test.dart +++ b/dart/test/sentry_user_feedback_test.dart @@ -7,9 +7,11 @@ import 'mocks.dart'; import 'mocks/mock_transport.dart'; void main() { + // ignore: deprecated_member_use_from_same_package group('$SentryUserFeedback', () { final id = SentryId.newId(); + // ignore: deprecated_member_use_from_same_package final feedback = SentryUserFeedback( eventId: id, comments: 'this is awesome', @@ -45,6 +47,7 @@ void main() { test('copyWith', () { final id = SentryId.newId(); + // ignore: deprecated_member_use_from_same_package final feedback = SentryUserFeedback( eventId: id, comments: 'this is awesome', @@ -68,17 +71,21 @@ void main() { test('disallow empty id', () { final id = SentryId.empty(); + // ignore: deprecated_member_use_from_same_package expect(() => SentryUserFeedback(eventId: id), throwsA(isA())); }); }); + // ignore: deprecated_member_use_from_same_package group('$SentryUserFeedback to envelops', () { test('to envelope', () { + // ignore: deprecated_member_use_from_same_package final feedback = SentryUserFeedback( eventId: SentryId.newId(), name: 'test', ); + // ignore: deprecated_member_use_from_same_package final envelope = SentryEnvelope.fromUserFeedback( feedback, SdkVersion(name: 'a', version: 'b'), @@ -95,9 +102,11 @@ void main() { }); }); + // ignore: deprecated_member_use_from_same_package test('sending $SentryUserFeedback', () async { final fixture = Fixture(); final sut = fixture.getSut(); + // ignore: deprecated_member_use_from_same_package await sut.captureUserFeedback(SentryUserFeedback( eventId: SentryId.newId(), name: 'test', @@ -106,18 +115,23 @@ void main() { expect(fixture.transport.envelopes.length, 1); }); + // ignore: deprecated_member_use_from_same_package test('cannot create $SentryUserFeedback with empty id', () async { expect( + // ignore: deprecated_member_use_from_same_package () => SentryUserFeedback(eventId: const SentryId.empty()), throwsA(isA()), ); }); + // ignore: deprecated_member_use_from_same_package test('do not send $SentryUserFeedback when disabled', () async { final fixture = Fixture(); final sut = fixture.getSut(); await sut.close(); + // ignore: deprecated_member_use_from_same_package await sut.captureUserFeedback( + // ignore: deprecated_member_use_from_same_package SentryUserFeedback( eventId: SentryId.newId(), name: 'test', @@ -127,10 +141,12 @@ void main() { expect(fixture.transport.envelopes.length, 0); }); + // ignore: deprecated_member_use_from_same_package test('do not send $SentryUserFeedback with empty id', () async { final fixture = Fixture(); final sut = fixture.getSut(); await sut.close(); + // ignore: deprecated_member_use_from_same_package await sut.captureUserFeedback( SentryUserFeedbackWithoutAssert( eventId: SentryId.empty(), @@ -147,7 +163,9 @@ void main() { final sut = Hub(options); await expectLater(() async { + // ignore: deprecated_member_use_from_same_package await sut.captureUserFeedback( + // ignore: deprecated_member_use_from_same_package SentryUserFeedback(eventId: SentryId.newId(), name: 'name'), ); }, returnsNormally); @@ -168,6 +186,7 @@ class Fixture { // You cannot create an instance of SentryUserFeedback with an empty id. // In order to test that UserFeedback with an empty id is not sent // we need to implement it and remove the assert. +// ignore: deprecated_member_use_from_same_package class SentryUserFeedbackWithoutAssert implements SentryUserFeedback { SentryUserFeedbackWithoutAssert({ required this.eventId, @@ -204,12 +223,14 @@ class SentryUserFeedbackWithoutAssert implements SentryUserFeedback { } @override + // ignore: deprecated_member_use_from_same_package SentryUserFeedback copyWith({ SentryId? eventId, String? name, String? email, String? comments, }) { + // ignore: deprecated_member_use_from_same_package return SentryUserFeedback( eventId: eventId ?? this.eventId, name: name ?? this.name, diff --git a/flutter/example/integration_test/integration_test.dart b/flutter/example/integration_test/integration_test.dart index 7a961083b5..d1ae5f876c 100644 --- a/flutter/example/integration_test/integration_test.dart +++ b/flutter/example/integration_test/integration_test.dart @@ -85,6 +85,7 @@ void main() { testWidgets('setup sentry and capture user feedback', (tester) async { await setupSentryAndApp(tester); + // ignore: deprecated_member_use_from_same_package final feedback = SentryUserFeedback( eventId: SentryId.newId(), name: 'fixture-name', diff --git a/flutter/example/lib/user_feedback_dialog.dart b/flutter/example/lib/user_feedback_dialog.dart index 495c9c7b7a..a219db6376 100644 --- a/flutter/example/lib/user_feedback_dialog.dart +++ b/flutter/example/lib/user_feedback_dialog.dart @@ -1,7 +1,6 @@ // ignore_for_file: library_private_types_in_public_api import 'package:flutter/material.dart'; - import 'package:sentry_flutter/sentry_flutter.dart'; class UserFeedbackDialog extends StatefulWidget { @@ -86,6 +85,7 @@ class _UserFeedbackDialogState extends State { ElevatedButton( key: const ValueKey('sentry_submit_feedback_button'), onPressed: () async { + // ignore: deprecated_member_use final feedback = SentryUserFeedback( eventId: widget.eventId, comments: commentController.text, @@ -108,7 +108,9 @@ class _UserFeedbackDialogState extends State { ); } + // ignore: deprecated_member_use Future _submitUserFeedback(SentryUserFeedback feedback) { + // ignore: deprecated_member_use return (widget.hub ?? HubAdapter()).captureUserFeedback(feedback); } }