Sentry API does not work

Once again, my bad, the source was right but not yet released, version 2.0.0 of sentry-expo does not send the releaseId to the Sentry init, therefore the code from docs is required in the meantime,

This is what the code looks like in version 2.0.0:

Looks like sentry-expo has been failing to send the release with sentry.init. A fix for this was merged in 11 days ago. But no new releases have been pushed since then.

The issue I linked above does include a workaround.

hi @outatime

sentry is working now for me with sources.
i had a wrong import statement.
old:

import * as Sentry from "@sentry/react-native";

new:
import * as Sentry from 'sentry-expo';

and also setting the release:
Sentry.setRelease(Constants.manifest.revisionId);

what still is not working is the redux integration.
switching from expo32 to expo35 i changed from raven-for-redux to redux-sentry-middleware
but the redux-state and redux-lastAction don’t show up in sentry.

Finally sentry-expo@2.0.1 includes revision / release in their sources, Sentry.setRelease is no longer required, @charliecruzan !!!

Yeah, I’m sorry about that. I must have made a mistake publishing 2.0.0 :frowning:

Using sentry-expo v2.0.1 will now automatically configure a release for you (using revisionId)

Hi @charliecruzan

yup it does, take a look the following code, release passed as Sentry init parameter using Constants.manifest.revisionId or i am wrong?

https://github.com/expo/sentry-expo/blob/master/index.js#L159

woops! typo in my last response:
Using sentry-expo v2.0.1 will now** automatically configure a release for you (using revisionId)

1 Like

:raised_hands:

Were you able to get your implementation working with web?

I’m using Expo SDK 35, Sentry Expo 2.0.1 and getting the following like you did.

Module parse failed: Unexpected token (25:12)
You may need an appropriate loader to handle this file type.
| 
| class ExpoIntegration {
>   static id = 'ExpoIntegration';
|   name = ExpoIntegration.id;
1 Like

I was not able to get it to work. I’m still thinking that it’s something Babel-related that might fix it, but after some trial and error I made no progress and had to shelve it.

Thanks for getting back to me. @charliecruzan Are you able to shed any light on getting this to work with Web? Should I start a new topic maybe?

sentry-expo doesn’t support web just yet, it is something we want to get to eventually. In the meantime, we’re always open to PRs to the repo to get it working :smile:

Quest accepted. If I get it working, I’ll submit a PR!!

2 Likes

That’d be awesome! Happy to help and collab on it, so keep me updated and feel free to open a WIP PR

So it seems like it’s just a babel/webpack issue. static id = 'ExpoIntegration'; Throws an error because it’s a class property. I added

['@babel/plugin-proposal-class-properties', { loose: true }],

to my babel.config.js file, but it still throws the error. Do you know if I also have to add anything to webpack.config.js to respect the addition to the babel config?

FYI: As a workaround until we come up with a consolidated native+web sentry-expo, I’m using .native and .web config files to import and initialize either sentry-expo for the native packages or “@sentry/browser” for the web build of my app. In addition to giving me working error tracking on the web, I can also track git commits with my releases (something I don’t get from sentry-expo).

@charliecruzan @apoyando @craig-venturetec

Has anyone gotten Expo web to compile while having Sentry installed? I’m happy to not use Sentry on the web for now, but I can’t even get my web project to compile (“You may need an appropriate loader…” error above) because Sentry is installed ("sentry-expo@2.0.1).

@apoyando Could you explain your solution further if it does this? Thanks

More generally, it seems like this happens quite frequently. Another package that’s cause it for me currently is rn-sliding-up-panel. It would be nice if there were a way to make all these issues go away. I also tried getting “[‘@babel/plugin-proposal-class-properties’, { loose: true }],” but couldn’t get it to work.

EDIT: Downgrading to Sentry 1.13.0 seems to fix the issue for now.

@vjsingh, here’s a simplified version of what I did to sidestep the sentry-expo web incompatibility:

  1. I created two files: sentry.native.js and sentry.web.js
  2. In sentry.native.js, I import and initialize sentry from ‘sentry-expo’ just as the Expo docs specify, then export the Sentry object.
  3. In sentry.web.js, I import and initialize sentry from ‘@sentry/browser’ (which I installed) as specified in the sentry standard JS documentation (it’s very similar, but there’s no ‘enableInExpoDevelopment’). I also export the Sentry object from this file.
  4. In my App.js, I import Sentry from ‘./sentry’. Now when I build the native files, Expo will import from ‘sentry.native.js’. When I build the web files, I’ll be importing from ‘sentry.web.js’.

That’s hopefully enough just to get things working. In my case, I added an error boundary and am also reporting separate releases to Sentry for my web app at publish time.

2 Likes

@apoyando Thanks that’s a good explanation. And a clever trick about the “.native.js” and “.web.js” I didn’t realize Expo would do that automatically.

I’m a little confused though since I’m not even attempting to use Sentry in my web project at all. I believe it doesn’t require Sentry in any way, so I’m not sure why it’s causing the compile time error. If it’s working for you then perhaps I set up my project in the wrong way somehow.

@vjsingh I think if you’re importing and initializing Sentry from ‘sentry-expo’ anywhere in your app, you’re going to run into a problem when doing the web build. Are you doing it in App.js?