Unified Ad Revenue Dashboard: Why CSVSense Uses a Provider Pattern for Google AdSense, Ezoic, and Mediavine

10 min readPublisher Tools

Publishers juggling Google AdSense, Ezoic, Mediavine, or other networks often export CSVs or screenshot dashboards. CSVSense now offers a unified Ad Revenue Dashboard that stores normalized daily metrics in a database—starting with the official Google AdSense Management API, and architected so additional providers plug in without rewriting your core app.

What problem does this solve?

File-based workflows are fine for one-off analysis, but they do not scale when you need consistent daily totals, historical queries, or a single place to compare networks. By moving daily ad revenue into PostgreSQL (via Prisma), CSVSense can upsert one row per user, per calendar day, per ad service—without duplicating your existing CSV upload features.

OAuth vs API keys: how connections work

Google AdSense is connected through OAuth 2.0 with read-only AdSense scope. Access and refresh tokens are stored using the same NextAuth Account pattern already used elsewhere in CSVSense—no passwords or write access to your AdSense account.

For networks that issue API keys (common for programmatic reporting), CSVSense stores keys encrypted at the application layer (AES-256-GCM) when you configure AD_PROVIDER_SECRET_KEY on the server. That keeps secrets out of logs and separates them from generic environment variables.

The provider pattern (extensible by design)

Each network implements a small TypeScript interface: fetch normalized stats for a given user and UTC date. A registry maps AdService enum values to concrete classes. Adding Ezoic or Mediavine means implementing one class and registering it—no changes to the dashboard contract or duplicate sync loops.

Resilient sync: rate limits and empty days

Sync runs per provider. If the AdSense API returns HTTP 429, that outcome is recorded without aborting other networks. If a day has no reporting row, CSVSense skips the upsert instead of overwriting good data with zeros—so "no data" does not look like a revenue crash.

How this fits next to CSV import

Your existing Import AdSense Data tool remains the best path for ad-hoc CSV exports and sharing. The Ad Revenue Dashboard is for users who want structured, queryable history in the database. Both can coexist: CSV for flexibility, API sync for operational metrics.

Try the dashboard

Sign in, open the Ad Revenue Dashboard, connect AdSense, choose your publisher account (and optional site filter), then sync. Daily rows appear in USD with impressions and clicks when the API exposes them.

Related on CSVSense