Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/connectors/openrouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
8 changes: 7 additions & 1 deletion src/connectors/vercel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
Expand Down
Loading