1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
//! Crate for sending errors or events to Sentry.
//!
//! If not done already, create a Sentry project and Cloudflare Access credentials to access the
//! Sentry API:
//! - Create a Sentry project: [Create a new Project].
//! - Create an AM Ticket (example [Create Service token for sentry-access.cfdata.org for Eth Resolver]) for issuing an Access Token using the [SOP - Adding an Access Service Token to a Cloudflare Account Managed by Terraform CFAccounts (cfdata.org, cfops.it, etc)].
//!
//! Once the Sentry and creds created, configure your worker:
//!
//! Configure wrangler.toml:
//! ```toml
//! [vars]
//! SENTRY_DSN = ...
//! SENTRY_CF_ACCESS_CLIENT_ID = ...
//! ```
//!
//! Add Cloudflare Access' secret token:
//! ```ignore
//! wrangler secret put SENTRY_CF_ACCESS_CLIENT_SECRET
//! ```
//!
//! Add the npm/yarn dependency:
//! ```ignore
//! yarn add toucan-js
//! ```
//!
//! Finally, use the Sentry client in worker using workers-rs:
//! ```rust
//! #[event(fetch)]
//! pub async fn main(req: Request, env: Env, _ctx: worker::Context) -> Result<Response> {
//! let sentry_config = sentry::SentryConfig::from_env(&env)?;
//! let sentry = sentry::SentryClient::new(sentry_config, &req, &ctx);
//!
//! sentry.set_tag("colo", "LHR");
//! sentry.capture_message("this is a message");
//! sentry.capture_exception(&Err("this is a error"));
//!
//! todo!();
//! }
//! ```
//!
//! [SOP - Adding an Access Service Token to a Cloudflare Account Managed by Terraform CFAccounts (cfdata.org, cfops.it, etc)]: https://wiki.cfdata.org/pages/viewpage.action?pageId=320054360
//! [Create Service token for sentry-access.cfdata.org for Eth Resolver]: https://jira.cfdata.org/browse/AM-10731
//! [Create a new Project]: https://sentry10.cfdata.org/organizations/cloudflare/projects/new/
mod client;
mod toucan_sys;
pub use client::{SentryClient, SentryConfig};