fix: attribute PostHog events to automation actors - #265
Merged
Conversation
6 tasks
Contributor
neubig
marked this pull request as ready for review
July 27, 2026 13:01
6 tasks
Contributor
|
🚀 Released in 1.4.0. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Automations currently emits every event under one backend-wide PostHog
distinct_id, including when local automations are launched through Agent Canvas. This fragments one person's Canvas and automation activity and forces dashboards to recover identity with expensivecoalesce(cloud_user_id, distinct_id)HogQL.PostHog recommends identifying authenticated users with a unique, stable ID and retaining the same identity across their activity: https://posthog.com/docs/product-analytics/identify
Fixes #264.
Summary
Testing
uv run ruff format --check openhands/automation/telemetry.py tests/test_telemetry.py tests/test_router.pyuv run ruff check openhands/automation/telemetry.py tests/test_telemetry.py tests/test_router.pyuv run pyright openhands/automation/telemetry.py tests/test_telemetry.py— 0 errorsuv run pytest -q— 1,065 passedThe tests cover Cloud and local identity selection, exact per-actor consent, manual dispatch, scheduled runs, webhook runs, API route events, background attribution, the headerless backend fallback, and rejection of spoofed Cloud browser identity.
Notes
The new columns are nullable so existing automations and runs continue to fall back safely. Browser IDs are only accepted in local mode; Cloud derives identity exclusively from authenticated server state.
The companion Agent Canvas PR identifies Cloud sessions, preserves the Canvas actor across local-backend use, and safely hands off revocation before PostHog resets identity: OpenHands/agent-canvas#1948