Astro
This page documents the Bugsee JavaScript SDK, which is in beta (0.1.x) and can change between betas.
@bugsee/astro is an Astro integration. It launches the browser client on every page and adds a server middleware that launches the server SDK, reports request errors and injects the trace. It is a single install: it bundles the browser, Node.js and Edge SDKs.
Requirements
- Astro with the integration API (
integrationsinastro.config.mjs). - Node.js 18 or newer for server code.
- An app token. Create a JavaScript application in Bugsee and choose Astro as its target; see Create your app.
Install
- npm
- pnpm
- yarn
- bun
npm install @bugsee/astro
pnpm add @bugsee/astro
yarn add @bugsee/astro
bun add @bugsee/astro
Set up
Add the integration to your Astro config. There is nothing else to wire.
import { defineConfig } from 'astro/config';
import { bugsee } from '@bugsee/astro';
export default defineConfig({
integrations: [bugsee({ appToken: process.env.BUGSEE_TOKEN, runtime: 'node' })],
});
Use runtime: 'edge' for Vercel or Cloudflare edge deployments. The default is the Node.js runtime.
The token is inlined into the client script so the browser can launch. An application token is not a secret.
Options
| Option | Type | Default | Description |
|---|---|---|---|
appToken | string | required | Your Bugsee application token. |
runtime | 'node' | 'edge' | 'node' | The server runtime. Use 'edge' for Vercel or Cloudflare edge deployments. |
client | object | {} | Extra browser launch options, for example { replay: false } or { maxRecordingTime: 30 }. |
server | object | {} | Extra server launch options, for example { captureLocalVariables: true }. |
bugsee({
appToken: process.env.BUGSEE_TOKEN,
client: { captureNetwork: true },
server: { instrumentIncomingRequests: true },
});
client takes the browser options. server takes the Node.js options, or the Vercel Edge options with runtime: 'edge'. client and server are serialized into the generated code, so pass plain values, not functions.
Entry points
| Entry | Description |
|---|---|
@bugsee/astro | The integration: bugsee (also the default export). |
@bugsee/astro/client | registerClient(appToken, options?), relaunch. |
@bugsee/astro/server | registerServer(appToken, options?) for Node.js. |
@bugsee/astro/edge | registerServerEdge, createEdgeMiddleware. |
@bugsee/astro/middleware | createBugseeMiddleware(options?) and the generated onRequest. |
You normally use only the integration.
Island hydration errors
Astro catches an island's hydration failure itself and re-dispatches it as a cancelable astro:hydration-error event, plus a console.error. Nothing is rethrown, so the page's error handlers never see it. The browser launch listens for that event and reports the error without cancelling the event, so Astro's own console output is unchanged.
For component errors during rendering, also add the adapter for your island framework: React, Vue, Svelte or Solid.
Notes
- Source maps. Astro builds with Vite. See Bundler plugins.
- Backend context. Each server request gets a context so logs and errors tie to it. See Backend.
Verify
Throw from a server-rendered page:
---
throw new Error('Bugsee test error');
---
Open /test. The error shows up in the Bugsee dashboard.
Related pages
- Browser — client launch options
- Node.js — server launch options
- Vercel Edge — the edge runtime build
- Bundler plugins — upload source maps from Vite