|
6 | 6 | </p> |
7 | 7 |
|
8 | 8 | Sentry integration for `hive` package |
9 | | -=========== |
| 9 | +=========== |
| 10 | + |
| 11 | +| package | build | pub | likes | popularity | pub points | |
| 12 | +|-------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------| ------- | |
| 13 | +| sentry_hive | [](https://github.com/getsentry/sentry-dart/actions?query=workflow%3Asentry-hive) | [](https://pub.dev/packages/sentry_hive) | [](https://pub.dev/packages/sentry_hive/score) | [](https://pub.dev/packages/sentry_hive/score) | [](https://pub.dev/packages/sentry_hive/score) |
| 14 | + |
| 15 | +Integration for the [`hive`](https://pub.dev/packages/hive) package. |
| 16 | + |
| 17 | +#### Usage |
| 18 | + |
| 19 | +- Sign up for a Sentry.io account and get a DSN at https://sentry.io. |
| 20 | + |
| 21 | +- Follow the installing instructions on [pub.dev](https://pub.dev/packages/sentry/install). |
| 22 | + |
| 23 | +- Initialize the Sentry SDK using the DSN issued by Sentry.io. |
| 24 | + |
| 25 | +- Call... |
| 26 | + |
| 27 | +```dart |
| 28 | +import 'package:sentry/sentry.dart'; |
| 29 | +import 'package:hive/hive.dart'; |
| 30 | +import 'package:sentry_hive/sentry_hive.dart'; |
| 31 | +
|
| 32 | +Future<void> main() async { |
| 33 | + await SentryFlutter.init( |
| 34 | + (options) { |
| 35 | + options.dsn = 'https://example@sentry.io/add-your-dsn-here'; |
| 36 | + options.tracesSampleRate = 1.0; |
| 37 | + }, |
| 38 | + appRunner: () => runApp(YourApp()), |
| 39 | + ); |
| 40 | +} |
| 41 | +
|
| 42 | +Future<void> insertUser() async { |
| 43 | + // Use [SentryHive] where you would use [Hive] |
| 44 | + SentryHive |
| 45 | + ..init(Directory.current.path) |
| 46 | + ..registerAdapter(PersonAdapter()); |
| 47 | +
|
| 48 | + var box = await SentryHive.openBox('testBox'); |
| 49 | +
|
| 50 | + var person = Person( |
| 51 | + name: 'Dave', |
| 52 | + age: 22, |
| 53 | + ); |
| 54 | +
|
| 55 | + await box.put('dave', person); |
| 56 | +
|
| 57 | + print(box.get('dave')); // Dave: 22 |
| 58 | +} |
| 59 | +
|
| 60 | +@HiveType(typeId: 1) |
| 61 | +class Person { |
| 62 | + Person({required this.name, required this.age}); |
| 63 | +
|
| 64 | + @HiveField(0) |
| 65 | + String name; |
| 66 | +
|
| 67 | + @HiveField(1) |
| 68 | + int age; |
| 69 | +
|
| 70 | + @override |
| 71 | + String toString() { |
| 72 | + return '$name: $age'; |
| 73 | + } |
| 74 | +} |
| 75 | +``` |
| 76 | + |
| 77 | +#### Resources |
| 78 | + |
| 79 | +* [](https://docs.sentry.io/platforms/dart/) |
| 80 | +* [](https://forum.sentry.io/c/sdks) |
| 81 | +* [](https://discord.gg/Ww9hbqr) |
| 82 | +* [](https://stackoverflow.com/questions/tagged/sentry) |
| 83 | +* [](https://twitter.com/intent/follow?screen_name=getsentry) |
0 commit comments