Introduction
SunGlasses is a privacy-first analytics SDK for web and mobile apps. It gives you event tracking (capture, screen, identify) with consent gating, automatic PII redaction, and pluggable output destinations — without shipping user data to third parties unless you explicitly wire an adapter.
Core concepts
- Consent gate — Every public method checks consent before any I/O. Opted-out users produce zero side effects: no queue writes, no storage writes, no network calls.
- Middleware pipeline —
PiiSanitizeralways runs first, then your custom middleware. Events can be transformed or dropped before they reach adapters. - Local queue — Events are persisted via
IStorageAdapterand flushed toIAnalyticsAdapterinstances on a timer or when you callflush(). - Anonymous identity — A UUID v4
anonymousIdis generated on first run and stored locally. It is never derived from PII.
What you'll need
- Web: React 18+, a bundler (Vite, Next.js, etc.)
- React Native / Expo: Expo SDK 50+ or bare RN with AsyncStorage
- Node.js 20+ for local development of the monorepo