Skip to content
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

fix: don't initiate DeviceContext if enableNative is false #993

Merged
merged 2 commits into from
Jul 24, 2020

Conversation

cruzach
Copy link
Contributor

@cruzach cruzach commented Jul 24, 2020

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

📜 Description

DeviceContext calls into native, which can result in extraneous error logs if the user has already stated they don't want to enable the native SDK.
I also silenced the console warning if enableNativeNagger is false

💡 Motivation and Context

This is an issue for our integration of sentry-expo expo/sentry-expo#120

💚 How did you test it?

Ran yarn test and tested in an expo project with sentry, no more bad logs! 🎉

📝 Checklist

  • I reviewed submitted code
  • I added tests to verify changes
  • All tests passing
  • No breaking changes

🔮 Next steps

Copy link
Member

@bruno-garcia bruno-garcia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix

@bruno-garcia bruno-garcia merged commit 93dfe79 into getsentry:master Jul 24, 2020
@luizjr
Copy link

luizjr commented Jul 24, 2020

Congratulations on the correction.
I would like to know when it will be available in the repository:
https://github.com/expo/sentry-expo

@lukebars
Copy link
Contributor

Looks like you have to specify enableNative: true, else it will be false now?

@cruzach
Copy link
Contributor Author

cruzach commented Jul 29, 2020

@lukebars I don't think so. It should default to true

@lukebars
Copy link
Contributor

@cruzach hmm, I've tried to send example crash to Sentry without specifying enableNative: true and DeviceContext was completely empty...

@cruzach
Copy link
Contributor Author

cruzach commented Jul 29, 2020

Oh you're right, I assigned default options after that deviceContext check 🤦

In sdk.ts:

if (options.enableNative) {
      options.defaultIntegrations.push(new DeviceContext());
}
options = assignDefaultOptions(options);

should be

options = assignDefaultOptions(options);
if (options.enableNative) {
      options.defaultIntegrations.push(new DeviceContext());
}

@bruno-garcia
Copy link
Member

Looks like we have no tests for that eh :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants