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

Ensure we're always including timezone in myPersonalDetails #2040

Merged
merged 4 commits into from
Mar 25, 2021

Conversation

NikkiWines
Copy link
Contributor

@NikkiWines NikkiWines commented Mar 24, 2021

cc: @jasperhuangg since you made this original issue for this one.

Details

  • Fixes a whitescreen issue where new users were blocked from using the product.
  • Adds a migration so we always get the timezone in the correct format.

Fixed Issues

Fixes https://github.com/Expensify/Expensify/issues/158295

Tests

To test that personalDetails are getting set correctly:

  1. Go to https://www.emailondeck.com/ to get a temporary email.
  2. Use the temporary email to register for Expensify.cash
  3. Use the validation link sent to the temporary email address.
  4. Set a password.
  5. After logging in, confirm everything works as anticipated and you don't get an error in the JS console.

To test timezone migration:

  1. Log into E.cash
  2. Open the JS console navigate to Application, select Local Storage, and search for myPersonalDetails
  3. Manually modify your timezone in your myPersonalDetails so that it's a string like so
    OLD
"timezone": {
  "automatic": true,
  "selected": "America/Los_Angeles"
}

NEW

"timezone": "America/Los_Angeles"
  1. Set your log levels for the console drawer to include Verbose
  2. Refresh the page and confirm you see [Migrate Onyx] Ran migration ReformatTimezone logged.
  3. Check your myPersonalDetails onyx key again and confirm it is an object matching the OLD format above.

Tested On

  • Web
  • Mobile Web
  • Desktop
  • iOS
  • Android

Screenshots

No platform-specific changes here, no screenshots necessary.

@NikkiWines NikkiWines requested a review from jasperhuangg March 24, 2021 17:37
@NikkiWines NikkiWines requested a review from a team as a code owner March 24, 2021 17:37
@NikkiWines NikkiWines self-assigned this Mar 24, 2021
@botify botify requested review from sketchydroide and removed request for a team March 24, 2021 17:38
@NikkiWines
Copy link
Contributor Author

NikkiWines commented Mar 24, 2021

🤔 this test is failing for me on master as well... Gonna post in eng-chat
image

@AndrewGable
Copy link
Contributor

You can fix your local error by

brew tap wix/brew
brew install applesimutils

I am not sure what is wrong with the remote version yet

@NikkiWines
Copy link
Contributor Author

@AndrewGable, works on master after running those two commands! 🎉
image

@NikkiWines
Copy link
Contributor Author

Was still broken on my branch, but should be fixed now 🎉

@NikkiWines NikkiWines removed the request for review from sketchydroide March 24, 2021 23:26
src/libs/migrations/ReformatTimezone.js Outdated Show resolved Hide resolved
return resolve();
}

// Replace the old timezone with the default timezone
Copy link
Contributor

Choose a reason for hiding this comment

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

Hey @NikkiWines! I'm confused as to why we're setting the old string timezone to the DEFAULT_TIME_ZONE when migrating?

My current understanding is this: the migration isn't supposed to actually change the timezone, it's just meant to change its format so that when you pick it up in DateUtil.js you can be sure that it's an object (to prevent all that conditional logic you had before when reading it from Onyx). Why would we default it to America/Los Angeles here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a good point. I opted to use the default because we technically only have half the user's timezone NVP information if it's in string format. We'd be missing the automatic: true/false portion and using the default value instead just seemed like a simple solution rather than trying to guess half of their NVP value.

However, in retrospect, I think it's fine to use the old timezone value for timezone.selected and default to true, since the user can always modify that in their settings in E.cash.

@NikkiWines
Copy link
Contributor Author

Updated! Also updated the testing steps to include steps for testing the migration

@jasperhuangg jasperhuangg merged commit 12aaf9d into master Mar 25, 2021
@jasperhuangg jasperhuangg deleted the nikki-dateutils-whitescreen branch March 25, 2021 02:49
@isagoico
Copy link

@NikkiWines I was trying to qa this and I don't think I'm editing correctly the myPersonalDetails because I'm getting this error.
image

