Skip to content

Decouple SentryAndroid initialisation from Events sending #1752

Closed
@pchoroscin

Description

@pchoroscin

Discussed in #1751

Originally posted by PGliw October 4, 2021
SentryAndroid does call installDefaultIntegrations in init Method.
There are some integrations included that are not "the best" choice for my use case.
(SendCachedEventFireAndForgetIntegration and EnvelopeFileObserverIntegration I suppose).

The workflow I do want to achieve is following (assuming #1739 is closed by the time):

  1. First, init SentryAndroid framework, so breadcrumbs are collected
  2. Do not send any events automatically!
  3. Check if there was a crash during last app run
  4. If there was, ask the user what to do with the crash event
  5. If the user wants to send the cached event, send it. Otherwise just delete the event from the cache.

Sadly, because of coupling SentryAndroid.init with SendCachedEventFireAndForgetIntegration, the crash reports are being sent once the app was started after crash. So it's impossible to achieve step 2. having done step 1., isn't it?
Could the initialisation of the framework (that is initialisation of collecting breadcrumbs etc.) be decoupled from sending the cached events? And could sending the events be made "on-demand"?

I assume it's impossible because of coupling SendCachedEventFireAndForgetIntegration integration's register method to submitting sending tasks, isn't it? And there is no clean way to enable/disable it on demand.

It might be way of doing it by implementing custom TransportGate, but how to invoke SendCachedEventFireAndForgetIntegration later, once we need to send the event? (see point 5.)

Also sending the crash event should not be done after the crash, by on-demand on the next start of the app (UncaughtExceptionHandlerIntegration seems to do the opposite by default?)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions