Skip to content

fix: also send device user agent as $raw_user_agent#604

Draft
lricoy wants to merge 1 commit into
mainfrom
lricoy/mirror-raw-user-agent
Draft

fix: also send device user agent as $raw_user_agent#604
lricoy wants to merge 1 commit into
mainfrom
lricoy/mirror-raw-user-agent

Conversation

@lricoy

@lricoy lricoy commented Jul 3, 2026

Copy link
Copy Markdown
Member

💡 Motivation and Context

The SDK attaches the device user agent (http.agent) to every event as $user_agent, but PostHog's server-side classification — web analytics bot detection ($virt_is_bot and friends) and the materialized-column fast path — keys on the standardized $raw_user_agent property (the one posthog-js sends). posthog-android is the only mobile SDK putting a real device UA in $user_agent while omitting $raw_user_agent, so its events can't be classified without an expensive fallback.

PostHog/posthog#68253 removes that fallback for performance (it forced a full properties-blob read on every classification query — see the PR for production measurements), so this change mirrors the user agent into $raw_user_agent, aligning Android with the standardized property. Related: PostHog/posthog#68232.

$user_agent is still sent for backwards compatibility.

💚 How did you test it?

Agent-authored. Extended the existing PostHogAndroidContextTest dynamic-context test to assert $raw_user_agent carries the same value as $user_agent; relying on CI to run the suite (no local Android toolchain in this session).

📝 Checklist

  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • I updated the docs if needed.
  • No breaking change or entry added to the changelog.

If releasing new changes

  • Ran pnpm changeset to generate a changeset file (changeset file added manually with the same format)

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Built with Claude Code as part of a cross-repo effort to standardize on $raw_user_agent (PostHog/posthog#68232, PostHog/posthog#68253, with sibling PRs to posthog-python and posthog-ruby). The value duplicated is the existing http.agent string; no truncation added since the current $user_agent isn't truncated either.

@lricoy lricoy self-assigned this Jul 3, 2026
@greptile-apps

greptile-apps Bot commented Jul 3, 2026

Copy link
Copy Markdown

Reviews (1): Last reviewed commit: "fix: also send device user agent as $raw..." | Re-trigger Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant