Skip to content

OnCrashedLastRun for MAUI Android #4044

Closed

Description

@dalux-era

Problem Statement

Hi, in one of the most recent updates this issue was resolved by merging OnCrashLastRun for iOS C# implementation #3958.
However, when setting up SentrySdk in MAUI options.CrashedLastRun is always null for Android, even if its a startup after a cash. Is it possible to add OnCrashLastRun for Android MAUI as well, or maybe we are not using options.CrashedLastRun correctly. There are no Samples on how to detect the result of the Func.

Solution Brainstorm

No response

Activity

  1. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Mar 18, 2025
  2. jamescrosswell commented on Mar 18, 2025

    @jamescrosswell
    Collaborator

    It looks like we're exposing whether a crash occurred or not:

    options.CrashedLastRun = () => JavaSdk.Sentry.IsCrashedLastRun()?.BooleanValue() is true;

    However there's not yet any callback where you can see what the event was.

    @adinauer does that functionality exist in the Java SDK?

  3. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Mar 18, 2025
  4. adinauer commented on Mar 19, 2025

    @adinauer
    Member

    I'm not aware of that functionality. As far as I know any event from a previous run is sent to Sentry without going through public callbacks (EnvelopeSender -> Scopes.captureEnvelope -> SentryClient.captureEnvelope.

    There is an internal callback it should go through (beforeEnvelopeCallback) but that is used for Spotlight.

    Maybe @markushi knows a different way and/or can confirm this.

  5. markushi commented on Mar 19, 2025

    @markushi
    Member

    On Android a crash is usually reported and sent to sentry right after it is detected. Thus the crash event is not available anymore on the next app run. You should still be able to use hooks like beforeSend on Android, but based on the above they will be executed right after the crash occured.

  6. dalux-era commented on Mar 19, 2025

    @dalux-era
    Author

    While initiating Sentry for MAUI the options.CrashedLastRun is always null. Maybe the following line is run later?
    options.CrashedLastRun = () => JavaSdk.Sentry.IsCrashedLastRun()?.BooleanValue() is true;

    I know iOS implementation has the feature added to the sample, could the android sample also be updated to expose how CrashedLatRun should be interpreted in the consumer code?

  7. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Mar 19, 2025
  8. jamescrosswell commented on Mar 19, 2025

    @jamescrosswell
    Collaborator

    could the android sample also be updated to expose how CrashedLatRun should be interpreted in the consumer code?

    @dalux-era that sounds like a good idea. I've added #4048 to track this.

    While initiating Sentry for MAUI the options.CrashedLastRun is always null. Maybe the following line is run later?
    options.CrashedLastRun = () => JavaSdk.Sentry.IsCrashedLastRun()?.BooleanValue() is true;

    Yes, this gets wired up in the call to InitSentryAndroidSdk, which occurs part way through initialising the Sentry SDK. You won't be able to rely on getting a value back from this until after the SDK has been initialised.

  9. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Mar 19, 2025
  10. jamescrosswell commented on Mar 28, 2025

    @jamescrosswell
    Collaborator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions