feat(payment-next): Pass experimentationPreview param through to Nimbus#20422
feat(payment-next): Pass experimentationPreview param through to Nimbus#20422david1alvarez wants to merge 1 commit intomainfrom
Conversation
There was a problem hiding this comment.
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
searchParamsplumbing togetCart/getSuccessCartactions and validators. - Propagate
searchParamsinto cart/free-trial eligibility evaluation and mapexperimentationPreview→Nimbuspreview. - 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.
| this.nimbusManager.fetchExperiments({ | ||
| nimbusUserId: this.nimbusManager.generateNimbusId(uid), | ||
| preview: false, | ||
| preview: searchParams?.['experimentationPreview'] === 'true', | ||
| }), |
There was a problem hiding this comment.
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.
| @@ -66,9 +67,12 @@ async function getCartOrRedirectAction( | |||
| : undefined; | |||
| const urlSearchParams = new URLSearchParams(filteredParams); | |||
| const params = searchParams ? `?${urlSearchParams.toString()}` : ''; | |||
There was a problem hiding this comment.
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).
| const params = searchParams ? `?${urlSearchParams.toString()}` : ''; | |
| const queryString = urlSearchParams.toString(); | |
| const params = queryString ? `?${queryString}` : ''; |
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
Because:
This commit:
Closes #PAY-3668
Checklist
Put an
xin the boxes that applyHow to review (Optional)
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.