fix(llma): use distinct_id from outer context if not provided#449
fix(llma): use distinct_id from outer context if not provided#449andrewm4894 merged 5 commits intoPostHog:masterfrom
Conversation
|
Some of these failed tests are passing on my machine. Do the tests set an outer distinct_id? |
|
Nevermind, I realize I was running them incorrectly. I think I found the issue and will push a commit soon |
|
Should be good to go |
|
Thanks for the contribution @ethanporcaro! Great bug find — the outer context distinct_id was indeed being ignored. I pushed a commit on top with a few tweaks:
|
…, add tests - Fix personless check to consider outer context distinct_id (not just the explicit param), so events from users who set distinct_id via outer context are not incorrectly marked as personless. - Fix typo: "district_id" -> "distinct_id" in comments. - Add test coverage for distinct_id resolution: no id (personless), explicit param, outer context, and explicit overriding outer context.
91ad399 to
0067cdf
Compare
|
Awesome, thanks for the help |
Related to #443
Right now, the LLM analytics wrappers accept a
posthog_distinct_idparameter, but override any existing distinct_id, even if the parameter is None.The utility functions pass
However, if posthog_distinct_id is None (default) it will default to the
posthog_trace_id, even if an ID exists on the outer context.This PR modifies the logic to do the following:
distinct_idis passed by parameter, it is used inidentify_contexttrace_id.ph_client.capturewithout the distinct_id parameter, so that it uses whatever was set from the above steps.Let me know if any changes are needed or if I should implement this differently.