This is a custom C++ Godot Module that reports crashes (and other events) to Sentry.io or GlitchTip.
This is super handy when trying to track down crashes that happen in release builds on your users devices.
So far this has only been tested on Windows 10 using Godot 4.0 rc1 64 bit and Sentry-native 0.6.0.
Sentry-native also supports macOS, Linux, and Android. So this module should be usable on those platforms with minor tweaking of the instructions below.
This is a bit tricky to setup and get the folder structure right. After following the next couple of steps your folder structure should look like:
+-- godot
| +-- bin
+-- modules/sentry
| +-- example
| +-- modules
| +-- thirdparty
| +-- sentry-native
First things first, you need to be able to build Godot from source See Compiling in Godot Docs
Continue only once you've got Godot compiling and running. For the rest of the instructions it's assumed that you're building Godot 3.4 32 bit on Windows.
- git clone https://github.com/V-Sekai/godot-sentry-native
- Or download and extract zip https://github.com/V-Sekai/godot-sentry-native/archive/refs/heads/master.zip
- Download latest release (Currently 0.6.0) of sentry-native.zip from https://github.com/getsentry/sentry-native/releases
- Extract to
thirdparty/sentry-native
We need the sentry.dll and sentry.lib built before building godot-sentry-native
cd thirdparty/sentry-native
- Run:
cmake -B build -DSENTRY_BACKEND=breakpad -DSENTRY_BUILD_SHARED_LIBS=NO -DCMAKE_BUILD_TYPE=RelWithDebInfo -DSENTRY_BUILD_EXAMPLES=off -G"MinGW Makefiles"
- Run:
cd build && mingw32-make.exe -j8
This is to build Godot editor for testing integration
- cd to your godot folder
- Run:
scons target=release_debug custom_modules=../modules use_llvm=yes use_mingw=yes LINKFLAGS='-Wl,-pdb=' CCFLAGS='-Wall -Wno-tautological-compare -g -gcodeview'
- If everything is successful, you should have:
godot/bin/godot.windows.opt.tools.exe
scoop install sentry-cli
- Upload debug symbols.
sentry-cli debug-files upload bin --org godot --project godot-project
Use--wait
if you want to see errors.
Documentation to be written.
Sentry.io is a hosted service that listens for crashes from your game, saves them, then presents them in a pretty dashboard. It's free for the first 5,000 crashes per month. Or you can run your own sentry server if you prefer.
- Create an account at Sentry.io
- Walk through the onboarding process
- Choose your project's platform
- Click on Desktop
- Click Native
- Click Create Project
- Prepare the Native SDK
- It will show you a chunk of C code, the only thing we need from it is the dsn
- It looks like this: https://1234567890abcd@01234567.ingest.sentry.io/1234567
- Leave your browser on this page, Note in the corner of the page it says Waiting to receive first event to continue
- Choose your project's platform
- Run your custom build of Godot:
godot/bin/godot.windows.opt.tools.exe
- Import the example project:
godot-sentry-native/example/project.godot
- Click Project -> Project Settings
- At the bottom of the list look for Third Party and click Sentry
- Set Dsn to the url you copied from Sentry.io
- Click Close
- Click Play(F5) to run Example project
- Click Crash
- Note the Sentry.io page should now say Event was received! with a Take me to my error button. Click that.
- You should now see a pretty report all about the crash
This step is optional, but highly recommended.
If you look at a crash's raw call stack you'll notice some lines that look like:
godot.windows.opt.tools.32.exe 0x41ccccd <unknown>
That isn't very helpful, luckily we can get sentry.io to replace <unknown>
with the name of the function by uploading godot's pdb symbol file to sentry.io
Here's how:
- Download the latest release of Sentry Cli for Windows from: https://github.com/getsentry/sentry-cli/releases/
- 32-bit: sentry-cli-Windows-i686.exe
- 64-bit: sentry-cli-Windows-x86_64.exe
- Copy and rename it to:
godot\bin\sentry-cli.exe
- cd to
godot\bin\
- Login to Sentry.io:
sentry-cli login
- Open browser now? [y/n] y
- This will open a browser window, hopefully using the same browser you already logged into Sentry.io with.
- Click Create New Token
- The default Scopes should be fine. Click Create Token
- Copy the Auth Token and Paste into your cmd window prompt Enter Your Token:
- Verify it's working:
sentry-cli info
- Get your Oranization Slug
- On Sentry.io Click on your name in the upper left Corner
- Click Organization settings
- Copy the value for Organization Slug
- Get your Project Name
- Underneath General Settings click Projects
- Copy the project name, likely it is the same as your Organization Slug
- Now upload symbol file:
sentry-cli upload-dif -o your-organization -p your-project --wait godot.windows.opt.tools.32.pdb
- Replace
your-organization
with your Organization Slug copied from website - Replace
your-project
with your Project Name copied from website
- Replace
- Then run the Example again and click Crash. Go look at the new crash on sentry.io and you should now see function names in the call stacks instead of
<unknown>
So far we've got the Godot editor to report crashes, but what we really want is for our packaged released games to report crashes happening to real users. To do that we need to build a new Godot Export Template.
- See Godot Docs: Creating Windows export templates
- Just add
custom_modules=../godot-sentry-native/modules/sentry
to any of the scons commands - For example:
scons platform=windows tools=no target=release bits=32 custom_modules=../godot-sentry-native/modules/sentry
- Be sure to copy
godot/bin/sentry.dll
andgodot/bin/crashpad_handler.exe
to your game's export folder - Don't forget to upload symbol file any time you rebuild:
sentry-cli upload-dif -o your-organization -p your-project --wait godot.windows.opt.32.pdb
To have your own games report crashes to Sentry.io:
- Set Sentry Dsn in Project Settings
- Export using the Custom Export Template
- Be sure to copy
godot/bin/sentry.dll
andgodot/bin/crashpad_handler.exe
to your Export folder and ship with your game.
- String thirdparty/sentry/dsn
Dsn for your Sentry.io account - String thirdparty/sentry/app_version
Version of your game, you should increment everytime you make a release. So that you can tell if a crash is coming from the current or old version. - bool thirdparty/sentry/send_ip_address
Include ip address of user in crash report. Handy to tell if multiple crashes are coming from the same user or multiple users.
Sentry is a singleton that will be available in all your gd script files
- You can send an event to Sentry.io at any time with:
Sentry.send_event("Test Event!")
This can be handy for reporting errors other then crashes. - Set username of user:
Sentry.set_username("Bob")