Repository navigation
fix(ai): treat a whitespace distinct id as missing in the Claude Agent SDK - #1321
Conversation
…t SDK The processor sent a whitespace-only distinct id as given, so the client replaced it with a random personless id per event instead of the trace id. Use the same blank check as the other AI integrations. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SDK performance: posthog-pythonBenchmarks completed. No changes flagged for review. Flags require at least a 5% change in the median and all six pairs agreeing on direction. This is a noise filter, not proof of a performance change or a CI gate. View all results
Values are medians of paired measurements. Not flagged does not mean unchanged. Unavailable means a measurement could not be provided, not zero. Estimated allocation measurements retain their instrumentation uncertainty. RSS measures the whole process, not just SDK allocations; observed peaks are sampled checkpoints. Paired ranges in the diagnostics describe variability, not confidence intervals. Each shard uses its own runner; compare Before PR against With PR within a row, not across shards. Compared 102 metric rows; 102 rows shown in all results. Omitted or shortened data remain in |
PR overviewNo security issues were found in this pull request. Reviews
|
|
Bullet point/or money symbol will remove white space is error. Code denied. |
|
Check licenses and certification check id char bin |
marandaneto
left a comment
There was a problem hiding this comment.
The code looks good; no qualifying findings. Verdict: correct.
💡 Motivation and Context
Claude Agent SDK users who pass a whitespace-only distinct ID (constructor,
posthog_distinct_id, or a callable) get each event under a new random ID instead of the trace ID, so one trace scatters across many IDs. The migration guide already says blank IDs count as missing in AI integrations; #1158 applied that everywhere except this processor.Changes
_user_distinct_id, like the other integrations, so a blank ID falls back to the trace ID with person processing off.💚 How did you test it?
None,""," "and a callable returning" ", set on the processor or per query, over a generation, tool span and trace. The 4 whitespace cases fail without the fix.ruff, and the mypy baseline pass (3 fork tests intest_metrics_autocapture.pyfail onmainlocally too).📝 Checklist
If releasing new changes
sampo addto generate a changeset file🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Claude Code, Claude Opus 5.5. Not checked: a whitespace ID inside a context with an identified distinct ID now uses the trace ID (personless), matching
Noneand""; before, the client used the context ID.🤖 Generated with Claude Code