Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes release of drift & hive #1729

Merged
merged 7 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 5 additions & 0 deletions drift/lib/src/sentry_query_executor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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);
}

Expand Down
5 changes: 5 additions & 0 deletions drift/lib/src/version.dart
Original file line number Diff line number Diff line change
@@ -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';
44 changes: 41 additions & 3 deletions drift/test/sentry_database_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
5 changes: 5 additions & 0 deletions hive/lib/src/sentry_hive_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);
}
Expand Down
5 changes: 5 additions & 0 deletions hive/lib/src/version.dart
Original file line number Diff line number Diff line change
@@ -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';
41 changes: 39 additions & 2 deletions hive/test/sentry_hive_impl_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion scripts/bump-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading