Sentry
installSentry builds an axonpush DSN from your API key and channel id and hands it to any Sentry SDK, so errors land in axonpush without a second reporting path.
axonpush accepts Sentry’s envelope protocol. installSentry derives a DSN from
your axonpush credentials and passes it to Sentry.init(...), after that, the
Sentry SDK you already use reports to axonpush instead of (or as well as)
sentry.io, and nothing else in your error-handling code changes.
Tested against @sentry/*@^8. Works with @sentry/node, @sentry/browser,
@sentry/nextjs, and anything else exposing an init function.
Install
npm install @axonpush/sdk @sentry/nodeInitialise
import * as Sentry from "@sentry/node";
import { installSentry } from "@axonpush/sdk/integrations/sentry";
installSentry(Sentry, {
apiKey: process.env.AXONPUSH_API_KEY!,
channelId: process.env.AXONPUSH_CHANNEL_ID!,
release: process.env.GIT_SHA,
tracesSampleRate: 1.0,
});
Sentry.captureException(new Error("boom"));Call it as early as your Sentry setup would normally run, the first import in
instrument.ts, or the top of your entry point.
This integration does not use the axonpush client
Unlike every other integration on this page, installSentry takes no
AxonPush instance, no channelId typed as an integration config, and no
publisher. It only computes a DSN string and calls init. Delivery, batching,
retries, and sampling are the Sentry SDK’s job from that point on.
Options
| Option | Env fallback | Default | Notes |
|---|---|---|---|
apiKey | AXONPUSH_API_KEY | Becomes the DSN’s public key. | |
channelId | AXONPUSH_CHANNEL_ID | Becomes the DSN’s project id. | |
host | AXONPUSH_HOST | api.axonpush.xyz | Point at your own deployment when self-hosting. |
dsn | derived | Supply a fully-formed DSN and the three fields above are ignored. | |
environment | see below | detected | Forwarded to Sentry.init. |
release | Forwarded to Sentry.init. |
Any other key on the options bag is passed straight through to Sentry.init,
so tracesSampleRate, integrations, beforeSend, and the rest work as they
always have.
installSentry throws if it cannot assemble a DSN, no dsn, and either
apiKey or channelId missing after the env fallbacks.
Environment detection
When you do not pass environment, the first of these with a value wins:
AXONPUSH_ENVIRONMENT, SENTRY_ENVIRONMENT, NODE_ENV, APP_ENV, ENV. An
explicit environment in the options bag always takes precedence.
The DSN
buildSentryDsn is exported if you want the string without initialising
anything, for a sentry-cli invocation, a client-side bundle, or a framework
that wants the DSN in config rather than in code:
import { buildSentryDsn } from "@axonpush/sdk";
const dsn = buildSentryDsn(apiKey, channelId, "api.axonpush.xyz");The shape is:
<scheme>://<apiKey>@<host>/<channelId>The scheme is http when the host starts with localhost or 127., and
https otherwise, so a local backend works without extra configuration.
The channel id fills Sentry’s project-id slot. axonpush’s ingest routes at
/api/:projectId/store, /envelope, /minidump, and /security treat that
segment as a channel id, and it is string-typed on the backend, a UUID works
as-is.
The DSN contains your API key
A Sentry DSN is normally safe to ship to browsers because its public key is write-only. Here the public-key slot holds a real axonpush API key. Use a key scoped to event ingest before putting this DSN in client-side code.
OpenTelemetry
AxonPushSpanExporter is a SpanExporter for any OTel tracer provider, add it alongside your existing exporters and spans land in axonpush as app.span events.
BullMQ
Swap the in-memory publish queue for a Redis-backed BullMQ queue, so log and span events survive restarts and retry on transient failures.