Skip to content

Commit

Permalink
fix snippets
Browse files Browse the repository at this point in the history
  • Loading branch information
AbhiPrasad committed Aug 26, 2024
1 parent a25f852 commit 8bd801f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ notSupported:
- javascript.hapi
- javascript.koa
- javascript.nestjs
- javascript.
- javascript.deno
- javascript.cloudflare
- javascript.bun
---
Expand Down
2 changes: 1 addition & 1 deletion docs/platforms/javascript/guides/cloudflare/config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
title: Cloudflare
description: 'Official Sentry SDK for Cloudflare Workers and Cloudflare Pages.'
sdk: sentry.javascript.bun
sdk: sentry.javascript.cloudflare
categories:
- javascript
- server
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ To use this SDK, add the `sentryPagesPlugin` as
We recommend adding a `functions/_middleware.js` for the middleware setup so that Sentry is initialized for your entire
app.

```javascript
// functions/_middleware.js
```javascript {filename:functions/_middleware.js}
import * as Sentry from "@sentry/cloudflare";

export const onRequest = [
Expand All @@ -39,8 +38,6 @@ export const onRequest = [
To use this SDK, wrap your handler with the `withSentry` function. This will initialize the SDK and hook into the
environment. Note that you can turn off almost all side effects using the respective options.

Currently only ESM handlers are supported.

```javascript
import * as Sentry from '@sentry/cloudflare';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,60 +1,35 @@
<SignInNote />

```javascript
import * as Sentry from "@sentry/bun";

Sentry.init({
dsn: "___PUBLIC_DSN___",
integrations: [],
});
```

## Cloudflare Pages

To use this SDK, add the `sentryPagesPlugin` as
[middleware to your Cloudflare Pages application](https://developers.cloudflare.com/pages/functions/middleware/).

We recommend adding a `functions/_middleware.js` for the middleware setup so that Sentry is initialized for your entire
app.

```javascript
// functions/_middleware.js
```javascript {filename:functions/_middleware.js}
import * as Sentry from "@sentry/cloudflare";

export const onRequest = [
// Make sure Sentry is the first middleware
Sentry.sentryPagesPlugin((context) => ({
dsn: "___PUBLIC_DSN___",
// We recommend adjusting this value in production, or using tracesSampler
// for finer control
tracesSampleRate: 1.0,
// To set a uniform sample rate
tracesSampleRate: 0.2

// Set `tracePropagationTargets` to control for which URLs trace propagation should be enabled
tracePropagationTargets: ["localhost", /^https:\/\/yourserver\.io\/api/],
// Alternatively, to control sampling dynamically
tracesSampler: samplingContext => { ... }
})),
// Add more middlewares here
];
```

## Cloudflare Workers

To use this SDK, wrap your handler with the `withSentry` function. This will initialize the SDK and hook into the
environment. Note that you can turn off almost all side effects using the respective options.

Currently only ESM handlers are supported.

```javascript
```javascript {filename:functions/_middleware.js}
import * as Sentry from '@sentry/cloudflare';

export default withSentry(
env => ({
dsn: "___PUBLIC_DSN___",
// We recommend adjusting this value in production, or using tracesSampler
// for finer control
tracesSampleRate: 1.0,
// To set a uniform sample rate
tracesSampleRate: 0.2

// Set `tracePropagationTargets` to control for which URLs trace propagation should be enabled
tracePropagationTargets: ["localhost", /^https:\/\/yourserver\.io\/api/],
// Alternatively, to control sampling dynamically
tracesSampler: samplingContext => { ... }
}),
{
async fetch(request, env, ctx) {
Expand Down

0 comments on commit 8bd801f

Please sign in to comment.