Detect social milestones when scans arrive

This commit is contained in:
2026-08-14 11:47:28 +02:00
parent 6081b9e6ae
commit e0c32542f9
3 changed files with 49 additions and 40 deletions

View File

@@ -5,6 +5,7 @@ import { getWwwOrigin } from '@/lib/hosts';
import { db } from '@/lib/db';
import { hashIP } from '@/lib/hash';
import { triggerLifecycleScoring } from '@/lib/revops-server';
import { detectSocialMilestones } from '@/lib/social-milestones-server';
export async function GET(
request: NextRequest,
@@ -260,6 +261,12 @@ async function trackScan(qrId: string, userId: string, request: NextRequest) {
},
});
// The customer sees a newly crossed milestone on their next dashboard
// visit; no separate cron invocation is required after a real scan.
if (isUnique) {
await detectSocialMilestones(qrId);
}
const activatedUsers = await db.user.updateMany({
where: {
id: userId,