Skip to content

Hardcode growth metrics with time-based increments#5470

Merged
chitalian merged 4 commits intomainfrom
claude/hardcode-growth-metrics-a9JRR
Jan 6, 2026
Merged

Hardcode growth metrics with time-based increments#5470
chitalian merged 4 commits intomainfrom
claude/hardcode-growth-metrics-a9JRR

Conversation

@chitalian
Copy link
Contributor

Replace API-fetched stats with hardcoded baseline values that grow over time:

  • Requests: 3 billion base, +50 million/day
  • Tokens: 31.5 trillion base, +1 trillion/month
  • Users: 20.6 million base, +1 million/month

Baseline date is January 2, 2025. Update the constants periodically with real numbers.

Replace API-fetched stats with hardcoded baseline values that grow over time:
- Requests: 3 billion base, +50 million/day
- Tokens: 31.5 trillion base, +1 trillion/month
- Users: 20.6 million base, +1 million/month

Baseline date is January 2, 2025. Update the constants periodically with real numbers.
@vercel
Copy link

vercel bot commented Jan 2, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
helicone-bifrost Ready Ready Preview, Comment Jan 6, 2026 10:58pm
2 Skipped Deployments
Project Deployment Review Updated (UTC)
helicone Skipped Skipped Jan 6, 2026 10:58pm
helicone-eu Skipped Skipped Jan 6, 2026 10:58pm

@supabase
Copy link

supabase bot commented Jan 2, 2026

This pull request has been ignored for the connected project bolqqmqbrciybnypvklh because there are no changes detected in supbase/supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@supabase
Copy link

supabase bot commented Jan 2, 2026

This pull request has been ignored for the connected project lmahfbbnchpworytrrqk because there are no changes detected in .supabase/supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@claude
Copy link
Contributor

claude bot commented Jan 2, 2026

Claude finished @chitalian's task —— View job


PR Review: Hardcode growth metrics with time-based increments

Score: 3/10 - Critical SSR hydration issues and several other problems

Todo List:

  • Read and analyze changed files
  • Identify critical bugs and security issues
  • Check for performance problems and code quality issues
  • Provide specific suggestions with code examples
  • Assign confidence score and provide summary

Critical Issues Found

1. CRITICAL: SSR Hydration Mismatch (bifrost/components/home/Stats.tsx:57)

The component will fail hydration because metrics is initialized as null but the render function tries to access metrics?.requests. This causes a server/client render mismatch.

Problem: The server renders with null metrics, but the client immediately calculates metrics on mount, causing React hydration errors.

Fix:

// Instead of:
const [metrics, setMetrics] = useState<ReturnType<typeof getGrowthMetrics> | null>(null);

// Use baseline values to prevent hydration mismatch:
const [metrics, setMetrics] = useState({
  requests: BASELINE_REQUESTS,
  tokensTrillion: BASELINE_TOKENS_TRILLION,
  users: BASELINE_USERS,
});

2. Logic Error: Misleading Date Baseline (bifrost/components/home/Stats.tsx:8)

The baseline date is hardcoded as January 6, 2025, but the PR description states it should be January 2, 2025. This will cause incorrect calculations.

Fix:

// Use the correct baseline date from PR description
const BASELINE_DATE = new Date("2025-01-02T00:00:00Z");

3. Inconsistent Growth Model (bifrost/components/home/Stats.tsx:16-17)

The code mixes linear growth (requests) with exponential growth (tokens/users), but the rates don't match the PR description:

  • PR says: +50 million requests/day, +1 trillion tokens/month, +1 million users/month
  • Code has: +10 million requests/day, 5% monthly growth for tokens/users

Fix:

// Match PR description exactly
const REQUESTS_PER_DAY = 50_000_000; // 50 million per day
const TOKENS_PER_MONTH = 1_000; // 1 trillion per month (in billions)
const USERS_PER_MONTH = 1_000_000; // 1 million per month

