From c037e78a0b2fe247c30e5ed402b68c4c5b90362e Mon Sep 17 00:00:00 2001 From: GIancarlo Buenaflor Date: Wed, 15 Nov 2023 15:47:23 +0100 Subject: [PATCH 1/7] Add integrations --- drift/lib/src/sentry_query_executor.dart | 4 +++ drift/lib/src/version.dart | 5 +++ drift/test/sentry_database_test.dart | 44 ++++++++++++++++++++++-- hive/CHANGELOG.md | 1 - hive/lib/src/sentry_hive_impl.dart | 4 +++ hive/lib/src/version.dart | 5 +++ hive/test/sentry_hive_impl_test.dart | 36 +++++++++++++++++++ 7 files changed, 95 insertions(+), 4 deletions(-) create mode 100644 drift/lib/src/version.dart delete mode 120000 hive/CHANGELOG.md create mode 100644 hive/lib/src/version.dart diff --git a/drift/lib/src/sentry_query_executor.dart b/drift/lib/src/sentry_query_executor.dart index 29697e3c92..6bf7939b64 100644 --- a/drift/lib/src/sentry_query_executor.dart +++ b/drift/lib/src/sentry_query_executor.dart @@ -4,6 +4,7 @@ import 'package:drift/backends.dart'; import 'package:drift/drift.dart'; import 'package:meta/meta.dart'; import 'package:sentry/sentry.dart'; +import 'version.dart'; import 'sentry_span_helper.dart'; import 'sentry_transaction_executor.dart'; @@ -56,6 +57,9 @@ class SentryQueryExecutor extends QueryExecutor { }) : _hub = hub ?? HubAdapter(), _dbName = databaseName, _executor = queryExecutor ?? LazyDatabase(opener) { + final options = _hub.options; + options.sdk.addIntegration('SentryDriftTracing'); + options.sdk.addPackage(packageName, sdkVersion); _spanHelper.setHub(_hub); } diff --git a/drift/lib/src/version.dart b/drift/lib/src/version.dart new file mode 100644 index 0000000000..42f7bd4ad9 --- /dev/null +++ b/drift/lib/src/version.dart @@ -0,0 +1,5 @@ +/// The SDK version reported to Sentry.io in the submitted events. +const String sdkVersion = '7.13.0'; + +/// The package name reported to Sentry.io in the submitted events. +const String packageName = 'pub:sentry_drift'; diff --git a/drift/test/sentry_database_test.dart b/drift/test/sentry_database_test.dart index 2b3dd96536..6486f181d0 100644 --- a/drift/test/sentry_database_test.dart +++ b/drift/test/sentry_database_test.dart @@ -10,6 +10,7 @@ import 'package:sentry/sentry.dart'; import 'package:sentry/src/sentry_tracer.dart'; import 'package:sentry_drift/src/sentry_query_executor.dart'; import 'package:sentry_drift/src/sentry_transaction_executor.dart'; +import 'package:sentry_drift/src/version.dart'; import 'package:sqlite3/open.dart'; import 'mocks/mocks.mocks.dart'; @@ -118,10 +119,11 @@ void main() { setUp(() async { fixture = Fixture(); - await fixture.setUp(); when(fixture.hub.options).thenReturn(fixture.options); when(fixture.hub.getSpan()).thenReturn(fixture.tracer); + + await fixture.setUp(); }); tearDown(() async { @@ -375,10 +377,11 @@ void main() { setUp(() async { fixture = Fixture(); - await fixture.setUp(); when(fixture.hub.options).thenReturn(fixture.options); when(fixture.hub.getSpan()).thenReturn(fixture.tracer); + + await fixture.setUp(); }); tearDown(() async { @@ -410,12 +413,13 @@ void main() { setUp(() async { fixture = Fixture(); - await fixture.setUp(injectMock: true); when(fixture.hub.options).thenReturn(fixture.options); when(fixture.hub.getSpan()).thenReturn(fixture.tracer); when(fixture.mockLazyDatabase.ensureOpen(any)) .thenAnswer((_) => Future.value(true)); + + await fixture.setUp(injectMock: true); }); tearDown(() async { @@ -597,6 +601,40 @@ void main() { ); }); }); + + group('integrations', () { + late Fixture fixture; + + setUp(() async { + fixture = Fixture(); + + when(fixture.hub.options).thenReturn(fixture.options); + when(fixture.hub.getSpan()).thenReturn(fixture.tracer); + + await fixture.setUp(); + }); + + tearDown(() async { + await fixture.tearDown(); + }); + + test('adds integration', () { + expect( + fixture.options.sdk.integrations.contains('SentryDriftTracing'), + true, + ); + }); + + test('adds package', () { + expect( + fixture.options.sdk.packages.any( + (element) => + element.name == packageName && element.version == sdkVersion, + ), + true, + ); + }); + }); } class Fixture { diff --git a/hive/CHANGELOG.md b/hive/CHANGELOG.md deleted file mode 120000 index 04c99a55ca..0000000000 --- a/hive/CHANGELOG.md +++ /dev/null @@ -1 +0,0 @@ -../CHANGELOG.md \ No newline at end of file diff --git a/hive/lib/src/sentry_hive_impl.dart b/hive/lib/src/sentry_hive_impl.dart index 4eccc87506..58b7b05e39 100644 --- a/hive/lib/src/sentry_hive_impl.dart +++ b/hive/lib/src/sentry_hive_impl.dart @@ -3,6 +3,7 @@ import 'dart:typed_data'; import 'package:hive/hive.dart'; import 'package:meta/meta.dart'; import 'package:sentry/sentry.dart'; +import 'package:sentry_hive/src/version.dart'; import 'sentry_box.dart'; import 'sentry_lazy_box.dart'; import 'sentry_hive_interface.dart'; @@ -44,6 +45,9 @@ class SentryHiveImpl implements SentryHiveInterface { @override void setHub(Hub hub) { + final options = hub.options; + options.sdk.addIntegration('SentryHiveTracing'); + options.sdk.addPackage(packageName, sdkVersion); _hub = hub; _spanHelper.setHub(hub); } diff --git a/hive/lib/src/version.dart b/hive/lib/src/version.dart new file mode 100644 index 0000000000..30f3add162 --- /dev/null +++ b/hive/lib/src/version.dart @@ -0,0 +1,5 @@ +/// The SDK version reported to Sentry.io in the submitted events. +const String sdkVersion = '7.13.0'; + +/// The package name reported to Sentry.io in the submitted events. +const String packageName = 'pub:sentry_hive'; diff --git a/hive/test/sentry_hive_impl_test.dart b/hive/test/sentry_hive_impl_test.dart index 5bca3b75db..261ce6511f 100644 --- a/hive/test/sentry_hive_impl_test.dart +++ b/hive/test/sentry_hive_impl_test.dart @@ -9,6 +9,7 @@ import 'package:sentry/src/sentry_tracer.dart'; import 'package:sentry_hive/src/sentry_box.dart'; import 'package:sentry_hive/src/sentry_hive_impl.dart'; import 'package:sentry_hive/src/sentry_lazy_box.dart'; +import 'package:sentry_hive/src/version.dart'; import 'package:test/test.dart'; import 'mocks/mocks.mocks.dart'; @@ -270,6 +271,41 @@ void main() { ); }); }); + + group('integrations', () { + late Fixture fixture; + + setUp(() async { + fixture = Fixture(); + + when(fixture.hub.options).thenReturn(fixture.options); + when(fixture.hub.getSpan()).thenReturn(fixture.tracer); + + await fixture.setUp(); + }); + + tearDown(() async { + await fixture.tearDown(); + }); + + test('adds integration', () { + print(fixture.options.sdk.integrations.length); + expect( + fixture.options.sdk.integrations.contains('SentryHiveTracing'), + true, + ); + }); + + test('adds package', () { + expect( + fixture.options.sdk.packages.any( + (element) => + element.name == packageName && element.version == sdkVersion, + ), + true, + ); + }); + }); } class Fixture { From b79b66009682e67acecebfe06fe826d1eb8ff24b Mon Sep 17 00:00:00 2001 From: GIancarlo Buenaflor Date: Wed, 15 Nov 2023 15:48:16 +0100 Subject: [PATCH 2/7] Readd changelog --- hive/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) create mode 120000 hive/CHANGELOG.md diff --git a/hive/CHANGELOG.md b/hive/CHANGELOG.md new file mode 120000 index 0000000000..04c99a55ca --- /dev/null +++ b/hive/CHANGELOG.md @@ -0,0 +1 @@ +../CHANGELOG.md \ No newline at end of file From 5d1ff190d2254c68ca2be8cbeb43d73616a16844 Mon Sep 17 00:00:00 2001 From: GIancarlo Buenaflor Date: Wed, 15 Nov 2023 15:48:44 +0100 Subject: [PATCH 3/7] Add drift and hive to bump versions --- scripts/bump-version.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/bump-version.sh b/scripts/bump-version.sh index 30ddf659dd..d3e8fae081 100755 --- a/scripts/bump-version.sh +++ b/scripts/bump-version.sh @@ -10,7 +10,7 @@ NEW_VERSION="${2}" echo "Current version: ${OLD_VERSION}" echo "Bumping version: ${NEW_VERSION}" -for pkg in {dart,flutter,logging,dio,file,sqflite}; do +for pkg in {dart,flutter,logging,dio,file,sqflite,drift,hive}; do # Bump version in pubspec.yaml perl -pi -e "s/^version: .*/version: $NEW_VERSION/" $pkg/pubspec.yaml # Bump sentry dependency version in pubspec.yaml From 953791cf79decbc6ec6286f29730b8b9d4215cd1 Mon Sep 17 00:00:00 2001 From: GIancarlo Buenaflor Date: Wed, 15 Nov 2023 15:51:15 +0100 Subject: [PATCH 4/7] Formatting and analyze --- drift/lib/src/sentry_query_executor.dart | 1 + drift/test/sentry_database_test.dart | 4 ++-- hive/lib/src/sentry_hive_impl.dart | 1 + hive/test/sentry_hive_impl_test.dart | 5 ++--- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/drift/lib/src/sentry_query_executor.dart b/drift/lib/src/sentry_query_executor.dart index 6bf7939b64..aaf453dad7 100644 --- a/drift/lib/src/sentry_query_executor.dart +++ b/drift/lib/src/sentry_query_executor.dart @@ -57,6 +57,7 @@ class SentryQueryExecutor extends QueryExecutor { }) : _hub = hub ?? HubAdapter(), _dbName = databaseName, _executor = queryExecutor ?? LazyDatabase(opener) { + // ignore: invalid_use_of_internal_member final options = _hub.options; options.sdk.addIntegration('SentryDriftTracing'); options.sdk.addPackage(packageName, sdkVersion); diff --git a/drift/test/sentry_database_test.dart b/drift/test/sentry_database_test.dart index 6486f181d0..1a2f594007 100644 --- a/drift/test/sentry_database_test.dart +++ b/drift/test/sentry_database_test.dart @@ -628,8 +628,8 @@ void main() { test('adds package', () { expect( fixture.options.sdk.packages.any( - (element) => - element.name == packageName && element.version == sdkVersion, + (element) => + element.name == packageName && element.version == sdkVersion, ), true, ); diff --git a/hive/lib/src/sentry_hive_impl.dart b/hive/lib/src/sentry_hive_impl.dart index 58b7b05e39..7a3ce43ea8 100644 --- a/hive/lib/src/sentry_hive_impl.dart +++ b/hive/lib/src/sentry_hive_impl.dart @@ -45,6 +45,7 @@ class SentryHiveImpl implements SentryHiveInterface { @override void setHub(Hub hub) { + // ignore: invalid_use_of_internal_member final options = hub.options; options.sdk.addIntegration('SentryHiveTracing'); options.sdk.addPackage(packageName, sdkVersion); diff --git a/hive/test/sentry_hive_impl_test.dart b/hive/test/sentry_hive_impl_test.dart index 261ce6511f..9ded4066e3 100644 --- a/hive/test/sentry_hive_impl_test.dart +++ b/hive/test/sentry_hive_impl_test.dart @@ -289,7 +289,6 @@ void main() { }); test('adds integration', () { - print(fixture.options.sdk.integrations.length); expect( fixture.options.sdk.integrations.contains('SentryHiveTracing'), true, @@ -299,8 +298,8 @@ void main() { test('adds package', () { expect( fixture.options.sdk.packages.any( - (element) => - element.name == packageName && element.version == sdkVersion, + (element) => + element.name == packageName && element.version == sdkVersion, ), true, ); From 83be1294c2ebd3bd9b475e4f900b70e582776776 Mon Sep 17 00:00:00 2001 From: GIancarlo Buenaflor Date: Wed, 15 Nov 2023 15:55:56 +0100 Subject: [PATCH 5/7] Update CHANGELOG and fix test --- CHANGELOG.md | 6 ++++++ hive/test/sentry_hive_impl_test.dart | 6 ++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9278de5425..f71f32d379 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## Unreleased + +### Fix + +- Fixes release of drift & hive and adds missing integration & sdk version information in the hub options ([#1729](https://github.com/getsentry/sentry-dart/pull/1729)) + ## 7.13.0 ### Fixes diff --git a/hive/test/sentry_hive_impl_test.dart b/hive/test/sentry_hive_impl_test.dart index 9ded4066e3..df5c8502f9 100644 --- a/hive/test/sentry_hive_impl_test.dart +++ b/hive/test/sentry_hive_impl_test.dart @@ -46,10 +46,11 @@ void main() { setUp(() async { fixture = Fixture(); - await fixture.setUp(); when(fixture.hub.options).thenReturn(fixture.options); when(fixture.hub.getSpan()).thenReturn(fixture.tracer); + + await fixture.setUp(); }); tearDown(() async { @@ -114,11 +115,12 @@ void main() { setUp(() async { fixture = Fixture(); - await fixture.setUp(injectMockHive: true); when(fixture.hub.options).thenReturn(fixture.options); when(fixture.hub.getSpan()).thenReturn(fixture.tracer); when(fixture.mockHive.close()).thenAnswer((_) async => {}); + + await fixture.setUp(injectMockHive: true); }); test('throwing boxExists adds error span', () async { From 5dd6e178490779b60e1563395e981a8f28adb2b9 Mon Sep 17 00:00:00 2001 From: GIancarlo Buenaflor Date: Wed, 15 Nov 2023 15:56:06 +0100 Subject: [PATCH 6/7] Update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f71f32d379..3600c5e78d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## Unreleased -### Fix +### Fixes - Fixes release of drift & hive and adds missing integration & sdk version information in the hub options ([#1729](https://github.com/getsentry/sentry-dart/pull/1729)) From e6e9ac121984585198abe461934f587d034e69d6 Mon Sep 17 00:00:00 2001 From: GIancarlo Buenaflor Date: Wed, 15 Nov 2023 16:01:19 +0100 Subject: [PATCH 7/7] fix analyze issue --- hive/lib/src/sentry_hive_impl.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hive/lib/src/sentry_hive_impl.dart b/hive/lib/src/sentry_hive_impl.dart index 7a3ce43ea8..83e0e2234a 100644 --- a/hive/lib/src/sentry_hive_impl.dart +++ b/hive/lib/src/sentry_hive_impl.dart @@ -3,7 +3,7 @@ import 'dart:typed_data'; import 'package:hive/hive.dart'; import 'package:meta/meta.dart'; import 'package:sentry/sentry.dart'; -import 'package:sentry_hive/src/version.dart'; +import 'version.dart'; import 'sentry_box.dart'; import 'sentry_lazy_box.dart'; import 'sentry_hive_interface.dart';