Skip to content

experiments: promotion impact ledger section (companion to lantern-cloud#3118) - #78

Merged
reflog merged 2 commits into
mainfrom
reflog/promotion-impact-ledger
Aug 6, 2026
Merged

experiments: promotion impact ledger section (companion to lantern-cloud#3118)#78
reflog merged 2 commits into
mainfrom
reflog/promotion-impact-ledger

Conversation

@reflog

@reflog reflog commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

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/impactfetchPromotionImpact() + types mirroring promotionImpactRow in cmd/api/dashboard_experiments_handler.go.
  • usePromotionImpact hook: single fetch per tab activation — rows are terminal (one per promotion, written hourly by the backend worker), so no polling.
  • PromotionImpactLedger component:
    • totals strip headlining the outcome ratio (market win / no effect / regression / inconclusive / no data), tolerant of outcome tokens this build doesn't know yet;
    • one row per measured promotion: outcome badge, market, promoted track, goodput DiD (relative %), ok-rate DiD (pp), control-basket size, promotion date;
    • expandable detail: full reason, before/after windows, bucket-layout-clamped goodput sub-windows when present, target p50/ok-rate raw values (labeled relative-scale — the goodput histogram clips), and the control-basket audit table with per-market deltas and exclusions.

Notes

  • Empty state explains that rows appear as after-windows elapse and backfill once promotion_impact_enabled is on (server-side; 41 of the 46 existing promotions are due immediately on enable).
  • npm run build clean; npm run lint introduces no new issues (the 17 reported problems are pre-existing on main).
  • Renders real data only after lantern-cloud#3118 deploys and the flag is enabled; until then the section shows its empty state.

Summary by CodeRabbit

  • New Features
    • Added a promotion impact ledger to the Experiments view.
    • Displays promotion outcomes, aggregate totals, market and track effects, measurement windows, target metrics, and control-market details.
    • Added expandable rows with loading, error, empty, and fallback states.
    • Impact effects are formatted and color-coded for easier interpretation.

…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.
Copilot AI lite review requested due to automatic review settings August 6, 2026 13:17
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 6, 2026

Copy link
Copy Markdown

Deploying lantern-dashboard with  Cloudflare Pages  Cloudflare Pages

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

View logs

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@reflog, you've reached your PR review limit, so we couldn't start this review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: bf38a322-a023-4fe8-945d-f4c67719ee9b

📥 Commits

Reviewing files that changed from the base of the PR and between cb58e21 and 2070f75.

📒 Files selected for processing (1)
  • src/components/PromotionImpactLedger.tsx
📝 Walkthrough

Walkthrough

Adds 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.

Changes

Promotion impact ledger

Layer / File(s) Summary
Impact API contract and endpoint
src/api/client.ts
Defines promotion-impact data types and adds fetchPromotionImpact() for /experiments/impact.
Impact loading and tab wiring
src/hooks/useExperiments.ts, src/components/ExperimentsOverview.tsx
Adds conditional authenticated loading and renders the ledger only in the enabled experiments view.
Ledger presentation and detail views
src/components/PromotionImpactLedger.tsx
Displays outcome totals, effects, control-market metrics, expandable details, and loading, error, and empty states.

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
Loading

Possibly related PRs

Suggested reviewers: copilot

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: adding a Promotion Impact Ledger section to the Experiments tab.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch reflog/promotion-impact-ledger

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between cb6c293 and cb58e21.

📒 Files selected for processing (4)
  • src/api/client.ts
  • src/components/ExperimentsOverview.tsx
  • src/components/PromotionImpactLedger.tsx
  • src/hooks/useExperiments.ts

Comment thread src/components/PromotionImpactLedger.tsx Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 PromotionImpactLedger UI component and mount it in ExperimentsOverview.

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.

Comment thread src/components/PromotionImpactLedger.tsx Outdated
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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

  • usePromotionImpact can leave isLoading stuck true if enabled or isAuthenticated flips to false while the fetch is in-flight. The effect cleanup sets cancelled = true, which prevents the finally block 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 when rows.length === 0).
  useEffect(() => {
    if (!enabled || !isAuthenticated) return;
    let cancelled = false;

@reflog
reflog merged commit c631b3e into main Aug 6, 2026
3 checks passed
@reflog
reflog deleted the reflog/promotion-impact-ledger branch August 6, 2026 13:30
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