Sentry over Access for Worker
npm install -D @cloudflare/worker-sentryimport { initSentry } from "@cloudflare/worker-sentry";
export default {
async fetch(request, env, context) {
const sentry = initSentry(request, env, context);
try {
console.log("Got request", request);
const response = await fetch(request);
console.log("Got response", response);
return response;
} catch (e) {
sentry.captureException(e);
return new Response("internal error", { status: 500 });
}
}
} The API: initSentry(request, env, context, additionalOptions = {}) allows any options to be passed directly to toucan-js. For instance to specify the environment the worker is running in.
name = "sentry-test"
account_id = "your account_id"
[vars]
SENTRY_DSN = "Sentry DSN"
SENTRY_CLIENT_ID = "Access client ID"
SENTRY_CLIENT_SECRET = "Access client secret"