tlianza / pigeon

Sentry Client for Cloudflare Workers
MIT License
44 stars 1 forks source link

WARNING: Check out 'Toucan' instead!

The fundamental design of this project, Pigeon, has problems at scale due to the nature of the Workers runtime and Sentry library design. A colleague of mine went on to tackle this problem in a more scalable way with Toucan, which you should check out instead: https://github.com/robertcepa/toucan-js

Sentry Client for Cloudflare Workers

This client attempts to adhere to the Sentry SDK Guidelines and works inside a Cloudflare Workers environment.

Usage

  1. Install it: npm install --save tlianza/pigeon
  2. Initialize the client in your worker

    import * as Pigeon from "pigeon";
    
    // Your cloudflare worker starts here
    addEventListener("fetch", event => {
      // Initialize the client with your DSN & current event
      Pigeon.init({
        dsn: "YOUR_DSN",
        event: event
      });
    
      // Make sure this is on.
      event.passThroughOnException();
    
      //Rest of your logic/routing/etc here.
    });
  3. Use it within your code like this:

    Pigeon.captureMessage("Test Message");
    
    Pigeon.captureException(new Error("TEST Error"));
    
    Pigeon.addBreadcrumb({
        category: 'method',
        message: 'Method "testmethod" was called',
        level: Severity.Info
    });

What do you get in Sentry?

You should see all of the expected request info. Stack traces should be present but line numbers will be a little sad if your code is webpacked/wrangled up. Still, you'll get the appropriate column numbers.

Sentry Example Screenshot

This is a real example from debugging the "not my phone" app.

Why is it called Pigeon?

It seemed like the Sentry clients were all named after birds (Raven, etc) and a Pigeon is a "worker bird".