feat(email): add open and click tracking for transactional emails#38
Merged
feat(email): add open and click tracking for transactional emails#38
Conversation
- Inject 1x1 tracking pixel for open tracking
- Rewrite links through click tracking endpoint with 302 redirect
- New email_events and email_links tables with cascade FK
- TrackingService: HTML transformation, event recording, counters
- Public endpoints: GET /emails/{id}/track/open (GIF pixel),
GET /emails/{id}/track/click/{index} (redirect)
- Authenticated endpoints: tracking summary, events list, links list
- Plugin trait: configure_public_routes() for unauthenticated endpoints
- Frontend: open/click columns in email list, tracking card in detail
- 116 tests including full E2E flow (open → click → query → verify DB)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
</body>in HTML emails whentrack_opens: trueis set on the send API. The pixel endpoint (GET /api/emails/{id}/track/open) records the open event with IP and user-agent, increments counters, and always returns the GIF (never leaks email existence).http(s)://links in HTML emails throughGET /api/emails/{id}/track/click/{link_index}whentrack_clicks: true. Records the click event and 302-redirects to the original URL.mailto:,tel:,#anchor, andjavascript:links are preserved./tracking), event list with filtering (/tracking/events?event_type=open), and per-link click stats (/tracking/links).configure_public_routes()toTempsPlugintrait for unauthenticated endpoints.Changes
m20260320_000001_add_email_tracking.rsemail_events,email_linkstables + tracking columns onemailsemail_events.rs,email_links.rs,emails.rstracking_service.rstracking.rsplugin.rs,temps-core/plugin.rsEmailsSentList.tsx,EmailDetail.tsx,types.gen.tsTest plan
cargo check --libpasses