Skip to main content

Escalate JS errors and add breadcrumbs

API​

const traceId = window.TINGYUN.captureException(err, options)

Request Parameters:

  • Err: error object, required. A standard Error object or a custom object that contains an error message message and an error stack stack. If there is no stack, the fileName needs to be passed.
    • message : string type, error message.
    • stack : String type, error stack.
    • fileName : string type, error file name.
    • lineNumber : Error line number.
    • columnNumber : Error column number.
  • Options: Custom options, optional, object type.
    • breadcrumbs : Array, passing in the value of the Breadcrumbs breadcrumb.
      • timestamp : Required. A 10-digit POSIX timestamp or a 10-digit timestamp followed by three decimal places, such as 1661511702 or 1661511822.445.
      • type : Required, string type.
      • category : Required, string type.
      • level : Required, string type.
      • data : Required, object type.
      • message : Required, string type.
      • Remaining fields. Optional.

Return parameters:

  • TraceId: JS error traceId generated by the probe. By default, the probe parses the file name, row and column from the stack. If the lower version IE browser cannot get the stack, be sure to pass the fileName Otherwise, the JS error of empty file name will not be uploaded by default.. The row and column numbers also support manual passing. When fileName, lineNumber, and columnNumber are passed together, the probe is no longer resolved from the stack.

Examples​

window.TINGYUN.captureException({
message: 'Uncaught ReferenceError: a is not defined',
stack: 'ReferenceError: a is not defined\n at triggerError (http://localhost:5500/event_merge/:44:13)\n at HTMLButtonElement.onclick (http://localhost:5500/event_merge/:39:39 )'
}, {
breadcrumbs: [
{
"timestamp": 1646734787.111,
"type": "default",
"category": "navigation",
"level": "info",
"message": "123",
"data": {
"from": "/organizations/sentry/issues/",
"to": "/organizations/sentry/performance/"
}
},
{
"timestamp": 1646734787,
"type": "http",
"category": "fetch",
"level": "info",
"message": "123",
"data": {
"__span": "bca29be770e45a58",
"method": "GET",
"status_code": 200,
"url": "/api/0/prompts-activity/?feature=sdk_updates&organization_id=1"
}
}
...
]
})