retention

This commit is contained in:
2026-08-11 23:35:57 +02:00
parent ca1e432f80
commit e3276f5943
4 changed files with 77 additions and 23 deletions

View File

@@ -2,6 +2,7 @@ import { NextRequest, NextResponse } from 'next/server';
import { getSessionUserId } from '@/lib/session';
import { db } from '@/lib/db';
import { rateLimit, getClientIdentifier, RateLimits } from '@/lib/rateLimit';
import { touchAnalyticsView } from '@/lib/analyticsActivity';
import { TrendData } from '@/types/analytics';
export const dynamic = 'force-dynamic';
@@ -67,6 +68,10 @@ export async function GET(request: NextRequest) {
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
}
// Serves both the analytics page and the dashboard, so this is the one
// place that knows the user actually saw their numbers. Fire and forget.
touchAnalyticsView(userId);
// Get date range from query params (default: last 30 days)
const { searchParams } = request.nextUrl;
const range = searchParams.get('range') || '30';