Skip to content

Commit

Permalink
Add isar breadcrumbs (#1800)
Browse files Browse the repository at this point in the history
  • Loading branch information
denrase committed Jan 8, 2024
1 parent ca7f531 commit f12d09d
Show file tree
Hide file tree
Showing 5 changed files with 687 additions and 17 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- Add `ConnectivityIntegration` for web ([#1765](https://github.com/getsentry/sentry-dart/pull/1765))
- We only get the info if online/offline on web platform. The added breadcrumb is set to either `wifi` or `none`.
- APM for isar ([#1726](https://github.com/getsentry/sentry-dart/pull/1726))
- Add isar breadcrumbs ([#1800](https://github.com/getsentry/sentry-dart/pull/1800))
- Starting with Flutter 3.16, Sentry adds the [`appFlavor`](https://api.flutter.dev/flutter/services/appFlavor-constant.html) to the `flutter_context` ([#1799](https://github.com/getsentry/sentry-dart/pull/1799))

### Dependencies
Expand Down
18 changes: 18 additions & 0 deletions isar/lib/src/sentry_span_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,28 +38,46 @@ class SentrySpanHelper {
// ignore: invalid_use_of_internal_member
span?.origin = _origin;

var breadcrumb = Breadcrumb(
message: description,
data: {},
type: 'query',
);

span?.setData(SentryIsar.dbSystemKey, SentryIsar.dbSystem);

if (dbName != null) {
span?.setData(SentryIsar.dbNameKey, dbName);
breadcrumb.data?[SentryIsar.dbNameKey] = dbName;
}

if (collectionName != null) {
span?.setData(SentryIsar.dbCollectionKey, collectionName);
breadcrumb.data?[SentryIsar.dbCollectionKey] = collectionName;
}

try {
final result = await execute();

span?.status = SpanStatus.ok();
breadcrumb.data?['status'] = 'ok';

return result;
} catch (exception) {
span?.throwable = exception;
span?.status = SpanStatus.internalError();

breadcrumb.data?['status'] = 'internal_error';
breadcrumb = breadcrumb.copyWith(
level: SentryLevel.warning,
);

rethrow;
} finally {
await span?.finish();

// ignore: invalid_use_of_internal_member
await _hub.scope.addBreadcrumb(breadcrumb);
}
}
}
4 changes: 2 additions & 2 deletions isar/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ environment:
dependencies:
isar: ^3.1.0
isar_flutter_libs: ^3.1.0 # contains Isar Core
sentry: 7.12.0
sentry: 7.14.0
meta: ^1.3.0
path: ^1.8.3

dev_dependencies:
isar_generator: ^3.1.0
build_runner: ^2.4.2
build_runner: ^2.4.6
lints: ^3.0.0
flutter_test:
sdk: flutter
Expand Down

0 comments on commit f12d09d

Please sign in to comment.