Skip to content

[REACT-NATIVE] Send device information like model and OS version #877

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

Closed
brunolemos opened this issue Mar 3, 2017 · 4 comments
Closed

Comments

@brunolemos
Copy link

brunolemos commented Mar 3, 2017

I was expecting to have the device details on the crash reports, but that didn't happen.

Is this going to be supported? Any way we can do that today?

image

@brunolemos
Copy link
Author

There are libs that get this information, like https://github.com/rebeccahughes/react-native-device-info, but I see #809 wasn't merged, so I'm not sure we can set this somehow. cc @orlando

@orlando
Copy link

orlando commented Mar 4, 2017

@brunolemos I ended up using my fork https://github.com/orlando/raven-js. You only need device information from JavaScript, in Java you should use the raven-java library

@brunolemos
Copy link
Author

brunolemos commented Mar 4, 2017

@orlando thanks for your insight!

I was able to fully implement it without a fork, here is my solution:

Code

import DeviceInfo from 'react-native-device-info'
import Raven from 'raven-js'
import RavenNative from 'raven-js/plugins/react-native'

import pkg from '../package.json'

RavenNative(Raven)

if (!__DEV__) {
  Raven
    .config('https://[email protected]/...', {
      release: pkg.version,
      dataCallback: data => {
        data.contexts = data.contexts || {}

        data.contexts.device = Object.assign(data.contexts.device || {}, {
          name: DeviceInfo.getDeviceName(),
          family: DeviceInfo.getBrand(),
          model: DeviceInfo.getModel(),
        })

        data.contexts.os = Object.assign(data.contexts.os || {}, {
          name: DeviceInfo.getSystemName(),
          version: DeviceInfo.getSystemVersion(),
        })

        return data
      },
    })
    .install()
}

Result

image

image

@brunolemos
Copy link
Author

brunolemos commented Mar 14, 2017

All right, sentry just released a more complete React Native integration!
It will now send device details and catch native crashes.

https://blog.sentry.io/2017/03/14/react-native
https://docs.sentry.io/clients/react-native/

EDIT: iOS only by now 😒 So the code above is still useful.

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

No branches or pull requests

2 participants