App
App copied to clipboard
[No QA] Opt out of crashlytics with environment variable
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
- 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);
- Build a RELEASE version of the iOS app and make sure "Debug executable" is unchecked
- Open the app
- Verify it crashes after 15 seconds
- Reopen the app
- Verify that a crash report was generated in the Crashlytics dashboard
- 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);
+
- Build again and wait 15 seconds for the app to crash
- Reopen the app
- Check crashlytics dashboard and verify no new crash report has been generated.
- Crash the app a few more times and check the dashboard to be sure the crashes are not getting reported.
- 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
- [x] I linked the correct issue in the
### Fixed Issues
section above - [x] I wrote clear testing steps that cover the changes made in this PR
- [x] I added steps for local testing in the
Tests
section - [x] I added steps for Staging and/or Production testing in the
QA steps
section - [x] I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
- [x] 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)
- [x] I added steps for local testing in the
- [x] I included screenshots or videos for tests on all platforms
- [x] I ran the tests on all platforms & verified they passed on:
- [x] iOS / native
- [x] Android / native
- [x] iOS / Safari
- [x] Android / Chrome
- [x] MacOS / Chrome
- [x] MacOS / Desktop
- [x] 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)
- [x] I followed proper code patterns (see Reviewing the code)
- [x] 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 notonIconClick
) - [x] I verified that comments were added to code that is not self explanatory
- [x] 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.
- [x] I verified any copy / text shown in the product was added in all
src/languages/*
files - [x] 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. - [x] 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.
- [x] I verified the JSDocs style guidelines (in
STYLE.md
) were followed
- [x] 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.
- [x] If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
- [x] I followed the guidelines as stated in the Review Guidelines
- [x] 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 usingAvatar
are working as expected) - [x] I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
- [x] 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
- [x] If a new component is created I verified that:
- [x] A similar component doesn't exist in the codebase
- [x] All props are defined accurately and each prop has a
/** comment above it */
- [x] The file is named correctly
- [x] The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
- [x] The only data being stored in the state is data necessary for rendering and nothing else
- [x] For Class Components, any internal methods passed to components event handlers are bound to
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor) - [x] Any internal methods bound to
this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
) - [x] All JSX used for rendering exists in the render method
- [x] 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
- [x] If a new CSS style is added I verified that:
- [x] A similar style doesn't already exist
- [x] The style can't be created with an existing StyleUtils function (i.e.
StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG
)
- [x] 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 thatAvatar
is working as expected in all cases) - [x] 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.
- [x] I have checked off every checkbox in the PR author 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 verified the steps for local testing are in the
- [ ] 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 notonIconClick
). - [ ] 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
- [ ] 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.
- [ ] 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 usingAvatar
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. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor) - [ ] Any internal methods bound to
this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
) - [ ] 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 thatAvatar
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
iOS
Android
@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]
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!
@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).
Bump @sobitneupane
@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!
@marcaaron I don't have access to Crashlytics dashboard
- Verify that a crash report was generated in the Crashlytics dashboard
@sobitneupane That's ok just review the code if you can. @dangrous mind taking over the testing for this?
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.
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)?
Hmm weird. Maybe cleaning the build folder will help?
I would also try deleting the app off of the physical device and reinstalling it.
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...
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 .env
s? 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?
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:
https://github.com/Expensify/App/blob/7bc444c4891c82bbb0edccb542dc7d3db56c4306/src/CONFIG.js#L75
And this code here should run to disable the crash reporting
https://github.com/Expensify/App/blob/7bc444c4891c82bbb0edccb542dc7d3db56c4306/src/setup/platformSetup/index.native.js#L21
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.
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.
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.
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.)
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.)
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...
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 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.
Checklists are all filled out not sure why that check continues to fail.
🚀 Deployed to staging by @marcaaron in version: 1.2.30-0 🚀
platform | result |
---|---|
🤖 android 🤖 | success ✅ |
🖥 desktop 🖥 | success ✅ |
🍎 iOS 🍎 | failure ❌ |
🕸 web 🕸 | success ✅ |
🚀 Deployed to staging by @marcaaron in version: 1.2.30-0 🚀
platform | result |
---|---|
🤖 android 🤖 | success ✅ |
🖥 desktop 🖥 | success ✅ |
🍎 iOS 🍎 | success ✅ |
🕸 web 🕸 | success ✅ |
🚀 Deployed to production by @luacmartins in version: 1.2.30-0 🚀
platform | result |
---|---|
🤖 android 🤖 | success ✅ |
🖥 desktop 🖥 | success ✅ |
🍎 iOS 🍎 | success ✅ |
🕸 web 🕸 | success ✅ |
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
@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.
@dangrous Not sure either! Seems like a good question for the #bug-zero
channel.
According to https://expensify.slack.com/archives/C02NK2DQWUX/p1667333777293729?thread_ts=1665685158.152769&cid=C02NK2DQWUX,
- 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.
Sorry about that @sobitneupane - getting someone on this now
👋 @sobitneupane I've sent you a contract. Let me know when you accept and I'll settle it up 👍