In order to understand what happened in your application before each error, it can be helpful to leave short log statements that we call breadcrumbs. A configurable number of breadcrumbs are attached to each error report to help diagnose what events led to the error.
This documentation is for version 6+ of the BugSnag Unity notifier. If you are using older versions, we recommend upgrading to the latest release using our Upgrade guide. Documentation for the previous release can be found on our legacy pages.
By default, BugSnag captures breadcrumbs for common actions and device changes, including:
This can be controlled using the Enabled Breadcrumb Types configuration option.
If you use the built-in UnityWebRequest class for network requests in your app, you can use the BugnsagUnityWebRequest
wrapper to capture network requests as breadcrumbs in your error reports:
var bugsnagWebRequest = BugsnagUnityWebRequest.Get("https://myUrl.com");
yield return bugsnagWebRequest.SendWebRequest();
Append manual breadcrumbs with a message via the Bugsnag
client:
Bugsnag.LeaveBreadcrumb("App loaded")
Bugsnag.LeaveBreadcrumb("User clicked a button")
BugSnag will keep track of the time and order of the breadcrumbs, and show them on your dashboard.
If you do not want to use the BugsnagUnityWebRequest
wrapper you can manually record network breadcrumbs:
var startTime = DateTimeOffset.UtcNow;
var unityWebRequest = UnityWebRequest.Get("https://myUrl.com");
yield return unityWebRequest.SendWebRequest();
Bugsnag.LeaveBreadcrumb(unityWebRequest, DateTimeOffset.UtcNow - startTime);
Additional data can be attached to breadcrumbs by providing the additional Metadata
argument. Metadata will be presented on the BugSnag dashboard alongside the breadcrumb name and type:
var metadata = new Dictionary<string, object> {
{ "delivery", "express" },
{ "sale", "spring" }
};
Bugsnag.LeaveBreadcrumb("Preference updated", metadata, BreadcrumbType.State);
Breadcrumb “types” can be used to differentiate different types of events, such as user activity and changes in application state. See the Enabled Breadcrumb Types configuration option for a description of the types available. This type will affect how your breadcrumb is shown on the dashboard but they will not be affected by the Enabled Breadcrumb Types configuration option.