<svg viewBox="-40 -40 800 528" xmlns="http://www.w3.org/2000/svg" role="img" aria-labelledby="insert-id-dedup-title insert-id-dedup-desc" font-family="Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif">
  <title id="insert-id-dedup-title">How insert_id deduplication works</title>
  <desc id="insert-id-dedup-desc">A good-versus-bad comparison. When an event and its retry have the same device_id and insert_id, Amplitude stores one event. When two real events on the same device reuse an insert_id within seven days, Amplitude drops the second event.</desc>

  <defs>
    <marker id="iid-arrow" viewBox="0 0 10 10" refX="10" refY="5"
            markerWidth="8" markerHeight="8" orient="auto">
      <path d="M0,0 L10,5 L0,10 Z" fill="#f0f0f0" />
    </marker>
    <marker id="iid-arrow-danger" viewBox="0 0 10 10" refX="10" refY="5"
            markerWidth="8" markerHeight="8" orient="auto">
      <path d="M0,0 L10,5 L0,10 Z" fill="#f87171" />
    </marker>
  </defs>

  <!-- ===== GOOD ROW ===== -->
  <!-- Status pill -->
  <rect x="0" y="0" width="150" height="24" rx="12" ry="12" fill="#2a2a2a" stroke="#3ecf8e" stroke-width="1" />
  <text x="75" y="16" text-anchor="middle" font-size="12" font-weight="600" fill="#3ecf8e">Unique <tspan font-family="'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, monospace">insert_id</tspan></text>

  <!-- Event card 1 -->
  <rect x="0" y="40" width="200" height="64" rx="8" ry="8" fill="#232323" stroke="#a8a8a8" stroke-width="1" />
  <text x="16" y="66" font-size="14" font-weight="600" fill="#f0f0f0">Event sent</text>
  <text x="16" y="88" font-size="12" font-weight="400" fill="#f0f0f0" font-family="'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, monospace">insert_id: a1</text>

  <!-- Event card 2 -->
  <rect x="0" y="128" width="200" height="64" rx="8" ry="8" fill="#232323" stroke="#a8a8a8" stroke-width="1" />
  <text x="16" y="154" font-size="14" font-weight="600" fill="#f0f0f0">Retry (network)</text>
  <text x="16" y="176" font-size="12" font-weight="400" fill="#f0f0f0" font-family="'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, monospace">insert_id: a1</text>

  <!-- Manifold: both events collect onto one bus, one trunk into Amplitude -->
  <line x1="208" y1="72" x2="240" y2="72" stroke="#f0f0f0" stroke-width="1.5" />
  <line x1="208" y1="160" x2="240" y2="160" stroke="#f0f0f0" stroke-width="1.5" />
  <line x1="240" y1="72" x2="240" y2="160" stroke="#f0f0f0" stroke-width="1.5" />
  <line x1="240" y1="116" x2="312" y2="116" stroke="#f0f0f0" stroke-width="1.5" marker-end="url(#iid-arrow)" />

  <!-- Result box (focal) -->
  <rect x="320" y="80" width="224" height="72" rx="8" ry="8" fill="#1c3252" stroke="#93c5fd" stroke-width="1" />
  <text x="336" y="110" font-size="14" font-weight="600" fill="#f0f0f0">Amplitude stores 1 event</text>
  <text x="336" y="132" font-size="12" font-weight="400" fill="#f0f0f0">duplicate ignored</text>

  <!-- Correct / safe note -->
  <text x="568" y="120" font-size="12" font-weight="600" fill="#3ecf8e">Correct: safe retry</text>

  <!-- Divider -->
  <line x1="0" y1="224" x2="720" y2="224" stroke="#a8a8a8" stroke-width="1" />

  <!-- ===== BAD ROW ===== -->
  <!-- Status pill -->
  <rect x="0" y="256" width="150" height="24" rx="12" ry="12" fill="#2a2a2a" stroke="#f87171" stroke-width="1" />
  <text x="75" y="272" text-anchor="middle" font-size="12" font-weight="600" fill="#f87171">Reused <tspan font-family="'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, monospace">insert_id</tspan></text>

  <!-- Event card 1 (different purchase) -->
  <rect x="0" y="296" width="200" height="64" rx="8" ry="8" fill="#232323" stroke="#a8a8a8" stroke-width="1" />
  <text x="16" y="322" font-size="14" font-weight="600" fill="#f0f0f0">Purchase #1</text>
  <text x="16" y="344" font-size="12" font-weight="400" fill="#f0f0f0" font-family="'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, monospace">(insert_id: x9)</text>

  <!-- Event card 2 (different purchase, same id) -->
  <rect x="0" y="384" width="200" height="64" rx="8" ry="8" fill="#232323" stroke="#a8a8a8" stroke-width="1" />
  <text x="16" y="410" font-size="14" font-weight="600" fill="#f0f0f0">Purchase #2</text>
  <text x="16" y="432" font-size="12" font-weight="400" fill="#f0f0f0" font-family="'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, monospace">(insert_id: x9)</text>

  <!-- Manifold (danger, dashed) -->
  <line x1="208" y1="328" x2="240" y2="328" stroke="#f87171" stroke-width="1.5" stroke-dasharray="5 4" />
  <line x1="208" y1="416" x2="240" y2="416" stroke="#f87171" stroke-width="1.5" stroke-dasharray="5 4" />
  <line x1="240" y1="328" x2="240" y2="416" stroke="#f87171" stroke-width="1.5" stroke-dasharray="5 4" />
  <line x1="240" y1="372" x2="312" y2="372" stroke="#f87171" stroke-width="1.5" stroke-dasharray="5 4" marker-end="url(#iid-arrow-danger)" />

  <!-- Result box (drop) -->
  <rect x="320" y="336" width="224" height="72" rx="8" ry="8" fill="#2a2a2a" stroke="#f87171" stroke-width="1.5" stroke-dasharray="5 4" />
  <text x="336" y="366" font-size="14" font-weight="600" fill="#f87171">Amplitude drops the second</text>
  <text x="336" y="388" font-size="12" font-weight="400" fill="#f87171">real event lost</text>

  <!-- Caption -->
  <text x="568" y="368" font-size="11" font-weight="400" fill="#a8a8a8">Same <tspan font-family="'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, monospace">device_id</tspan> + <tspan font-family="'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, monospace">insert_id</tspan></text>
  <text x="568" y="383" font-size="11" font-weight="400" fill="#a8a8a8">within seven days.</text>
</svg>
