Skip to content

feat(billing): report who saw and reviewed a plan proposal - #3306

Open
evoxmusic wants to merge 1 commit into
stagingfrom
feat/billing-proposal-engagement
Open

evoxmusic wants to merge 1 commit into
stagingfrom
feat/billing-proposal-engagement

Conversation

@evoxmusic

@evoxmusic evoxmusic commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Issue: none (asked by Romaric on 3 Dec 2026)

When Qovery staff send a plan proposal ("The Qovery team suggests Growth…"), they only knew whether someone saw the banner once. They want to know who saw it, who opened Review and who came from the email, to decide whom to recontact. The console now reports what each billing person does with a proposal; pricing-api keeps one line per person and shows it to staff.

  • Seen: each display of the Usage page card or the top bar, with where it showed (card or bar). pricing-api counts repeats within 30 minutes as one visit.
  • Review opened: Review on the card, or the proposal link opening the review.
  • Email clicked: the proposal link came from the email. The email's button now carries &source=email; a link without a source is treated as the email, since emails already sent have none.
  • Top bar: its Review link now carries &source=bar, so it is not counted as an email click.
  • Older pricing-api: if the client has no events call, the first-view call is used as before. Reporting never throws and never blocks the banner or the review.
  • SDK: the Console pins qovery-pricing-typescript-axios 0.1.2. The new types are declared in data-access and the events call (POST /organization/{id}/proposals/{proposalId}/events) goes through the same Axios instance with the user's token. Once sdk-v0.1.7 is published from pricing-api, bump the pin and switch to the generated proposalEvent.

Merge after the pricing-api change is deployed: before that, the events route does not exist there and the reports are dropped (the banner and the review still work).

pricing-api side: gitlab qovery/backend/pricing-api, docs/INTEGRATION.md section 3.4j.

Screenshots / Recordings

No visual change in the Console. I have not checked this branch in the running Console app.

Testing

  • settings-billing-usage.spec.tsx: seen from the card, review opened from the card, the email link reports the click then the review, the top bar link reports a review from the bar, proposalEvent is mounted
  • offers-bar.spec.tsx: the card and the top bar each report a seen with their source, the older view call is not used
  • utils/paywall-rules.spec.ts: link source parsing, the events a link reports, the top bar review path, the fallback to the first-view call, the request sent with the user's token
  • Billing feature suite: 18 suites, 130 tests pass
  • Prettier on the changed files; ESLint shows no errors
  • Changes tested in the running Console

PR Checklist

  • Conventional Commits title with a scope
  • Self-review of the diff
  • New business logic covered by unit tests

Summary by cubic

Reports what each billing person does with a plan proposal, so Qovery staff see who saw it, who opened Review and who came from the email. Previously they only knew a proposal was seen once.

Reporting

  • seen fires each time the Usage page card or top bar shows, with its source; repeats within 30 minutes count as one visit. review_opened fires on the card's Review or when a proposal link opens the review.
  • email_clicked fires when the link came from the email. The email's button now carries &source=email; links without a source count as the email. The top bar's Review link now carries &source=bar.
  • Older pricing-api without the events route falls back to the first-view call. Reporting never throws or blocks the banner or the review.
  • The events call goes through the same Axios instance with the user's token until qovery-pricing-typescript-axios 0.1.7 is published.
  • Merge after the pricing-api change is deployed; before that, reports are dropped.

Written for commit e4b2e81. Summary will update on new commits.

View guided diff Turn on auto-fix

The console now tells pricing-api what each billing person does with a plan
proposal, so Qovery staff can see who saw it, who opened Review and who came
from the email, and decide whom to recontact.

- seen: each display of the Usage page card or the top bar, with where it showed
- review_opened: Review from the card, or the proposal link opening the review
- email_clicked: the proposal link came from the email (source=email, or no
  source for emails sent before this change)
- the top bar's Review link now carries source=bar
- older pricing-api without the events route: falls back to the first-view call

The events call goes through the same Axios instance until the SDK publishes it.
@RemiBonnet

Copy link
Copy Markdown
Member

Qovery Preview

Qovery can create a Preview Environment for this PR.
To trigger its creation, please post a comment with one of the following command.

