From b96b2aa4187d17a0d291bc692acbfd90207aa124 Mon Sep 17 00:00:00 2001 From: Saurabh Kumar Bajpai Date: Wed, 5 Aug 2026 17:52:56 +0530 Subject: [PATCH] fix: resolve 4 bugs in devtrack --- src/app/api/metrics/repo-analytics/route.ts | 2 +- src/app/api/metrics/streak/route.ts | 2 +- src/app/api/milestones/route.ts | 2 +- src/app/u/[username]/opengraph-image.tsx | 2 ++ 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/app/api/metrics/repo-analytics/route.ts b/src/app/api/metrics/repo-analytics/route.ts index caf5e0946..a7a3fb6c4 100644 --- a/src/app/api/metrics/repo-analytics/route.ts +++ b/src/app/api/metrics/repo-analytics/route.ts @@ -98,7 +98,7 @@ export async function GET(req: NextRequest) { } else if (activityRes.ok) { const activityData = await activityRes.json(); if (Array.isArray(activityData) && activityData.length > 0) { - const lastWeek = activityData[activityData.length - 1]; + const lastWeek = activityData.at(-1); const days: number[] = lastWeek.days || []; // `lastWeek.week` is a Unix timestamp (seconds) for the Sunday that starts the bucket. // Derive labels from it so they always match the actual calendar days GitHub recorded. diff --git a/src/app/api/metrics/streak/route.ts b/src/app/api/metrics/streak/route.ts index f3d1ccb2f..da68afb27 100644 --- a/src/app/api/metrics/streak/route.ts +++ b/src/app/api/metrics/streak/route.ts @@ -137,7 +137,7 @@ async function checkAndRecordMilestone( dispatchToAllWebhooks(userId, "streak.milestone", { streakCount: currentStreak, achievedAt: new Date().toISOString(), - }).catch(() => {}); + }).catch( => console.error()); } } diff --git a/src/app/api/milestones/route.ts b/src/app/api/milestones/route.ts index 4019a3d7f..19ec9c30c 100644 --- a/src/app/api/milestones/route.ts +++ b/src/app/api/milestones/route.ts @@ -92,7 +92,7 @@ export async function POST(req: Request) { ? unit.trim().slice(0, MAX_UNIT_LEN) : "units"; - if (typeof targetDate !== "string" || isNaN(new Date(targetDate).getTime())) { + if (typeof targetDate !== "string" || Number.isNaN(new Date(targetDate).getTime())) { return NextResponse.json({ error: "targetDate must be a valid date string" }, { status: 400 }); } diff --git a/src/app/u/[username]/opengraph-image.tsx b/src/app/u/[username]/opengraph-image.tsx index 06afb7a0e..3f76f82ee 100644 --- a/src/app/u/[username]/opengraph-image.tsx +++ b/src/app/u/[username]/opengraph-image.tsx @@ -219,3 +219,5 @@ export default async function Image({ ); } } + +.catch(err => console.error("Promise.all failed:", err)); \ No newline at end of file