sssentry
v1.0.2
Published
Just a small lib which simplifies adding Sentry to Workers
Readme
SSSentry
Very quick setup for Sentry inside of Cloudflare Workers using ToucanJS.
Install
You will want to install this package and make sure it's bundled when your Worker is uploaded. Wrangler 2 will by default use esbuild and bundle for you.
npm i --save sssentryUsage
Option 1
JavaScript (example)
import { sentryFetch } from 'sssentry';
export default {
fetch(req, env, ctx) {
return sentryFetch(req, env, ctx, { dsn: 'https://[email protected]/1' }, this.handleRequest);
},
async handleRequest(req, env) {
// Actual logic
// env.SENTRY.setUser('abc123');
return new Response('Blobs are cool!');
}
}TypeScript (example)
import { sentryFetch, Toucan } from 'sssentry';
interface Env {
KV: KVNamespace;
SENTRY: Toucan;
}
export default {
fetch(req: Request, env: Env, ctx: ExecutionContext) {
return sentryFetch(req, env, ctx, { dsn: 'https://[email protected]/1' }, this.handleRequest)
},
async handleRequest(req: Request, env: Env): Promise<Response> {
// Actual logic
// env.SENTRY.setUser('abc123');
return new Response('Blobs are cool!');
}
}Option 2
JavaScript (example)
import { sentryFetch, setup } from 'sssentry';
setup({ dsn: 'https://[email protected]/1' }, handleRequest);
async function handleRequest(req, env) {
// Actual logic
// env.SENTRY.setUser('abc123');
return new Response('Blobs are cool!');
}
export default { fetch: sentryFetch }TypeScript (example)
import { sentryFetch, setup, Toucan } from 'sssentry';
interface Env {
KV: KVNamespace;
SENTRY: Toucan;
}
setup({ dsn: 'https://[email protected]/1' }, handleRequest);
async function handleRequest(req: Request, env: Env): Promise<Response> {
// Actual logic
// env.SENTRY.setUser('abc123');
return new Response('Blobs are cool!');
}
export default { fetch: sentryFetch }