Command Blueprint environment
/qovery preview 28c47145-c8e7-4b9d-8d9e-c65c95b48425 staging
/qovery preview 964984c5-fba6-4371-88d3-a5daf99642ab test-prod
/qovery preview cc1de7de-94e5-40f8-8e45-bc8986d9dfec storybook
/qovery preview {all|UUID1,UUID2,...} To preview multiple environments

This comment has been generated from Qovery AI 🤖.
Below, a word from its wisdom :

Don’t Sacrifice Readability, you are going to debug it in 6 months

@nx-cloud

nx-cloud Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit e4b2e81

Command Status Duration Result
nx run console:build --parallel=3 --configurati... ✅ Succeeded 1m 14s View ↗
nx run-many --target=test --parallel=3 --config... ✅ Succeeded 4m 8s View ↗
nx affected --target=lint --parallel=3 ✅ Succeeded 2m 31s View ↗
nx-cloud record -- yarn nx format:check ✅ Succeeded 3s View ↗

💡 With Ultracache enabled, Nx Cloud learns each task's file inputs in CI and uses them on later runs. Turn on Ultracache in workspace settings ↗ · Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-12-03 11:42:14 UTC

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

3 issues found across 14 files

Confidence score: 3/5

  • In shared-billing-data-access.ts, a 404 from proposalEvent skips viewProposal, and the outer catch swallows the error, so proposal viewing can fail when the events route is not deployed. Add a fallback to viewProposal for that case.
  • In organization-banners.tsx, navigation builds raw query parameters instead of using TanStack Router’s typed search API, leaving this route’s search parameters outside its type checks. Use search: { proposal: proposal.id, source: 'bar' } and define the route search schema.
  • In settings-billing-usage.spec.tsx, the event assertions can run before the fire-and-forget POST is recorded, making the tests flaky. Wrap the expectations at lines 609, 662, and 680 in waitFor.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="libs/shared/billing/data-access/src/lib/shared-billing-data-access.ts">

<violation number="1" location="libs/shared/billing/data-access/src/lib/shared-billing-data-access.ts:513">
P2: When the events route is not deployed, `proposalEvent` rejects with a 404, but this branch never calls `viewProposal`: `createPricingClient` always supplies `proposalEvent`, and the outer catch only swallows the error. Fall back to `viewProposal` for the `seen` event on the unavailable-route response so legacy first-view tracking remains active.</violation>
</file>

<file name="apps/console/src/app/components/organization-banners/organization-banners.tsx">

<violation number="1" location="apps/console/src/app/components/organization-banners/organization-banners.tsx:41">
P2: This navigation still constructs raw query parameters instead of using TanStack Router’s typed `search` API. Navigate to the usage route with `search: { proposal: proposal.id, source: 'bar' }` and define the route search schema so malformed proposal state is caught consistently.

