# sssentry

> Just a small lib which simplifies adding Sentry to Workers

Latest version **1.0.2** (published 2022-11-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install sssentry
pnpm add sssentry
yarn add sssentry
bun add sssentry
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2022-11-25 |
| First published | 2022-11-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 138.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Blob Development Ltd |
| Maintainers | blobdevelopment |

## Links

- npm: https://www.npmjs.com/package/sssentry
- npm.io page: https://npm.io/package/sssentry

## Dependencies (1)

- [toucan-js](https://npm.io/package/toucan-js.md) 2.7.0

## Recent versions

- 1.0.2 (latest) — 2022-11-25

## README

# SSSentry

Very quick setup for Sentry inside of Cloudflare Workers using [ToucanJS](https://github.com/robertcepa/toucan-js).

## 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 sssentry
```

## Usage

### Option 1

#### JavaScript ([example](https://github.com/BlobDevelopment/sssentry/blob/main/examples/no_global.js))

```js
import { sentryFetch } from 'sssentry';

export default {
  fetch(req, env, ctx) {
    return sentryFetch(req, env, ctx, { dsn: 'https://project@ingest.sentry.io/1' }, this.handleRequest);
  },

  async handleRequest(req, env) {
    // Actual logic
    // env.SENTRY.setUser('abc123');
    return new Response('Blobs are cool!');
  }
}
```

#### TypeScript ([example](https://github.com/BlobDevelopment/sssentry/blob/main/examples/no_global.ts))

```ts
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://project@ingest.sentry.io/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](https://github.com/BlobDevelopment/sssentry/blob/main/examples/setup.js))

```js
import { sentryFetch, setup } from 'sssentry';

setup({ dsn: 'https://project@ingest.sentry.io/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](https://github.com/BlobDevelopment/sssentry/blob/main/examples/setup.ts))

```ts
import { sentryFetch, setup, Toucan } from 'sssentry';

interface Env {
  KV: KVNamespace;
  SENTRY: Toucan;
}

setup({ dsn: 'https://project@ingest.sentry.io/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 }
```

---
_Source: https://npm.io/package/sssentry · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
