posthog
posthog copied to clipboard
fix: Person properties updates to update op and ts too
Problem
EDIT: latest discussion: https://posthog.slack.com/archives/C0374DA782U/p1660840149534569
Closes https://github.com/PostHog/posthog/issues/10661
We have last updated at and last operation for debugging among other reasons, however they weren't correct.
If we send events to update the person properties, then last operation and last timestamp aren't updated properly specifically sending these events:
posthog.capture('test-ts-op', 'test-event', properties={'$set':{'p1':'tretwdw', 'p2': 'trwhrts' }})
posthog.capture('test-ts-op', 'test-event', properties={'$set':{'p1':'new', 'p3': 'nnn' }})
Before this PR
Notice how last op and last updated ts didn't get updated with the second event
select * from posthog_person where id=7;
id | created_at | properties | team_id | is_user_id | is_identified | uuid | properties_last_updated_at | properties_last_operation | version
----+----------------------------+---------------------------------------------+---------+------------+---------------+--------------------------------------+----------------------------------------------------------------------+----------------------------+---------
7 | 2022-08-17 14:22:05.103+00 | {"p1": "new", "p2": "trwhrts", "p3": "nnn"} | 1 | | f | 0182ac2f-bfc9-0000-01f9-de3abab094f5 | {"p1": "2022-08-17T14:22:05.103Z", "p2": "2022-08-17T14:22:05.103Z"} | {"p1": "set", "p2": "set"} | 1
After this PR
select * from posthog_person where id=8;
id | created_at | properties | team_id | is_user_id | is_identified | uuid | properties_last_updated_at | properties_last_operation | version
----+----------------------------+---------------------------------------------+---------+------------+---------------+--------------------------------------+--------------------------------------------------------------------------------------------------------+-----------------------------------------+---------
8 | 2022-08-17 14:29:21.547+00 | {"p1": "new", "p2": "trwhrts", "p3": "nnn"} | 1 | | f | 0182ac36-6737-0000-073f-9ad95542ac67 | {"p1": "2022-08-17T14:30:59.446Z", "p2": "2022-08-17T14:29:21.547Z", "p3": "2022-08-17T14:30:59.446Z"} | {"p1": "set", "p2": "set", "p3": "set"} | 1
Changes
👉 Stay up-to-date with PostHog coding conventions for a smoother review.
Also updated person-state to not have a .only test
How did you test this code?
See above in problem statement.