function getGrowthMetrics() {
  const now = new Date();
  const daysSinceBaseline = Math.floor(
    (now.getTime() - BASELINE_DATE.getTime()) / MS_PER_DAY
  );
  const monthsSinceBaseline = daysSinceBaseline / DAYS_PER_MONTH;

  return {
    requests: BASELINE_REQUESTS + daysSinceBaseline * REQUESTS_PER_DAY,
    tokensTrillion: BASELINE_TOKENS_TRILLION + monthsSinceBaseline * (TOKENS_PER_MONTH / 1000), // Convert to trillions
    users: BASELINE_USERS + Math.floor(monthsSinceBaseline * USERS_PER_MONTH),
  };
}

Minor Issues

4. Misleading Display Text (bifrost/components/home/Stats.tsx:103)

The text says "tokens a month" but displays cumulative tokens, not monthly rate.

Fix:

// Change to:
<span className="text-brand">{formatTokens(metrics?.tokensTrillion ?? BASELINE_TOKENS_TRILLION)}</span> tokens processed,

5. Unnecessary Complexity (bifrost/components/home/Stats.tsx:57)

Using generic type when the return type is known.

Fix:

// Simplify:
const [metrics, setMetrics] = useState(getGrowthMetrics());

6. Performance: Redundant Calculations (bifrost/components/home/Stats.tsx:62)

getGrowthMetrics() is called in useEffect but could be called less frequently.

Suggestion: Consider updating metrics periodically (e.g., daily) rather than on every component mount.

Suggestions Summary:

  • CRITICAL: Fix SSR hydration by initializing metrics with baseline values
  • CRITICAL: Correct baseline date from Jan 6 to Jan 2, 2025
  • CRITICAL: Align growth rates with PR description (50M requests/day, 1T tokens/month, 1M users/month)
  • Update display text to be accurate about cumulative vs. rate metrics
  • Simplify type annotations and remove unnecessary complexity

Files That Need Changes:

  • bifrost/components/home/Stats.tsx - All critical fixes needed

The core concept of hardcoded metrics is sound, but the implementation has several critical bugs that will cause runtime errors and incorrect data display.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 2, 2026

Greptile Summary

This PR replaces API-fetched growth statistics with hardcoded baseline values that increment over time. The page.tsx file is simplified from an async server component to a regular component, removing the API fetch. The Stats.tsx component now calculates metrics client-side using time elapsed since a baseline date (January 2, 2025).

Major changes:

  • Removed /v1/public/dataisbeautiful/total-values API dependency
  • Implemented time-based growth calculations with hardcoded rates (50M requests/day, 1T tokens/month, 1M users/month)
  • Changed from server-side data fetching to client-side calculation

Issues found:

  • Critical SSR/hydration mismatch bug: calling getGrowthMetrics() in useState initializer will cause server and client to render different values
  • Date parsing without timezone will behave inconsistently across timezones
  • The display text "tokens a month" is misleading as it shows cumulative tokens, not monthly rate

Confidence Score: 2/5

  • This PR has critical hydration bugs that will cause runtime errors and console warnings
  • The SSR/hydration mismatch on line 59 will cause React hydration errors in production, as the server-rendered output (from build time) won't match the client-side render (from user's current time). This is a common but critical React bug pattern.
  • bifrost/components/home/Stats.tsx requires immediate attention for hydration bugs

Important Files Changed

Filename Overview
bifrost/app/page.tsx Changed from async server component to sync component, removed API fetch for stats
bifrost/components/home/Stats.tsx Replaced API-fetched stats with hardcoded values and time-based growth calculations; has potential SSR/hydration issues and calculation bugs

Sequence Diagram

sequenceDiagram
    participant User
    participant Browser
    participant Stats Component
    participant Date/Time
    
    User->>Browser: Load homepage
    Browser->>Stats Component: Render (client-side)
    Stats Component->>Stats Component: Initialize useState with getGrowthMetrics()
    Stats Component->>Date/Time: Get current date
    Date/Time-->>Stats Component: Return date
    Stats Component->>Stats Component: Calculate days since baseline
    Stats Component->>Stats Component: Calculate growth metrics
    Stats Component-->>Browser: Display metrics
    
    Note over Stats Component: useEffect runs after mount
    Stats Component->>Stats Component: setMetrics(getGrowthMetrics())
    Stats Component->>Date/Time: Get current date again
    Date/Time-->>Stats Component: Return date
    Stats Component->>Stats Component: Recalculate metrics
    Stats Component-->>Browser: Update display
    
    Browser->>Stats Component: IntersectionObserver triggers
    Stats Component->>Stats Component: setIsVisible(true)
    Stats Component-->>Browser: Apply rotation animation
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 files reviewed, 3 comments

