Files
wiki/convex/convex.config.ts
Wayne Sutton 8d28e36458 feat(stats): switch to aggregate component for O(log n) counts
- Add @convex-dev/aggregate package for efficient aggregation
- Update convex.config.ts with pageViewsByPath, totalPageViews, uniqueVisitors aggregates
- Update recordPageView to insert into aggregate components
- Update getStats to use aggregate counts instead of O(n) table scans
- Add backfillAggregates internal mutation for existing data
- Update prds/howstatsworks.md with old vs new comparison
- Update changelog.md with v1.11.0 entry
- Update files.md with aggregate component info
2025-12-20 14:39:53 -08:00

17 lines
483 B
TypeScript

import { defineApp } from "convex/server";
import aggregate from "@convex-dev/aggregate/convex.config.js";
const app = defineApp();
// Aggregate component for efficient page view counts (O(log n) instead of O(n))
app.use(aggregate, { name: "pageViewsByPath" });
// Aggregate component for total page views count
app.use(aggregate, { name: "totalPageViews" });
// Aggregate component for unique visitors count
app.use(aggregate, { name: "uniqueVisitors" });
export default app;