Skip to main content

Astro

Beta

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 (integrations in astro.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 install @bugsee/astro

Set up​

Add the integration to your Astro config. There is nothing else to wire.

astro.config.mjs
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​

OptionTypeDefaultDescription
appTokenstringrequiredYour Bugsee application token.
runtime'node' | 'edge''node'The server runtime. Use 'edge' for Vercel or Cloudflare edge deployments.
clientobject{}Extra browser launch options, for example { replay: false } or { maxRecordingTime: 30 }.
serverobject{}Extra server launch options, for example { captureLocalVariables: true }.
astro.config.mjs
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​

EntryDescription
@bugsee/astroThe integration: bugsee (also the default export).
@bugsee/astro/clientregisterClient(appToken, options?), relaunch.
@bugsee/astro/serverregisterServer(appToken, options?) for Node.js.
@bugsee/astro/edgeregisterServerEdge, createEdgeMiddleware.
@bugsee/astro/middlewarecreateBugseeMiddleware(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:

src/pages/test.astro
---
throw new Error('Bugsee test error');
---

Open /test. The error shows up in the Bugsee dashboard.

Found an issue, typo, or wrong statement on this page? Report it now →