Configure SDK observability
Send SDK product events and sanitized failures through a host-owned PostHog client.
Initialize PostHog once in the host, then adapt that existing client:
import { createCapxulClient, postHogObservability } from "@capxul/sdk";
const observability = postHogObservability(posthog, {
enabled: () => analyticsConsentGranted,
capxulEnv: "production",
context: () => ({
application: "operations-console",
release: appVersion,
sessionId,
organizationId,
correlationId,
}),
});
const created = await createCapxulClient({
publishableKey,
observability,
});The module carries SDK product events and captures one sanitized record when a public operation returns a failed result or unexpectedly throws. Delivery is best-effort and cannot change the domain result.
Do not put email addresses, wallet addresses, URLs, JSON, tokens, or arbitrary messages in observation context. Unsafe values are dropped. The backend derives actor identity from authentication and verifies Organization/application hints.
Backend linkage is deliberately bounded. A configured backend may emit linked engineering events. This behavior does not prove universal backend exception delivery.
Omit observability when the host has no consented analytics destination. The SDK
does not initialize PostHog, replay, page views, or global exception capture.
Engineering logs and traces do not add another application prop. The backend optionally supplies a validated PostHog ingest policy in the versioned bootstrap response; missing or invalid policy simply leaves engineering export disabled.