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

Send platform info when making api requests #15973

Closed

Conversation

hayata-suenaga
Copy link
Contributor

@hayata-suenaga hayata-suenaga commented Mar 14, 2023

Context

Master tracking issue here. This PR is one of three PRs necessary to send a hash along with a validation SMS message to Android device for auto-fill of magic code upon user sign in.

Deployment schedule

App, Auth (this PR) -> Web-E
This PR can be deployed independent of other PRs.

Details

We only need to add a hash when the user is trying to sign in from an android device. To determine what device the user is using on the server side, we need to pass platform information along with the request.

Fixed Issues

$ GH_LINK #15342

Tests

Internal QA

Development

  1. In Web-Expensify, update api.php and add the following line somewhere in the beginning of the file (maybe line 35):
    Log::info("Platform: ".($_REQUEST['platform'] ?? 'Idk dude'));

The WAF rule is already set for platform parameter in the current Web-E code. So you can test with the main code.
2. Open a chat in NewDot
3. Open your terminal and start tailing logs with ../script/tail.sh "Platform:"
4. Sign into a NewDot (we want to send the BeginSignIn command as this is the command on which the new parameter is added). If you're already sign in, log out to sign in from the beginning.
5. Make sure you see a log for the Platform and it matches the platform you tested
image
6. Make sure that you remove the log statement you added on step 1.

Staging

  1. Go to staging.new.expensify on a laptop web browser
  2. If you're already signed in, sign out
  3. Open the network inspector on Chrome development console
  4. Type your account email address and click "Continue"
  5. Find api?command=BeginSignIn network request and click it
  6. Go to the payload tab to check the Form Data section
  7. Check there is platform name (the value should be set to web)
    We want to check that the new parameter is sent in the request payload correctly. Although the purpose of the new parameter is to figure out if requests are coming from android, the existence of the platform payload confirms that the new parameter is at least sent without problem.
    The ideal QA test is to check this on an Android native app, but since a web browser is more easy to test, I used a web in the above testing steps

Offline tests

N/A

QA Steps

N/A

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android / native
    • Android / Chrome
    • iOS / native
    • iOS / Safari
    • MacOS / Chrome / Safari
    • MacOS / Desktop
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I verified the translation was requested/reviewed in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is correct English and approved by marketing by adding the Waiting for Copy label for a copy review on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR author checklist, including those that don't apply to this PR.

Screenshots/Videos

N/A

@hayata-suenaga hayata-suenaga added the InternalQA This pull request required internal QA label Mar 14, 2023
@hayata-suenaga hayata-suenaga self-assigned this Mar 14, 2023
@hayata-suenaga
Copy link
Contributor Author

hayata-suenaga commented Mar 15, 2023

I marked this PR and other related PRs ready for review. But I cannot still confirm automatic sms validation behavior on the emulator (the magic code is not automatically extracted and passed to the input field).

Please share ideas how we can test on a real device or or what might be the reason for the behavior not being observed on the Web-E PR.

@hayata-suenaga hayata-suenaga marked this pull request as ready for review March 15, 2023 19:36
@hayata-suenaga hayata-suenaga requested a review from a team as a code owner March 15, 2023 19:36
@melvin-bot melvin-bot bot requested review from PauloGasparSv and removed request for a team March 15, 2023 19:37
@MelvinBot
Copy link

@PauloGasparSv Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@hayata-suenaga hayata-suenaga requested review from mountiny, a team and roryabraham and removed request for PauloGasparSv March 15, 2023 19:37
@melvin-bot melvin-bot bot requested review from PauloGasparSv and removed request for a team March 15, 2023 19:37
@MelvinBot
Copy link

@PauloGasparSv Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@hayata-suenaga
Copy link
Contributor Author

Please hold reviews now. I'll implement the change suggested here.

@hayata-suenaga
Copy link
Contributor Author

ready for review now

@PauloGasparSv
Copy link
Contributor

