Skip to content

CF Worker tracking pixel endpoint + KV schema #52

@AojdevStudio

Description

@AojdevStudio

Summary

Implement a Cloudflare Worker HTTP endpoint that serves a 1x1 transparent tracking pixel and logs open events to KV storage. Includes KV schema design for campaign-based open tracking.

Context

  • Repository: ~/Projects/local-mcps/gdrive
  • GitHub: AojdevStudio/gdrive
  • Plan Doc: docs/plans/2026-03-10-email-outreach-features.md (Task 5)
  • Relevant Files: src/worker/tracking.ts (new), wrangler.toml (KV binding), src/worker/kv-schema.ts (new)
  • Related Issues: None (first P1 tracking infrastructure issue)

Current Behavior

N/A — new feature. No email open tracking infrastructure exists.

Expected Behavior

A CF Worker route (e.g., /t/:campaignId/:recipientHash) serves a 1x1 transparent PNG pixel. On each request, it writes an open event to KV with structure: track:{campaignId}:{recipientHash} -> { openedAt, ip, userAgent, count }. KV schema supports querying all opens for a given campaign prefix.

Acceptance Criteria (max 3)

  • AC-1: GET /t/:campaignId/:recipientHash returns a 1x1 transparent PNG with correct Content-Type header
  • AC-2: Each pixel request writes/updates an open event in KV with timestamp, count, and metadata
  • AC-3: KV key schema supports efficient prefix-based listing by campaignId

Scope

In scope: Worker HTTP route, KV binding config, KV schema design, pixel response, open event recording, unit tests
Out of scope: Click tracking, unsubscribe handling, analytics aggregation, dashboard UI

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions