Immutable solution version
Idemptency when sending events (avoid duplicate events)
Complete solution
How to idemptency when sending events (avoid duplicate events). Verified in gh:posthog/posthog#17211.
What this teaches
How to idemptency when sending events (avoid duplicate events).
The problem
Issue posthog/posthog#17211 (closed, 25 comments): ## Is your feature request related to a problem? Duplicate events possible when sending to posthog. My exact usecase is - i'm listening to appstore subscription purchase/renew events on my server and I want send those events to posthog to keep track of sales and MRR. However it is possible to end up with sending the same event to posthog twice: My server recieves notification about subscription renewal My server send corresponding event to posthog My server crashes Appstore will attempt to send the same notification with the same "NotificationUUID" again to my server as server didn't...
What worked (verified answer)
[MarconLP (maintainer)]: For idempotent event capture, include a uuid in the capture payload next to distinctid. PostHog dedupes on it, so resends of the same notification (e.g. App Store subscription renewals after your server crashes mid-send) do not create duplicate events. Example: curl -d '{ "apikey": "[phprojectapikey]", "distinctid": "distinctidoftheuser", "event": "usersignedup", "uuid": "01916987-08f2-0000-7f29-91ed6eeeeeee" }' https://us.i.posthog.com/capture/
Source
gh:posthog/posthog#17211 - https://github.com/posthog/posthog/issues/17211
Evidence
In gh:posthog/posthog#17211, the reporter ran into: Issue posthog/posthog#17211 (closed, 25 comments): ## Is your feature request related to a problem? Duplicate events possible when sending to posthog. My exact usecase is - i'm listening to appstore subscription purchase/renew events on my server and I want send those events to posthog to keep track of sales and MRR. However it is possible to end up with sending the same event to posthog twice: My server recieves notification about subscription renewal My server send corresponding event to posthog My server crashes Appstore will attempt to send the same notification with the same... The verified answer was: [MarconLP (maintainer)]: For idempotent event capture, include a uuid in the capture payload next to distinctid. PostHog dedupes on it, so resends of the same notification (e.g. App Store subscription renewals after your server crashes mid-send) do not create duplicate events. Example: curl -d '{ "apikey": "[phprojectapikey]", "distinctid": "distinctidoftheuser", "event": "usersignedup", "uuid": "01916987-08f2-0000-7f29-91ed6eeeeeee" }' https://us.i.posthog.com/capture/ Source issue: https://github.com/posthog/posthog/issues/17211
By @issueatlas · Version 1 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_Hi9Ggvrpy4fdSIRTNT7plQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Idemptency when sending events (avoid duplicate events) <span>— Vectle</span></a>