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

[SignOutFlow] proper pusher event type for user typing event #14526

Merged
merged 1 commit into from
Jan 27, 2023
Merged

[SignOutFlow] proper pusher event type for user typing event #14526

merged 1 commit into from
Jan 27, 2023

Conversation

Prince-Mendiratta
Copy link
Contributor

Signed-off-by: Prince Mendiratta prince.mendi@gmail.com

Details

Console error was popping up related to the websocket when the user logged out. The issue was related to the pusher-js library and the disconnection sequence for channels.

Fixed Issues

$ #14350
#14350 (comment)

Tests

  1. Login with any account.
  2. Wait for any report to fully load.
  3. Go to settings.
  4. Click on sign out.
  5. Verify that no errors are reported in the JS console.
  • Verify that no errors appear in the JS console

Offline tests

Although the network connectivity does not affect the behaviour, still adding the test to ensure all is good.

  1. Login with any account.
  2. Wait for any report to fully load.
  3. Turn off internet connectivity.
  4. Go to settings.
  5. Click on sign out.
  6. Verify that no errors are reported in the JS console.

QA Steps

  1. Login with any account.
  2. Wait for any report to fully load.
  3. Go to settings.
  4. Click on sign out.
  5. Verify that no errors are reported in the JS console.
  • Verify that no errors appear in the JS console

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.
  • I have checked off every checkbox in the PR author checklist, including those that don't apply to this PR.

Screenshots/Videos

Web
Web.2023-01-25.01-00-06.mp4
Safari Desktop
safari.mp4
Mobile Web - Chrome
mWeb-chrome.mp4
Mobile Web - Safari
mweb-safari.mp4
Desktop
desktop.mp4
iOS
ios.mp4
Android
android.mp4

Signed-off-by: Prince Mendiratta <prince.mendi@gmail.com>
@Prince-Mendiratta Prince-Mendiratta requested a review from a team as a code owner January 24, 2023 23:06
@melvin-bot melvin-bot bot requested review from chiragsalian and Santhosh-Sellavel and removed request for a team January 24, 2023 23:06
@melvin-bot
Copy link

melvin-bot bot commented Jan 24, 2023

@chiragsalian @Santhosh-Sellavel One of you needs to 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]

@Santhosh-Sellavel
Copy link
Collaborator

Santhosh-Sellavel commented Jan 26, 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.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Web
Screen.Recording.2023-01-27.at.1.10.56.AM.mov
Mobile Web - Safari
Screen.Recording.2023-01-27.at.1.19.21.AM.mov
Mobile Web - Chrome
Screen.Recording.2023-01-27.at.1.17.40.AM.mov
Desktop
Screen.Recording.2023-01-27.at.1.12.58.AM.mov
iOS
Simulator.Screen.Recording.-.iPhone.14.-.2023-01-27.at.01.35.27.mp4
Android
Screen.Recording.2023-01-27.at.1.23.45.AM.mov

@Santhosh-Sellavel
Copy link
Collaborator

@chiragsalian @Prince-Mendiratta
I noticed this consoler warning while testing this PR on all platforms, this one is irrelevant to the PR changes. Let me know what can we do about this.

Screenshot 2023-01-27 at 1 36 09 AM

@Prince-Mendiratta
Copy link
Contributor Author

@Santhosh-Sellavel Can you please share how you encountered this issue and the steps to reproduce this?

@Santhosh-Sellavel
Copy link
Collaborator

I'm not sure what I did before but while performing logout this log showed, occurs randomly

Screen.Recording.2023-01-27.at.1.48.08.AM.mov

@Santhosh-Sellavel
Copy link
Collaborator

@Prince-Mendiratta
Signout
Just Reload Android App by pressing R from the metro terminal.
Screenshot_1674765060

@Prince-Mendiratta
Copy link
Contributor Author

@Santhosh-Sellavel I'll explore this and share my findings once I figure out the RCA.

@Prince-Mendiratta
Copy link
Contributor Author

Prince-Mendiratta commented Jan 26, 2023

@Santhosh-Sellavel Looks like a regression caused by #12447. It was just merged a couple of minutes ago and you were able to encounter this. It's not caused due to Sign Out, but rather due to rendering of the TermsAndLicenses component.

RCA

