shipd-sdk
v0.2.1
Published
Catch production bugs. Shipd fixes them automatically.
Maintainers
Readme
shipd-sdk
Catch production bugs. Shipd fixes them automatically.
Lightweight, non-blocking error tracking SDK. Auto-detects Node.js vs Browser environments. Supports source maps for original file/line mapping.
Install
npm install shipd-sdkQuick Start
import { shipd } from 'shipd-sdk';
shipd.init({
key: 'shipd_xxxxxxxxxxxx',
repo: 'owner/repo-name',
environment: 'production',
release: '1.0.0',
});That's it. The SDK automatically catches:
- Uncaught exceptions (Node.js
uncaughtException) - Unhandled promise rejections (Node.js + Browser)
- Browser errors (
window.onerror)
Manual Capture
try {
riskyOperation();
} catch (err) {
shipd.captureError(err, { userId: '123', action: 'checkout' });
}Wrap Functions
// Automatically catches errors from async functions
const handler = shipd.wrap(async (req, res) => {
const data = await fetchData();
res.json(data);
});Express Middleware
import { shipd } from 'shipd-sdk';
import { shipdErrorHandler, shipdRequestHandler } from 'shipd-sdk/express';
shipd.init({ key: 'shipd_xxx', repo: 'owner/repo' });
const app = express();
// Optional: adds response time tracking
app.use(shipdRequestHandler());
// ... your routes ...
// Must be LAST — catches unhandled errors
app.use(shipdErrorHandler());Configuration
shipd.init({
key: 'shipd_xxxxxxxxxxxx', // Required: your API key
repo: 'owner/repo-name', // Required: GitHub repo
endpoint: 'https://...', // Optional: custom API endpoint
environment: 'production', // Optional: environment tag
release: '1.0.0', // Optional: release/version tag
debug: false, // Optional: log SDK activity
beforeSend: (payload) => { // Optional: filter/modify errors
if (payload.message.includes('ignore')) return null;
return payload;
},
});Features
- ~10KB — Lightweight, no dependencies
- Non-blocking — Fire-and-forget, batched sending
- Auto-deduplication — Same error won't be reported more than once per minute
- Source maps — Automatically resolves to original source files (Node.js)
- Smart stack parsing — V8, Firefox, and Safari stack trace formats
- beforeSend hook — Filter or modify errors before sending
- Express middleware — Drop-in error handler with request context
- wrap() — Automatically catch errors from async functions
How It Works
- SDK catches production errors
- Errors are sent to Shipd
- Shipd's AI analyzes the error and your code
- A fix PR is automatically opened on your repo
License
MIT
