Skip to content

feat(tracking): suppress Apple MPP opens and bot click prefetches#50

Open
jusso-dev wants to merge 1 commit into
mainfrom
claude/issue-31-mpp-bot-suppression
Open

feat(tracking): suppress Apple MPP opens and bot click prefetches#50
jusso-dev wants to merge 1 commit into
mainfrom
claude/issue-31-mpp-bot-suppression

Conversation

@jusso-dev

Copy link
Copy Markdown
Owner

Summary

Closes #31. Stops Apple Mail Privacy Protection and security-gateway URL scanners from polluting open/click metrics.

  • New lib/tracking/bot-detection.ts:
    • detectAppleMailPrivacyProtection({ userAgent, ip }) — matches Apple Mail UA strings and a snapshot of iCloud Private Relay egress ranges (operator-refreshable from mask-api.icloud.com/egress-ip-ranges.csv).
    • detectBotClick({ userAgent, method, isBot, sentAt }) — flags HEAD requests, headless / scanner UAs (curl, wget, python-requests, Mimecast, Proofpoint URLDefense, etc.), agent.isBot, and clicks within 1.5s of sentAt.
  • recordTrackingEvent now takes a suppressionDecision callback that runs after the campaign target is loaded so the click route can see sentAt for the prefetch-window check.
  • When suppressed:
    • The events row is still inserted, tagged unverified: true (pixel) or bot: true (click) plus a suppressionReason for forensics.
    • campaignTargets.openedAt / clickedAt are NOT written, so dashboards stop counting these.
    • The SIEM/SOAR push is skipped to avoid SOC noise.
  • Pixel route (/p/[...token]) and click route (/c/[token]) wired up.

Test plan

  • Hit the pixel with User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) → event row exists with unverified: true, campaignTargets.openedAt stays NULL.
  • Hit the click URL within 1500ms of sentAt → event row tagged bot: true, suppressionReason: "prefetch_window", campaignTargets.clickedAt stays NULL.
  • curl -X HEAD /c/<token> → tagged head_request, no clickedAt write.
  • Normal browser open / click still updates the target timestamps.

https://claude.ai/code/session_01PiiqDRQJdW1sBLvEmZ3GBC


Generated by Claude Code

…oses #31)

Apple Mail Privacy Protection prefetches the open pixel, and security
gateways like Mimecast / Proofpoint / Barracuda HEAD or GET the click
URL seconds after delivery. Both inflate metrics and produce false
clicked_at timestamps on campaign targets.

A new `lib/tracking/bot-detection.ts` provides:
  - `detectAppleMailPrivacyProtection({ userAgent, ip })` — matches
    Apple Mail UA strings and iCloud Private Relay egress ranges.
  - `detectBotClick({ userAgent, method, isBot, sentAt })` — matches
    HEAD requests, headless / scanner UAs, and clicks within 1.5s of
    sentAt (the gateway prefetch window).

`recordTrackingEvent` now accepts a `suppressionDecision` callback that
runs after the campaign target is loaded. When suppression fires we
still insert the events row tagged with `unverified: true` or `bot:
true` and the reason, but we skip the `campaignTargets.openedAt /
clickedAt` write and the SIEM/SOAR push. The dashboards (which read
those target timestamps) therefore stop counting bot traffic by
default, while the underlying hits remain available for forensics.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Apple MPP open-inflation suppression + bot-click fingerprinting

2 participants