Auto-instrumentation
What the SDK captures in the browser without any code, and at which level.
Overview
In a browser, the SDK captures events without any code from you. Choose which with autoCapture; anything you leave out keeps its default.
import { Apperio } from 'apperio';
const logger = new Apperio({
apiKey: 'your-api-key',
projectId: 'your-project-id',
autoCapture: {
errors: true, // default true
performance: true, // default true
networkRequests: true, // default true
pageViews: true, // default true
consoleMessages: false, // default false
userInteractions: false // default false
},
});None of this runs in Node.js. On a server, log what you need yourself; see the Node.js guide.
Levels decide what is sent
Every captured event becomes a log with a level, and the SDK drops logs below minLogLevel (default info). Many routine events are logged at debug or trace, so they are captured but never sent unless you lower minLogLevel. The tables below list each event’s level.
errors
| Event | Level | Message |
|---|---|---|
| Uncaught error (window error event) | error | The error’s name and message, such as TypeError: x is undefined |
| Unhandled promise rejection | error | The rejection’s name and message |
Each report includes the stack trace, the file, line and column the browser gave, the recent breadcrumb trail, and a snapshot of the page: its address, viewport size, scroll position, whether the browser was online and, where the browser exposes them, the connection type and memory use. See Error tracking.
performance
| Event | Level |
|---|---|
| Page load | warn over 3 s, info over 1 s, otherwise debug |
| Script or stylesheet | warn over 3 s, info over 1 s, otherwise debug |
| Other resource | warn over 3 s, otherwise debug |
| Paint timing and your own performance measures | debug |
| LCP | warn over 4 s, info over 2.5 s, otherwise debug |
| CLS | warn over 0.25, info over 0.1, otherwise debug |
| INP, per interaction of 40 ms or more | warn over 500 ms, info over 200 ms, otherwise debug |
Web Vitals carry a good, needs-improvement or poor rating. See Performance and Web Vitals.
networkRequests
| Event | Level | Message |
|---|---|---|
| Response with status 500 or above | error | Server Error |
| Response with status 400 to 499 | warn | Client Error |
| Response below 400 that took over 5 s | warn | Slow Network Request |
| Request that fails outright (fetch only) | error | Network Request Failed |
| Any other response | debug | Network Request |
Covers fetch and XMLHttpRequest, so libraries built on them, such as axios, are covered too. Each entry has the method, URL, status and duration. The token, key, password, secret and api_key query parameters are replaced with [REDACTED]. Requests to Apperio itself are skipped.
pageViews
Logs a Page View at info when the page loads and after every history.pushState, history.replaceState and back or forward navigation, with the address, title and referrer. Single-page app route changes are therefore counted, and so are calls to replaceState that don’t change the page.
consoleMessages
| Call | Level | Message |
|---|---|---|
console.error | error | Console Error |
console.warn | warn | Console Warning |
console.log | info | Console Log |
console.info | info | Console Info |
console.debug | debug | Console Debug |
The arguments are converted to strings and stored in the log’s data. The console still prints as usual.
Noisy, and it counts itself
Every console.error becomes an error and can open an issue, including ones from third-party scripts.
The SDK’s own console messages are captured too, such as Apperio: Network error on attempt 1 when Apperio can’t be reached. Turn this on while investigating, not permanently.
userInteractions
| Event | Level |
|---|---|
| Click, with the element’s selector and coordinates | debug |
| Focus and blur | debug |
| Scroll, at most one per 100 ms | trace |
| Key press, at most one per 100 ms, without the key | trace |
All of these are below info, so with the default level none are sent. Clicks still feed the breadcrumb trail. To see clicks and scrolling in context, use session replay instead.
The breadcrumb trail
The SDK keeps the last 50 page views, network requests, console messages and clicks it has captured (each kind only when its capture is on), and attaches them to every error it captures by itself. The trail lives in memory and is only sent as part of an error. logger.addBreadcrumb() doesn’t add to it.
How it hooks in
window.fetchandXMLHttpRequest.prototype.openandsendare wrapped.history.pushStateandreplaceStateare wrapped.- The
consolemethods are wrapped whenconsoleMessagesis on. - Errors, rejections and interactions use event listeners; timings use
PerformanceObserver.
logger.shutdown() removes all of them and restores the originals.