quickstart-unity
quickstart-unity copied to clipboard
[Question] Is there any way to enable Crashlytics in the Editor?
[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?
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 ~~
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?
Hi @paulinon ~
Yes, I would love to see a feature like that supported. Thanks for the clarification as well.
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.