Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mhart/cf-sentry
A template to create a Cloudflare worker that logs errors to Sentry
https://github.com/mhart/cf-sentry
Last synced: about 1 month ago
JSON representation
A template to create a Cloudflare worker that logs errors to Sentry
- Host: GitHub
- URL: https://github.com/mhart/cf-sentry
- Owner: mhart
- License: apache-2.0
- Fork: true (cloudflare/worker-template)
- Created: 2019-07-26T17:37:36.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-09-28T18:25:00.000Z (about 2 years ago)
- Last Synced: 2024-08-04T09:04:07.950Z (5 months ago)
- Language: JavaScript
- Homepage:
- Size: 32.2 KB
- Stars: 56
- Watchers: 3
- Forks: 9
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE_APACHE
Awesome Lists containing this project
README
# cf-sentry
A template to create a [Cloudflare worker](https://www.cloudflare.com/products/cloudflare-workers/)
that logs errors to [Sentry](https://sentry.io).## Generating
Use [wrangler](https://github.com/cloudflare/wrangler)
```
wrangler generate projectname https://github.com/bustle/cf-sentry
```Then edit the config variables in [`sentry.js`](https://github.com/bustle/cf-sentry/blob/master/sentry.js)
to suit your environment:```js
// Get the key from the "DSN" at: https://sentry.io/settings//projects//keys/
// The "DSN" will be in the form: https://@sentry.io/
// eg, https://[email protected]/123456
const SENTRY_PROJECT_ID = '123456'
const SENTRY_KEY = '0000aaaa1111bbbb2222cccc3333dddd'// Useful if you have multiple apps within a project – not necessary, only used in TAGS and SERVER_NAME below
const APP = 'my-app'// https://docs.sentry.io/error-reporting/configuration/?platform=javascript#environment
const ENV = 'development'// https://docs.sentry.io/error-reporting/configuration/?platform=javascript#release
// A string describing the version of the release – we just use: git rev-parse --verify HEAD
// You can use this to associate files/source-maps: https://docs.sentry.io/cli/releases/#upload-files
const RELEASE = '0000aaaa1111bbbb2222cccc3333dddd'// https://docs.sentry.io/enriching-error-data/context/?platform=javascript#tagging-events
const TAGS = { app: APP }// https://docs.sentry.io/error-reporting/configuration/?platform=javascript#server-name
const SERVER_NAME = `${APP}-${ENV}`
```Then you can build your project, publish it, etc with `wrangler`:
```
cd projectname
wrangler build
```## License
Licensed under either of
- Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)at your option.