The containerStyles prop in Picker used in LocalePicker checks if the prop passed to it is small or not and then sets the height of the container accordingly. However, the checks used are incorrect and it resolves to a boolean value instead of as an array of object or an empty array. The correct way to implement the checks would be to use ternary operators. The only places where LocalePicker is used is PreferencesPage and TermsAndLicenses components. The existing code works for PreferencesPage but is incorrect since it sets the value to containerStyles: [false] when it should instead be []. Nonetheless, it still works and no error occurs. On the TermsAndLicenses page instead, it is unable to resolve properly since it is passed the incorrect props. The value passed to TermsAndLicenses is containerStyles: [[{"height": 28}]] when it should instead be containerStyles: [{"height": 28}]

Solution

diff --git a/src/components/LocalePicker.js b/src/components/LocalePicker.js
index ebd471ca96..8a347bc53a 100644
--- a/src/components/LocalePicker.js
+++ b/src/components/LocalePicker.js
@@ -47,6 +47,8 @@ const LocalePicker = (props) => {
         return null;
     }
 
     return (
         <Picker
             label={props.size === 'normal' ? props.translate('preferencesPage.language') : null}
@@ -60,7 +62,7 @@ const LocalePicker = (props) => {
             items={_.values(localesToLanguages)}
             size={props.size}
             value={props.preferredLocale}
-            containerStyles={[props.size === 'small' && [styles.pickerContainerSmall]]}
+            containerStyles={props.size === 'small' ? [styles.pickerContainerSmall] : []}
         />
     );
 };

How should we deal with reporting and fixing this?

@Santhosh-Sellavel
Copy link
Collaborator

Thanks for the detailed analysis, I think the PR Author & Reviewer should take care of this one!

Copy link
Collaborator

@Santhosh-Sellavel Santhosh-Sellavel left a comment

Choose a reason for hiding this comment

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

LGTM tests well!

@Santhosh-Sellavel
Copy link
Collaborator

@chiragsalian Left a comment for this warning here -> #12445 (comment)

@Santhosh-Sellavel
Copy link
Collaborator

@chiragsalian bump!

Copy link
Contributor

@chiragsalian chiragsalian left a comment

Choose a reason for hiding this comment

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

LGTM

@chiragsalian chiragsalian merged commit 142fbba into Expensify:main Jan 27, 2023
@OSBotify
Copy link
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@github-actions
Copy link
Contributor

Performance Comparison Report 📊

Significant Changes To Duration

There are no entries

Meaningless Changes To Duration

Show entries
Name Duration
App start TTI 694.630 ms → 721.679 ms (+27.049 ms, +3.9%)
App start runJsBundle 194.250 ms → 200.469 ms (+6.219 ms, +3.2%)
App start regularAppStart 0.017 ms → 0.015 ms (-0.001 ms, -8.2%)
App start nativeLaunch 20.406 ms → 20.258 ms (-0.148 ms, -0.7%)
Open Search Page TTI 617.435 ms → 604.624 ms (-12.811 ms, -2.1%)
Show details
Name Duration
App start TTI Baseline
Mean: 694.630 ms
Stdev: 35.831 ms (5.2%)
Runs: 628.510937999934 635.3411849997938 641.6454980000854 652.5563210006803 657.6470129992813 657.6493360009044 660.522365000099 665.62654799968 668.7827100008726 669.1482239998877 673.4859909992665 675.3264680001885 678.0801720004529 683.6998629998416 683.9459440000355 694.1237160004675 700.2648760005832 704.6872780006379 707.4625220000744 712.7408540006727 714.5052540004253 714.6092089992017 714.7342089992017 717.9426140002906 721.0274439994246 724.3313129991293 727.6879639998078 730.7662269994617 732.0468830000609 740.1442350000143 759.8504159990698 779.2646440006793

Current
Mean: 721.679 ms
Stdev: 34.254 ms (4.7%)
Runs: 669.7440310008824 672.1018879991025 684.547038000077 684.8822579998523 688.9428070001304 689.9207639992237 695.3794309999794 695.4373410008848 698.4205239992589 700.3478629998863 702.2522309999913 702.4119130000472 704.8643849994987 705.3294169995934 708.6059959996492 709.8779230006039 713.4729500003159 715.0765969995409 719.1658330000937 720.671452999115 720.7963679991663 732.8380069993436 734.3190420009196 736.6480730008334 749.7138940002769 752.6864250004292 774.5632869992405 776.9873810000718 778.630612000823 779.4877950008959 783.9014999996871 791.7160630002618
App start runJsBundle Baseline
Mean: 194.250 ms
Stdev: 25.361 ms (13.1%)
Runs: 163 164 166 166 168 169 170 171 173 176 177 179 179 179 181 185 188 194 199 201 204 206 207 208 211 214 215 234 240 242 243 244

