{"_id":"@aidenappleby/monitor-js","_rev":"4-5fccf63d125b9107b7d07bbf46b5b44e","name":"@aidenappleby/monitor-js","dist-tags":{"latest":"1.2.1"},"versions":{"1.0.0":{"name":"@aidenappleby/monitor-js","version":"1.0.0","keywords":["monitor","observability","events","logging","error-tracking"],"author":{"name":"aidenappl"},"license":"MIT","_id":"@aidenappleby/monitor-js@1.0.0","maintainers":[{"name":"aidenappleby","email":"aiden.appleby3@gmail.com"}],"dist":{"shasum":"8ab6031668b7c9434793d34fb9c8e548b390dbf5","tarball":"https://registry.npmjs.org/@aidenappleby/monitor-js/-/monitor-js-1.0.0.tgz","fileCount":7,"integrity":"sha512-U/YsscOY5WpeEJo28kt+LR5VilEsB6CCAMmRYVaPaivzbIOD9QYrHuXx42K8rRBvdDlE8CY9rEao0+OsoNcreg==","signatures":[{"sig":"MEUCIDYJ4nKg0zhKgzGSOrOgFVGAw6F+tGPuqm61czADPDKnAiEA9AV3ukiit+EUfw50x1Kb831b3b4NZhbL2zThmQ+WyN8=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":62304},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.mjs","engines":{"node":">=18.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"gitHead":"8799065679b20585cd38168a30952830cdf20c7f","scripts":{"test":"vitest run","build":"tsup","check":"tsc --noEmit","prepublishOnly":"npm run build"},"_npmUser":{"name":"aidenappleby","email":"aiden.appleby3@gmail.com"},"_npmVersion":"11.8.0","description":"Lightweight JavaScript/TypeScript client for Monitor event ingestion","directories":{},"_nodeVersion":"24.1.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","vitest":"^3.0.0","typescript":"^5.4.0"},"_npmOperationalInternal":{"tmp":"tmp/monitor-js_1.0.0_1778446398735_0.9233998752488513","host":"s3://npm-registry-packages-npm-production"}},"1.1.0":{"name":"@aidenappleby/monitor-js","version":"1.1.0","keywords":["monitor","observability","events","logging","error-tracking"],"author":{"name":"aidenappl"},"license":"MIT","_id":"@aidenappleby/monitor-js@1.1.0","maintainers":[{"name":"aidenappleby","email":"aiden.appleby3@gmail.com"}],"dist":{"shasum":"3d8573bd33801ae2a8168b0532e594851e172410","tarball":"https://registry.npmjs.org/@aidenappleby/monitor-js/-/monitor-js-1.1.0.tgz","fileCount":7,"integrity":"sha512-0P7RlShF1EMxW9mYPsTLfl2/cCWndea/YLdkSi39nrVzzyprVgxlpCNmdgH00fQYSb/WrKPCXmuQw8oAgk/YUg==","signatures":[{"sig":"MEQCIE9zQE4pNHDIO5h8ZW2+ucv0gv74fRoSNQiwbx23jmskAiBcid0kosfRGIq9sbepuIHAB2UyoINUhiJgL+kSO+1+bg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":67646},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.mjs","engines":{"node":">=18.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"gitHead":"17adedc710728806f67e0be8d1189b8ddf67f607","scripts":{"test":"vitest run","build":"tsup","check":"tsc --noEmit","prepublishOnly":"npm run build"},"_npmUser":{"name":"aidenappleby","email":"aiden.appleby3@gmail.com"},"_npmVersion":"11.8.0","description":"Lightweight JavaScript/TypeScript client for Monitor event ingestion","directories":{},"_nodeVersion":"24.1.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","vitest":"^3.0.0","typescript":"^5.4.0"},"_npmOperationalInternal":{"tmp":"tmp/monitor-js_1.1.0_1780177559689_0.6636384222607934","host":"s3://npm-registry-packages-npm-production"}},"1.2.0":{"name":"@aidenappleby/monitor-js","version":"1.2.0","keywords":["monitor","observability","events","logging","error-tracking"],"author":{"name":"aidenappl"},"license":"MIT","_id":"@aidenappleby/monitor-js@1.2.0","maintainers":[{"name":"aidenappleby","email":"aiden.appleby3@gmail.com"}],"dist":{"shasum":"aaac05f96a059d533570113e09250547984f08ba","tarball":"https://registry.npmjs.org/@aidenappleby/monitor-js/-/monitor-js-1.2.0.tgz","fileCount":8,"integrity":"sha512-IdIULcbCx8BKb3YZERwWrKUL91N8bgs2U1ZNf9JpWFwdNDZ56nnRrzcZklQCMPl0zVIc/HNJ2MWfPEgnx7nP1g==","signatures":[{"sig":"MEUCIQDdv7y156aTgnmSB2BVUv3Tf6r/8FAx7WBjVLsKfg3UDQIgJTDHIJN5ApQ5l90ARb3qrLa7THwIn3JDfZymO5JjLTw=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"sig":"MEQCIEVuvMHNfwPUHI5N2MRmZEjXbyzYtHfN2TiX3lpa+nAlAiBQ6GAcZHruPNYjgYZcE9r6hiar9fn4AyFG+VFXx4XZ3w==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":139020},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.mjs","engines":{"node":">=18.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"gitHead":"34963d258ceedd3bfc602ff899e85a13f10ca826","scripts":{"test":"vitest run","build":"tsup","check":"tsc --noEmit","prepublishOnly":"npm run build"},"_npmUser":{"name":"aidenappleby","email":"aiden.appleby3@gmail.com"},"_npmVersion":"11.4.2","description":"Lightweight JavaScript/TypeScript client for Monitor event ingestion","directories":{},"_nodeVersion":"24.3.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","vitest":"^3.0.0","typescript":"^5.4.0"},"_npmOperationalInternal":{"tmp":"tmp/monitor-js_1.2.0_1789264119117_0.33307920547100567","host":"s3://npm-registry-packages-npm-production"}},"1.2.1":{"_id":"@aidenappleby/monitor-js@1.2.1","dist":{"shasum":"b1d52631ec9b22de42c485e1054920cb7b144074","tarball":"https://registry.npmjs.org/@aidenappleby/monitor-js/-/monitor-js-1.2.1.tgz","fileCount":8,"integrity":"sha512-He8NZMRBaaNwu059+baSxpbOpliLniuM9sHH5Y7HKEHkxxzxBQnSj2eDT7/v98B7ogQp0Hz/kVFKP8tItBsHUw==","signatures":[{"sig":"MEYCIQDbEPJLgTNaewrw7t2JndyVOYhfoB/0L4Gb/05fVXGBgwIhANBZ3BXFV0wg3LcZkaBP4MdYRrnU99T5PA1cAU0H/wQD","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCICsX5VKKoqaNPRPEpABfceY3jrq/9XX3nbPkQnyxNaznAiEAp2Y3i1qy7BJlZI+m8jnrmwJFTdwukUDc0XKjTK3eTF8="}],"unpackedSize":150360},"main":"dist/index.js","name":"@aidenappleby/monitor-js","types":"dist/index.d.ts","author":{"name":"aidenappl"},"module":"dist/index.mjs","engines":{"node":">=18.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"gitHead":"34963d258ceedd3bfc602ff899e85a13f10ca826","license":"MIT","scripts":{"test":"vitest run","build":"tsup","check":"tsc --noEmit","prepublishOnly":"npm run build"},"version":"1.2.1","_npmUser":{"name":"aidenappleby","email":"aiden.appleby3@gmail.com"},"keywords":["monitor","observability","events","logging","error-tracking"],"_npmVersion":"11.4.2","description":"Lightweight JavaScript/TypeScript client for Monitor event ingestion","directories":{},"maintainers":[{"name":"aidenappleby","email":"aiden.appleby3@gmail.com"}],"_nodeVersion":"24.3.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","vitest":"^3.0.0","typescript":"^5.4.0"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/monitor-js_1.2.1_1789268150274_0.0824809078792863"}}},"time":{"created":"2026-05-10T20:53:18.660Z","modified":"2026-09-13T02:55:50.594Z","1.0.0":"2026-05-10T20:53:18.892Z","1.1.0":"2026-05-30T21:45:59.859Z","1.2.0":"2026-09-13T01:48:39.200Z","1.2.1":"2026-09-13T02:55:50.361Z"},"author":{"name":"aidenappl"},"license":"MIT","keywords":["monitor","observability","events","logging","error-tracking"],"description":"Lightweight JavaScript/TypeScript client for Monitor event ingestion","maintainers":[{"name":"aidenappleby","email":"aiden.appleby3@gmail.com"}],"readme":"# monitor-js\n\nLightweight JavaScript/TypeScript client for the Monitor platform — ships structured\nevents (and auto-captured browser errors) as NDJSON to `monitor-core`.\n\n> **Monitor platform** · TypeScript SDK · `@aidenappleby/monitor-js` (npm)\n\n---\n\n## Overview\n\n`monitor-js` is the browser/Node SDK for Monitor, the counterpart to `go-monitor`. It\nqueues and batches events, ships them to a zone's ingest endpoint over `fetch`, and can\nauto-capture uncaught errors and unhandled promise rejections (browser and Node). It keeps\nthe same wire format as the Go SDK — including its rules for surviving ingest's\nall-or-nothing validation: invalid ids are cleared before sending, a rejected batch is\nsplit until only the malformed event is dropped, and transient failures are retried with\nbackoff instead of discarded.\n\n## Install\n\n```bash\nnpm install @aidenappleby/monitor-js\n```\n\n## Usage\n\n```ts\nimport { Monitor } from \"@aidenappleby/monitor-js\";\n\nconst monitor = new Monitor({\n  service: \"my-web-app\",\n  ingestUrl: \"https://appleby-monitor-api.appleby.cloud/v1/events\", // one zone's ingest endpoint\n  apiKey: process.env.MONITOR_API_KEY!,   // ingest-scoped key minted on that zone\n  env: \"production\",\n  onDrop: (total) => droppedEvents.set(total), // optional: be told about loss\n});\n\nmonitor.setUser(\"user_123\");\nmonitor.info(\"checkout.start.success\", { data: { cartTotal: 4200 } });\nmonitor.error(\"checkout.payment.failed\", { data: { reason: \"card_declined\" } });\n\nmonitor.stats(); // { enqueued, flushed, dropped, quarantined, queued }\n\n// on teardown\nmonitor.shutdown();\n```\n\n> **In a browser, `apiKey` is public** — anyone who loads the page can read it. Prefer\n> pointing `ingestUrl` at a route on your own origin that forwards to Monitor server-side.\n\nUncaught errors and unhandled rejections are captured automatically in **both** the\nbrowser (`window`) and Node (`process.on`) — disable with `captureErrors: false` /\n`captureUnhandledRejections: false`. Filter noise with\n`ignoreErrors: [/extension/i, \"ResizeObserver\"]`.\n\nIn Node, installing a process listener would normally stop an uncaught exception from\ncrashing the process. The SDK keeps Node's behavior: when it is the **only**\n`uncaughtException` listener, it reports, prints the error, waits up to 1.5s for the batch\nto leave, and exits 1; an unhandled rejection with no other listener is re-raised as an\nuncaught exception, exactly as Node does by default. If your app has its own listener, the\nSDK only reports. Server code that manages its own crash handling (e.g. a Next.js\n`instrumentation.ts`) should pass `captureErrors: false, captureUnhandledRejections: false`.\n\n### Correlation ids\n\n`request_id`, `trace_id` and `job_id` must be a UUID or 8–64 hex characters — anything\nelse is cleared before sending and kept in `data.invalid_<field>`. Each `Monitor` mints a\nsession `job_id`; mint the others with the helpers:\n\n```ts\nimport { newRequestId, newTraceId, isValidCorrelationId } from \"@aidenappleby/monitor-js\";\n\nmonitor.info(\"upload.start.success\", { requestId: newRequestId(), traceId: newTraceId() });\n```\n\n### Axios integration\n\n```ts\nimport axios from \"axios\";\nimport { attachAxiosMonitor } from \"@aidenappleby/monitor-js\";\n\nconst api = axios.create({ baseURL: \"/api\", validateStatus: () => true });\nattachAxiosMonitor(api, monitor, { ignorePaths: [\"/health\"] });\n```\n\nReported URLs have their query string removed.\n\n## Role in the Monitor ecosystem\n\n- **`monitor-core`** — ingestion target (`POST /v1/events`, `X-Api-Key`).\n- **`go-monitor`** — the Go SDK; shares the wire format and delivery rules.\n- **`monitor-web`** — displays the events (it does not use this SDK).\n\n## Development\n\n| Command | What it does |\n|---|---|\n| `npm run check` | `tsc --noEmit` |\n| `npm test` | vitest |\n| `npm run build` | tsup → `dist/` (CJS + ESM + d.ts) |\n\nPublishing to npm runs the build via `prepublishOnly` and requires 2FA.\n\n## Contributing & further reading\n\nRead **[AGENTS.md](./AGENTS.md)** before working here — it documents the event pipeline,\nthe delivery rules, the exact wire contract (kept in lockstep with `go-monitor` /\n`monitor-core`), the config surface, and current known issues.\n","readmeFilename":"README.md"}