Analytics dashboard

Real-time metrics, sales data, and user behavior insights

Overview

Current state

No centralized analytics, relying on Vercel Analytics and manual queries.

Target state

  • Real-time sales and listing metrics
  • User behavior funnels
  • Seller performance dashboards
  • Admin insights panel

Tech stack

  • Analytics: PostHog or Mixpanel
  • Data Warehouse: Supabase + materialized views
  • Visualization: Tremor components or Recharts
  • Real-time: Supabase Realtime subscriptions

Dashboards

Admin dashboard

  • Total GMV (Gross Merchandise Value)
  • Active listings count
  • Daily/weekly/monthly transactions
  • User acquisition funnel
  • Top categories and brands

Seller dashboard

  • Total sales and revenue
  • Listing performance (views, saves, inquiries)
  • Response time metrics
  • Best performing items
  • Suggested actions

Marketplace health

  • Listing-to-sale conversion rate
  • Average time to sell
  • Price distribution by category
  • Geographic heatmap
  • Fraud flags and reports

Architecture

Event tracking

packages/analytics/track.ts
analytics.track('item_viewed', {
  itemId: item.id,
  categoryId: item.categoryId,
  price: item.price,
  sellerId: item.sellerId,
});

analytics.track('purchase_completed', {
  itemId: item.id,
  price: item.price,
  buyerId: user.id,
  sellerId: item.sellerId,
});

Materialized views

packages/db/views/daily-sales.sql
CREATE MATERIALIZED VIEW daily_sales AS
SELECT
  DATE(created_at) as date,
  COUNT(*) as transactions,
  SUM(price) as gmv,
  COUNT(DISTINCT buyer_id) as unique_buyers
FROM transactions
GROUP BY DATE(created_at);

-- Refresh daily
REFRESH MATERIALIZED VIEW daily_sales;

Real-time metrics

apps/admin/hooks/use-live-metrics.ts
const channel = supabase
  .channel('dashboard')
  .on('postgres_changes', {
    event: 'INSERT',
    schema: 'public',
    table: 'transactions'
  }, (payload) => {
    updateLiveMetrics(payload.new);
  })
  .subscribe();

Implementation

Event infrastructure

Set up PostHog/Mixpanel, add tracking to key user flows, and define the event schema.

Admin dashboard

Build dashboard UI in admin app, create materialized views, and implement real-time metrics display.

Seller dashboard

Add seller-specific metrics, performance insights, and actionable recommendations.

Advanced analytics

Implement cohort analysis, funnel visualization, and A/B testing framework.

Checklist

Infrastructure

  • Set up analytics provider
  • Create materialized views in Supabase
  • Build dashboard components

Tracking

  • Item views, saves, shares
  • Search queries and results
  • Purchase funnel events
  • Chat/message events

Dashboards

  • Admin overview dashboard
  • Seller performance page
  • Category insights
  • User acquisition funnel