Could you check this string? (It's the last one I tried I tried several possible combinations but all displayed the same error 🤯)

{"login":"isagoicotest+mar5@gmail.com","avatar":"https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/avatar_6.png","displayName":"isagoicotest+mar5@gmail.com","pronouns":"",timezone: "America/Los_Angeles","firstName":"","lastName":""}

@NikkiWines
Copy link
Contributor Author

@isagoico you were missing quotes around timezone. This should work:

{"login":"isagoicotest+mar5@gmail.com","avatar":"https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/avatar_6.png","displayName":"isagoicotest+mar5@gmail.com","pronouns":"","timezone":"America/Los_Angeles","firstName":"","lastName":""}

@isagoico
Copy link

@NikkiWines I got the correct Onyx Log but I think it broke the page
image

@NikkiWines
Copy link
Contributor Author

NikkiWines commented Mar 26, 2021

Hmm, that's not good. Because that's the error this was intended to fix. Can you show me the results of your myPersonalDetails key?

It also might useful to retry logging into the same account in incognito mode, to see if the error is reproducable then.

Also to be clear have you been able to successfully complete the To test that personalDetails are getting set correctly steps with this account?

@NikkiWines
Copy link
Contributor Author

NikkiWines commented Mar 26, 2021

OH, I know it is! Wait... maybe I don't.

@isagoico
Copy link

I'm getting the same issue in a Incognito window.
For the personalDetails steps. I created a new account and followed the steps and didn't see a JS error 🤔

@NikkiWines
Copy link
Contributor Author

And your myPersonalDetails key contains the correctly updated information?

@isagoico
Copy link

It displays the OLD format

{"login":"isagoicotest+mar5@gmail.com","avatar":"https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/avatar_6.png","displayName":"Isabella  Goicoechea","pronouns":"","timezone":{"automatic":true,"selected":"America/Los_Angeles"},"firstName":"Isabella ","lastName":"Goicoechea"

@NikkiWines
Copy link
Contributor Author

@isagoico you might need to click away from it first, then navigate back to it to see the updated values:

I can reproduce this locally, but I'm wondering if it's a function of the way we're testing this.

It's weird to me that we run the migration, and I see the updated value in my onyx key (though the default is set to true which makes me think we're overriding it somewhere else) but that we're still getting the formatting error. Seems like a race condition and to be fair most users wouldn't been changing their onyx key

image

@NikkiWines
Copy link
Contributor Author

Either way, I think it would be a pretty small percentage of users who would be experiencing the old timezone issue, since we've had the new timezone format out for a couple of week nows. We're basically manually replicating the old timezone issue to test this.

I can make another PR to remove the migration and go back to our old timezone check in DateUtils, but I'm not sure this should block the deploy since I think it would impact a small number of users.

@isagoico
Copy link

Ohh I was confused. Before refreshing the page it does display the updated MyPersonalDetails after editing it. After I refreshed and the JS error appears it displayed the OLD MyPersonalDetails.

@NikkiWines
Copy link
Contributor Author

OK - here's what's happening so far:

  1. Running the steps in To test timezone migration results in the following error
    image
  2. The myPersonalDetails key in local storage IS updated to an object.
  3. Doing a hard-refresh after seeing this page does resolve the issue

Here's TLDR; of what led up to this.

  1. When we first starting using E.cash add the timezone value to the myPersonalDetails key as a string: "timezone":"Los_Angeles"
  2. Soon after we wanted to use the whole timezone NVP, so we changed it to "timezone": {"automatic": true, "selected": "Los_Angeles"}
    • This was before we had migrations, so we had to add a bunch of manual checks all over the place
    • This change went out 2 weeks ago
  3. We now finally have migrations in place, so I made one for timezones, but to test it we have to simulate having an old timezone string by manually editing the myPersonalDetails key. From this PR we see that something goes wrong when we do that as we see Ran migration ReformatTimezome but we're getting a formatting error for the timezone even though it should be in the correct format.
  4. Since we update the myPersonalDetails key every 30 minutes here for someone to still have the old key they would've had to meet a very niche set of conditions.
    • They'd have to have manually modified it like we did to try to test this.
    • They would've had to somehow not had their myPersonalDetails key updated in the last 2 weeks
  5. Note that we know this doesn't impact NEW users since @isagoico was able to successfully complete the To test that personalDetails are getting set correctly steps for this PR which involves creating a brand-new user.

I'm going to reproduce this error on staging, then let it sit for 30min to confirm that the issue will be resolved after 30min when the myPersonalDetails key gets automatically updated. I'll also try to reproduce it on mobile and run the same test there.

@NikkiWines
Copy link
Contributor Author

NikkiWines commented Mar 26, 2021

Hmm, so, unfortunately, looks like things won't self-resolve after 30 minutes, which makes this more serious if someone were to encounter it.

I still think the number of users who would meet the criteria is super small, but I'm less hesitant to move ahead with the deploy.

Sidenote: weirdly I can only reproduce this issue locally if I have the merge commit checked out. If I try to use the latest master it works without issue.

Edit: Looks like it works on master because we modified DateUtils.js to no longer rely on the timezone for getLocalMomentFromTimestamp in this PR

@NikkiWines NikkiWines mentioned this pull request Mar 26, 2021
5 tasks
@NikkiWines
Copy link
Contributor Author

Retested on staging now that the timezone migration has been removed, no more formatting error + whitescreen

Screen.Recording.2021-03-26.at.2.41.51.PM.mov

@NikkiWines
Copy link
Contributor Author

@isagoico would you mind going through these steps once more 🦸‍♀️

To test that personalDetails are getting set correctly:

  1. Go to https://www.emailondeck.com/ to get a temporary email.
  2. Use the temporary email to register for Expensify.cash
  3. Use the validation link sent to the temporary email address.
  4. Set a password.
  5. After logging in, confirm everything works as anticipated and you don't get an error in the JS console.

@isagoico
Copy link

I posted on the wrong PR. Here's what I found:

Staging link does work and I'm able to set the password but there's a JS error in console after login in.
image

I also used the production link (by mistake) and I'm unable to set up a password here's the screenshot with the JS
image

@NikkiWines
Copy link
Contributor Author

Interesting, I'm unable to reproduce that issue on a new account sawyer6@bedroomsod.com on staging:
image

@NikkiWines
Copy link
Contributor Author

Just tried it again on a new account using the link that gets you to set your password in E.com then log in, still no JS console error.
image

@isagoico
Copy link

Just tried again and no JS error 🎉
image

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.

4 participants