Integrate Seamward
Node.js collector
Install and configure the backend collector.
Backend only
Before you begin
- Node.js 20 or later
- A Source key
- An Integration key
- A secret ingest token
Install
Add the collector package to a Node backend.
- Install
@seamward/collectorin the backend package. - Keep the collector package version pinned through the application lockfile.
Install collector
pnpm add @seamward/collectorConfigure
Create one collector for the application process.
Create one collector for the application process. Reuse that collector across observed handlers so batching, retry, and shutdown behavior remain centralized.
Create collector
import { createSeamwardCollector } from "@seamward/collector";
export const seamward = createSeamwardCollector({ sourceKey: process.env.SEAMWARD_SOURCE_KEY!, ingestToken: process.env.SEAMWARD_INGEST_TOKEN!,});Instrument
Wrap an inbound webhook handler.
Wrap the existing handler with observeWebhook. The handler result or thrown error remains authoritative; collection happens after the operation and is not a replacement response.
Observe webhook
const handleCandidate = seamward.observeWebhook( { integrationKey: process.env.SEAMWARD_INTEGRATION_KEY!, routeTemplate: "/webhooks/candidate", }, async (payload) => processCandidate(payload),);Shut down
Flush queued observations before the process exits.
Call stop() during application shutdown. This gives queued observations an opportunity to flush before the process exits.
Stop collector
process.on("SIGTERM", async () => { await seamward.stop(); process.exit(0);});