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

Fullscreen loader logging #8347

Merged

Conversation

kidroca
Copy link
Contributor

@kidroca kidroca commented Mar 29, 2022

Details

As per the ticket requirement we're adding logging to Fullscreen loaders in order to capture a loader never being removed from the screen
When name and timeout props are used on the loader, it would log a message when it mounts/unmounts or stays longer than the specified timeout
In order to have simpler component did mount / will unmount logic, the visible prop was removed and existing usages refactored. FullScreenLoadingIndicator is used uniformly across the app by conditional rendering:

{this.state.isLoading && <FullScreenLoadingIndicator />}

Fixed Issues

$ #7424

Tests

  • Verify [LoadingIndicator] "${this.props.name}" became visible is logged when loader is visible
    • logged for NavigationRoot when launching App (on ios/android)
    • logged for MainDrawerNavigation after login (on all platforms)
  • Verify [LoadingIndicator] "${this.props.name}" disappeared is logged when loader hides
    • logged for NavigationRoot when launching App (on ios/android)
    • logged for MainDrawerNavigation after login (on all platforms)
  • Verify [LoadingIndicator] "${this.props.name}" is still visible after ${this.props.timeout} ms is logged when loader is displayed for longer than timeout duration
  • There should be no regressions on places that use the FullscreenLoadingIndicator

I was able to test the timeout message (3rd bullet) when I forced the MainDrawerLoader to never hide. It also happened once (on dev) because loading was too slow and took longer than 15 sec. (after signing in)

Sample logging output

image
note: Since "Disappeared" is logged on unmount, the component didn't received the new props and logs whatever logDetail it last had, hence reportID is still "" in the log

PR Review Checklist

