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

[No QA] Opt out of crashlytics with environment variable #12611

Merged
merged 3 commits into from
Nov 17, 2022

Conversation

marcaaron
Copy link
Contributor

@marcaaron marcaaron commented Nov 9, 2022

Details

Local release build crashes are reaching crashlytics - this should make them opt-out when local release builds crash and eliminate and false positives.

Fixed Issues

$ https://github.com/Expensify/Expensify/issues/230440

Tests

  1. Apply this diff
diff --git a/src/setup/platformSetup/index.native.js b/src/setup/platformSetup/index.native.js
index 89cdb9892e..af33b3a1fc 100644
--- a/src/setup/platformSetup/index.native.js
+++ b/src/setup/platformSetup/index.native.js
@@ -18,9 +18,13 @@ export default function () {
     // We do not want to send crash reports if we are on a locally built release version of the app.
     // Crashlytics is disabled by default for debug builds, but not local release builds so we are using
     // an environment variable to enable them in the staging & production apps and opt-out everywhere else.
-    if (!CONFIG.SEND_CRASH_REPORTS) {
-        crashlytics().setCrashlyticsCollectionEnabled(false);
-    }
+    // if (!CONFIG.SEND_CRASH_REPORTS) {
+    //     crashlytics().setCrashlyticsCollectionEnabled(false);
+    // }
+
+    setTimeout(() => {
+        crashlytics().crash();
+    }, 15000);
  1. Build a RELEASE version of the iOS app and make sure "Debug executable" is unchecked
    2022-11-09_10-38-06
  2. Open the app
  3. Verify it crashes after 15 seconds
  4. Reopen the app
  5. Verify that a crash report was generated in the Crashlytics dashboard
    2022-11-09_11-51-58
  6. Now rollback the part of the diff that will disable sending logs, and update the part that will crash the app to call a function that doesn't exist like this
diff --git a/src/setup/platformSetup/index.native.js b/src/setup/platformSetup/index.native.js
index 89cdb9892e..adc54d7021 100644
--- a/src/setup/platformSetup/index.native.js
+++ b/src/setup/platformSetup/index.native.js
@@ -22,6 +22,10 @@ export default function () {
         crashlytics().setCrashlyticsCollectionEnabled(false);
     }

+    setTimeout(() => {
+        callFunctionThatDoesNotExist();
+    }, 15000);
+
  1. Build again and wait 15 seconds for the app to crash
  2. Reopen the app
  3. Check crashlytics dashboard and verify no new crash report has been generated.
  4. Crash the app a few more times and check the dashboard to be sure the crashes are not getting reported.
  5. Repeat test on Android
  • Verify that no errors appear in the JS console

QA Steps

  • Verify that no errors appear in the JS console

PR Author 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:
    • iOS / native
    • Android / native
    • iOS / Safari
    • Android / Chrome
    • MacOS / Chrome
    • 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 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 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 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.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

PR Reviewer Checklist

The reviewer will copy/paste it into a new comment and complete it after the author checklist is completed

  • 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:
    • iOS / native
    • Android / native
    • iOS / Safari
    • Android / Chrome
    • MacOS / Chrome
    • 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 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 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 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.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots

I'm only testing on Web (to verify the build still works), iOS and Android

Web

2022-11-09_14-39-31

iOS

2022-11-09_12-02-10

Android

2022-11-09_13-04-55

@marcaaron marcaaron self-assigned this Nov 9, 2022
@marcaaron marcaaron marked this pull request as ready for review November 10, 2022 00:41
@marcaaron marcaaron requested a review from a team as a code owner November 10, 2022 00:41
@melvin-bot melvin-bot bot requested review from dangrous and sobitneupane and removed request for a team November 10, 2022 00:42
@melvin-bot
Copy link

melvin-bot bot commented Nov 10, 2022

@sobitneupane @dangrous 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]

@dangrous
Copy link
Contributor

Hey! Code looks good, but I'm struggling to test. I've managed to make the release build on my Simulator, and it successfully crashes in 15 seconds. I've also gotten access to Crashlytics. But, I'm not seeing any crashes in the dashboard despite adding the diff. However, I'm just literally seeing no crashes from any source in the past 60 minutes, so maybe I'm looking in the wrong place? This is the link I'm using - https://console.firebase.google.com/project/expensify-chat/crashlytics/app/ios:com.chat.expensify.chat/issues?state=all&time=last-hour&tag=all - if that's not right let me know where I should go - thanks!

@marcaaron
Copy link
Contributor Author

@dangrous did you reopen the app after it crashed? Do you have a physical device you can test on? The link looks correct to me, maybe there's an issue with simulator (I used my iPhone to test in this case).

@marcaaron
Copy link
Contributor Author

Bump @sobitneupane

@dangrous
Copy link
Contributor

@dangrous did you reopen the app after it crashed? Do you have a physical device you can test on? The link looks correct to me, maybe there's an issue with simulator (I used my iPhone to test in this case).

Yeah I tried reopening it and was definitely getting the crash, but no Crashlytics. I do have a physical iOS device but don't have it set up to test with XCode yet. I can get that started shortly!

@sobitneupane
Copy link
Contributor

@marcaaron I don't have access to Crashlytics dashboard

  1. Verify that a crash report was generated in the Crashlytics dashboard

@marcaaron
Copy link
Contributor Author

@sobitneupane That's ok just review the code if you can. @dangrous mind taking over the testing for this?

@dangrous
Copy link
Contributor

dangrous commented Nov 14, 2022

Yep! Happy to. Once I get my physical device set up (the convo you're in in Slack) I can try again, since I wasn't able to get anything sent to Crashlytics (with or without the change) on my simulator.

@dangrous
Copy link
Contributor

Blah even on a physical device, I'm still seeing:

2022-11-14 14:12:21.377011-0500 New Expensify[1984:97202] [native] Crashlytics - WARNING: Debugger detected. Crashlytics will not receive crash reports.

in the logs. I made sure the build settings look like yours (release, unchecked debug executable) and I looked through other settings to see if there was anything else (found a couple places where constants were declared e.g. DEBUG=1 and removed them) but still no dice. I'll keep looking, but do you remember changing anything else (in the code, on your phone, in xcode)?

@marcaaron
Copy link
Contributor Author

Hmm weird. Maybe cleaning the build folder will help?

@marcaaron
Copy link
Contributor Author

I would also try deleting the app off of the physical device and reinstalling it.

@dangrous
Copy link
Contributor

dangrous commented Nov 14, 2022

Interesting, I tried that and am now getting a different note in the logs (and the app isn't crashing anymore) - 2022-11-14 14:43:00.943045-0500 New Expensify[84666:6457477] [native] Crashlytics - INFO: crashlytics collection is not enabled, not crashing.

I'm starting fresh with a completely new App directory and then trying again...

@dangrous
Copy link
Contributor

Okay, so good/bad news. Good: I finally got it working! Successfully saw my crash reports in Crashlytics. Bad: I saw crash reports when I shouldn't have, as well (the callFunctionThatDoesNotExist second steps). I didn't have SEND_CRASH_REPORTS in my .env; when I added it and set it to false, then I no longer got the crash reports (i.e. it worked as expected). Do we have a plan to tell people to update that in their .envs? Or should this work if that just isn't there at all (if so, something isn't quite there yet).

I can move on to Android for now. Will the regular npm run android work for this one?

@marcaaron
Copy link
Contributor Author

Okay, so good/bad news. Good: I finally got it working

Awesome! Thanks for sticking it out!

Bad: I saw crash reports when I shouldn't have, as well (the callFunctionThatDoesNotExist second steps). I didn't have SEND_CRASH_REPORTS in my .env; when I added it and set it to false, then I no longer got the crash reports (i.e. it worked as expected).

Weird, that seems... wrong. Because if you do not have this variable set at all it should default to 'false', which does not equal 'true', so you'd get a false for that value:

SEND_CRASH_REPORTS: lodashGet(Config, 'SEND_CRASH_REPORTS', 'false') === 'true',

And this code here should run to disable the crash reporting

if (!CONFIG.SEND_CRASH_REPORTS) {

What do you get when you console.log() out the value of CONFIG.SEND_CRASH_REPORTS?

One thing that I've run into before is that while just about everything in the app "hot reloads" the config vars do not (especially when building for release which bundles the JS). So, if you're changing one of those you'll need to create a whole new build (sorry in advance you know this already and your problem is something else).

I can move on to Android for now. Will the regular npm run android work for this one?

Fun stuff 😄 it will not, because the debug version of the apps will always skip crash reporting. It only affects release builds. Instructions on how to build one of those for Android here.

@dangrous
Copy link
Contributor

hm, yeah console.log says false. Maybe it was a hot reload thing? I'll try again a couple times and see what I can make of it.

@dangrous
Copy link
Contributor

Okay it looked like that worked! I guess something wasn't fully loaded. Will look at android first thing tomorrow. Sorry this is all taking forever to test.

Copy link
Contributor

@sobitneupane sobitneupane left a comment

Choose a reason for hiding this comment

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

Reviewer Checklist

@dangrous Changes look good. SEND_CRASH_REPORTS is false in dev.

🎀👀🎀 C+ reviewed

  • 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:
    • iOS / native
    • Android / native
    • iOS / Safari
    • Android / Chrome
    • MacOS / Chrome
    • 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 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 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 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.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots

Web

Screenshot 2022-11-15 at 20 38 27

Mobile Web - Chrome

Mobile Web - Safari

Desktop

Screenshot 2022-11-15 at 20 39 31

iOS

Screenshot 2022-11-15 at 19 35 03

Android

Screenshot 2022-11-15 at 19 49 49

@dangrous
Copy link
Contributor

Okay FINALLY got this working. Android was easier to set up a release build than iOS, but it still must have cached something so I had to try a couple times to get it not to send a report. But eventually it did!

IOS (first tests are at beginning of this range and tests with the second set of instructions are at the end - with no crashes reported.)
Screen Shot 2022-11-14 at 17 25 37
Android (first tests are at the middle of this range and tests with the second set of instructions are at the end - with no crashes reported.)
Screen Shot 2022-11-15 at 16 42 57

@dangrous
Copy link
Contributor

Blah unfortunately test failures (not related to your stuff I assume) - can you merge main and then I can merge! (I'm hoping that'll also fix the PR Reviewer Checklist check too since that's also not working even though @sobitneupane I can see you filled it out correctly...

@marcaaron
Copy link
Contributor Author

Awesome thanks @sobitneupane and @dangrous - great job testing here 🙇

I updated the PR checklist to the latest version but it might be that the reviewer template has changed.

@marcaaron marcaaron merged commit 5280f7a into main Nov 17, 2022
@marcaaron marcaaron deleted the marcaaron-devCrashReports branch November 17, 2022 18:00
@melvin-bot melvin-bot bot added the Emergency label Nov 17, 2022
@melvin-bot
Copy link

melvin-bot bot commented Nov 17, 2022

@marcaaron looks like this was merged without the test (job 1) test passing. Please add a note explaining why this was done and remove the Emergency label if this is not an emergency.

@marcaaron
Copy link
Contributor Author

Checklists are all filled out not sure why that check continues to fail.

@OSBotify
Copy link
Contributor

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

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

@OSBotify
Copy link
Contributor

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

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

@OSBotify
Copy link
Contributor

🚀 Deployed to production by @luacmartins in version: 1.2.30-0 🚀

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

@sobitneupane
Copy link
Contributor

PR was deployed to production 11 days ago. Requesting for C+ payment here as I don't have access to the linked issue.

cc: @marcaaron @dangrous

@dangrous
Copy link
Contributor

dangrous commented Dec 5, 2022

@marcaaron should we add the Bug Zero label here to grab someone to help with payment? Not sure how that process works in this case.

@marcaaron
Copy link
Contributor Author

@dangrous Not sure either! Seems like a good question for the #bug-zero channel.

@sobitneupane
Copy link
Contributor

According to https://expensify.slack.com/archives/C02NK2DQWUX/p1667333777293729?thread_ts=1665685158.152769&cid=C02NK2DQWUX,

  1. For all PRs that are linked to E/E issues, C+ comments and tags any assigned Expensify engineers in the PR asking them to check the E/E issue.
    a. If the E/E issue is a bug, a BZ is already assigned, internal engineer cc's the BZ in a comment on the PR so C+ knows who is paying.
    b. If the E/E isn't a bug, internal engineers add the Bug label to assign a BZ, then the engineer comments on the PR tagging the BZ who's assigned to issue payment.

@dangrous
Copy link
Contributor

Sorry about that @sobitneupane - getting someone on this now

@trjExpensify
Copy link
Contributor

👋 @sobitneupane I've sent you a contract. Let me know when you accept and I'll settle it up 👍

@sobitneupane
Copy link
Contributor

@trjExpensify Accepted.

@trjExpensify
Copy link
Contributor

Settled! 👍

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