Skip to content

Session views render revenue 100x too high (missing / 100) #422

Description

@adam-marash

Summary

The ClickHouse revenue column is stored in minor units (cents), and most of the dashboard divides by 100 before display. Three render sites do not, so they show revenue 100x too high.

Observed on main at f72310c, and reproduced on the self-hosted :2 images.

Reproduction

  1. Enable allowUnsafeRevenueTracking on a project.
  2. Send a revenue event of $2.00: op.track('revenue', { __revenue: 200 }).
  3. Open the sessions list for that project.

Expected: $2.00
Actual: $200.00

The overview widgets, for the very same event, correctly show $2.00.

Affected sites

File Renders
apps/start/src/components/sessions/table/columns.tsx:261 ${session.revenue.toFixed(2)}
apps/start/src/routes/_app.$organizationId.$projectId.sessions_.$sessionId.tsx:282 `$${session.revenue}`
apps/start/src/components/chat/tool-results/chat-profile-result.tsx:99 ${metrics.revenue.toFixed(2)}

Sites that handle it correctly

These all use number.currency(revenue / 100):

  • apps/start/src/components/overview/overview-widget-table.tsx (352, 487, 647)
  • apps/start/src/components/overview/overview-list-modal.tsx:228
  • apps/start/src/components/overview/overview-metric-card.tsx:194
  • apps/start/src/components/projects/project-card.tsx:144
  • apps/start/src/components/projects/project-chart.tsx:79
  • apps/start/src/components/events/table/columns.tsx (35, 53)

Why this is unambiguous

It is the same value from the same column in both cases. session-buffer.ts:257 accumulates the event's revenue into the session, and session.service.ts:149 passes it through untouched. Nothing in the query path scales it, so the only difference is the missing / 100 at the render site.

The cents convention is also stated in overview-metrics.tsx:185 ("Synthesize plausible-looking revenue (in cents)").

Suggested fix

Use the existing useNumber() helper at each of the three sites, matching the pattern already used in events/table/columns.tsx:

const number = useNumber();
// ...
{number.currency(session.revenue / 100)}

Note that in chat-profile-result.tsx the revenue row lives in SuccessCard, not Inner, so the hook belongs in the former.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions