sentry_hive 8.12.0 copy "sentry_hive: ^8.12.0" to clipboard
sentry_hive: ^8.12.0 copied to clipboard

An integration which adds support for performance tracing for the hive package.

example/example.dart

import 'package:sentry/sentry.dart';
import 'package:hive/hive.dart';
import 'package:sentry_hive/sentry_hive.dart';

part 'main.g.dart';

Future<void> main() async {
  // ATTENTION: Change the DSN below with your own to see the events in Sentry. Get one at sentry.io
  const dsn =
      'https://e85b375ffb9f43cf8bdf9787768149e0@o447951.ingest.sentry.io/5428562';

  await Sentry.init(
    (options) {
      options.dsn = dsn;
      options.tracesSampleRate = 1.0;
      options.debug = true;
    },
    appRunner: runApp, // Init your App.
  );
}

Future<void> runApp() async {
  // Use [SentryHive] where you would use [Hive]
  SentryHive
    ..init(Directory.current.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';
  }
}
3
likes
160
points
1.69k
downloads

Publisher

verified publishersentry.io

Weekly Downloads

An integration which adds support for performance tracing for the hive package.

Homepage
Repository (GitHub)
View/report issues
Contributing

Documentation

API reference

License

MIT (license)

Dependencies

hive, meta, sentry

More

Packages that depend on sentry_hive