@argusdev/sdk-astro
v0.3.0
Published
Argus SDK for Astro — one integration wires browser capture on every page and SSR error capture in middleware.
Maintainers
Readme
@argusdev/sdk-astro
Astro SDK for Argus — one integration wires both runtimes: browser capture (errors + web vitals) on every page, and SSR error capture in middleware.
Install
npm install @argusdev/sdk-astroUsage
// astro.config.mjs
import { defineConfig } from "astro/config";
import argus from "@argusdev/sdk-astro";
export default defineConfig({
integrations: [
argus({ dsn: "https://<publicKey>@<host>/<projectId>", environment: "production" }),
],
});That one line does three things at astro:config:setup:
- Injects a page script — the browser SDK's
init()on every page:window.onerror, unhandled rejections, web vitals (vitals: falseopts out). - Adds server middleware (
order: "pre") — wraps the request pipeline, captures SSR errors (frontmatter, endpoints, server islands), and rethrows untouched so Astro still renders its error page and dev overlay. - Compiles your DSN into the middleware via vite
define— no config files, no env-var contract.
Options
| Option | Default | What |
| ------------- | ---------- | --------------------------------------------- |
| dsn | required | https://KEY@host/PROJECT_ID |
| environment | — | e.g. "production" |
| release | — | version string, for regression tracking |
| vitals | true | page.load transaction with LCP/CLS/FCP/TTFB |
What server events carry
| Tag / field | Example |
| -------------- | --------------- |
| routePattern | /blog/[slug] |
| request.url | /blog/hello |
| request.method | GET |
routePattern (Astro 5+) is the dynamic pattern, stable across requests — the tag worth filtering by. Only user-agent is forwarded from headers; cookies and authorization never are.
Manual capture
import { captureException } from "@argusdev/sdk-astro/client";
try {
await checkout();
} catch (err) {
captureException(err);
}Notes
- No
astrodependency — the integration and middleware are typed structurally and satisfy Astro's ownAstroIntegration/MiddlewareHandlertypes (verified against Astro 5). - The middleware entry uses no Node built-ins and never imports
sdk-browser, so it runs on edge adapters as-is. - The injected page script imports from
@argusdev/sdk-astro/client(the package you installed) rather than a transitive dep — it resolves under pnpm's strictnode_moduleslayout too.
MIT © Treasure Odetokun