Current
Mean: 200.469 ms
Stdev: 19.428 ms (9.7%)
Runs: 172 177 178 181 181 182 182 182 183 183 185 190 193 194 196 198 199 203 203 203 203 204 205 213 215 218 222 224 226 227 246 247
App start regularAppStart Baseline
Mean: 0.017 ms
Stdev: 0.002 ms (8.9%)
Runs: 0.014973999932408333 0.015177000313997269 0.015257999300956726 0.015257999300956726 0.015502000227570534 0.015502998605370522 0.01550300046801567 0.015583999454975128 0.015625 0.015786999836564064 0.01607300154864788 0.016112999990582466 0.016114000231027603 0.016276000067591667 0.01635799929499626 0.01643899828195572 0.016479000449180603 0.016682999208569527 0.01672299951314926 0.017007999122142792 0.0170889999717474 0.017090000212192535 0.017619000747799873 0.01769999973475933 0.018025999888777733 0.01806599833071232 0.01879899948835373 0.019043000414967537 0.019816000014543533 0.02001900039613247 0.020711001008749008

Current
Mean: 0.015 ms
Stdev: 0.001 ms (6.5%)
Runs: 0.013875000178813934 0.013956001028418541 0.014079000800848007 0.014118999242782593 0.014200998470187187 0.014444999396800995 0.014444999396800995 0.014607999473810196 0.014852000400424004 0.01489199884235859 0.014932999387383461 0.015135999768972397 0.01521800085902214 0.01521800085902214 0.015298999845981598 0.01534000039100647 0.015461999922990799 0.015462001785635948 0.015543000772595406 0.015625 0.015706000849604607 0.015829000622034073 0.015869999304413795 0.01603199914097786 0.016071999445557594 0.016276000067591667 0.016600999981164932 0.016641998663544655 0.016968000680208206 0.016968000680208206 0.017578000202775 0.017741000279784203
App start nativeLaunch Baseline
Mean: 20.406 ms
Stdev: 1.747 ms (8.6%)
Runs: 17 18 18 18 18 18 19 19 19 19 19 20 20 20 20 21 21 21 21 21 21 21 22 22 22 22 22 22 22 23 23 24

Current
Mean: 20.258 ms
Stdev: 2.170 ms (10.7%)
Runs: 18 18 18 18 18 18 19 19 19 19 19 19 19 19 19 19 19 19 21 21 21 21 21 22 22 22 23 23 24 25 26
Open Search Page TTI Baseline
Mean: 617.435 ms
Stdev: 20.413 ms (3.3%)
Runs: 574.6990150008351 584.4016520008445 585.4800630006939 590.9081219993532 595.4326169993728 595.7326670009643 596.4971520006657 602.253539999947 603.9321699999273 606.550904000178 606.6385089997202 609.3379309996963 613.6022950001061 615.2804369982332 615.725627001375 616.1549890004098 618.4567869994789 620.5632330011576 621.8813480008394 623.4056799989194 624.1978350002319 624.9267580006272 629.4351400006562 634.2104090005159 634.6752119995654 638.7441410012543 638.7675379998982 640.0460209995508 641.9999599996954 643.2742929998785 648.1916910000145 662.5262050013989

Current
Mean: 604.624 ms
Stdev: 17.973 ms (3.0%)
Runs: 570.5565600004047 572.9125570002943 580.1084800008684 582.4897459987551 584.6732579991221 585.5056570004672 591.655802000314 593.7600110005587 593.9507250003517 594.0946040004492 595.8618980012834 597.7885340005159 599.2442629989237 599.3870449997485 600.9807140007615 602.032267998904 603.0245779994875 605.2179370000958 609.2126059997827 611.6962489988655 612.7757980003953 616.6357829999179 619.0462650004774 619.2478840015829 619.7377530001104 620.0137939993292 621.2284350004047 626.9718019999564 634.9154460001737 637.0298270005733 641.5994869992137

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by https://github.com/chiragsalian in version: 1.2.62-0 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@OSBotify
Copy link
Contributor

🚀 Deployed to production by https://github.com/thienlnam in version: 1.2.62-1 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@Prince-Mendiratta Prince-Mendiratta deleted the pusher-error-fix branch April 1, 2023 10:24
@Prince-Mendiratta Prince-Mendiratta changed the title proper pusher event type for user typing event [SignOutFlow] proper pusher event type for user typing event May 5, 2023
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