(Based on your team's feedback about typed router search parameters.) [d7a1bbdb-f2df-4305-a9f8-8ddf61301535]</violation>
</file>

<file name="libs/domains/organizations/feature/src/lib/settings-billing-usage/settings-billing-usage.spec.tsx">

<violation number="1" location="libs/domains/organizations/feature/src/lib/settings-billing-usage/settings-billing-usage.spec.tsx:662">
P2: These assertions can race the fire-and-forget event reports and fail before the adapter records the POST. Wrap the event expectations at lines 609, 662, and 680 in `waitFor` so the tests wait for the request rather than relying on scheduling.</violation>
</file>

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment on lines +513 to +514
if (client.proposalEvent) await client.proposalEvent(organizationId, proposalId, event, source)
else if (event === 'seen') await client.viewProposal?.(organizationId, proposalId)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2: When the events route is not deployed, proposalEvent rejects with a 404, but this branch never calls viewProposal: createPricingClient always supplies proposalEvent, and the outer catch only swallows the error. Fall back to viewProposal for the seen event on the unavailable-route response so legacy first-view tracking remains active.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At libs/shared/billing/data-access/src/lib/shared-billing-data-access.ts, line 513:

<comment>When the events route is not deployed, `proposalEvent` rejects with a 404, but this branch never calls `viewProposal`: `createPricingClient` always supplies `proposalEvent`, and the outer catch only swallows the error. Fall back to `viewProposal` for the `seen` event on the unavailable-route response so legacy first-view tracking remains active.</comment>

<file context>
@@ -466,3 +499,20 @@ export const billing = createQueryKeys('billing', {
+  source: ProposalSource
+): Promise<void> {
+  try {
+    if (client.proposalEvent) await client.proposalEvent(organizationId, proposalId, event, source)
+    else if (event === 'seen') await client.viewProposal?.(organizationId, proposalId)
+  } catch {
</file context>
Suggested change
if (client.proposalEvent) await client.proposalEvent(organizationId, proposalId, event, source)
else if (event === 'seen') await client.viewProposal?.(organizationId, proposalId)
if (client.proposalEvent) {
try {
await client.proposalEvent(organizationId, proposalId, event, source)
return
} catch (error) {
if (!(error instanceof BillingError) || error.status !== 404) return
}
}
if (event === 'seen') await client.viewProposal?.(organizationId, proposalId)

variant="bar"
modal={false}
onReviewProposal={(proposal) => window.location.assign(`${usagePath}?proposal=${proposal.id}`)}
onReviewProposal={(proposal) => window.location.assign(proposalReviewPath(usagePath, proposal.id))}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2: This navigation still constructs raw query parameters instead of using TanStack Router’s typed search API. Navigate to the usage route with search: { proposal: proposal.id, source: 'bar' } and define the route search schema so malformed proposal state is caught consistently.

(Based on your team's feedback about typed router search parameters.) [d7a1bbdb-f2df-4305-a9f8-8ddf61301535]

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At apps/console/src/app/components/organization-banners/organization-banners.tsx, line 41:

<comment>This navigation still constructs raw query parameters instead of using TanStack Router’s typed `search` API. Navigate to the usage route with `search: { proposal: proposal.id, source: 'bar' }` and define the route search schema so malformed proposal state is caught consistently.

(Based on your team's feedback about typed router search parameters.) [d7a1bbdb-f2df-4305-a9f8-8ddf61301535]</comment>

<file context>
@@ -38,7 +38,7 @@ export function OrganizationBanners() {
           variant="bar"
           modal={false}
-          onReviewProposal={(proposal) => window.location.assign(`${usagePath}?proposal=${proposal.id}`)}
+          onReviewProposal={(proposal) => window.location.assign(proposalReviewPath(usagePath, proposal.id))}
           onAction={(offer) => {
             const action = offer.content.action
</file context>

expect(bodyOf(adapter, '/proposals/7/accept')).toEqual([{ dry_run: true }])
expect(calledPaths(adapter).filter((path) => path.endsWith('/proposals'))).toHaveLength(1)
// An email link without a source is the email: the click, then the review opened
const events = bodyOf(adapter, '/proposals/7/events') as { event: string }[]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2: These assertions can race the fire-and-forget event reports and fail before the adapter records the POST. Wrap the event expectations at lines 609, 662, and 680 in waitFor so the tests wait for the request rather than relying on scheduling.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At libs/domains/organizations/feature/src/lib/settings-billing-usage/settings-billing-usage.spec.tsx, line 662:

<comment>These assertions can race the fire-and-forget event reports and fail before the adapter records the POST. Wrap the event expectations at lines 609, 662, and 680 in `waitFor` so the tests wait for the request rather than relying on scheduling.</comment>

<file context>
@@ -656,6 +658,27 @@ describe('SettingsBillingUsage', () => {
       expect(bodyOf(adapter, '/proposals/7/accept')).toEqual([{ dry_run: true }])
       expect(calledPaths(adapter).filter((path) => path.endsWith('/proposals'))).toHaveLength(1)
+      // An email link without a source is the email: the click, then the review opened
+      const events = bodyOf(adapter, '/proposals/7/events') as { event: string }[]
+      expect(events.filter((e) => e.event !== 'seen')).toEqual([
+        { event: 'email_clicked', source: 'email' },
</file context>

@codecov

codecov Bot commented Dec 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 66.66667% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 55.32%. Comparing base (3f618ff) to head (e4b2e81).

Files with missing lines Patch % Lines
libs/shared/billing/feature/src/lib/usage-page.tsx 0.00% 4 Missing ⚠️
...feature/src/lib/hooks/use-proposal/use-proposal.ts 33.33% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           staging    #3306      +/-   ##
===========================================
- Coverage    55.32%   55.32%   -0.01%     
===========================================
  Files         1558     1558              
  Lines        38331    38344      +13     
  Branches     12118    12126       +8     
===========================================
+ Hits         21206    21213       +7     
- Misses       13841    13847       +6     
  Partials      3284     3284              
Flag Coverage Δ
unittests 55.32% <66.66%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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