Contributor (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 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 included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • iOS / native
    • Android / native
    • iOS / Safari
    • Android / Chrome
    • MacOS / Chrome
    • 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 was added in all src/languages/* files
    • I verified any copy / text that was added to the app is correct English and approved by marketing by tagging the marketing team 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
  • 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 */
    • Any functional components have the displayName property
    • 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
  • 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.

PR Reviewer Checklist

  • 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 verified tests pass on all platforms & I tested again on:
    • iOS / native
    • Android / native
    • iOS / Safari
    • Android / Chrome
    • MacOS / Chrome
    • 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 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 was added in all src/languages/* files
    • I verified any copy / text that was added to the app is correct English and approved by marketing by tagging the marketing team 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 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 */
    • Any functional components have the displayName property
    • 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 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.

QA Steps

No feature or bug to be tested.
We're testing against any regressions around fullscreen loading indicators.
A fullscreen loading indicator is a small rotating circle in the middle of the page with semi-transparent (white/gray) background

On all platforms, verify loading circle still appears:

  • briefly after sign in
  • on Wallet statement modal, while statement is loading
  • after selecting "New chat" and search/users load
  • after selecting "Search" and search/users load
  • when you select a chat in LHN and it's loaded in the main view
  • on the IOU modal while it loads
  • on the Workspace / Manage Members / Invite page, while search/users load

(These are the pages that had the visible prop which was removed from the loader)

Screenshots

Web

image

Mobile Web

image

Desktop

image

iOS

image

Android

Android.Emulator.-.Pixel_2_API_29_5554.2022-03-29.22-00-54.mp4

@kidroca kidroca marked this pull request as ready for review March 29, 2022 20:00
@kidroca kidroca requested review from marcaaron and a team as code owners March 29, 2022 20:00
@melvin-bot melvin-bot bot removed the request for review from a team March 29, 2022 20:00
@kidroca kidroca changed the title Kidroca/fix/fullscreen loader logs Fullscreen loader logging Mar 29, 2022
Copy link
Contributor

@marcaaron marcaaron left a comment

Choose a reason for hiding this comment

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

Can we pause reviews on this pending answers to the questions in this comment? Thanks 🙇

#7424 (comment)

@marcaaron marcaaron self-requested a review March 30, 2022 00:26
Copy link
Contributor

@marcaaron marcaaron left a comment

Choose a reason for hiding this comment

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

Overall, I like this now that I understand the changes. Did have some suggestions though.

name: PropTypes.string,

/** Optional duration (ms) after which a message would be logged if the loader is still covering the screen */
timeout: PropTypes.number,
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: Rather than have a custom timeout here we can just make this shouldLogAlertOnTimeout since we use 15 seconds everywhere anyway and there are not cases where we need a more specific timeout (and maybe never will be)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In order to capture meaningful logs we need to have logDetail with at least the screen name, or some name we can use to distinct log messages

Instead of introducing a flag like shouldLogAlertOnTimeout we use the optional logDetail prop - if it is provided it's an indication that we'd like to capture logs

If you prefer to have an explicit flag anyway let me know and I'll update

return null;
class FullScreenLoadingIndicator extends React.Component {
componentDidMount() {
if (!this.props.name || !this.props.timeout) {
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: We could still log without additional context. But if we want to enforce additional context then maybe we should throw and return so that someone implementing this will remember to add details.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point in order to distinct the loader, we should require some context - at least the screen name where it's used, so we should throw an error - if someone tries to setup a new or existing loader with logging incorrectly they'll know right away

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated the logic to throw an error if props.logDetail exists but logDetail.name is not set

But since logDetail.name is flagged as PropTypes.required I don't know whether we need to throw an exception, and maybe we should remove it and just return

Copy link
Contributor Author

@kidroca kidroca left a comment

Choose a reason for hiding this comment

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

Left some notes, will address the changes tomorrow

BTW
I haven't checked some PR check items, because I'm not certain what I should do.
Waiting to be clarified in this slack thread: https://expensify.slack.com/archives/C01GTK53T8Q/p1648583058174529

return null;
class FullScreenLoadingIndicator extends React.Component {
componentDidMount() {
if (!this.props.name || !this.props.timeout) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point in order to distinct the loader, we should require some context - at least the screen name where it's used, so we should throw an error - if someone tries to setup a new or existing loader with logging incorrectly they'll know right away

- remove `name` and `timeout` props. Use fixed timeout and a `logDetail` prop
- use fixed strings in log messages and pass details as additional data
- extract timeout duration to CONST
- throw if logging is not configured correctly
- trigger a special CONST.ERROR.ENSURE_BUGBOT alert
Copy link
Contributor Author

@kidroca kidroca left a comment

Choose a reason for hiding this comment

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

Added changes from the provided suggestions

The updated logging looks like this:
image

  • note: since "Disappeared" is logged on unmount, the component didn't received the new props and logs whatever logDetail it last had, hence reportID is still "" in the log

A new change is the Timing API
We capture the duration for which a loader was visible using Timing.start/end
If that's undesired we can just discard the last commit

name: PropTypes.string,

/** Optional duration (ms) after which a message would be logged if the loader is still covering the screen */
timeout: PropTypes.number,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In order to capture meaningful logs we need to have logDetail with at least the screen name, or some name we can use to distinct log messages

Instead of introducing a flag like shouldLogAlertOnTimeout we use the optional logDetail prop - if it is provided it's an indication that we'd like to capture logs

If you prefer to have an explicit flag anyway let me know and I'll update

return null;
class FullScreenLoadingIndicator extends React.Component {
componentDidMount() {
if (!this.props.name || !this.props.timeout) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated the logic to throw an error if props.logDetail exists but logDetail.name is not set

But since logDetail.name is flagged as PropTypes.required I don't know whether we need to throw an exception, and maybe we should remove it and just return

@kidroca kidroca requested a review from marcaaron March 30, 2022 12:34
Copy link
Member

@parasharrajat parasharrajat left a comment

Choose a reason for hiding this comment

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

Looking good.

@kidroca
Copy link
Contributor Author

kidroca commented Apr 4, 2022

@marcaaron PR is ready for review

thienlnam
thienlnam previously approved these changes Apr 4, 2022
Copy link
Contributor

@thienlnam thienlnam left a comment

Choose a reason for hiding this comment

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

Changes look good to me 👌

@marcaaron
Copy link
Contributor

A new change is the Timing API We capture the duration for which a loader was visible using Timing.start/end If that's undesired we can just discard the last commit

Let's undo this as it feels like we're just tacking on extra scope. The timing stuff is pretty focused on a few key metrics and we don't even know what our issue is here. Let's not just time things for the sake of timing them.

Other components do not use class description
Removed to be uniform with the rest of our components
@kidroca kidroca force-pushed the kidroca/fix/fullscreen-loader-logs branch from 2f6e18b to 2e50713 Compare April 4, 2022 18:31
@kidroca
Copy link
Contributor Author

kidroca commented Apr 4, 2022

A new change is the Timing API We capture the duration for which a loader was visible using Timing.start/end If that's undesired we can just discard the last commit

Let's undo this as it feels like we're just tacking on extra scope. The timing stuff is pretty focused on a few key metrics and we don't even know what our issue is here. Let's not just time things for the sake of timing them.

Dropped the commit that introduced this change
Removed class level documentation - other components do not have such

Ready for review

Copy link
Member

@parasharrajat parasharrajat left a comment

Choose a reason for hiding this comment

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

LGTM.

cc: @thienlnam

PR Reviewer Checklist

  • I verified the PR has a small number of commits behind main
  • 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 testing environment is mentioned in the test steps
  • I verified testing steps cover success & fail scenarios (if applicable)
  • I checked that screenshots or videos are included for tests on all platforms
  • I verified tests pass on all platforms & I tested again on:
    • iOS / native
    • Android / native
    • iOS / Safari
    • Android / Chrome
    • MacOS / Chrome
    • MacOS / Desktop
  • I verified there are no console errors related to changes in this PR
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified comments were added when the code was not self explanatory
    • I verified any copy / text shown in the product was added in all src/languages/* files (if applicable)
    • I verified proper naming convention for platform-specific files was followed (if applicable)
    • I verified style guidelines were followed
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components are not impacted by changes in this PR (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 the UI performance was not affected (the performance is the same than main branch)
  • If a new component is created I verified that a similar component doesn't exist in the codebase
    🎀 👀 🎀 C+ reviewed

Copy link
Contributor

@thienlnam thienlnam left a comment

Choose a reason for hiding this comment

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

Changes look good, leaving to @marcaaron

@marcaaron marcaaron merged commit 0609796 into Expensify:main Apr 5, 2022
@OSBotify
Copy link
Contributor

OSBotify commented Apr 5, 2022

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

@kidroca kidroca deleted the kidroca/fix/fullscreen-loader-logs branch April 6, 2022 18:17
@OSBotify
Copy link
Contributor

OSBotify commented Apr 6, 2022

🚀 Deployed to staging by @marcaaron in version: 1.1.52-0 🚀

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

@OSBotify
Copy link
Contributor

OSBotify commented Apr 8, 2022

🚀 Deployed to production by @roryabraham in version: 1.1.52-0 🚀

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

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.

5 participants