Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: delay setting user.router_preference until statsig and redux initialize #7458

Merged
merged 1 commit into from
Oct 12, 2023

Conversation

just-toby
Copy link
Contributor

@just-toby just-toby commented Oct 12, 2023

Description

tl;dr: we're setting the user property to an incorrect value as we wait for the statsig and redux values to load into the app.

here we delay setting the user property until we are certain we have the right value, to avoid setting multiple values in a short time span. even though user properties apply to all subsequent events, this is important because we usually send unrelated events between the two user-prop-setting moments which solidifies the user prop in the shortest time frame amplitude supports, 1 hour. so our charts and metrics are broken because we're counting users in both buckets for that time frame.

see the slack thread for all the nitty gritty details.

Slack thread: https://uniswapteam.slack.com/archives/C0574KNS77S/p1697137960543169
Relevant docs: https://help.amplitude.com/hc/en-us/articles/115002380567-Overview-of-user-properties-and-event-properties-in-Amplitude

Test plan

Reproducing the error

  1. log the value we're setting like this and notice that it changes as we init statsig/redux
  useEffect(() => {
    // If we're not in the transition period to UniswapX opt-out, set the router preference to whatever is specified.
    if (!isUniswapXDefaultEnabled) {
      console.log(1, "setting user preference")
      user.set(CustomUserProperties.ROUTER_PREFERENCE, routerPreference)
      return
    }

    // In the transition period, override the stored API preference to UniswapX if the user hasn't opted out.
    if (routerPreference === RouterPreference.API && !userOptedOutOfUniswapX) {
      console.log(2, "overriding user preference")
      user.set(CustomUserProperties.ROUTER_PREFERENCE, RouterPreference.X)
      return
    }

      console.log(3, "setting user preference")
    // Otherwise, the user has opted out or their preference is UniswapX/client, so set the preference to whatever is specified.
    user.set(CustomUserProperties.ROUTER_PREFERENCE, routerPreference)
  }, [routerPreference, isUniswapXDefaultEnabled, userOptedOutOfUniswapX, isUniswapXDefaultLoading, rehydrated])

QA (ie manual testing)

  • logged the value we're setting and made sure it doesn't change within a session, unless i actually change the setting

@just-toby just-toby requested review from tinaszheng and a team October 12, 2023 20:14
@vercel
Copy link

vercel bot commented Oct 12, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
interface ✅ Ready (Inspect) Visit Preview Oct 12, 2023 8:14pm

@codecov
Copy link

codecov bot commented Oct 12, 2023

Codecov Report

Merging #7458 (580e98b) into main (7001452) will decrease coverage by 0.01%.
The diff coverage is 0.00%.

Flag Coverage Δ
cloud-tests 83.60% <ø> (ø)
unit-tests 42.81% <0.00%> (-0.01%) ⬇️

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

@cypress
Copy link

cypress bot commented Oct 12, 2023

4 flaky tests on run #15000 ↗︎

0 118 0 0 Flakiness 4

Details:

fix: delay setting user.router_preference until statsig and redux initialize
Project: Uniswap Interface Commit: 580e98bd39
Status: Passed Duration: 04:54 💡
Started: Oct 12, 2023 8:22 PM Ended: Oct 12, 2023 8:27 PM
Flakiness  swap/uniswapx.test.ts • 3 flaky tests • e2e

View Output Video

Test Artifacts
UniswapX Toggle > prompts opt-in if UniswapX is better Output Screenshots
UniswapX Orders > can swap exact-out trades using uniswapX Output Screenshots
UniswapX activity history > balances should refetch after uniswapx swap Output Screenshots
Flakiness  permit2.test.ts • 1 flaky test • e2e

View Output Video

Test Artifacts
Permit2 > prompts signature when existing permit approval amount is too low Output Screenshots

Review all test suite changes for PR #7458 ↗︎

@just-toby just-toby merged commit ad1e2c6 into main Oct 12, 2023
@just-toby just-toby deleted the fix/user-prop-setting branch October 12, 2023 22:42
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.

3 participants