Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/borderless/worker-sentry
Sentry client for Cloudflare Workers using `fetch` and native V8 stack traces
https://github.com/borderless/worker-sentry
Last synced: 15 days ago
JSON representation
Sentry client for Cloudflare Workers using `fetch` and native V8 stack traces
- Host: GitHub
- URL: https://github.com/borderless/worker-sentry
- Owner: borderless
- License: mit
- Created: 2020-05-17T15:23:57.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-12-12T06:42:16.000Z (11 months ago)
- Last Synced: 2024-10-20T12:50:48.297Z (26 days ago)
- Language: TypeScript
- Size: 1.1 MB
- Stars: 14
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Worker Sentry
[![NPM version][npm-image]][npm-url]
[![NPM downloads][downloads-image]][downloads-url]
[![Build status][build-image]][build-url]
[![Build coverage][coverage-image]][coverage-url]> Sentry client for Cloudflare Workers using `fetch` and native [V8 stack traces](https://v8.dev/docs/stack-trace-api).
## Installation
```
npm install @borderless/worker-sentry --save
```## Usage
```ts
import { Sentry } from "@borderless/worker-sentry";const sentry = new Sentry({ dsn: "https://[email protected]/789" });
addEventListener("fetch", (event) => {
event.respondWith(
handler(event.request).catch((err) => {
// Extend the event lifetime until the response from Sentry has resolved.
// Docs: https://developers.cloudflare.com/workers/runtime-apis/fetch-event#methods
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"),
},
})
);// Respond to the original request while the error is being logged (above).
return new Response(err.message || "Internal Error", { status: 500 });
})
);
});
```## License
MIT
[npm-image]: https://img.shields.io/npm/v/@borderless/worker-sentry
[npm-url]: https://npmjs.org/package/@borderless/worker-sentry
[downloads-image]: https://img.shields.io/npm/dm/@borderless/worker-sentry
[downloads-url]: https://npmjs.org/package/@borderless/worker-sentry
[build-image]: https://img.shields.io/github/workflow/status/borderless/worker-sentry/CI/main
[build-url]: https://github.com/borderless/worker-sentry/actions/workflows/ci.yml?query=branch%3Amain
[coverage-image]: https://img.shields.io/codecov/c/gh/borderless/worker-sentry
[coverage-url]: https://codecov.io/gh/borderless/worker-sentry