Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
7ebe6aa
docs(javascript): add the JavaScript SDK documentation (beta)
krassx Nov 23, 2026
ae1207c
docs(javascript): make Installation an index of per-package guides; m…
krassx Nov 23, 2026
efca4d4
docs(javascript): describe how a JavaScript app is created (type, the…
krassx Nov 23, 2026
fb2c510
docs(javascript): install framework adapters on their own; drop the @…
krassx Nov 23, 2026
43f5e83
docs(javascript): link the installation tables to the packages on npm
krassx Nov 23, 2026
a06a8ca
docs(javascript): link packages to npm with an external-link icon, no…
krassx Nov 23, 2026
2cfe48f
docs(javascript): list Bun next to Node.js in the installation prereq…
krassx Nov 23, 2026
7444133
docs(javascript): drop the Deno notes
krassx Nov 23, 2026
9a4e478
docs(javascript): give the component name plugins their own page unde…
krassx Nov 23, 2026
d06a461
docs(javascript): address review threads on Bun, relaunch, privacy, s…
krassx Nov 23, 2026
9e15750
docs(javascript): qualify Bun transaction claims, soften benchmark fi…
krassx Nov 23, 2026
c90744f
docs(javascript): mark the captureLocalVariables overhead as an appro…
krassx Nov 23, 2026
4586fc3
docs(javascript): CORS note for trace headers, tsup POSIX note, host-…
krassx Nov 23, 2026
ab78c06
docs(javascript): keep the browser launch promise out of top-level aw…
krassx Nov 23, 2026
2956b43
docs(javascript): one launch idiom (shared module with top-level awai…
krassx Nov 23, 2026
0e2c6d4
docs(javascript): make the two browser launch snippets alternatives
krassx Nov 23, 2026
5ce24ef
docs(javascript): align Hono runtime wording, scope the version troub…
krassx Nov 23, 2026
6d9d8de
docs(javascript): endBlackout always runs, shared bugsee module is im…
krassx Nov 23, 2026
00c5111
docs(javascript): avoid top-level await in server examples, align the…
krassx Nov 23, 2026
13a24d0
docs(javascript): align the browser app version and build sources
krassx Nov 23, 2026
6e04e98
docs(javascript): correct the host-boundary target regexes, add the C…
krassx Nov 23, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,29 @@
"version": "0.2",
"language": "en",
"words": [
"Rspack",
"rspack",
"Elysia",
"elysia",
"verylow",
"solidjs",
"navigations",
"workerd",
"traceresponse",
"rrweb",
"webtransport",
"unhandledrejection",
"speedscope",
"iban",
"ttfb",
"nitropack",
"melden",
"jsessionid",
"fastfail",
"bunx",
"Zusammenfassung",
"Senden",
"Kurze",
"SIGSYS",
"apptoken",
"libbugsee",
Expand Down
3 changes: 2 additions & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: "Overview"
description: "Overview of Bugsee SDK installation links and a feature comparison table across iOS, Android, React Native, Flutter, Unity, .NET, and Cordova."
description: "Overview of Bugsee SDK installation links and a feature comparison table across iOS, Android, React Native, Flutter, Unity, .NET, and Cordova (plus installation links for the JavaScript SDK)."
sidebar_position: 0
slug: "/"
---
Expand All @@ -14,6 +14,7 @@ Using Bugsee on mobile devices requires installation of Bugsee lightweight SDK:
* [Installing Cordova SDK](/sdk/cordova/installation/)
* [Installing React Native SDK](/sdk/react_native/v6/installation/)
* [Installing Flutter SDK](/sdk/flutter/installation/)
* [Installing JavaScript SDK (Beta)](/sdk/javascript/installation/) — browsers, Node.js, Bun, Electron, edge runtimes and web frameworks
* [Installing Unity SDK](/sdk/unity/installation/)
* [Installing KMP SDK (Beta)](/sdk/kmp/installation/)
* [Installing Xamarin SDK](/sdk/xamarin/installation/) — **deprecated**, use the [.NET SDK](/sdk/dotnet/installation/) for new projects
Expand Down
128 changes: 128 additions & 0 deletions docs/sdk/javascript/backend/elysia.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
---
title: "Elysia"
description: "Report errors and trace requests in an Elysia app on Bun or Node.js with the Bugsee JavaScript SDK: per-request context, http.server transactions and error capture."
sidebar_position: 8
slug: "/sdk/javascript/backend/elysia"
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

:::warning[Beta]
This page documents the Bugsee JavaScript SDK, which is in beta (0.1.x) and can change between betas.
:::

`@bugsee/elysia` adds a request context, error reporting and, where the performance extension is present (Node.js, not `@bugsee/bun`), an `http.server` transaction to an Elysia app. It runs on Bun, and on Node.js through the app's fetch handler. Read the [backend overview](/sdk/javascript/backend/overview) first for how context and trace correlation work.

You need an app token. Create a JavaScript application in Bugsee and choose **Elysia** as its target; see [Create your app](/sdk/javascript/installation#create-your-app).

## Install
Comment thread
krassx marked this conversation as resolved.
Resolved

<Tabs groupId="package-manager">
<TabItem value="npm" label="npm">

```bash
npm install @bugsee/elysia
```

</TabItem>
<TabItem value="pnpm" label="pnpm">

```bash
pnpm add @bugsee/elysia
```

</TabItem>
<TabItem value="yarn" label="yarn">

```bash
yarn add @bugsee/elysia
```

</TabItem>
<TabItem value="bun" label="bun">

```bash
bun add @bugsee/elysia
```

</TabItem>
</Tabs>

On Bun, also install `@bugsee/bun` and import `launch` from it, as described in [Running on Bun](/sdk/javascript/backend/overview#running-on-bun). In that setup the request context and error reporting work, but there is no `http.server` transaction.

The adapter declares no peer dependency. It only relies on the shape of your Elysia app. On Node.js it needs Node.js 18 or newer.

## Set up

Call `launch()` at the top of your server entry, then pass the app to `setupElysia`:

```ts title="server.ts"
import { launch, setupElysia } from '@bugsee/elysia';
import { Elysia } from 'elysia';

launch('<your_app_token>');

const app = new Elysia();
setupElysia(app);

// ... your routes ...
```

Hooks are scoped to the Elysia instance they are added to, so register `setupElysia` on the instance that owns your routes.

If your Elysia app type does not unify with the adapter's structural type, cast it:

```ts
import { type ElysiaAppLike, setupElysia } from '@bugsee/elysia';

setupElysia(app as unknown as ElysiaAppLike);
```

## Node.js and Bun

On Bun, the full Elysia server works.

On Node.js, Elysia's `.listen` is not supported: the adapter is tested only through the app's fetch handler, `app.fetch`, so use that. (Elysia's separate Node adapter is not covered by this SDK's tests.)

## What it does

Elysia hooks are additive, so `setupElysia` adds three without replacing yours:

| Hook | What it does |
| --- | --- |
| `onRequest` | Opens a request context, continues an inbound `traceparent` and starts an `http.server` transaction. |
| `onError` | Reports server errors, meaning a plain throw or a 5xx status. Framework control flow such as `NOT_FOUND` and `VALIDATION` is skipped. |
| `mapResponse` | Finishes the transaction without altering the response. |

## Options

Pass options as the second argument of `setupElysia`.

| Option | Type | Default | Description |
| --- | --- | --- | --- |
| `user` | `(c) => string \| undefined` | off | The end-user identity for reports raised during the request. |
| `shouldReport` | `(error) => boolean` | server errors only | Decides whether a thrown error is reported. |
| `onError` | `(error) => void` | none | Receives a failure of the adapter itself. It never reaches the request. |

`c` is a structural view of the Elysia context: `request`, `set` and `route`.

## Launch options

The adapter does not change the launch options. These are the ones that matter most on a server:

| Option | Default | Description |
| --- | --- | --- |
| `instrumentIncomingRequests` | `true` | Automatic per-request context and `http.server` transaction. See the [backend overview](/sdk/javascript/backend/overview#incoming-request-instrumentation). |
| `captureLocalVariables` | `false` | Attach local variables to the stack frames of a reported error. Always off on Bun. See [Diagnostics](/sdk/javascript/issue-detection/diagnostics). |
| `captureSourceContext` | `false` | Attach the source lines around each stack frame. See [Diagnostics](/sdk/javascript/issue-detection/diagnostics). |
| `detectHangs` | `true` | Report event-loop hangs. See [Hangs](/sdk/javascript/issue-detection/hangs). |
| `profiling` | `false` | Attach a rolling CPU profile to reports. See [Diagnostics](/sdk/javascript/issue-detection/diagnostics). |

`@bugsee/elysia` installs `@bugsee/bugsee` for you and re-exports everything from its Node entry, so `launch` and the SDK types come from this one package. You do not install or import `@bugsee/bugsee` separately. On Bun, use `@bugsee/bun` for `launch()` and note that it has no `http.server` transaction; see [Running on Bun](/sdk/javascript/backend/overview#running-on-bun).

## Related pages

- [Backend overview](/sdk/javascript/backend/overview) — request context, trace correlation and incoming-request instrumentation
- [Issue detection](/sdk/javascript/issue-detection/overview) — what else is detected on a server
- [Performance](/sdk/javascript/performance) — transactions and spans
144 changes: 144 additions & 0 deletions docs/sdk/javascript/backend/express.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
---
title: "Express"
description: "Report errors and trace requests in an Express app with the Bugsee JavaScript SDK: per-request context, http.server transactions and error capture."
sidebar_position: 2
slug: "/sdk/javascript/backend/express"
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

:::warning[Beta]
This page documents the Bugsee JavaScript SDK, which is in beta (0.1.x) and can change between betas.
:::

`@bugsee/express` adds a request context, an `http.server` transaction and error reporting to an Express app on Node.js. Read the [backend overview](/sdk/javascript/backend/overview) first for how context and trace correlation work.

You need an app token. Create a JavaScript application in Bugsee and choose **Express** as its target; see [Create your app](/sdk/javascript/installation#create-your-app).

## Install

<Tabs groupId="package-manager">
<TabItem value="npm" label="npm">

```bash
npm install @bugsee/express
```

</TabItem>
<TabItem value="pnpm" label="pnpm">

```bash
pnpm add @bugsee/express
```

</TabItem>
<TabItem value="yarn" label="yarn">

```bash
yarn add @bugsee/express
```

</TabItem>
<TabItem value="bun" label="bun">

```bash
bun add @bugsee/express
```

</TabItem>
</Tabs>

The adapter declares no peer dependency. It only relies on the shape of your Express app (Express 4 or 5).

## Set up

Call `launch()` at the top of your server entry, then pass the app to `setupExpress`:

```ts title="server.ts"
import { launch, setupExpress } from '@bugsee/express';
import express from 'express';

launch('<your_app_token>');

const app = express();
setupExpress(app);

// ... your routes ...

app.listen(3000);
```

`setupExpress` installs the request middleware immediately, so call it before you register routes. It installs the error handler for you:

- It wraps `app.listen`, so the handler is added when the server starts listening, after your routes exist.
- An app that never calls `app.listen` (for example one passed to `http.createServer`) gets the handler on its first request.
- The handler is placed in front of any error middleware you already registered, so an error-response middleware that ends the response without calling `next(err)` does not hide the error from Bugsee.

## Place the error handler yourself

To control the position, turn off the automatic handler and add it with `setupExpressErrorHandler`:

```ts title="server.ts"
import { setupExpress, setupExpressErrorHandler } from '@bugsee/express';

setupExpress(app, { autoErrorHandler: false });

// ... your routes ...

setupExpressErrorHandler(app); // reports, then calls next(err)

app.use((err, req, res, next) => {
// your error response
});
```

For full control, the two middlewares are also exported on their own: `requestHandler()` (mount it first) and `errorHandler()` (mount it after your routes).

## What it does

- Opens a request context for each request, so everything reported inside a route is tagged with that request.
- Continues an inbound `traceparent` header and records an `http.server` transaction named after the route pattern, such as `/users/:id`.
- Reports an error that reaches the error handler, with the request context merged in, and then passes it on with `next(err)`. Your own error handling still runs.
- Does nothing, and passes every request through, when no client is launched.

By default an error with no status, or with a status of 500 or higher, is reported, and a 4xx is skipped.

## Options

Pass options as the second argument of `setupExpress`. `setupExpressErrorHandler`, `requestHandler` and `errorHandler` take the same options, without `autoErrorHandler`.

| Option | Type | Default | Description |
| --- | --- | --- | --- |
| `user` | `(req) => string \| undefined` | off | The end-user identity for reports raised during the request. |
| `shouldReport` | `(error) => boolean` | 5xx or no status | Decides whether a thrown error is reported. |
| `onError` | `(error) => void` | none | Receives a failure of the adapter itself. It never reaches the request. |
| `autoErrorHandler` | `boolean` | `true` | Set `false` to place the error handler yourself. `setupExpress` only. |

`req` is a structural view of the Express request: `method`, `url`, `originalUrl`, `route`, `baseUrl` and `headers`. Cast it to read fields added by your own middleware:

```ts
setupExpress(app, {
user: (req) => (req as { user?: { id: string } }).user?.id,
});
```

## Launch options

The adapter does not change the launch options. These are the ones that matter most on a server:

| Option | Default | Description |
| --- | --- | --- |
| `instrumentIncomingRequests` | `true` | Automatic per-request context and `http.server` transaction. See the [backend overview](/sdk/javascript/backend/overview#incoming-request-instrumentation). |
| `captureLocalVariables` | `false` | Attach local variables to the stack frames of a reported error. See [Diagnostics](/sdk/javascript/issue-detection/diagnostics). |
| `captureSourceContext` | `false` | Attach the source lines around each stack frame. See [Diagnostics](/sdk/javascript/issue-detection/diagnostics). |
| `detectHangs` | `true` | Report event-loop hangs. See [Hangs](/sdk/javascript/issue-detection/hangs). |
| `profiling` | `false` | Attach a rolling CPU profile to reports. See [Diagnostics](/sdk/javascript/issue-detection/diagnostics). |

`@bugsee/express` installs `@bugsee/bugsee` for you and re-exports everything from its Node entry, so `launch` and the SDK types come from this one package. You do not install or import `@bugsee/bugsee` separately. On Bun, see [Running on Bun](/sdk/javascript/backend/overview#running-on-bun).

## Related pages

- [Backend overview](/sdk/javascript/backend/overview) — request context, trace correlation and incoming-request instrumentation
- [Issue detection](/sdk/javascript/issue-detection/overview) — what else is detected on a server
- [Performance](/sdk/javascript/performance) — transactions and spans
Loading
Loading