Overview
The Sparrow Bug Tracking package is a powerful tool for managing and reporting bugs directly from your Unity Editor and your Games from an Ingame-Overlay. It provides an abstract class APISettings
that can be extended to connect with different bug tracking APIs.
APISettings
The APISettings
class is the core of the Sparrow Bug Tracking package. It provides the following properties:
caption
: A virtual string property that can be overridden to provide a custom caption for the API setting.isWorking
: A boolean property that indicates whether the API is working correctly. This is determined by sending a test report to the API.isActive
: A boolean property that indicates whether the API is currently active.
The APISettings
class also provides the following methods:
SendReport(ReportData report)
: An abstract method that must be implemented in a derived class. It should send a report to the bug tracking API and return a boolean indicating whether the report was sent successfully.SendTestReport()
: A method that sends a test report to the API to check if it’s working correctly.
Unity Editor Interface
In the Unity Editor, the APISettings
class provides a user interface for managing the API settings. The interface includes a foldout that displays the caption and the status of the API (working or not working). If the foldout is expanded, it shows a toolbar for activating or deactivating the API, a label indicating the status of the API, and a button for sending a test report.
Extending APISettings
To use the Sparrow Bug Tracking package with a specific bug tracking API, you need to create a class that extends APISettings
and implements the SendReport(ReportData report)
and DrawInternalEditor()
methods. For more detailed information see the example Class below:
using Sparrow.BugTracking;
using UnityEditor;
using UnityEngine;
public class ExampleAPISettings : APISettings
{
public override string caption => "Example API Setting";
public string apiKey; // Add any additional settings your API might require
public override async Task<bool> SendReport(ReportData report)
{
// Implement the logic to send a report to the Example API here
// This will depend on the specifics of the Example API
// For now, let's just log the report and return true
Debug.Log($"Sending report to Example API: {report}");
return await Task.FromResult(true);
}
#if UNITY_EDITOR
public override void DrawInternalEditor()
{
// Implement the logic to draw the internal editor for the Example API here
// This could include fields for any additional settings your API requires
// For now, let's just add a field for the API key
apiKey = EditorGUILayout.TextField("API Key", apiKey);
}
#endif
}
Note
Please remember that this package is intended for use in the Unity Editor and your specific application. Always test your bug reporting functionality thoroughly before releasing your application.
Using the Backend
What to track?
The BugTrackingManager
class in the BugTrackingManager.cs
file allows you to specify what information to include in the bug reports. This is done by setting the boolean values of the following properties:
m_BuildNumber
: Includes the current build version from your build settings in your reports.m_BundleId
: Includes the bundle id from your build settings in your reports.m_OpenSceneCount
: Includes the number of open scenes in your reports.m_OpenSceneList
: Includes a list of open scenes in your reports.m_StartTime
: Includes the time when the game is started.m_CurrentTime
: Includes the current time when the log is sent.m_Platform
: Includes the platform the game is run on (Android/iOS etc).m_DeviceModel
: Includes the device model information.m_DeviceName
: Includes the device name information.m_DeviceType
: Includes the device type information.m_GraphicsDeviceName
: Includes the graphics device name information.m_GraphicsDeviceMemorySize
: Includes the graphics device memory size information.m_IncludeDebugLog
: Includes all information that was logged using Debug.Log().m_IncludeDebugException
: Includes all information that was logged using Debug.LogException().m_IncludeDebugError
: Includes all information that was logged using Debug.LogError().m_IncludeDebugWarnings
: Includes all information that was logged using Debug.LogWarning().m_IncludeDebugAssertion
: Includes all information that was logged using Debug.LogAssertion().m_IncludeStackTraces
: Includes stack traces for Exceptions and Errors (when available).m_IncludeCustomText
: You can set a custom text to be included, for example to identify different builds and versions.
When to send it?
The BugTrackingManager
class also allows you to specify when to automatically send bug reports. This is done by setting the boolean values of the following properties:
m_AutoSendOnError
: Automatically send a report when an error occurs.m_AutoSendOnException
: Automatically send a report when an exception occurs.m_AutoSendOnWarning
: Automatically send a report when a warning occurs.m_OnlySendInBuilds
: Only send reports in builds and not in the editor.
Where to send it?
The BugTrackingManager
class allows you to specify where to send the bug reports. This is done by setting the instances of the following properties:
- trello: Trello API settings.
- github: GitHub API settings.
- openproject: OpenProject API settings.
- notion: Notion API settings.
- email: Email API settings.
- discord: Discord API settings.
- slack: Slack API settings.
- unityCloud: Unity Cloud Diagnostics API settings.
- ownEndpoint: Own API Endpoint settings.
- jira: Jira API settings.
Each of these properties is an instance of a class that inherits from the APISettings
class. You can configure each instance according to the specific API’s requirements.