diff --git a/apps/telemetry-worker/src/index.test.ts b/apps/telemetry-worker/src/index.test.ts index 60eb5428c..b970043fe 100644 --- a/apps/telemetry-worker/src/index.test.ts +++ b/apps/telemetry-worker/src/index.test.ts @@ -89,13 +89,25 @@ describe('telemetry ingest', () => { expect(points[2].blobs).toEqual(['yes']); }); - it('rejects GET with 405', async () => { - const { env } = makeEnv(); + it('redirects GET to the telemetry docs with 302 without writing points', async () => { + const { env, points } = makeEnv(); const res = await worker.fetch( new Request('https://telemetry.pgflow.dev/', { method: 'GET' }), env, ); + expect(res.status).toBe(302); + expect(res.headers.get('location')).toBe('https://pgflow.dev/reference/telemetry/'); + expect(points).toHaveLength(0); + }); + + it.each(['HEAD', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'])('rejects %s with 405 without writing points', async (method) => { + const { env, points } = makeEnv(); + const res = await worker.fetch( + new Request('https://telemetry.pgflow.dev/', { method }), + env, + ); expect(res.status).toBe(405); + expect(points).toHaveLength(0); }); it('rejects malformed JSON with 400', async () => { diff --git a/apps/telemetry-worker/src/index.ts b/apps/telemetry-worker/src/index.ts index c41617973..5d0a1f69d 100644 --- a/apps/telemetry-worker/src/index.ts +++ b/apps/telemetry-worker/src/index.ts @@ -126,6 +126,9 @@ const reject = (status: number) => new Response(null, { export default { async fetch(request: Request, env: Env): Promise { + if (request.method === 'GET') { + return Response.redirect('https://pgflow.dev/reference/telemetry/', 302); + } if (request.method !== 'POST') return reject(405); const contentType = request.headers.get('content-type') ?? ''; diff --git a/apps/telemetry-worker/wrangler.toml b/apps/telemetry-worker/wrangler.toml index 27eb9f42a..bd5261aa3 100644 --- a/apps/telemetry-worker/wrangler.toml +++ b/apps/telemetry-worker/wrangler.toml @@ -2,6 +2,10 @@ name = "pgflow-telemetry" main = "src/index.ts" compatibility_date = "2026-09-01" +[[routes]] +pattern = "telemetry.pgflow.dev" +custom_domain = true + [[analytics_engine_datasets]] binding = "PGFLOW_TELEMETRY" dataset = "pgflow_telemetry"