Got some reports of obscure errors with no console screenshot? Can’t reproduce that one rare bug to get that sweet, sweet stack trace? Fear not, for Sentry Claus has come to town!
This module, called Raven, will help you log and keep track of errors on Sentry. This is how to set it up.
First, register an account and make an organization on sentry.io.
Then, create a project:
After naming your project, you should be met with this page:
Click on “Get your DSN.”
This should show you your project’s DSN, or Data Source Name, which you need to copy. Don’t share this with the public. If your DSN does get leaked, you can delete it and create a new one in your project’s settings.
After copying your DSN, get to your project’s live feed by clicking on your project’s name at the top.
Now, on to Studio!
Get the module from the GitLab project.
There is documentation in the module itself describing everything in detail, but I’ll give you a basic rundown here.
This module is meant to be used only on the server to prevent players from spamming requests to your Sentry project and potentially risking its termination, or the termination of your Sentry account.
To integrate Raven into your game, require the module and create a new Raven client with your project’s DSN that you copied earlier. A Raven client should not be confused with a ROBLOX client (player); a Raven client describes a configured instance of Raven.
local Raven = require(script.Raven)
local client = Raven:Client("<your DSN here>")
You can now send events to your Sentry project! There are two functions to do this. Here’s an example of both of them:
local success, err = pcall(function() error("test server error") end)
if (not success) then
client:SendException(raven.ExceptionType.Server, err, debug.traceback())
end
client:SendMessage("Fatal error", raven.EventLevel.Fatal)
client:SendMessage("Basic error", raven.EventLevel.Error)
client:SendMessage("Warning message", raven.EventLevel.Warning)
client:SendMessage("Info message", raven.EventLevel.Info)
client:SendMessage("Debug message", raven.EventLevel.Debug)
SendMessage is for basic errors, messages, or information, whereas SendException is for more complicated errors optionally paired with tracebacks from debug.traceback().
Since this module is supposed to be used only on the server, there is functionality for client > server error reporting built-in. Here’s how to use it, first on the server:
client:ConnectRemoteEvent(Instance.new("RemoteEvent", game.ReplicatedStorage))
Now, on the client:
local success, err = pcall(function() error("test client error") end)
if (not success) then
game.ReplicatedStorage.RemoteEvent:FireServer(err, debug.traceback())
end
The arguments sent are the same as SendException, excluding a few options.
Make sure the RemoteEvent you pass isn’t used for any other purposes!
Each ROBLOX client can report a (configurable) maximum of 5 events per server, however if Raven detects spoofed data being sent, it disables their ability to report errors in that server entirely.
Raven also tries to anonymize data received from ROBLOX clients before sending it to Sentry.
If you ran the above code, you can check your Sentry project’s live feed to find:
And there you go! You’re able to integrate Raven into your game, and you no longer have to spend hours trying to get that beautiful stack trace yourself- it’s right there in the live feed, in all its verbose, formatted glory.