Skip to content

Commit cbbdb5c

Browse files
AbhiPrasadbitsandfoxes
authored andcommitted
feat(cloudflare): Use explicit Env casting (#14085)
<!-- Use this checklist to make sure your PR is ready for merge. You may delete any sections you don't need. --> ## DESCRIBE YOUR PR Explicitly using `Env` should help with some type issues. Part of getsentry/sentry-javascript#16650 ## IS YOUR CHANGE URGENT? Help us prioritize incoming PRs by letting us know when the change needs to go live. - [ ] Urgent deadline (GA date, etc.): <!-- ENTER DATE HERE --> - [ ] Other deadline: <!-- ENTER DATE HERE --> - [x] None: Not urgent, can wait up to 1 week+ ## SLA - Teamwork makes the dream work, so please add a reviewer to your PRs. - Please give the docs team up to 1 week to review your PR unless you've added an urgent due date to it. Thanks in advance for your help! ## PRE-MERGE CHECKLIST *Make sure you've checked the following before merging your changes:* - [ ] Checked Vercel preview for correctness, including links - [ ] PR was reviewed and approved by any necessary SMEs (subject matter experts) - [ ] PR was reviewed and approved by a member of the [Sentry docs team](https://github.com/orgs/getsentry/teams/docs) ## LEGAL BOILERPLATE <!-- Sentry employees and contractors can delete or ignore this section. --> Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms. ## EXTRA RESOURCES - [Sentry Docs contributor guide](https://docs.sentry.io/contributing/)
1 parent 21a7c21 commit cbbdb5c

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

docs/platforms/javascript/guides/cloudflare/features/durableobject.mdx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@ _(Available in version [9.16.0](https://github.com/getsentry/sentry-javascript/r
77

88
You can use the `instrumentDurableObjectWithSentry` method to instrument [Cloudflare Durable Objects](https://developers.cloudflare.com/durable-objects/).
99

10-
```javascript
10+
```typescript
1111
import * as Sentry from "@sentry/cloudflare";
1212

1313
class MyDurableObjectBase extends DurableObject<Env> {
14-
// impl
14+
// impl
1515
}
1616

1717
// Export your named class as defined in your wrangler config
1818
export const MyDurableObject = Sentry.instrumentDurableObjectWithSentry(
19-
(env) => ({
20-
dsn: "___PUBLIC_DSN___",
21-
tracesSampleRate: 1.0,
22-
}),
23-
MyDurableObjectBase,
19+
(env: Env) => ({
20+
dsn: "___PUBLIC_DSN___",
21+
tracesSampleRate: 1.0,
22+
}),
23+
MyDurableObjectBase
2424
);
2525
```

platform-includes/getting-started-config/javascript.cloudflare.workers.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Hono, HTTPException } from "hono";
66
import * as Sentry from "@sentry/cloudflare";
77

88
export default Sentry.withSentry(
9-
(env) => {
9+
(env: Env) => {
1010
const { id: versionId } = env.CF_VERSION_METADATA;
1111

1212
return {
@@ -30,7 +30,7 @@ export default Sentry.withSentry(
3030
// https://docs.sentry.io/platforms/javascript/configuration/options/#traces-sample-rate
3131
tracesSampleRate: 1.0,
3232
// ___PRODUCT_OPTION_END___ performance
33-
}
33+
};
3434
},
3535
// your existing worker export
3636
app

platform-includes/logs/setup/javascript.cloudflare.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
To enable logging, you need to initialize the SDK with the `_experiments.enableLogs` option set to `true`.
22

3-
```js
3+
```typescript
44
import * as Sentry from "@sentry/cloudflare";
55

66
export default Sentry.withSentry(
7-
(env) => ({
7+
(env: Env) => ({
88
dsn: "___PUBLIC_DSN___",
99
// Enable logs to be sent to Sentry
1010
_experiments: { enableLogs: true },

platform-includes/performance/configure-sample-rate/javascript.cloudflare.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const onRequest = [
2121
import * as Sentry from "@sentry/cloudflare";
2222

2323
export default Sentry.withSentry(
24-
env => ({
24+
(env: Env) => ({
2525
dsn: "___PUBLIC_DSN___",
2626
// To set a uniform sample rate
2727
tracesSampleRate: 0.2

0 commit comments

Comments
 (0)