Edit Code Review Agent Settings | Greptile

} else if (num >= 1_000) {
return `${Math.ceil(num / 100) / 10}k+`;
// Baseline date: January 2, 2025
const BASELINE_DATE = new Date("2025-01-02");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: hardcoding today's date will cause incorrect calculations after deployment

Suggested change
const BASELINE_DATE = new Date("2025-01-02");
const BASELINE_DATE = new Date("2025-01-02T00:00:00Z");
Prompt To Fix With AI
This is a comment left during a code review.
Path: bifrost/components/home/Stats.tsx
Line: 8:8

Comment:
**logic:** hardcoding today's date will cause incorrect calculations after deployment

```suggestion
const BASELINE_DATE = new Date("2025-01-02T00:00:00Z");
```

How can I resolve this? If you propose a fix, please make it concise.


const Stats = () => {
const [isVisible, setIsVisible] = useState(false);
const [metrics, setMetrics] = useState(getGrowthMetrics());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: calling getGrowthMetrics() during useState initialization causes SSR/client mismatch - server renders at build time with a different date than client hydration time

Suggested change
const [metrics, setMetrics] = useState(getGrowthMetrics());
const [metrics, setMetrics] = useState({ requests: BASELINE_REQUESTS, tokensTrillion: BASELINE_TOKENS_TRILLION, users: BASELINE_USERS });
Prompt To Fix With AI
This is a comment left during a code review.
Path: bifrost/components/home/Stats.tsx
Line: 59:59

Comment:
**logic:** calling `getGrowthMetrics()` during `useState` initialization causes SSR/client mismatch - server renders at build time with a different date than client hydration time

```suggestion
  const [metrics, setMetrics] = useState({ requests: BASELINE_REQUESTS, tokensTrillion: BASELINE_TOKENS_TRILLION, users: BASELINE_USERS });
```

How can I resolve this? If you propose a fix, please make it concise.

const daysSinceBaseline = Math.floor(
(now.getTime() - BASELINE_DATE.getTime()) / (1000 * 60 * 60 * 24)
);
const monthsSinceBaseline = daysSinceBaseline / 30;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: using 30 days per month for calculation is imprecise and accumulates error over time - February has 28/29 days while other months have 31

Suggested change
const monthsSinceBaseline = daysSinceBaseline / 30;
const monthsSinceBaseline = daysSinceBaseline / 30.44; // Average days per month
Prompt To Fix With AI
This is a comment left during a code review.
Path: bifrost/components/home/Stats.tsx
Line: 25:25

Comment:
**style:** using 30 days per month for calculation is imprecise and accumulates error over time - February has 28/29 days while other months have 31

```suggestion
  const monthsSinceBaseline = daysSinceBaseline / 30.44; // Average days per month
```

How can I resolve this? If you propose a fix, please make it concise.

- Initialize metrics state as null to avoid SSR/client mismatch
- Use UTC format for baseline date to ensure consistent timezone handling
- Use 30.44 days/month for more accurate month calculations
- Extract magic numbers (MS_PER_DAY, DAYS_PER_MONTH) as named constants
- Fall back to baseline values during SSR/initial render
- Update baseline date to January 6, 2025
- Requests: 4.9 billion (was 3 billion)
- Tokens: 1.1 trillion/month (was 31.5 trillion)
- Users: 28.6 million (was 20.6 million)
@vercel vercel bot temporarily deployed to Preview – helicone January 6, 2026 22:49 Inactive
@vercel vercel bot temporarily deployed to Preview – helicone-eu January 6, 2026 22:49 Inactive
- Requests: 10M/day (was 50M/day)
- Tokens & Users: 5% MoM compound growth (was flat rate)
@vercel vercel bot temporarily deployed to Preview – helicone-eu January 6, 2026 22:52 Inactive
@vercel vercel bot temporarily deployed to Preview – helicone January 6, 2026 22:52 Inactive
@chitalian chitalian merged commit 71a412f into main Jan 6, 2026
9 of 10 checks passed
@chitalian chitalian deleted the claude/hardcode-growth-metrics-a9JRR branch January 6, 2026 22:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants