From b562139e8877b7bc738f7d17fb1e65ef2e6a3dfa Mon Sep 17 00:00:00 2001 From: Agent Date: Fri, 2 Oct 2026 07:37:19 +0000 Subject: [PATCH] fix(telemetry): route the collector domain and redirect browser visits Browser GET requests previously returned 405. Redirect them to the telemetry reference with 302 while preserving POST ingestion and rejecting other methods without Analytics Engine writes. Declare telemetry.pgflow.dev as a Worker Custom Domain so Wrangler manages DNS and TLS during deployment. Collector tests, typecheck, lint, and the Wrangler deployment dry-run pass; no live infrastructure changes or package release are part of this commit. --- apps/telemetry-worker/src/index.test.ts | 16 ++++++++++++++-- apps/telemetry-worker/src/index.ts | 3 +++ apps/telemetry-worker/wrangler.toml | 4 ++++ 3 files changed, 21 insertions(+), 2 deletions(-) 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"