From c120606d67324b239549b9aba7d8a5122cd9298b Mon Sep 17 00:00:00 2001 From: GIancarlo Buenaflor Date: Wed, 10 Jul 2024 17:12:12 +0200 Subject: [PATCH 1/6] deprecate --- dart/lib/src/scope.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dart/lib/src/scope.dart b/dart/lib/src/scope.dart index 3fef9a92a2..63123c89cb 100644 --- a/dart/lib/src/scope.dart +++ b/dart/lib/src/scope.dart @@ -268,6 +268,7 @@ class Scope { } /// Sets an extra to the Scope + @Deprecated('Additional Data is deprecated in favor of structured Contexts and should be avoided when possible') Future setExtra(String key, dynamic value) async { _setExtraSync(key, value); await _callScopeObservers( @@ -275,6 +276,7 @@ class Scope { } /// Removes an extra from the Scope + @Deprecated('Additional Data is deprecated in favor of structured Contexts and should be avoided when possible') Future removeExtra(String key) async { _extra.remove(key); await _callScopeObservers( From dd79ce9d42a5f576d154b0a12b37e32017626fe9 Mon Sep 17 00:00:00 2001 From: GIancarlo Buenaflor Date: Wed, 10 Jul 2024 17:12:39 +0200 Subject: [PATCH 2/6] update --- dart/lib/src/scope.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dart/lib/src/scope.dart b/dart/lib/src/scope.dart index 63123c89cb..cc6636e56e 100644 --- a/dart/lib/src/scope.dart +++ b/dart/lib/src/scope.dart @@ -268,7 +268,7 @@ class Scope { } /// Sets an extra to the Scope - @Deprecated('Additional Data is deprecated in favor of structured Contexts and should be avoided when possible') + @Deprecated('Additional data is deprecated in favor of structured Contexts and should be avoided when possible') Future setExtra(String key, dynamic value) async { _setExtraSync(key, value); await _callScopeObservers( @@ -276,7 +276,7 @@ class Scope { } /// Removes an extra from the Scope - @Deprecated('Additional Data is deprecated in favor of structured Contexts and should be avoided when possible') + @Deprecated('Additional data is deprecated in favor of structured Contexts and should be avoided when possible') Future removeExtra(String key) async { _extra.remove(key); await _callScopeObservers( From c2b96e986b3c2d095f0bf500675bfc9cfd98e7bf Mon Sep 17 00:00:00 2001 From: GIancarlo Buenaflor Date: Wed, 10 Jul 2024 18:52:34 +0200 Subject: [PATCH 3/6] Update deprecate message --- dart/lib/src/scope.dart | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/dart/lib/src/scope.dart b/dart/lib/src/scope.dart index cc6636e56e..15ce065752 100644 --- a/dart/lib/src/scope.dart +++ b/dart/lib/src/scope.dart @@ -268,7 +268,8 @@ class Scope { } /// Sets an extra to the Scope - @Deprecated('Additional data is deprecated in favor of structured Contexts and should be avoided when possible') + @Deprecated( + 'Use Contexts instead. Additional data is deprecated in favor of structured Contexts and should be avoided when possible') Future setExtra(String key, dynamic value) async { _setExtraSync(key, value); await _callScopeObservers( @@ -276,7 +277,8 @@ class Scope { } /// Removes an extra from the Scope - @Deprecated('Additional data is deprecated in favor of structured Contexts and should be avoided when possible') + @Deprecated( + 'Use Contexts instead. Additional data is deprecated in favor of structured Contexts and should be avoided when possible') Future removeExtra(String key) async { _extra.remove(key); await _callScopeObservers( From 6992954df269f65897e04287c1b5abeb1e189d02 Mon Sep 17 00:00:00 2001 From: GIancarlo Buenaflor Date: Wed, 10 Jul 2024 18:57:02 +0200 Subject: [PATCH 4/6] Update CHANGELOG --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 88967b15dc..1e9e124c6a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,11 @@ - [changelog](https://github.com/getsentry/sentry-cocoa/blob/main/CHANGELOG.md#8301) - [diff](https://github.com/getsentry/sentry-cocoa/compare/8.30.0...8.30.1) +### Deprecated + +- Deprecate `setExtra` and `removeExtra` ([#2159](https://github.com/getsentry/sentry-dart/pull/2159)) + - Use the `Contexts` structure via `setContexts` instead + ## 8.4.0-beta.1 ### Features From aec136c47f6372c5951b90fbfc5e7830ec1158b8 Mon Sep 17 00:00:00 2001 From: GIancarlo Buenaflor Date: Wed, 10 Jul 2024 19:01:49 +0200 Subject: [PATCH 5/6] Formatting and ignore warnings --- dart/example_web/web/main.dart | 1 + dart/example_web_legacy/web/main.dart | 1 + dart/test/scope_test.dart | 7 +++---- dart/test/sentry_client_test.dart | 1 + 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/dart/example_web/web/main.dart b/dart/example_web/web/main.dart index b39a05e0dc..3c0305b49e 100644 --- a/dart/example_web/web/main.dart +++ b/dart/example_web/web/main.dart @@ -44,6 +44,7 @@ Future runApp() async { ..transaction = '/example/app' ..level = SentryLevel.warning; await scope.setTag('build', '579'); + // ignore: deprecated_member_use await scope.setExtra('company-name', 'Dart Inc'); await scope.setUser( diff --git a/dart/example_web_legacy/web/main.dart b/dart/example_web_legacy/web/main.dart index 3034effe9b..506bedf159 100644 --- a/dart/example_web_legacy/web/main.dart +++ b/dart/example_web_legacy/web/main.dart @@ -44,6 +44,7 @@ Future runApp() async { ..transaction = '/example/app' ..level = SentryLevel.warning; await scope.setTag('build', '579'); + // ignore: deprecated_member_use await scope.setExtra('company-name', 'Dart Inc'); await scope.setUser( diff --git a/dart/test/scope_test.dart b/dart/test/scope_test.dart index 66cc543b6b..8a535541c1 100644 --- a/dart/test/scope_test.dart +++ b/dart/test/scope_test.dart @@ -1,3 +1,5 @@ +// ignore_for_file: deprecated_member_use_from_same_package + import 'package:collection/collection.dart'; import 'package:sentry/sentry.dart'; import 'package:sentry/src/sentry_tracer.dart'; @@ -417,7 +419,6 @@ void main() { test('apply context to event', () async { final event = SentryEvent( tags: const {'etag': '987'}, - // ignore: deprecated_member_use_from_same_package extra: const {'e-infos': 'abc'}, ); final scope = Scope(SentryOptions(dsn: fakeDsn)) @@ -442,9 +443,7 @@ void main() { expect(updatedEvent?.tags, {'etag': '987', 'build': '579', 'page-locale': 'en-us'}); expect( - // ignore: deprecated_member_use_from_same_package - updatedEvent?.extra, - {'e-infos': 'abc', 'company-name': 'Dart Inc'}); + updatedEvent?.extra, {'e-infos': 'abc', 'company-name': 'Dart Inc'}); expect(updatedEvent?.contexts['theme'], {'value': 'material'}); }); diff --git a/dart/test/sentry_client_test.dart b/dart/test/sentry_client_test.dart index 153c1515f0..a64ab2142c 100644 --- a/dart/test/sentry_client_test.dart +++ b/dart/test/sentry_client_test.dart @@ -812,6 +812,7 @@ void main() { ..fingerprint = fingerprint ..addBreadcrumb(crumb) ..setTag(scopeTagKey, scopeTagValue) + // ignore: deprecated_member_use_from_same_package ..setExtra(scopeExtraKey, scopeExtraValue); scope.setUser(user); From 6d446b88bdfa2ae285e0c7453f7bbc91c5043ff0 Mon Sep 17 00:00:00 2001 From: GIancarlo Buenaflor Date: Fri, 12 Jul 2024 01:04:54 +0200 Subject: [PATCH 6/6] analyze --- .../integration_test/integration_test.dart | 6 ++++-- flutter/example/lib/main.dart | 17 +++++++++-------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/flutter/example/integration_test/integration_test.dart b/flutter/example/integration_test/integration_test.dart index 570b8c1fe2..7a961083b5 100644 --- a/flutter/example/integration_test/integration_test.dart +++ b/flutter/example/integration_test/integration_test.dart @@ -6,10 +6,10 @@ import 'dart:convert'; import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:sentry_flutter/sentry_flutter.dart'; -import 'package:sentry_flutter_example/main.dart'; import 'package:http/http.dart'; +import 'package:sentry_flutter/sentry_flutter.dart'; import 'package:sentry_flutter/src/integrations/native_app_start_integration.dart'; +import 'package:sentry_flutter_example/main.dart'; void main() { // const org = 'sentry-sdks'; @@ -121,7 +121,9 @@ void main() { await scope.addBreadcrumb(breadcrumb); await scope.clearBreadcrumbs(); + // ignore: deprecated_member_use await scope.setExtra('extra-key', 'extra-value'); + // ignore: deprecated_member_use await scope.removeExtra('extra-key'); await scope.setTag('tag-key', 'tag-value'); diff --git a/flutter/example/lib/main.dart b/flutter/example/lib/main.dart index 86da143e31..784a6b30df 100644 --- a/flutter/example/lib/main.dart +++ b/flutter/example/lib/main.dart @@ -4,31 +4,31 @@ import 'dart:async'; import 'dart:convert'; import 'dart:math'; +import 'package:dio/dio.dart'; +import 'package:feedback/feedback.dart' as feedback; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:logging/logging.dart'; import 'package:path_provider/path_provider.dart'; +import 'package:provider/provider.dart'; +import 'package:sentry_dio/sentry_dio.dart'; import 'package:sentry_drift/sentry_drift.dart'; import 'package:sentry_flutter/sentry_flutter.dart'; +import 'package:sentry_hive/sentry_hive.dart'; import 'package:sentry_isar/sentry_isar.dart'; +import 'package:sentry_logging/sentry_logging.dart'; import 'package:sentry_sqflite/sentry_sqflite.dart'; import 'package:sqflite/sqflite.dart'; - // import 'package:sqflite_common_ffi/sqflite_ffi.dart'; // import 'package:sqflite_common_ffi_web/sqflite_ffi_web.dart'; import 'package:universal_platform/universal_platform.dart'; -import 'package:feedback/feedback.dart' as feedback; -import 'package:provider/provider.dart'; + import 'auto_close_screen.dart'; -import 'drift/database.dart'; import 'drift/connection/connection.dart'; +import 'drift/database.dart'; import 'isar/user.dart'; import 'user_feedback_dialog.dart'; -import 'package:dio/dio.dart'; -import 'package:sentry_dio/sentry_dio.dart'; -import 'package:sentry_logging/sentry_logging.dart'; -import 'package:sentry_hive/sentry_hive.dart'; // ATTENTION: Change the DSN below with your own to see the events in Sentry. Get one at sentry.io const String exampleDsn = @@ -474,6 +474,7 @@ class MainScaffold extends StatelessWidget { final entries = feedback.extra?.entries; if (entries != null) { for (final extra in entries) { + // ignore: deprecated_member_use scope.setExtra(extra.key, extra.value); } }