sentry_hive 8.12.0-beta.2 sentry_hive: ^8.12.0-beta.2 copied to clipboard
An integration which adds support for performance tracing for the hive package.
Sentry integration for hive
package #
package | build | pub | likes | popularity | pub points |
---|---|---|---|---|---|
sentry_hive |
Integration for the hive
package.
Usage
-
Sign up for a Sentry.io account and get a DSN at https://sentry.io.
-
Follow the installing instructions on pub.dev.
-
Initialize the Sentry SDK using the DSN issued by Sentry.io.
-
Call...
import 'package:sentry/sentry.dart';
import 'package:hive/hive.dart';
import 'package:sentry_hive/sentry_hive.dart';
import 'package:path_provider/path_provider.dart';
Future<void> main() async {
await SentryFlutter.init(
(options) {
options.dsn = 'https://example@sentry.io/add-your-dsn-here';
options.tracesSampleRate = 1.0;
},
appRunner: () => runApp(YourApp()),
);
}
Future<void> insertUser() async {
// Use [SentryHive] where you would use [Hive]
final appDir = await getApplicationDocumentsDirectory();
SentryHive
..init(appDir.path)
..registerAdapter(PersonAdapter());
var box = await SentryHive.openBox('testBox');
var person = Person(
name: 'Dave',
age: 22,
);
await box.put('dave', person);
print(box.get('dave')); // Dave: 22
}
@HiveType(typeId: 1)
class Person {
Person({required this.name, required this.age});
@HiveField(0)
String name;
@HiveField(1)
int age;
@override
String toString() {
return '$name: $age';
}
}