LogSure

Tracking errors

LogSure keeps your apps' errors as issues: reports of the same error are grouped, scrubbed before they are stored, and shown with their stack, their release and where they happen. Send the errors your code catches, let the tracker catch the rest, and report from servers and native apps with the server key.

Errors you catch

The tracker gives the page logsure.error:

try {
  checkout();
} catch (err) {
  logsure.error(err, { step: 'checkout' });
}

The first argument is an Error (its type, message and stack are read) or a message. The second, optional, holds properties, as for events. These reports have the source manual.

Name the release and the environment on the script tag, and every report carries them:

<script defer data-app="example-shop" data-release="2.4.1" data-environment="production"
  src="/_care/script.js"></script>

What the tracker catches by itself

Each kind has its own switch in the app's settings (Settings › Apps, the app, Errors), and all are off until you turn them on. The tracker asks the server which are on when the first candidate happens, and the server checks again.

SwitchWhat it catchesSource
Uncaught errorsUncaught errors and rejected promisesuncaught, promise
Consoleconsole.error calls, which still log. The arguments become the message, and an Error among them gives the stack.console
Networkfetch and XMLHttpRequest requests that fail or answer 5xx, such as POST /api/checkout answered 503network
Network 4xxWith Network, 4xx answers toonetwork
ResourcesScripts, style sheets and images that do not loadresource

A network error records the method, the address without its query, the status and the time, never the body or the headers. A page sends at most 10 reports, each distinct error once. The app can also list messages to ignore.

From servers and native apps

Back-ends and apps post to /_care/error with the app's server key:

curl -sS -X POST 'https://logsure.example.com/_care/error' \
  -H "authorization: Bearer $LOGSURE_KEY" \
  -H 'content-type: application/json' \
  --data '{"message":"Card declined by the payment provider","type":"PaymentDeclined",
           "stack":"PaymentDeclined: Card declined…\n    at charge (/srv/shop/payments.js:88:11)",
           "release":"api-1.18.0","environment":"production","props":{"code":"card_declined"}}'
Never send the server key from a browser. Pages use logsure.error.

Before anything is stored

Email addresses, tokens and keys, card-like numbers and URL query strings are removed from the message, the stack, the page and the properties. Stacks are cut at 16 KB and 50 frames.

Issues

An app's open errors: each issue with its type, message, the first frame of the app's own code, the release, a sparkline, events, users and when it was last seen.

The same is in the API (errors), the terminal (:errors) and over MCP (list_errors, get_error, set_error_status, add_error_note, set_error_settings).