← Back to Pull requests

Move the program earnings and bounties pages to the shared partner endpoints #4683

Closed
unknown closed this pull request without merging on Oct 13, 2026 21:10 UTC
View on GitHub
unknown unknown commented on Oct 13, 2026 16:16 UTC
Author

Changes

Fixes https://linear.app/dubinc/issue/ENG-1782/move-the-per-program-earnings-pages-to-the-shared-partner-earnings
Fixes https://linear.app/dubinc/issue/ENG-1843/move-the-partner-program-bounties-routes-to-the-shared-bounties

Clients

  • The program Overview, Earnings, customer and bounty pages and the payout details sheet now use /api/partner-profile/earnings with programIdOrSlug.

  • The shared earnings hooks take the filters, sorting, pages and a count, and the Earnings page passes its URL filters to them.

  • The Overview date range hook moved to lib/analytics/use-partner-date-range.ts and the program pages use it too.
  • API

  • Removed GET /api/partner-profile/programs/[programId]/earnings, /count and /timeseries, and the old usePartnerEarningsTimeseries and usePartnerEarningsCount hooks.

  • The earnings table on the program Overview page has a row limit and no pagination, so it no longer requests the count.

  • GET /api/partner-profile/earnings accepts startingAfter and endingBefore. The cursor must match the same filters (partner, program, status, dates and others), otherwise the route returns 422. Offset and cursor pages sort the same way.

  • Offset pages also sort by commission ID, so that earnings with the same date do not repeat or go missing between pages.
  • Bounties

  • GET /api/partner-profile/bounties accepts programIdOrSlug. With it, the route loads that one enrollment with getProgramEnrollmentOrThrow, like the old per-program route: any enrollment status, and 404 when the partner is not in the program. Without it, it returns the bounties of all active programs, as before.

  • Removed GET /api/partner-profile/programs/[programId]/bounties and the usePartnerProgramBounties hook. The program Bounties page and the program sidebar badge use usePartnerProfileBounties({ programIdOrSlug }).

  • After a submission, the claim sheet refreshes the bounty lists and the single bounty.

  • The single bounty routes (/programs/[programId]/bounties/[bountyId] and its social-content-stats) stay for now.
  • Motivation

    dubinc/dub#4649 added the shared earnings endpoints, and dubinc/dub#4684 added the shared bounties endpoint. The per-program routes already called the same functions. This moves the last clients over so there is one set of routes for each. The list gets cursor pagination before it can become part of the public Partner API.

    How to test

    1. Run pnpm dev in apps/web and log in to partners.localhost:8888 as a partner with earnings in a program.
    2. Open /programs/<slug>, /programs/<slug>/earnings with a filter (for example ?status=pending), a customer page and a payout. The network panel shows only /api/partner-profile/earnings requests with programIdOrSlug, and the data matches before.
    3. Open /api/partner-profile/earnings?startingAfter=<earning ID>&pageSize=2. It returns the next 2 earnings by ID.
    4. Open /programs/<slug>/bounties. The page and the sidebar badge send one /api/partner-profile/bounties?programIdOrSlug=<slug> request. /bounties still lists the bounties of all programs.
    5. Run pnpm exec playwright test playwright/api/partner-profile/earnings.spec.ts playwright/api/partner-profile/bounties.spec.ts --project=api in apps/web.

    <!-- This is an auto-generated comment: release notes by coderabbit.ai -->

    Summary by CodeRabbit

    New Features
    Partner earnings lists support cursor-based pagination, with validation for invalid cursors and cursors from another program.
    Improvements
    Earnings filters and counts are consistent across program, customer, payout, and performance views.
    Shared date-range selections keep partner analytics charts and summaries aligned.
    Earnings tables support sorting by date, amount, and earnings.
    Payout and performance views use consistent earnings data and filters.
    Bounty lists can be filtered to a specific program.
    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 501 lines (+375 / -126) across 6 files Reviewer: Joker666 Review duration: 294m
    All Vouch review confidence checks passed
    Residual risk 0.19 = Change Risk (0.48) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.48 · 501 lines diff across 6 files
    0.48
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.372
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #4683"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 47.5% (MEDIUM) · Higher = larger blast radius
    47.5%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 18.8% · Safe to merge
    18.8%
    Repository