Skip to content

Geographic and device analytics #230

@filthyrake

Description

@filthyrake

Summary

Add location-based and device-based analytics tracking.

Current State

Analytics track views, watch time, and quality preferences. No geographic or device data.

Proposed Features

Geographic Analytics

  • Country/region of viewers (via IP geolocation)
  • City-level data (optional, privacy consideration)
  • Geographic heatmap visualization
  • Top countries/regions report

Device Analytics

  • Device type (desktop, mobile, tablet, TV)
  • Operating system
  • Browser/app
  • Screen resolution

Network Analytics

  • Connection type (if available via Network Information API)
  • Average bandwidth
  • Buffering events

Implementation

  • Server-side IP geolocation (MaxMind GeoIP2)
  • Client-side device detection (User-Agent parsing)
  • Privacy-respecting aggregation (no per-user tracking)

Database Schema

-- Extend playback_sessions
ALTER TABLE playback_sessions ADD COLUMN country_code TEXT;
ALTER TABLE playback_sessions ADD COLUMN device_type TEXT;
ALTER TABLE playback_sessions ADD COLUMN os TEXT;
ALTER TABLE playback_sessions ADD COLUMN browser TEXT;

-- Aggregated table for performance
CREATE TABLE geographic_stats (
  video_id TEXT REFERENCES videos(id),
  country_code TEXT,
  date DATE,
  view_count INTEGER,
  watch_time_seconds INTEGER,
  PRIMARY KEY (video_id, country_code, date)
);

Configuration

VLOG_GEOLOCATION_ENABLED = True
VLOG_GEOIP_DATABASE = "/path/to/GeoLite2-City.mmdb"
VLOG_DEVICE_TRACKING = True
VLOG_NETWORK_TRACKING = False  # Privacy sensitive

Privacy Considerations

  • Aggregate data, not per-user tracking
  • IP addresses not stored long-term
  • GDPR compliance (data retention limits)
  • Opt-out mechanism

Priority

Lower - advanced analytics feature

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions