firebase / firebase/firebase-ios-sdk

[FR]: Ignore dependency-injected logging interfaces in non-fatal crash reports

Open
#12,462 3 comments 3 reactions 0 assignees View on GitHub
api: crashlytics type: feature request
Dominant language
C++
Stars
6.7k
Forks
1.8k
Avg merge
2d 18h
Merged PRs (30d)
75

Description

### Description

I'm using Crashlytics in my apps for crash reporting and general logging tool.

Naturally, to avoid writing `import Firebase` into every part of my app, I wrap the logging functionality in a `Logger` interface, and inject Firebase at the top level. This is a standard pattern adopted every time I've seen the Firebase SDK used in a complex app.

```
public protocol Logger {
func log(error: Error)
}

final class LoggerImpl: Logger {
func log(error: Error) {
Crashlytics.crashlytics().record(error: error)
}
}
```

Frustratingly, this means every non-fatal we log implicates the top-level app module, and the LoggerImpl file.

![Non-fatal has unhelpful file name and library](https://github.com/firebase/firebase-ios-sdk/assets/19807881/a9fec841-500e-45c5-9194-322810df682c)

We need to drill down into the error's stack trace to find the culprit.

![Drill-down into non-fatal](https://github.com/firebase/firebase-ios-sdk/assets/19807881/560cc5db-d28a-4465-9314-aa0210d0a659)

Is there any way to override behaviour on Crashlytics so this extremely common dependency-injection pattern can work better?

Looking through the Crashlytics API itself, the only method which seems plausible is `recordError(error: userInfo:)`, however I was unable to find any documentation or work out any combination of keys and values which overrode the basic library/file in the UI.

Thank you.

### API Proposal

Firebase uses `NSThread callStackReturnAddresses` internally to find the stack trace. Therefore, it's a bad idea to try to override this information.

What might be better is, implementing the same approach in the Crashlytics dashboard UI where the first item in a stack trace is greyed out.

```
FIRCLSUserLogging.m - Line 393
FIRCLSUserLoggingRecordError + 393
```

Allowing an option for a user to grey out and ignore the first app-sourced line in the stack trace would mean anyone using this DI pattern could get more useful crash reports.

### Firebase Product(s)

Crashlytics

Contributor guide

Open the contributing guide

Research direction

Start with the Crashlytics API method `recordError(error:userInfo:)` and the `NSThread callStackReturnAddresses` behavior described in the issue. Compare those with the proposed dashboard treatment of the first app-sourced stack-trace line. Done means agreeing on and implementing a supported way to ignore or visually de-emphasize dependency-injection logging frames.

Written by the indexing model from the issue text.

Assessment

Tech stack
firebase, swift
Domain
mobile-dev, observability-sre
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.