Error Tracking for Games
When releasing a game for mobile, the web, VR, PC, whether it's a live service or single-player game, error tracking is a must-have. When a new release goes out, you want to know if players are experiencing issues due to that release. You will want to know where the error occurred and if there are commonalities to the players who are experiencing the issue.
Tools for Error Tracking and Application Performance Monitoring
This is where error tracking tools come into play. There are many to choose from and they have different features and price points.
Here are some great options for error tracking tools, in a table for easier comparison. Note that each of the products and services may offer more than just error tracking in its feature set.
However, not all error tracking tools have official support for some programming languages and frameworks. Not all of them have clear documentation, tutorials and guides. It's important to evaluate error tracking tools based on whether they support the programming languages your team is using, the user interface to view the errors, whether it supports SAML and Single Sign On, and whether the documentation is helpful. For example, PostHog has an official Android SDK but does not have an SDK for iOS although that gap can be filled by capturing errors and exceptions and manually sending them via HTTPS. Self-hosted open source versions of the error tracking service may also differ in the feature set and offer fewer features than the cloud-hosted version.
Implementing Error Tracking
Typically, the SDKs for each error tracking service will provide a way to capture all errors and exceptions and send them to the service, the only requirement being that you create an account and supply an API key. Other parameters such as the version release number and user information can be included when sending data about the error that occurred.
The following is a reference with links to packages for each error tracking tool along with code samples to show how to add them to your project.
BugSnag:
- BugSnag for Android
- BugSnag for iOS
- BugSnag package for Unity
- BugSnag package for Unreal Engine
- BugSnag integration for Cocos2d-x
BugSink supports the Sentry SDKs:
- Sentry SDK for Android
- Sentry SDK for iOS
- Sentry SDK for Unity
- Sentry SDK for Unreal Engine
- Sentry SDK for Godot Engine
- Sentry SDK for browser JavaScript
DataDog:
GlitchTip:
- GlitchTip for Android
- GlitchTip for Objective-C
- GlitchTip for C#
- GlitchTip for C/C++
- GlitchTip for browser JavaScript
Highlight / LaunchDarkly:
PostHog:
Raygun:
Rollbar:
Implementing Error Tracking for a Python Server
The following are some code samples for implementing Error
Rollbar for Python
Rollbar can be implemented for FastAPI, Django, Celery, or directly in Python like this:
import os
import rollbar
rollbar.init(os.getenv('ROLLBAR_API_KEY'), os.getenv('SERVER_ENVIRONMENT'), code_version=os.getenv('COMMIT_SHA'))
try:
main_app_loop()
except IOError:
rollbar.report_message('Got an IOError in the main loop', 'warning')
except:
# catch-all
rollbar.report_exc_info()
BugSnag for Python
BugSnag for standalone Python scripts:
import os
import os.path
import bugsnag
bugsnag.configure(
api_key=os.getenv("BUGSNAG_API_KEY"),
project_root=os.path.abspath(os.path.dirname(__file__)),
)
BugSnag for Django applications:
# settings.py
import os
import os.path
import bugsnag
BUGSNAG = {
"api_key": os.getenv("BUGSNAG_API_KEY"),
"project_root": os.path.abspath(os.path.join(os.path.dirname(__file__), "..")),
}
# ...
MIDDLEWARE = (
"bugsnag.django.middleware.BugsnagMiddleware",
)
Implementing Error Tracking in JavaScript for Browser-Based Games
Rollbar for JavaScript and TypeScript
Rollbar can be added to React, Angular, and Vue:
import Rollbar from 'rollbar';
const rollbar = new Rollbar({
accessToken: 'ROLLBAR_ACCESS_TOKEN',
environment: 'production',
});
BugSnag for JavaScript
import Bugsnag from '@bugsnag/js';
Bugsnag.start({
apiKey: 'BUGSNAG_API_KEY',
onError: (event) => {
event.setUser('user-id', 'user-email@localhost', 'User Name');
}
);
Datadog for JavaScript
import { datadogRum } from '@datadog/browser-rum';
datadogRum.init({
applicationId: 'APP_ID',
clientToken: 'CLIENT_TOKEN',
service: 'SERVICE_NAME',
env: 'ENVIRONMENT_NAME',
version: '1.0.0',
trackUserInteractions: true,
trackResources: true
});