From 0026762a8413fa4910abb63908822d0e97ea2933 Mon Sep 17 00:00:00 2001 From: Giancarlo Buenaflor Date: Wed, 15 Nov 2023 15:20:44 +0000 Subject: [PATCH] Fixes release of drift & hive (#1729) * Add integrations * Readd changelog * Add drift and hive to bump versions * Formatting and analyze * Update CHANGELOG and fix test * Update changelog * fix analyze issue --- CHANGELOG.md | 6 ++++ drift/lib/src/sentry_query_executor.dart | 5 +++ drift/lib/src/version.dart | 5 +++ drift/test/sentry_database_test.dart | 44 ++++++++++++++++++++++-- hive/lib/src/sentry_hive_impl.dart | 5 +++ hive/lib/src/version.dart | 5 +++ hive/test/sentry_hive_impl_test.dart | 41 ++++++++++++++++++++-- scripts/bump-version.sh | 2 +- 8 files changed, 107 insertions(+), 6 deletions(-) create mode 100644 drift/lib/src/version.dart create mode 100644 hive/lib/src/version.dart diff --git a/CHANGELOG.md b/CHANGELOG.md index 9278de5425..3600c5e78d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## Unreleased + +### 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)) + ## 7.13.0 ### Fixes diff --git a/drift/lib/src/sentry_query_executor.dart b/drift/lib/src/sentry_query_executor.dart index 29697e3c92..aaf453dad7 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,10 @@ 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); _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..1a2f594007 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/lib/src/sentry_hive_impl.dart b/hive/lib/src/sentry_hive_impl.dart index 4eccc87506..83e0e2234a 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 'version.dart'; import 'sentry_box.dart'; import 'sentry_lazy_box.dart'; import 'sentry_hive_interface.dart'; @@ -44,6 +45,10 @@ 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); _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..df5c8502f9 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'; @@ -45,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 { @@ -113,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 { @@ -270,6 +273,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('SentryHiveTracing'), + true, + ); + }); + + test('adds package', () { + expect( + fixture.options.sdk.packages.any( + (element) => + element.name == packageName && element.version == sdkVersion, + ), + true, + ); + }); + }); } class Fixture { 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