[Android] store logs and send later. Does sentry persist breadcrumbs?

Hi,
in our use case we gather the logs but they should be send only after the user agrees on sharing the info with us. Currently sentry tries to send logs as soon as they appear.

We had some workaround around this issue using SentryOptions.BeforeSendCallback hook.
We’ve just converted “Events” to breadcrumbs, and then when we really want to send data we use the info gathered in breadcrumbs to restore true “Event” and send it.

It seems like Sentry doesn’t persist Breadcrumbs.
So assume we gather some breadcrumbs, then app crash / user kill the app. App start again and there are none breadcrumbs available.

I’ve tried to configure cacheDirPath in a hope that it will enable persistance:
options.cacheDirPath = context.filesDir.path + "/sentry/cache"
but it work only partially (only when in Flightmode) there are some files in data/data/app/.

So:

  1. Does Sentry persist breadcrumbs, do they survive app death?
  2. Is there any other way we could store breadcrumbs/event and send them later (not immedietaly?)

Hi, no, breadcrumbs are not persisted, please upvote this issue Retain breadcrumbs even if Android kill app process · Issue #547 · getsentry/sentry-java · GitHub if that’s very important for you.

user consent is something we don’t deal with just yet, the best idea would be either to not init. the SDK till the user has given consent otherwise the SDK will send all of its data if there’s an available connection or as just you did, using the BeforeSendCallback.

Answering your question, we still don’t have this mode that caches all the events and sends them later only if the user has given consent.

Please raise a feat request GitHub - getsentry/sentry-java: A Sentry SDK for Java, Android and other JVM languages. so people can upvote it, thanks.