-
Notifications
You must be signed in to change notification settings - Fork 58
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
Improve integration with sentry #1187
Comments
As I was writing this, I realized that maybe this was the problem, and deactivating those would help. What I remember seeing is that the RN client was trying to take over native reporting, which was problematic because that was already initialized on the app side. Maybe if we initialize the JS client with My question would still be: if there's a JS exception the JS client would log it, but the app would still crash? Will the native client log a second crash just like it was doing until now? Would there be a way to pair the two? |
That can be worked around without much difficulty by adjusting the Tracks+Sentry code to manage its own entire instance of the Sentry client without using the shared one. I'll try to get a PR for that done today.
My knowledge of RN is rather limited, but assuming it runs in a JSContext, we should be able to attach an exception handler that prevents the entire app from crashing. But I'm not entirely certain how RN works under the hood. IMHO going for mixed stack traces is ideal, if possible, so I'm happy to prioritize any work required on the native side to make this work. |
I spent some time today digging into this a little bit, and I have some thoughts on implementation. First off, using the https://github.com/getsentry/sentry-react-native framework may not be the best solution. It appears to be designed for react-native only apps, not embedded libraries. The full-stack capabilities seem to be more designed for tracing native dependencies of the react native app than for embedding the react-native project inside a larger app (that also uses Sentry). The main way this manifests is in the fact that That said, there might be another way around this. The editor defines an error boundary component that contains I'd expect that the The Android implementation would be a little bit more work. Sentry on Android doesn't bundle JS exception handling logic. That said, if we have a common format being sent by the RN bundle, reverse-engineering the parsing logic for Android shouldn't be terribly difficult – we could just translate the Obj-C implementation. Happy to hear your thoughts on this – I'm pretty new to RN, so I defer to y'all's collective wisdom on this! |
I did some quick tests and it seems import React from 'react';
import { View } from 'react-native';
import CrashButton from '@wordpress-mobile/crash-button';
class SimpleReactNativeApp extends React.Component {
constructor( props ) {
super( props );
const defaultHanlder = ErrorUtils.getGlobalHandler();
const appErrorHandler = ( e, isFatal ) => {
// Send error to Sentry
defaultHanlder( e, isFatal );
};
ErrorUtils.setGlobalHandler( appErrorHandler );
}
render() {
return (
<View>
<CrashButton
title='🙈 Crash me'
errorMessage='🙊 I crashed!'
/>
</View>
);
}
} I would have hoped we could use their library to save us some effort, but if we can't, the proposed approach sounds reasonable. |
Sounds good – I'll get started on implementation along these lines right away. If anyone has any objections to this, please let me know! 😄 |
👋 @jkmassel , I wonder if there are any updates on the implementation side of this. Any blockers found perhaps? In the meantime, removing this from the Open Beta target, as decided over a planning meeting. |
I tackled this issue as my HACK week project (June 2021), I only managed to integrate the iOS part but so far the tests I've run everything is working nice 🎊 . In the following links you can find the different PRs with the implementation:
Besides, feel free to check the recap of my work and the approach I proposed in this internal reference (p9ugOq-249-p2). |
We use Sentry for crash reporting in the apps, and they have a react-native client that allows for better stack traces. They even support mixed stack traces on iOS.
I did some initial experiments a while back but I recall the initialization of the JS client was running into some issues because we already had a client initialized on the iOS side.
We need more research to see how we can make this work.
The text was updated successfully, but these errors were encountered: