Skip to content

Commit f5b4686

Browse files
feat(init-eval): add Cloudflare Workers platform to eval suite
Add Cloudflare Workers as a new platform in the init-eval test suite. Uses Sentry.withSentry as the init pattern (instead of Sentry.init) since Cloudflare Workers use the withSentry wrapper pattern.
1 parent a6d62d7 commit f5b4686

File tree

8 files changed

+74
-0
lines changed

8 files changed

+74
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { createEvalSuite } from "./helpers/create-eval-suite";
2+
3+
createEvalSuite("cloudflare-workers");

test/init-eval/feature-docs.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,5 +141,17 @@
141141
"profiling": [
142142
"https://docs.sentry.io/platforms/javascript/guides/react/profiling/"
143143
]
144+
},
145+
146+
"cloudflare-workers": {
147+
"getting-started": [
148+
"https://docs.sentry.io/platforms/javascript/guides/cloudflare/"
149+
],
150+
"errors": [
151+
"https://docs.sentry.io/platforms/javascript/guides/cloudflare/"
152+
],
153+
"tracing": [
154+
"https://docs.sentry.io/platforms/javascript/guides/cloudflare/tracing/"
155+
]
144156
}
145157
}

test/init-eval/helpers/platforms.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,18 @@ export const PLATFORMS: Platform[] = [
134134
initPattern: /Sentry\.init/,
135135
timeout: 300_000,
136136
},
137+
{
138+
id: "cloudflare-workers",
139+
name: "Cloudflare Workers",
140+
templateDir: join(TEMPLATES_DIR, "cloudflare-workers-app"),
141+
sdkPackage: "@sentry/cloudflare",
142+
depFile: "package.json",
143+
docs: getDocs("cloudflare-workers"),
144+
installCmd: "npm install",
145+
buildCmd: "npx tsc --noEmit",
146+
initPattern: /Sentry\.withSentry/,
147+
timeout: 300_000,
148+
},
137149
];
138150

139151
export function getPlatform(id: string): Platform {
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules/
2+
.wrangler/
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "cloudflare-workers-app",
3+
"version": "0.1.0",
4+
"private": true,
5+
"scripts": {
6+
"start": "wrangler dev",
7+
"deploy": "wrangler deploy"
8+
},
9+
"devDependencies": {
10+
"@cloudflare/workers-types": "^4",
11+
"typescript": "^5",
12+
"wrangler": "^4"
13+
}
14+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
export default {
2+
async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
3+
const url = new URL(request.url);
4+
5+
if (url.pathname === "/") {
6+
return new Response(JSON.stringify({ message: "Hello World" }), {
7+
headers: { "Content-Type": "application/json" },
8+
});
9+
}
10+
11+
return new Response("Not Found", { status: 404 });
12+
},
13+
} satisfies ExportedHandler<Env>;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ES2022",
4+
"module": "ES2022",
5+
"moduleResolution": "bundler",
6+
"lib": ["ES2022"],
7+
"types": ["@cloudflare/workers-types"],
8+
"strict": true,
9+
"skipLibCheck": true,
10+
"forceConsistentCasingInFileNames": true,
11+
"noEmit": true
12+
},
13+
"include": ["src/**/*"],
14+
"exclude": ["node_modules"]
15+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
name = "cloudflare-workers-app"
2+
main = "src/index.ts"
3+
compatibility_date = "2024-12-01"

0 commit comments

Comments
 (0)