Groveman Sentry

pub License: MIT groveman_sentry codecov

Tree for the groveman.

It sends your logs to the Sentry.

This works perfectly with sentry-dart and sentry-flutter 🙌

Usage

Add it in your pubspec.yaml:

dependencies:    
  groveman:
  groveman_sentry:
  sentry: 
  // or
  sentry_flutter: 

Import it where you want to use it e.g, in your main file.

import 'package:groveman/groveman.dart';
import 'package:groveman_sentry/groveman_sentry.dart';

Initialize Sentry and plant the SentryTree at the start of your application.

import 'package:flutter/widgets.dart';
import 'package:groveman/groveman.dart';
import 'package:groveman_sentry/groveman_sentry.dart';
import 'package:sentry_flutter/sentry_flutter.dart';

void main() {  
  Groveman.plantTree(DebugTree());
  Groveman.captureErrorInZone(() async {
    WidgetsFlutterBinding.ensureInitialized();
    await SentryFlutter.init(
      (options) {
        options.dsn = 'https://[email protected]/add-your-dsn-here';
      },
    );    
    if (kReleaseMode) {
      Groveman.plantTree(SentryTree());
    }
    Groveman.captureErrorInCurrentIsolate();
    runApp(const MyApp());
  });
}

Usually, you only send your logs in production.

By default, the log levels info, warning, error, and fatal are sent to Sentry.

Groveman.error(message, error: exception);

If the LogRecord.error is not null, it will be sent using captureEvent, otherwise, is used addBreadcrumb.

LogRecord converted in SentryEvent:

  • LogRecord.level -> SentryLevel
  • LogRecord.message -> SentryMessage(message)
  • LogRecord.extra -> extra
  • LogRecord.error -> throwable
  • LogRecord.tag -> tags

groveman is sent as logger in SentryEvent.
The LogRecord.stackTrace is only sent in captureEvent.

LogRecord converted in Breadcrumb:

  • LogRecord.level -> SentryLevel
  • LogRecord.message -> message
  • LogRecord.extra -> data

To custom, pass the levels that desire to send when creating the SentryTree.

Groveman.plantTree(
    SentryTree(logLevels: [
        LogLevel.warning,
        LogLevel.info,
    ]),
  );
);

📝 License

Copyright © 2022 Kauê Martins
This project is MIT licensed

Libraries

groveman_sentry