Skip to content

feat(payment-next): Pass experimentationPreview param through to Nimbus#20422

Open
david1alvarez wants to merge 1 commit intomainfrom
PAY-3668
Open

feat(payment-next): Pass experimentationPreview param through to Nimbus#20422
david1alvarez wants to merge 1 commit intomainfrom
PAY-3668

Conversation

@david1alvarez
Copy link
Copy Markdown
Contributor

Because:

  • The Checkout Service was hardcoding "false" when fetching Nimbus experiments

This commit:

  • Passes through the query param through to the nimbusManager.fetchExperiments calls, like is done in the Glean Service

Closes #PAY-3668

Checklist

Put an x in the boxes that apply

  • My commit is GPG signed.
  • If applicable, I have modified or added tests which pass locally.
  • I have added necessary documentation (if appropriate).
  • I have verified that my changes render correctly in RTL (if appropriate).
  • I have manually reviewed all AI generated code.

How to review (Optional)

  • Key files/areas to focus on:
  • Suggested review order:
  • Risky or complex parts:

Screenshots (Optional)

Please attach the screenshots of the changes made in case of change in user interface.

Other information (Optional)

Any other information that is important to this pull request.

Copilot AI review requested due to automatic review settings April 21, 2026 20:25
@david1alvarez david1alvarez requested a review from a team as a code owner April 21, 2026 20:25
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR threads the experimentationPreview query parameter through the Payments Next UI → cart fetching flow so the cart/checkout path can pass preview correctly into NimbusManager.fetchExperiments, aligning behavior with the existing Glean metrics service.

Changes:

  • Add optional searchParams plumbing to getCart/getSuccessCart actions and validators.
  • Propagate searchParams into cart/free-trial eligibility evaluation and map experimentationPreviewNimbus preview.
  • Update one cart service unit test to account for the new optional argument.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
libs/payments/ui/src/lib/nestapp/validators/GetCartActionArgs.ts Extends validator args to allow optional searchParams.
libs/payments/ui/src/lib/nestapp/nextjs-actions.service.ts Extends getCart and getSuccessCart to accept/pass optional searchParams.
libs/payments/ui/src/lib/actions/getCartOrRedirect.ts Passes flattened searchParams into getCart action call (and uses query params for redirects).
libs/payments/ui/src/lib/actions/getCart.ts Extends server action to accept and forward flattened searchParams.
libs/payments/cart/src/lib/checkout.service.ts Passes searchParams into getFreeTrialEligibility and maps experimentationPreview to Nimbus preview.
libs/payments/cart/src/lib/cart.service.ts Extends getCart to accept optional searchParams and forward to free-trial eligibility.
libs/payments/cart/src/lib/cart.service.spec.ts Updates an expectation to include searchParams: undefined.
apps/payments/next/app/[locale]/error.tsx Forwards current URL search params into getCartAction.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 1004 to 1007
this.nimbusManager.fetchExperiments({
nimbusUserId: this.nimbusManager.generateNimbusId(uid),
preview: false,
preview: searchParams?.['experimentationPreview'] === 'true',
}),
Copy link

Copilot AI Apr 21, 2026

Choose a reason for hiding this comment

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

This change introduces new behavior for Nimbus preview selection based on searchParams.experimentationPreview, but there is no unit test asserting that nimbusManager.fetchExperiments is called with preview: true when that param is present. Adding a test case in checkout.service.spec.ts will help prevent regressions in the preview passthrough logic.

Copilot uses AI. Check for mistakes.
@@ -66,9 +67,12 @@ async function getCartOrRedirectAction(
: undefined;
const urlSearchParams = new URLSearchParams(filteredParams);
const params = searchParams ? `?${urlSearchParams.toString()}` : '';
Copy link

Copilot AI Apr 21, 2026

Choose a reason for hiding this comment

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

params is derived from the truthiness of searchParams, so callers that pass an empty object (common with Next searchParams) will produce a trailing ? (because urlSearchParams.toString() is empty). Consider deriving params from the serialized query string instead (only prefixing with ? when the string is non-empty).

Suggested change
const params = searchParams ? `?${urlSearchParams.toString()}` : '';
const queryString = urlSearchParams.toString();
const params = queryString ? `?${queryString}` : '';

Copilot uses AI. Check for mistakes.
Because:

* The Checkout Service was hardcoding "false" when fetching Nimbus experiments

This commit:

* Passes through the query param through to the nimbusManager.fetchExperiments calls, like is done in the Glean Service

Closes #PAY-3668
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