Installation
Choose the tab for your stack. All packages share the same ingest contract — data from any of them appears in the same dashboard.
Browser SDK
Use @emit-vision/sdk-js for vanilla JS, Svelte, Vue, or any browser app without a React tree.
npm install @emit-vision/sdk-js
# or: pnpm add @emit-vision/sdk-jsCall init() at your app's entry point, before any other SDK calls:
import { init } from "@emit-vision/sdk-js";
init({
// Paste your ingest token from the Setup page — safe to inline in browser code
apiKey: "evk_your_ingest_key",
environment: "production",
release: "[email protected]",
autoCapture: {
errors: true,
unhandledRejections: true,
},
});Bundle size
Bundle sizes are measured using Brotli compression (the default for modern CDNs and browsers). Limits are enforced in CI — a pull request that causes any package to exceed its budget will fail the sdk-size check.
| Package | Brotlied size | Budget |
|---|---|---|
@emit-vision/sdk-js | ~5.8 kB | 9 kB |
@emit-vision/sdk-react | ~0.9 kB | 2 kB |
sdk-react is small because it re-exports sdk-js rather than bundling it. Both are tree-shakeable — unused exports are dropped by your bundler.
Configuration reference
All packages share these init() options.
| Option | Type | Default | Description |
|---|---|---|---|
apiKey | string | — | Your ingest token — starts with evk_, safe to include in browser bundles |
endpoint | string | — | Override the ingest URL (self-hosted only) |
environment | string | — | Label for the deployment environment (production, staging, development) |
release | string | — | App version or git SHA — used to group errors by deploy |
sessionId | string | — | Browser session identifier; ties events into a session timeline |
autoCapture.errors | boolean | false | Auto-capture unhandled window errors |
autoCapture.unhandledRejections | boolean | false | Auto-capture unhandled promise rejections |
autoCapture.flagExposures | boolean | true | Fire a $flag_exposure event for each flag evaluation |
debug | boolean | false | Log SDK lifecycle events to console.debug |
flushIntervalMs | number | 5000 | Milliseconds between automatic flushes |
batchSize | number | 20 | Items in queue before an immediate flush is triggered |
flagEvalTtlMs | number | 60000 | In-memory cache TTL for flag evaluations |
Batch compression
Event batches larger than 8 KB are automatically gzipped and sent with the Content-Encoding: gzip header. The API accepts both compressed and uncompressed bodies. If your environment does not support the standard CompressionStream API (some React Native runtimes, older polyfills), the SDK automatically falls back to sending uncompressed JSON — no configuration needed.
If you run the SDK behind a reverse proxy, WAF, or corporate middlebox and see ingest errors, confirm the proxy is configured to accept Content-Encoding: gzip or set endpoint to point directly to the Emit Vision API.