Add Bugsnag to your Unity games and applications.
Download & Import the Bugsnag Unity Package
Download the latest Bugsnag Unity Notifier.
Double click the
.unitypackage file, then click the import button to
import Bugsnag into your Unity project.
Create a Bugsnag GameObject
Create a new
GameObject within your first/main scene
(GameObject Menu -> Create Empty), and rename it to Bugsnag.
Add the Bugsnag Component to Your GameObject
With your new GameObject selected, add the Bugsnag component (Component Menu -> Scripts -> Bugsnag).
Configure Your API Key
Finally, configure your Bugsnag API Key in the component inspector. You can find your API key on the Project Settings page on your Bugsnag dashboard.
If it is not possible to add a Bugsnag GameObject using the Unity editor then Bugsnag can be initialized in code instead.
Errors will only start being sent to Bugsnag after the call to
Bugsnag.createBugsnagInstance has been made.
GameObject bugsnagObject = new GameObject("Bugsnag"); GameObject.DontDestroyOnLoad(bugsnagObject); Bugsnag.createBugsnagInstance(bugsnagObject, "your-api-key-here");
By default, Bugsnag will be notified about any exception logged to
Debug.LogException. You can send additional log information to Bugsnag
Debug.LogError messages) by changing the Notify Level property
in the Unity Inspector.
You can also change this setting in your scripts as follows:
Bugsnag.NotifyLevel = LogSeverity.Error;
If you would like to send non-fatal or handled exceptions to Bugsnag, you can pass any
Exception object to Bugsnag’s
notify method in your Unity scripts:
It is often helpful to send us additional application-specific dianostic data, for
example the name of a subsystem in which an exception occurred. If you would like to add custom data to your Bugsnag error reports, you can use the
AddToTab method. Custom data is displayed inside tabs on each exception on your Bugsnag dashboard.
Bugsnag.AddToTab("system", "subsystem", "Player Mechanics"); Bugsnag.AddToTab("location", "region", "US");
You can add custom log messages called “breadcrumbs” to document what user interactions occurred in your application prior to a crash. Each breadcrumb also records the time at which it was left. To record a breadcrumb:
Bugsnag.LeaveBreadcrumb("Player won"); Bugsnag.LeaveBreadcrumb("Button was clicked");
By default, we’ll store and send the last 20 breadcrumbs you leave before errors are sent to Bugsnag. If you’d like to increase this number, you can call
Bugsnag.BreadcrumbCapacity = 50;
NOTE: Breadcrumbs are not supported for WebGL deployments.
Bugsnag helps you understand how many of your users are affected by each error. In order to do this, we send along a user ID with every exception. By default we will generate a unique ID and send this ID along with every exception from an individual device.
If you would like to override this userId, for example to set it to be a username of your currently logged in user, you can set the userId property:
Bugsnag.SetUser("userId", "User Name", "firstname.lastname@example.org");
You can also set the email and name of the user and these will be searchable in the dashboard.