New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

toucan-js

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

toucan-js

Cloudflare Workers client for Sentry

  • 0.0.1
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

toucan-js

Toucan is reliable Sentry client for Cloudflare Workers. It adheres to Sentry unified API guidelines - with minor differences.

Lightweight. Easy to use. In TypeScript.

Usage

npm install --save toucan-js

worker.ts

import Toucan from "toucan-js";

addEventListener("fetch", (event) => {
  const sentry = new Toucan({
    dsn: "dsn...",
    event,
    whitelistedHeaders: ["user-agent"],
    whitelistedSearchParams: /(.*)/,
  });

  sentry.setUser({ id: "1234" });

  event.respondWith(doStuff(event, sentry));
});

async function doStuff(event: FetchEvent, sentry: Toucan) {
  try {
    sentry.addBreadcrumb({
      message: "About to do some I/O...",
      category: "log",
    });
    // do some I/O
    return new Response("OK", {
      status: 200,
    });
  } catch (err) {
    sentry.captureException(err);
    return new Response("", {
      status: 200,
      statusText: "OK",
    });
  }
}

Features

  • addBreadcumb: Records a new breadcrumb which will be attached to future events.
  • captureException: Captures an exception event and sends it to Sentry.
  • captureMessage: Captures a message event and sends it to Sentry.
  • setRequestBody: Records incoming request's body which will be attached to future events.
  • setTag: Set key:value that will be sent as tags data with the event.
  • setTags: Set an object that will be merged sent as tags data with the event.
  • setUser: Updates user context information for future events.

Options

OptionTypeDescription
dsn*stringSentry Data Source Name.
event*FetchEventWorkers fetch event. Toucan needs this to be able to call waitUntil.
environmentstringYour application's environment (production/staging/...).
releasestringRelease tag.
pkgobjectEssentially your package.json. Toucan will use it to read project name, version, dependencies, and devDependencies.
whitelistedHeadersstring[] | RegExpArray of whitelisted headers, or a regular expression used to whitelist headers of incoming request. If not provided, headers will not be logged.
whitelistedCookiesstring[] | RegExpArray of whitelisted cookies, or a regular expression used to whitelist cookies of incoming request. If not provided, cookies will not be logged.
whitelistedSearchParamsstring[] | RegExpArray of whitelisted search params, or a regular expression used to whitelist search params of incoming request. If not provided, search params will not be logged.
beforeSend(event: Event) => EventThis function is applied to all events before sending to Sentry. If provided, all whitelists are ignored.

Keywords

FAQs

Package last updated on 10 Apr 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc