Flutter - include additional logs in case of errors only

Hi all,
newbie here, enjoying sentry so far :slight_smile:
My question: I would like to include some logging information only in case of errors, i.e. to trace back what the user was doing just before the crash.
I have tried to use Sentry.captureMessage(msg) but it seems to me that it logs all messages, with no condition on an actual crash.

Do you know if this is possible, and how?

This is something Breadcrumbs work well.

Throughout your app you can call Sentry.addBreadcrumb to add relevant information, and when an event (error or a captureMessage or similar) happens, all the previous 100 crumbs (configurable) are sent with that event.

Sentry SDK for Flutter is adding support to include calls to print as Breadcrumbs automatically. So if youโ€™re already using print this should work OOTB once the feature is shipped.

The Sentry.addBreadcrumb API is more rich since you can add a level, category, etc.

Thanks, seems fine!