sentry-react-native icon indicating copy to clipboard operation
sentry-react-native copied to clipboard

Initialize native SDKs before JS

Open krystofwoldrich opened this issue 1 year ago • 3 comments

Available in https://github.com/getsentry/sentry-react-native/releases/tag/6.7.0-alpha.0

Create sentry.options.json in the React Native project root and set options the same as you currently have in Sentry.init in JS.

{
    "dsn": "https://[email protected]/value",
}

Initialize Sentry on the native layers by newly provided native methods.

import io.sentry.react.RNSentrySDK

class MainApplication : Application(), ReactApplication {
    override fun onCreate() {
        super.onCreate()
        RNSentrySDK.init(this)
    }
}
#import <RNSentry/RNSentry.h>

@implementation AppDelegate
- (BOOL)application:(UIApplication *)application
    didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [RNSentrySDK start];
    return [super application:application didFinishLaunchingWithOptions:launchOptions];
}
@end

Development

Tasks

  • [x] Create RNSentry.init for Android
  • [x] Create RNSentry.init for Cocoa
  • [ ] Update @sentry/wizard to optionally use sentry.options.json
  • [ ] Add new manual init docs
  • [ ] Add JSON file schema
  • [ ] Add E2E tests using manual init
  • [ ] Update Sample App to use manual init by default

Native RNSentry.init tasks

  • [x] Drop JS Errors https://github.com/getsentry/sentry-react-native/blob/942161665edbac984baf81bc4e1ec289ebb0e58c/ios/RNSentry.mm#L127
  • [x] Add event origin and environment https://github.com/getsentry/sentry-react-native/blob/942161665edbac984baf81bc4e1ec289ebb0e58c/ios/RNSentry.mm#L177

krystofwoldrich avatar Feb 19 '24 16:02 krystofwoldrich

@krystofwoldrich customer is asking:

do you have any timeline/estimate around when this issue could be fixed?

maxkosty avatar May 16 '24 05:05 maxkosty

@realkosty We don't have a timeline yet. But it's possible to capture the startup crashes when initializing the native SDKs manually. The How to set up for start up crashes at the moment part of the issue.

krystofwoldrich avatar May 17 '24 08:05 krystofwoldrich