1.0.2 • Published 1 year ago

sssentry v1.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

SSSentry

Very quick setup for Sentry inside of Cloudflare Workers using ToucanJS.

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)

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)

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)

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)

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 }
1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago