Skip to content

feat(features): offer server-side HTTP log capture on Cloudflare Workers projects - #1114

Open
lricoy wants to merge 2 commits into
mainfrom
posthog/http-log-additional-feature
Open

feat(features): offer server-side HTTP log capture on Cloudflare Workers projects#1114
lricoy wants to merge 2 commits into
mainfrom
posthog/http-log-additional-feature

Conversation

@lricoy

@lricoy lricoy commented Aug 19, 2026

Copy link
Copy Markdown
Member

Problem

Bots, crawlers, and AI agents rarely run JavaScript, so a wizard-installed JS SDK never sees them. Web analytics bot analytics needs server-side $http_log events, and the wizard has no way to offer that setup even on projects where it is a one-file change.

Changes

  • Feature discovery now detects projects that can forward server logs with one file: a wrangler config, a Cloudflare package (wrangler, @cloudflare/workers-types, framework adapters), or a root middleware file (Next.js convention).
  • On detection, the tips card shows an opt-in toggle (key b): "PostHog can show you bot and AI crawler traffic". Opting in queues an additional-feature prompt, exactly like the existing LLM observability opt-in.
  • The queued prompt points the agent at the $http_log payload reference (sending HTTP log events) and states the invariants: one event per request, $raw_user_agent/$current_url/$ip, anonymous person processing, hashed per-client distinct ID, off the request path, skip static assets.

Test plan

  • Three new cases in features.test.ts: the HttpLog feature is discovered from a wrangler dependency, a wrangler.toml config file, and a root middleware.ts. Suite passes locally (15/15).
  • pnpm typecheck fails only on pre-existing errors in src/utils/bounded-fs.ts, untouched here; eslint reports 0 errors.
  • Not run: an end-to-end wizard session exercising the new toggle.

LLM context

Authored with Claude Code in a PostHog Desktop cloud task, mirroring the AdditionalFeature.LLM opt-in flow. Part of a wider $http_log adoption effort: source templates in PostHog/posthog#85969, docs in PostHog/posthog.com#19588.


Created with PostHog Desktop

…ers projects

Detect Cloudflare Workers projects (wrangler config or Cloudflare packages) and surface an opt-in tip that queues an additional-feature prompt guiding the agent to set up $http_log capture for bot analytics, mirroring the LLM observability opt-in.

Generated-By: PostHog Desktop
Task-Id: 9023dadc-319f-42e8-a662-7990f1aff585
@github-actions

Copy link
Copy Markdown

🧙 Wizard CI

Run the Wizard CI and test your changes against wizard-workbench example apps by replying with a GitHub comment using one of the following commands:

Test all apps:

  • /wizard-ci all

Test all apps in a directory:

  • /wizard-ci ai-observability
  • /wizard-ci basic-integration
  • /wizard-ci mcp-analytics
  • /wizard-ci revenue
  • /wizard-ci self-driving

Test an individual app:

  • /wizard-ci ai-observability/anthropic
  • /wizard-ci ai-observability/groq
  • /wizard-ci ai-observability/manual-capture
Show more apps
  • /wizard-ci ai-observability/openai
  • /wizard-ci ai-observability/openai-agents
  • /wizard-ci ai-observability/vercel-ai
  • /wizard-ci basic-integration/android
  • /wizard-ci basic-integration/angular
  • /wizard-ci basic-integration/astro
  • /wizard-ci basic-integration/django
  • /wizard-ci basic-integration/fastapi
  • /wizard-ci basic-integration/flask
  • /wizard-ci basic-integration/javascript-node
  • /wizard-ci basic-integration/javascript-web
  • /wizard-ci basic-integration/laravel
  • /wizard-ci basic-integration/next-js
  • /wizard-ci basic-integration/nuxt
  • /wizard-ci basic-integration/python
  • /wizard-ci basic-integration/rails
  • /wizard-ci basic-integration/react-native
  • /wizard-ci basic-integration/react-router
  • /wizard-ci basic-integration/sveltekit
  • /wizard-ci basic-integration/swift
  • /wizard-ci basic-integration/tanstack-router
  • /wizard-ci basic-integration/tanstack-start
  • /wizard-ci basic-integration/vue
  • /wizard-ci mcp-analytics/custom-dispatcher
  • /wizard-ci mcp-analytics/typescript-sdk
  • /wizard-ci revenue/stripe
  • /wizard-ci self-driving/astro
  • /wizard-ci self-driving/fastapi
  • /wizard-ci self-driving/nuxt
  • /wizard-ci self-driving/react-router
  • /wizard-ci self-driving/sveltekit

Results will be posted here when complete.

项目 without a wrangler config but with a root middleware file (Next.js convention) also get the server-log opt-in, and the tip copy no longer claims Cloudflare specifically.

Generated-By: PostHog Desktop
Task-Id: 9023dadc-319f-42e8-a662-7990f1aff585
@lricoy
lricoy marked this pull request as ready for review August 25, 2026 19:29
@lricoy
lricoy requested a review from a team as a code owner August 25, 2026 19:29

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: af80cec8c4

ℹ️ 关于 Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/lib/wizard-session.ts
/** Agent prompts for each additional feature, injected via the stop hook */
export const ADDITIONAL_FEATURE_PROMPTS: Record<AdditionalFeature, string> = {
[AdditionalFeature.LLM]: `Now integrate AI observability with PostHog. Use the PostHog MCP server to find the appropriate AI observability skill, install it, and follow its workflow. PostHog basics are already installed. Update the setup report markdown file when complete with additions from this task. `,
[AdditionalFeature.HttpLog]: `Now integrate server-side HTTP log capture with PostHog so bots, crawlers, and AI agents show up in web analytics. 关注 https://posthog.com/docs/web-analytics/sending-http-logs: send one $http_log event per request to the capture API, with $raw_user_agent, $current_url, $ip, and $process_person_profile set to false, using a hashed per-client distinct ID. Prefer the platform's native hook (a Cloudflare Worker on Workers projects, otherwise server middleware), keep it off the request path, and skip static asset requests. PostHog basics are already installed. Update the setup report markdown file when complete with additions from this task. `,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Move the HTTP-log workflow into a skill

This embeds the complete product-specific HTTP-log integration workflow in wizard-session.ts, so changes to the payload requirements or supported platforms require a wizard release and can drift from the documentation. Put this workflow in a context-mill markdown skill and have the queued prompt discover and install that skill, as the existing LLM feature does.

AGENTS.md reference: AGENTS.md:L16-L17

Useful? React with 👍 / 👎.

store.session.discoveredFeatures.includes(DiscoveredFeature.HttpLog),
toggle: {
key: 'b',
feature: AdditionalFeature.HttpLog,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Honor the HTTP-log opt-in in orchestrator runs

When the wizard-orchestrator flag routes posthog-integration through the orchestrator, pressing B displays “queued next,” but orchestrator-runner.ts passes additionalFeatureQueue: [] to both the seed and every task (lines 659 and 935). Consequently the new prompt is never injected for that experiment cohort even though the UI accepted the opt-in; thread the session queue through that sequence or suppress the toggle when the selected sequence cannot consume it.

Useful? React with 👍 / 👎.

Comment on lines +113 to +115
[...WRANGLER_CONFIG_FILES, ...MIDDLEWARE_FILES].some(
(file) => safeRead(installDir, file) !== null,
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Detect marker files without requiring package.json

The new Wrangler and middleware file checks execute only after package.json has been read and parsed, because discoverNodeFeatures returns at lines 88 and 97 otherwise. A config-only Wrangler project, a non-Node Worker project, or a project with a temporarily malformed manifest therefore never gets HttpLog despite having one of the advertised marker files; perform these file checks independently of package-manifest parsing.

Useful? React with 👍 / 👎.

注册 for free to join this conversation on GitHub. Already have an account? 登录 to comment

标签

None yet

项目

None yet

Development

Successfully merging this pull request may close these issues.

1 participant