indiesoftby/defold-sentinel/sentinel
Unofficial Sentry.io SDK for Defold.
- GitHub: indiesoftby/defold-sentinel — pinned to
1.3.1- Pick a release from indiesoftby/defold-sentinel releases and add its Source code (zip) URL (or a packaged
.zipasset, if the library ships one) togame.projectunder[project]dependencies, then Fetch Libraries in the Defold editor. - Run
bunx @defold-typescript/cli resolveto materialize its types. - Import it under a namespace alias of your choice:
import * as sentinel from "sentinel.sentry"
- Pick a release from indiesoftby/defold-sentinel releases and add its Source code (zip) URL (or a packaged
Functions
init(config: Config)
Starts the client. Call it as early as possible. Sentinel keeps the table it is
given, filling in defaults and its tags and extra; set_tag and set_extra
write into it.
Parameters
config:Config
add_breadcrumb(breadcrumb: Breadcrumb)
Records something that happened, sent with every later event. Sentinel adds a
timestamp to the table and keeps the last 10. Does nothing before init.
Parameters
breadcrumb:Breadcrumb
set_tag(key: string, value: string | number | boolean)
Sets a tag sent with every later event. Does nothing before init.
Parameters
key:stringvalue:string | number | boolean
set_extra(key: string, value: string | number | boolean)
Sets extra data sent with every later event. Does nothing before init.
Parameters
key:stringvalue:string | number | boolean
capture_exception(err: ExceptionInfo)
Sends an error to Sentry. With config.set_error_handler on, every uncaught error
is already sent through this. Raises before init. At most 10 events are sent per
300 seconds; a throttled event goes to callback as an error.
Parameters
err:ExceptionInfo
capture_message(msg: MessageInfo)
Sends a message to Sentry. Raises before init. At most 10 events are sent per
300 seconds; a throttled event goes to callback as an error.
Parameters
msg:MessageInfo
Types
Config
Config.dsn: string
Where events are sent. init asserts it is a string that parses as
{PROTOCOL}://{PUBLIC_KEY}@{HOST}/{PATH}{PROJECT_ID}.
Config.debug?: boolean
Print what Sentinel sends. Defaults to false.
Config.dry_run?: boolean
Build events without sending them; each callback receives the id "(dry run)". Defaults to false.
Config.gameanalytics?: boolean
Also report each captured exception to GameAnalytics when that extension is
present. Every exception then needs a traceback, or capture_exception raises.
Defaults to false.
Config.send_timeout?: number
HTTP request timeout in seconds. Defaults to 30.
Config.set_error_handler?: boolean
Install a Lua error handler that captures every uncaught error. It takes the
single sys.set_error_handler slot, replacing any handler set before init.
Defaults to true.
Config.load_previous_crash?: boolean
Submit the crash dump a previous session left, from inside init. Defaults to true.
Config.release?: string
The release id sent with every event.
Config.dist?: string
The distribution, to tell builds or deployment variants of one release apart.
Config.environment?: string
A freeform environment name, e.g. "staging" or "prod".
Config.tags?: Fields
Tags sent with every event.
Config.extra?: Fields
Extra data sent with every event.
Config.user?: Record<string | number, unknown>
User information sent with every event. The table is JSON-encoded and sent as given, nested tables included.
Config.on_soft_crash?: (info: CrashInfo) => string | number
Called after an uncaught error is captured; only installed with
set_error_handler. The first return value is concatenated into a log line, so
returning nothing raises inside the error handler.
Config.on_hard_crash?: (info: CrashInfo) => string | number
Called from init after a previous session's crash dump is captured. The first
return value is concatenated into a log line, so returning nothing raises out of
init.
CrashInfo
CrashInfo.source: string
"lua" or "js" for a soft crash, "crash" for a hard one.
CrashInfo.message: string
The error message. On a hard crash, the JSON-encoded crash dump extra data.
CrashInfo.traceback: string
The traceback. On a hard crash, the JSON-encoded crash dump backtrace.
CrashInfo.fatal?: boolean
true on a hard crash, absent on a soft one.
Breadcrumb
Breadcrumb.category: string
Breadcrumb.message: string
ExceptionInfo
ExceptionInfo.message: string
Sent as the exception type.
ExceptionInfo.traceback?: string
Sent as the exception value. Required when config.gameanalytics is on and the extension is present.
ExceptionInfo.source?: string
Sent as the source tag.
ExceptionInfo.fatal?: boolean
Sends the event at level "fatal" instead of "error".
ExceptionInfo.tags?: Fields
Tags for this event, merged over the global ones.
ExceptionInfo.extra?: Fields
Extra data for this event, merged over the global ones.
ExceptionInfo.callback?: (id: string | undefined, err: string | undefined) => void
Receives the event id on success, or the error when the request fails or the event is throttled.
MessageInfo
MessageInfo.message: string
MessageInfo.level?: "fatal" | "error" | "warning" | "info" | "debug"
Defaults to "info".
MessageInfo.tags?: Fields
Tags for this event, merged over the global ones.
MessageInfo.extra?: Fields
Extra data for this event, merged over the global ones.
MessageInfo.callback?: (id: string | undefined, err: string | undefined) => void
Receives the event id on success, or the error when the request fails or the event is throttled.