experiments: promotion impact ledger section (companion to lantern-cloud#3118) - #78
Conversation
…oud#3118) New section on the Experiments tab reading GET /v1/dashboard/experiments/impact: per-outcome totals strip (market win / no effect / regression / inconclusive / no data) and one row per measured promotion with the goodput and ok-rate diff-in-diff effects, expandable to the full reason, measurement windows (including bucket-layout-clamped goodput sub-windows), target values, and the control-basket audit table.
Deploying lantern-dashboard with
|
| Latest commit: |
2070f75
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://518f1205.lantern-dashboard.pages.dev |
| Branch Preview URL: | https://reflog-promotion-impact-ledg.lantern-dashboard.pages.dev |
|
Warning Review limit reached
Next review available in: 55 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds a promotion-impact API, authenticated loading hook, and experiments-tab ledger. The ledger displays promotion outcomes, aggregate totals, effects, control-market measurements, expandable details, and loading, error, and empty states. ChangesPromotion impact ledger
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant PromotionImpactLedger
participant usePromotionImpact
participant fetchPromotionImpact
participant ImpactEndpoint
PromotionImpactLedger->>usePromotionImpact: request impact data when enabled
usePromotionImpact->>fetchPromotionImpact: load promotion impact
fetchPromotionImpact->>ImpactEndpoint: GET /experiments/impact
ImpactEndpoint-->>fetchPromotionImpact: PromotionImpactResponse
fetchPromotionImpact-->>usePromotionImpact: ledger data or error
usePromotionImpact-->>PromotionImpactLedger: loading, error, and data state
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/components/PromotionImpactLedger.tsx`:
- Around line 236-256: Replace the clickable row div in the promotion ledger
with an accessible button control, preserving its existing styling and expansion
behavior through setExpandedId. Add aria-expanded={expanded} so the row’s
current state is exposed to assistive technologies, and ensure the control does
not introduce unwanted default button styling.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 4d672c16-8147-468e-abc7-fcf86fc95757
📒 Files selected for processing (4)
src/api/client.tssrc/components/ExperimentsOverview.tsxsrc/components/PromotionImpactLedger.tsxsrc/hooks/useExperiments.ts
There was a problem hiding this comment.
Pull request overview
Adds a new “Promotion impact ledger” section to the Experiments dashboard tab to display per-promotion, terminal impact outcomes (with rollups and drill-down details) backed by a new dashboard API endpoint.
Changes:
- Add
fetchPromotionImpact()and strongly-typed response models for the promotion impact ledger API. - Add
usePromotionImpact()hook to load the ledger once per tab activation (no polling). - Introduce
PromotionImpactLedgerUI component and mount it inExperimentsOverview.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/hooks/useExperiments.ts | Adds usePromotionImpact hook for one-shot loading of impact ledger data on activation. |
| src/components/PromotionImpactLedger.tsx | New ledger UI: totals strip, per-promotion rows, and expandable detail (reason/windows/basket audit). |
| src/components/ExperimentsOverview.tsx | Inserts the new ledger section into the Experiments tab layout. |
| src/api/client.ts | Adds impact-ledger API types and fetchPromotionImpact() client function. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Expandable rows are now <button type=button> with aria-expanded instead of a clickable div, so keyboard and assistive-tech users can toggle the detail panel.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
Suppressed comments (1)
src/hooks/useExperiments.ts:169
usePromotionImpactcan leaveisLoadingstucktrueifenabledorisAuthenticatedflips to false while the fetch is in-flight. The effect cleanup setscancelled = true, which prevents thefinallyblock from clearing the loading flag, and because the hook instance stays mounted across tab switches, the UI can remain in a loading state indefinitely (especially whenrows.length === 0).
useEffect(() => {
if (!enabled || !isAuthenticated) return;
let cancelled = false;
What
Companion UI for getlantern/lantern-cloud#3118 (promotion impact ledger). New section on the Experiments tab, between the lifecycle pipeline and the promoted-vs-original traffic cards, answering: did each promotion move its target market, or did the cohort win just substitute experiment-track share for incumbent share?
How
GET /v1/dashboard/experiments/impact→fetchPromotionImpact()+ types mirroringpromotionImpactRowincmd/api/dashboard_experiments_handler.go.usePromotionImpacthook: single fetch per tab activation — rows are terminal (one per promotion, written hourly by the backend worker), so no polling.PromotionImpactLedgercomponent:Notes
promotion_impact_enabledis on (server-side; 41 of the 46 existing promotions are due immediately on enable).npm run buildclean;npm run lintintroduces no new issues (the 17 reported problems are pre-existing on main).Summary by CodeRabbit