Unity
A Unity Sample app is available at Github Bugfender Unity
Bugfender is a game-changing platform that logs every detail your users experience and feeds the data directly to an easy-to-use web console. Bugfender SDK is multi-platform and available for mobile and web apps, so you can use the same tool for all your apps.
Specifically for Unity developers, Bugfender offers powerful capabilities to remotely monitor and debug any log or error. You can easily reproduce and fix issues using our detailed log viewer and the stack trace of exceptions.
If you don't have a Bugfender account yet, go to Bugfender Signup and come back here.
Installation
Bugfender is compatible with Unity iOS and Android platforms. We have made an asset package to adapt the native iOS and Android to the interface required by Unity.
To use Bugfender in your Unity project, follow these steps:
- Browse to this repository: Bugfender SDK for Unity.
- Download and import the assets available in the Github releases package into your project.
- Drag the Assets / Bugfender / Prefabs / Bugfender prefab to your hierarchy.
- Select Bugfender GameObject and set the Bugfender app key in the Inspector panel.
- If your game has several scenes, you only need to add Bugfender once, on the first scene that gets executed.
- You can use the
Bugfender.Log()
method to write logs.
Note: If you use Bugfender in a platform other than iOS or Android, any calls to Bugfender will be just ignored but other than that, your application will keep working as usual. Please note the WebGL platform is currently not supported yet, although we plan to support it in the future.
Script Execution Order
Bugfender is provided as a Prefab that you can drop into your project. Before using Bugfender, the Start()
method of the Prefab needs to be called, so you can ensure it's available before your scripts start running by setting a Script Execution Order in your Project Settings, like so:
Usage
Send logs
After the successful installation and configuration, you can now use our APIs in your Unity application to send logs.
Bugfender.Log("This is a debug log in Bugfender");
Set Device Data
Once your application is running on several devices, it will be useful to know which device belongs to whom. You can associate information to a device as if it were a dictionary:
// Set device values
Bugfender.SetDeviceString("key", "value");
Bugfender.SetDeviceString("key2", "remove me");
This will later on let you search this device by “key” in the Bugfender Dashboard and you can use any of the associated data to filter our your device list.
If you want to remove a data from the device, you can call RemoveDeviceKey
:
Bugfender.RemoveDeviceKey("key2");
Send Issues
Bugfender allows you to send issues to the server. An issue is similar to an exception but they are showed in the issues section and you can send issues any time from the app, even if the device is not enabled in the system. Issues are useful to keep track of important errors that you can detect in your code.
For sending an issue you can use the following function:
Bugfender.sendIssue("Issue titile", "This will create a new issue in Bugfender");
Send User Feedback
Getting feedback from the final users is one of the most important things for an app developer. Good user feedback allows you to detect errors in your app and helps you to understand better your product.
Sending User Feedback automatically sends all cached logs for the current session, even if the device is not enabled for sending logs.
Bugfender.SendUserFeedback("Feedback title", "This will create a new feedback in Bugfender");
Advanced Usage
Send Logs with Tags and Levels
Bugfender has a more advanced logging system than sending regular logs, you can use the following method to add a tag or a different level that will allow you to find and filter logs easily in the Bugfender log viewer.
// Send low level log
Bugfender.Log({
level: LogLevel.Debug,
tag: "tag",
message: "Sending low level debug log.",
});
The LogLevel
is an enum with the following valid values:
public enum LogLevel { Debug, Warning, Error, Trace, Info, Fatal };
Having your app decide when to send logs
In some special circumstances you may want to send logs, regardless of the enabled state of the device in the Bugfender console, for example in a custom exception handler. Use ForceSendOnce
to force sending the logs once, and use SetForceEnabled
to force it for some period of time.
Bugfender.ForceSendOnce();
Bugfender.SetForceEnabled(true);
Manually sending crashes
If you have your own crash reporting system and need to send crashes, you can do so by calling directly SendCrash
Bugfender.SendCrash("Crash title", "This will create a new crash in Bugfender");
Get Session Link
Sometimes you want to integrate Bugfender with a third party tool. For this purpose, the SDK provides a method that returns the URL for the session. You can send it to the third party tool to easily go to the logs of the current session from the other tool.
Bugfender.SessionIdentifierUrl();
Get Device Link
Sometimes you want to integrate Bugfender with a third party tool. For this purpose, the SDK provides a method that returns the URL for the current device. You can send it to the third party tool and easily navigate back to the logs of the device from the other tool.
Bugfender.DeviceIdentifierUrl();
Log buffer size
Bugfender keeps up to 5 MB worth of log data in the device. This way Bugfender can work offline, and you can get some log data from the past when enabling a device. You can change that limit with SetMaximumLocalStorageSize
.
// Setting maximum cache size to 1 Mb
Bugfender.SetMaximumLocalStorageSize(1024*1024);
How to update the libraries
To update the Android library:
- Download the Bugfender Android SDK aar file (click on Browse, then download the file)
- Delete the current file in
Assets/Plugins/Android
and replace it with the .aar file just downloaded.
To update the iOS framework:
- Download the latest Bugfender iOS SDK release:
BugfenderSDK.xcframework.zip
- Unzip it
- Under
Assets/Plugins/iOS
, delete the currentBugfenderSDK.xcframework
and replace it with the one you just downloaded (keepBugfenderBridge.mm
) - Edit the
BugfenderSDK.xcframework
item and, under the iOS Platform settings, add the following Framework Dependencies:MobileCoreServices
andSecurity
; and check Add to Embedded Binaries.
Exporting the .unitypackage
- Run
./export.sh
Custom Instances
On custom instances, the Base URL
and API URL
settings have to be set to the following values.
- Base URL:
https://your-custom-url
- API URL:
https://custom-sdk.api.url