@borderless/worker-sentry

Sentry client for Cloudflare Workers using `fetch` and V8 stack traces

Usage no npm install needed!

<script type="module">
  import borderlessWorkerSentry from 'https://cdn.skypack.dev/@borderless/worker-sentry';
</script>

README

Worker Sentry

NPM version NPM downloads Build status Test coverage

Sentry client for Cloudflare Workers using fetch and native V8 stack traces.

Installation

npm install @borderless/worker-sentry --save

Usage

import { Sentry } from "@borderless/worker-sentry";

const sentry = new Sentry({ dsn: "https://123@456.ingest.sentry.io/789" });

addEventListener("fetch", (event) => {
  event.respondWith(
    handler(event.request).catch((err) => {
      // Wait until the response from Sentry has resolved.
      event.waitUntil(
        // Sends a request to Sentry and returns the response promise.
        sentry.captureException(err, {
          tags: {},
          user: {
            ip_address: event.request.headers.get("cf-connecting-ip"),
          },
        })
      );
    })
  );
});

License

MIT