-
-
Notifications
You must be signed in to change notification settings - Fork 60
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
feat(react-native): Wrap root app component #835
base: master
Are you sure you want to change the base?
Conversation
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #835 +/- ##
==========================================
+ Coverage 51.15% 51.22% +0.07%
==========================================
Files 53 53
Lines 3517 3590 +73
Branches 825 831 +6
==========================================
+ Hits 1799 1839 +40
- Misses 1591 1750 +159
+ Partials 127 1 -126
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
const jsPath = traceStep('find-app-js-file', () => | ||
getFirstMatchedPath(jsFileGlob), | ||
); | ||
const jsPath = getMainAppFilePath('find-app-js-file'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The traceStep
function creates a span, and since those have parent-child relations we can reuse the same name. No need to pass unique for different steps.
|
||
const js = fs.readFileSync(jsPath, 'utf-8'); | ||
|
||
const result = checkAndWrapRootComponent(js); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Sentry.init
used regex mainly because it was written before we started using AST manipulation.
Checkout
sentry-wizard/src/react-native/metro.ts
Line 114 in fe849fe
export async function patchMetroConfigWithSentrySerializer() { |
sentry-wizard/src/utils/ast-utils.ts
Line 85 in f30cfee
export function getOrSetObjectProperty( |
Using the AST manipulation will be more safe to adjust the code.
Fixes #280
Wraps root app component with
Sentry.wrap
in the following cases:export default App;
export default Another.wrapper(App);
Another approach tested which works for the cases above (and covered by the tests) and may cover even more since it is more generic is the replacing the
addSentryWrap
method with the following:I chose the more complicated "regex" approach to be more in control of the cases covered, but happy to discuss if this or any other suggestion makes more sense🙏