PauloGasparSv commented Mar 17, 2023

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified tests pass on all platforms & I tested again on:
    • Android / native
    • Android / Chrome
    • iOS / native
    • iOS / Safari
    • MacOS / Chrome / Safari
    • MacOS / Desktop
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick).
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is correct English and approved by marketing by adding the Waiting for Copy label for a copy review on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Web

image

Mobile Web - Chrome

image

Mobile Web - Safari

image

Desktop

image

iOS

image

Android

image

@PauloGasparSv
Copy link
Contributor

Hey @hayata-suenaga I think we need to update the test steps right?

Maybe we can do the following for testing:

  1. In Web-Expensify, update api.php and add the following line somewhere in the beginning of the file (maybe line 35):
    Log::info("Platform: ".($_REQUEST['platform'] ?? 'Idk dude'));
  2. Open a chat in NewDot
  3. Open your terminal and start tailing logs with ../script/tail.sh "Platform:"
  4. Send a message in the chat
  5. Make sure you see a log for the Platform and it matches the platform you tested
    image

I'll do that here but if those don't match the final test steps I'll re-test here : )

@hayata-suenaga
Copy link
Contributor Author

@PauloGasparSv thank you for suggesting test steps 🙇🏻‍♂️. These steps look good to me. I just added a few details on sending BeginSignIn command specifically and posted the steps on the initial comment. You don't have to redo the test.

Also I updated some old comments in the initial comment.

@PauloGasparSv
Copy link
Contributor

Hey @hayata-suenaga I forgot to mention: I think we may also have to change the Internal QA Steps as people won't be able to add that Log in prod and staging!

@hayata-suenaga
Copy link
Contributor Author

hayata-suenaga commented Mar 19, 2023

@PauloGasparSv thank you for pointing that out. I'm actually not sure on which stage internal QAs are performed. If internal QA tests are needed, can people pull staging and production branches?

@PauloGasparSv
Copy link
Contributor

If internal QA tests are needed, can people pull staging and production branches?

I don't think so @hayata-suenaga!

I think both QA stages (staging and prod) are done without having the source code or running anything locally but instead it's all done either direcly in https://staging.new.expensify.com/ or https://new.expensify.com/ or the Staging/Prod builds for Desktop, Android and iOS!

BTW, here is an example of how QA is done in staging: https://github.com/Expensify/Expensify/issues/268894
And another in for prod: https://github.com/Expensify/Expensify/issues/268122

IMO sometimes it's a bit hard to come up with valid QA steps because we can't do certain things in staging or prod that we can locally (a good example is creating and validating a VBA, that's pretty easy in dev but requires some extra steps in staging/prod)

Copy link
Contributor

@PauloGasparSv PauloGasparSv left a comment

Choose a reason for hiding this comment

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

LGTM!

@hayata-suenaga just saw the extra QA line you added! I still think those steps may not be possible to follow during QA.

If we log the platform in logSearch the QA steps can be to Sign In and search for the platform in logSearch (but I'm not sure if we log that).

But I think it could also be:

  1. Have QA steps for Web for checking if the platform was sent in the request (e.g. BeginSignIn) by analyzing the request in the Network Tab of the Chrome Dev Tools.

  2. For all the remaining platforms, simply test if you can sign-in correctly and open a chat. That will trigger many requests that send the platform field and we'll make sure nothing is broken.

@hayata-suenaga
Copy link
Contributor Author

@PauloGasparSv thank you for the info on internal QA. I checked this SO. So internal QA checklists are automatically created when the PR with the label internalQA is merged to staging?

@hayata-suenaga
Copy link
Contributor Author

I made a staging section in QA testing steps in the original comment.

@hayata-suenaga
Copy link
Contributor Author

@PauloGasparSv I just realized the production NewDot might be already sending platform info. I'll double check on this. Please don't merge this PR. I'll mark this PR as draft.

@hayata-suenaga hayata-suenaga marked this pull request as draft March 20, 2023 04:23
@hayata-suenaga
Copy link
Contributor Author

I realized that the platform parameter is already being sent from NewDot to the backend. This PR is not necessary. I'm closing this now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
InternalQA This pull request required internal QA
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants