About this project

This is a CDK serverless website analytics construct that deploys a full-stack solution on AWS. It creates a frontend dashboard, backend APIs, and ingestion pipelines to track website traffic and user interactions. Designed for low to moderate traffic sites (up to 10M page views), it emphasizes minimal cost, privacy (no PII stored), and ease of deployment. Features include page view tracking with time on page, event tracking, anomaly detection with alerts, custom domain support, and three authentication options (none, basic auth, AWS Cognito). Tracks referrers, geolocation by country/city, device type, UTM parameters, and query parameters. Bot detection is built-in. Integration is available via a standalone JavaScript snippet or an SDK for use in any frontend framework. The architecture consists of a Vue 3 frontend hosted on S3/CloudFront, a TypeScript backend using Lambda Function URLs and tRPC, and an ingestion API that buffers events via Kinesis Firehose into partitioned Parquet files in S3. Data is queried through Athena. Location data is derived from MaxMind GeoLite2 without storing IPs. Deployment requires `aws-cdk` and `aws-cdk-lib` > 2.79.1. After installing the npm package, users define the construct in their CDK stack with configuration for sites, origins, authentication, domain, observability, and anomaly detection. Client-side setup involves adding a script tag or initializing the SDK in the application. Cost estimates are provided for various traffic levels, with worst-case projections significantly higher than actual costs due to daily data vacuum processes. Upgrades from v0 to v1 involve breaking changes related to partitioning and DNS record IDs. Documentation includes design decisions, contributing guidelines, and detailed cost breakdowns. A live demo is available.