Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crashlytics groups unrelated logs #124

Open
ninovanhooff opened this issue May 17, 2024 · 0 comments
Open

Crashlytics groups unrelated logs #124

ninovanhooff opened this issue May 17, 2024 · 0 comments

Comments

@ninovanhooff
Copy link

Google Crashlytics has a feature to log non-fatal errors using (Android): Firebase.crashlytics.recordException

It takes a throwable as an argument. But let's say you want to log a non-fatal event that doesn't have an Exception associated with it. For example: "Logged-in user does not exist", "Cannot handle objects of type X" etc.

I implemented it in our CrashlyticsLogger like so:

https://github.com/Q42/Template.Android/blob/191ba61cfe6785fcb8204dec07bf3b0ba189ac20/app/src/main/kotlin/nl/q42/template/logging/CrashlyticsLogger.kt#L46

As you can see, the message is simply wrapped in a generic Exception. This works and the error appears in Crashlytics non-fatal errors section.

However, all events that are logged in this way are grouped as occurrences of the same event, and it is thus impossible to estimate how often a specific event occurs because only the total of all events is shown.
It seems the reason is that Crashlytics groups errors by the line of code where the Exception was created, which in all of these cases will the be line I linked to.

Te workaround would be to always explicitly wrap the message in an Exception at the call site:

Napier.e(RuntimeException("Open Second Screen tapped. This will be shown as the non-fatal title")) {
            "Open Second Screen Tapped. This will be shown in the Crashlytics breadcrumbs"
        }

It would be nice for developers to simply be able to call

Napier.e { "Open Second screen Tapped" }

On one idea I have to make this possible would be to make a change to napier where all functions have the inline keyword. So that they get injected in the callsite, where the Exception would then be created. Thus making the stacktrace unique and pointing to the actual file and line where a problem occurred.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant