Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat(rewards): send wallet address with benefit impression#30914

Open
jeremytsng wants to merge 3 commits into
mainfrom
feat/miracle-impressions-missing-wallet-add
Open

feat(rewards): send wallet address with benefit impression#30914
jeremytsng wants to merge 3 commits into
mainfrom
feat/miracle-impressions-missing-wallet-add

Conversation

@jeremytsng

@jeremytsng jeremytsng commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Description

Benefit-impression events sent to the rewards backend identified which benefit was viewed but not which wallet viewed it, so there was no per-wallet visibility into benefit engagement.

This adds the currently selected account's address to the POST /benefits/impression request body. The address is threaded through RewardsController.postBenefitImpression and the rewards data service, and is omitted from the body when no account is selected so existing behaviour is preserved. The rewards backend then attributes the impression to that wallet.

Changelog

CHANGELOG entry: null

Related issues

Fixes:

Manual testing steps

Feature: Benefit impression wallet attribution

  Scenario: user opens a benefit detail with an account selected
    Given the user is signed in to rewards with a selected account
    When the user opens a benefit's full view
    Then a POST /benefits/impression request is sent
    And the request body includes the selected account's walletAddress

  Scenario: no account is selected
    Given the user has no selected internal account
    When the user opens a benefit's full view
    Then a POST /benefits/impression request is sent
    And the request body omits walletAddress

Screenshots/Recordings

Before

After

Pre-merge author checklist

Performance checks (if applicable)

  • I've tested on Android
    • Ideally on a mid-range device; emulator is acceptable
  • I've tested with a power user scenario
    • Use these power-user SRPs to import wallets with many accounts and tokens
  • I've instrumented key operations with Sentry traces for production performance metrics

For performance guidelines and tooling, see the Performance Guide.

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

Note

Low Risk
Additive optional API field and URL parsing only; no auth or payment logic changes, though wallet addresses are sent to the rewards backend when present in the benefit URL.

Overview
Benefit impressions can now be attributed to a wallet by sending an optional walletAddress on POST /benefits/impression.

When the user opens BenefitFullView, the app parses the benefit’s url for a wallet query parameter and passes that value through RewardsController:postBenefitImpression into the rewards data service. The field is omitted from the JSON body when the URL is missing, empty, or has no wallet param, so callers without a URL still behave like before.

Controller, messenger action types, and service tests were updated to forward or serialize walletAddress; BenefitFullView tests cover URL parsing, missing wallet, and a single impression after subscription hydration.

Reviewed by Cursor Bugbot for commit aac3efa. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions

github-actions Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@github-actions github-actions Bot added the size-M label Jun 2, 2026
@jeremytsng jeremytsng added the team-networks Networks team label Jun 2, 2026
@jeremytsng jeremytsng marked this pull request as ready for review June 2, 2026 04:34
@jeremytsng jeremytsng requested a review from a team as a code owner June 2, 2026 04:34
@github-actions github-actions Bot added the risk:low AI analysis: low risk label Jun 2, 2026
Include the currently selected account address in the POST /benefits/impression request body so the rewards backend can attribute each impression to a wallet. Thread an optional walletAddress through RewardsController.postBenefitImpression and the rewards data service; it is omitted from the body when no account is selected, preserving existing behaviour.

Update unit tests for the data service, controller, and BenefitFullView.
Adds the walletAddress @param line emitted by messenger-generate-action-types
now that postBenefitImpression accepts it. Fixes the lint job's
generate-method-action-types:check diff.
@jeremytsng jeremytsng force-pushed the feat/miracle-impressions-missing-wallet-add branch from 3333301 to 9280115 Compare July 8, 2026 06:22
@mm-token-exchange-service

Copy link
Copy Markdown
Contributor

PR template — items to address before "Ready for review"

Warnings — informational, address before merging:

  • Related issues section is empty. Add Fixes: #123 / Closes: <URL> / Refs: <Jira key>, or write a short rationale after the colon.
  • Screenshots/Recordings section is empty. Add an image/video for user-facing changes, logs/console output for non-user-facing changes, or write N/A if no evidence is applicable.
  • Pre-merge author checklist has unchecked items (e.g. "I've followed MetaMask Contributor Docs and MetaMask Mobile Coding Standards."). Every box must be consciously checked — see docs/readme/ready-for-review.md.

See docs/readme/ready-for-review.md for the full Definition of Ready for Review.

Comment thread app/components/UI/Rewards/Views/BenefitFullView.tsx Outdated
@github-actions github-actions Bot added risk:medium AI analysis: medium risk and removed risk:low AI analysis: low risk labels Jul 8, 2026
The impression wallet must match the wallet the click is attributed to.
Reading the selected internal account picked the wrong wallet whenever a
benefit targeted an account other than the first in the list, and its
async hydration re-fired the effect, posting a second impression.

Derive walletAddress from the 'wallet' query param on benefit.url, which
makes it a pure function of the route param: one impression per view.
@github-actions github-actions Bot added risk:low AI analysis: low risk and removed risk:medium AI analysis: medium risk labels Jul 8, 2026
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: None (no tests recommended)
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: low
  • AI Confidence: 90%
click to see 🤖 AI reasoning details

E2E Test Selection:
The PR makes additive, backward-compatible changes to the Rewards feature:

  1. RewardsController.ts - Adds an optional walletAddress parameter to postBenefitImpression(). The parameter is optional, so existing callers are unaffected.
  2. RewardsController-method-action-types.ts - Only a JSDoc comment update documenting the new optional parameter.
  3. rewards-data-service.ts - Conditionally includes walletAddress in the API request body only when provided (...(walletAddress ? { walletAddress } : {})). No breaking change.
  4. BenefitFullView.tsx - Extracts wallet address from benefit URL query params using url-parse and passes it to postBenefitImpression(). This is a UI enhancement to pass wallet context to the impression API.

No E2E tests exist for the Rewards/Benefits feature - confirmed by searching tests/smoke/ directory and all spec files. There are no smoke test specs covering BenefitFullView, RewardsController, or benefit impressions.

No shared components are affected - the changes are isolated to the Rewards feature module and don't touch TabBar, Browser, Confirmations, navigation, or any other shared infrastructure.

Risk is low because:

  • All changes are additive (optional parameter)
  • No existing callers are broken
  • The feature has no E2E test coverage to validate or break
  • Changes are well-isolated within the Rewards domain

Performance Test Selection:
The changes add an optional wallet address parameter to a benefit impression API call. This is a minor additive change that doesn't affect any performance-sensitive flows (app launch, login, onboarding, asset loading, swaps, account list, perps, or predictions). No performance test tags are warranted.

View GitHub Actions results

@cursor cursor 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.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit aac3efa. Configure here.

)
.catch();
}, [benefit, subscriptionId]);
}, [benefit, subscriptionId, walletAddress]);

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.

Wallet omitted without URL param

Medium Severity

Benefit impressions now take walletAddress only from the wallet query param on benefit.url, but opening a benefit from BenefitCard passes the API benefit unchanged and nothing in the rewards flow adds that param. With a selected account and a typical claim URL, impressions still omit walletAddress, so per-wallet attribution does not match the PR’s selected-account behavior.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit aac3efa. Configure here.

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.

we no longer use selected-account

@sonarqubecloud

sonarqubecloud Bot commented Jul 8, 2026

Copy link
Copy Markdown

@stanleyyconsensys stanleyyconsensys 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.

LGTM

@jeremytsng jeremytsng enabled auto-merge July 8, 2026 07:09
@jeremytsng jeremytsng added this pull request to the merge queue Jul 8, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Jul 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk:low AI analysis: low risk size-M team-networks Networks team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants