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

[Question] Is there any way to enable Crashlytics in the Editor? #1164

Open
dginovker opened this issue Oct 27, 2021 · 4 comments
Open

[Question] Is there any way to enable Crashlytics in the Editor? #1164

dginovker opened this issue Oct 27, 2021 · 4 comments

Comments

@dginovker
Copy link

[REQUIRED] Please fill in the following fields:

  • Unity editor version: 2019.4.28f1
  • Firebase Unity SDK version: 8.4.0
  • Source you installed the SDK: .unitypackage
  • Problematic Firebase Component: Crashlytics
  • Other Firebase Components in use: Analytics, auth, crashlytics, messaging, remote config, database, storage
  • Additional SDKs you are using: AdMob, couple others
  • Platform you are using the Unity editor on: Mac, Linux
  • Platform you are targeting: iOS, Android
  • Scripting Runtime: IL2CPP

[REQUIRED] Please describe the question here:

When using Crashlytics, I'm able to use lines like

Crashlytics.LogException(new Exception("Test logging exception with LogException!"));

or

throw new Exception("Test exception by throwing it!");

And they appear in Firebase just fine, but only on builds and not in the editor. For testing purposes, I'd like to enable them in the editor too, then just filter them out on Firebase's end like with Unity crashlytics.

Is this possible?

@dginovker
Copy link
Author

dginovker commented Oct 27, 2021

Doing some poking around in the code, it doesn't look like this sort of thing is supported, so I've made a wrapper function that at least logs it instead:

public static class FirebaseLog
{
    private static string AppendStacktrace(string msg)
    {
        // Needed because LogException doesn't include stacktrace
        // Replacing newlines with 5 spaces since crashlytics doesn't display newlines
        return $"{msg}     {Environment.StackTrace.Replace("\n", "     ")}";
    }
    
    public static void FirebaseLogError(string msg)
    {
        Crashlytics.SetCustomKey("Log Severity", "Error");
        Crashlytics.LogException(new Exception(AppendStacktrace(msg)));
        Debug.LogError(msg);
        Crashlytics.SetCustomKey("Log Severity", "");
    }

    public static void FirebaseLogWarn(string msg)
    {
        Crashlytics.SetCustomKey("Log Severity", "Warn");
        Crashlytics.LogException(new Exception(AppendStacktrace(msg)));
        Debug.LogWarning(msg);
        Crashlytics.SetCustomKey("Log Severity", "");
    }

    public static void FirebaseLogDebug(string msg)
    {
        Crashlytics.SetCustomKey("Log Severity", "Debug");
        Crashlytics.LogException(new Exception(AppendStacktrace(msg)));
        Debug.Log(msg);
        Crashlytics.SetCustomKey("Log Severity", "");
    }
}

Hopefully someone finds this useful ~~

@paulinon
Copy link
Contributor

Hi @dginovker,

The reason this isn't supported is because the crash reports are sent only once the app has been relaunched, so it's important that you build your app for this.

With that being said, would you like this feature to be supported in future releases?

@paulinon paulinon added the needs-info Need information for the developer label Oct 27, 2021
@dginovker
Copy link
Author

Hi @paulinon ~

Yes, I would love to see a feature like that supported. Thanks for the clarification as well.

@google-oss-bot google-oss-bot added needs-attention Need Googler's attention and removed needs-info Need information for the developer labels Oct 27, 2021
@SabreRunner
Copy link

I expect that all crashlytics logs, regardless of device, to be sent immediately (or after X logs or Y seconds) and then on restart, it'll check what is saved vs what was sent and fill in the blanks.

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

No branches or pull requests

4 participants