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.

Service Can it be self-hosted? Free Tier
Rollbar No Yes, 5,000 occurrences and 1,000 sessions per month, maximum data retention of 30 days
Datadog No No free tier, only a 14-day trial is available
BugSnag No Yes, 7500 events and 1M spans per month, 1 user only
Raygun No 14-day trial only
PostHog Yes, instructions for self-hosting open source PostHog Yes, 100,000 exceptions per month
GlitchTip Yes, installation instructions for open source GlitchTip Up to 1000 events per month, unlimited projects, unlimited team members
Highlight.io, now part of LaunchDarkly Yes, instructions for self-hosting for up to 50k errors per month Yes, 5k errors per month
BugSink Yes Yes, 5k errors per month

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:

BugSink supports the Sentry SDKs:

DataDog:

GlitchTip:

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
});