`Sentry.wrap` was called before `Sentry.init` warning when using CodePush.getUpdateMetadata
OS:
- [ ] Windows
- [x] MacOS
- [ ] Linux
Platform:
- [x] iOS
- [x] Android
SDK:
- [x]
@sentry/react-native(>= 1.0.0) - [ ]
react-native-sentry(<= 0.43.2)
SDK version: 5.11.1
react-native version: 0.72.4
Are you using Expo?
- [ ] Yes
- [x] No
Are you using sentry.io or on-premise?
- [x] sentry.io (SaaS)
- [ ] on-premise
If you are using sentry.io, please post a link to your issue so we can take a look:
[Link to issue]
Configuration:
(@sentry/react-native)
export async function initSentry() {
const update = await CodePush.getUpdateMetadata();
const codePushSentryRelease =
Config.ENV === 'dev' ? codePushProps.staging.sentryRelease : codePushProps.production.sentryRelease;
const configSentryRelease = Platform.OS === 'ios' ? IOS_SENTRY_RELEASE : ANDROID_SENTRY_RELEASE;
Sentry.init({
dsn: 'https://[email protected]/xxx',
environment: Config.env === 'dev' ? 'staging' : 'production',
release: `${configSentryRelease}+${update ? codePushSentryRelease : Config.VERSION_CODE}`,
dist: Config.VERSION_CODE,
integrations: [
new Sentry.ReactNativeTracing({
tracePropagationTargets: ['localhost', Config.MY_API],
}),
],
});
}
I have the following issue:
If using await CodePush.getUpdateMetadata(); I'm getting a warning: App Start Span could not be finished. Sentry.wrap was called before Sentry.init. Also, I'm not sure if the following issue is related to wrapping before init:
Steps to reproduce: Basically setup App like stated here: https://docs.sentry.io/platforms/react-native/manual-setup/codepush/
Expected result:
I'm aware that the docs say it's not recommended because of the delay for getting early errors. But is it okay to do it this way? If it's, the warning can be supressed? Should I init sentry with basic config and init it again with codepush info? Are the missing span instrumentation on sentry.io related to this?
Thanks for any help!
Hi, thank you for the message, the warning only shows in dev builds, in production it's disabled.
The missing span instrumentation is not caused by it.
I would recommend using Sentry.withProfiler(YourComponent) on your app components, this will automatically create spans when you components are mounted.
@krystofwoldrich should we wrap the entire app with withProfiler or wrap ?
registerRootComponent(Sentry.withProfiler(Entry)
registerRootComponent(Sentry.wrap(Entry) // this also has a TS error.
@krystofwoldrich What's the different between Sentry.withProfiler and Sentry.wrap? If I use Sentry.withProfiler, does it impact the track the crash event? does it track more data than Sentry.wrap
@krystofwoldrich What's the different between Sentry.withProfiler and Sentry.wrap? If I use Sentry.withProfiler, does it impact the track the crash event? does it track more data than Sentry.wrap
same question here?..
Sentry.wrap is intended for your application roots to to capture user interactions, and tracking your root component mount time and app start.
https://docs.sentry.io/platforms/react-native/#wrap-your-app
Sentry.withProfiler is intended for you application's React components to track their individual mount times.
https://docs.sentry.io/platforms/javascript/guides/react/features/component-monitoring/
Let us know if you have any other questions.