diff --git a/src/connectors/openrouter.ts b/src/connectors/openrouter.ts index f2a2315..b0e34cb 100644 --- a/src/connectors/openrouter.ts +++ b/src/connectors/openrouter.ts @@ -4,6 +4,7 @@ import { type CostLine, type Credentials, getJson, toCents } from "./types"; const BASE = "https://openrouter.ai/api/v1"; const headers = (c: Credentials) => ({ Authorization: `Bearer ${c.key}` }); +// `date` comes as "2026-11-08 00:00:00"; a line keeps the day alone. type Row = { date: string; model: string; usage: number }; type Key = { hash: string; @@ -44,7 +45,7 @@ export function activityLines( if (!cents) continue; out.push({ externalId: `${k}:${key.hash}`, - date: r.date, + date: r.date.slice(0, 10), currency: "USD", amountCents: cents, service: r.model, @@ -58,7 +59,7 @@ export function activityLines( if (cents <= 0) continue; out.push({ externalId: `${k}:none`, - date: r.date, + date: r.date.slice(0, 10), currency: "USD", amountCents: cents, service: r.model, diff --git a/src/connectors/vercel.ts b/src/connectors/vercel.ts index 717487e..34c8b7c 100644 --- a/src/connectors/vercel.ts +++ b/src/connectors/vercel.ts @@ -72,7 +72,13 @@ export const vercel = register({ // https://vercel.com/docs/rest-api/reference/endpoints/billing/list-focus-billing-charges async fetchCosts(c, range: SyncRange) { const team = await teamId(c); - const end = Date.parse(`${range.to}T00:00:00Z`) + DAY; + // `to` is exclusive and day-granular. Stop at the start of the current + // UTC day rather than past it: today's partial day comes with the next + // sync, which rereads the last 3 days. + const end = Math.min( + Date.parse(`${range.to}T00:00:00Z`) + DAY, + Math.floor(Date.now() / DAY) * DAY, + ); let text = ""; for ( let start = Date.parse(`${range.from}T00:00:00Z`);