Skip to content

Commit f12d09d

Browse files
authored
Add isar breadcrumbs (#1800)
1 parent ca7f531 commit f12d09d

File tree

5 files changed

+687
-17
lines changed

5 files changed

+687
-17
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
- Add `ConnectivityIntegration` for web ([#1765](https://github.com/getsentry/sentry-dart/pull/1765))
1010
- We only get the info if online/offline on web platform. The added breadcrumb is set to either `wifi` or `none`.
1111
- APM for isar ([#1726](https://github.com/getsentry/sentry-dart/pull/1726))
12+
- Add isar breadcrumbs ([#1800](https://github.com/getsentry/sentry-dart/pull/1800))
1213
- 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))
1314

1415
### Dependencies

isar/lib/src/sentry_span_helper.dart

+18
Original file line numberDiff line numberDiff line change
@@ -38,28 +38,46 @@ class SentrySpanHelper {
3838
// ignore: invalid_use_of_internal_member
3939
span?.origin = _origin;
4040

41+
var breadcrumb = Breadcrumb(
42+
message: description,
43+
data: {},
44+
type: 'query',
45+
);
46+
4147
span?.setData(SentryIsar.dbSystemKey, SentryIsar.dbSystem);
4248

4349
if (dbName != null) {
4450
span?.setData(SentryIsar.dbNameKey, dbName);
51+
breadcrumb.data?[SentryIsar.dbNameKey] = dbName;
4552
}
4653

4754
if (collectionName != null) {
4855
span?.setData(SentryIsar.dbCollectionKey, collectionName);
56+
breadcrumb.data?[SentryIsar.dbCollectionKey] = collectionName;
4957
}
5058

5159
try {
5260
final result = await execute();
61+
5362
span?.status = SpanStatus.ok();
63+
breadcrumb.data?['status'] = 'ok';
5464

5565
return result;
5666
} catch (exception) {
5767
span?.throwable = exception;
5868
span?.status = SpanStatus.internalError();
5969

70+
breadcrumb.data?['status'] = 'internal_error';
71+
breadcrumb = breadcrumb.copyWith(
72+
level: SentryLevel.warning,
73+
);
74+
6075
rethrow;
6176
} finally {
6277
await span?.finish();
78+
79+
// ignore: invalid_use_of_internal_member
80+
await _hub.scope.addBreadcrumb(breadcrumb);
6381
}
6482
}
6583
}

isar/pubspec.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ environment:
1212
dependencies:
1313
isar: ^3.1.0
1414
isar_flutter_libs: ^3.1.0 # contains Isar Core
15-
sentry: 7.12.0
15+
sentry: 7.14.0
1616
meta: ^1.3.0
1717
path: ^1.8.3
1818

1919
dev_dependencies:
2020
isar_generator: ^3.1.0
21-
build_runner: ^2.4.2
21+
build_runner: ^2.4.6
2222
lints: ^3.0.0
2323
flutter_test:
2424
sdk: flutter

0 commit comments

Comments
 (0)