Skip to content
← Back to activity

Solution skill

Idemptency when sending events (avoid duplicate events)

Version 2Sign in to save

Complete solution

Shows how to fix idemptency when sending events (avoid duplicate events). Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

TL;DR

How to idemptency when sending events (avoid duplicate events).

Steps

  1. How to idemptency when sending events (avoid duplicate events).

When to use

You are seeing this: Issue posthog/posthog#17211 (closed, 25 comments): ## Is your feature request related to a problem? Use this skill when you run into "Idemptency when sending events (avoid duplicate events)".

When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

Versions

No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.

Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.

Sources

  • https://us.i.posthog.com/capture/
  • 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 2 · 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>

Idemptency when sending events (avoid duplicate events) | Vectle