getsentry / sentry-react-native

Official Sentry SDK for React Native
https://sentry.io
MIT License
1.57k stars 337 forks source link

Allow adding --dist option in uploading source map #703

Closed nathantqn closed 4 years ago

nathantqn commented 5 years ago

Hi @HazAT, currently I'm facing a problem of Source code was not found in Url app:///index.android.bundle. I'm using Sentry together with Codepush, after using the command:

sentry-cli react-native appcenter --deployment Staging MyAppName android ./build/android/CodePush

Inthe Artifacts tab,index.android.bundleandindex.android.bundle.mapwere uploaded but theDistributionfields areNone. But my error includes bothrelease_nameanddist`, so it cannot map with those artifacts.

So my question is: How can I resolve this? I cannot find --dist as an option in sentry-cli react-native appcenter -h. I already tried to use --dist but it's not a valid option.

Originally posted by @nenjamin2405 in https://github.com/getsentry/sentry-react-native/issues/612#issuecomment-534402454

lobsterkatie commented 4 years ago

@nenjamin2405 (and anyone else who runs into this) - Currently, your best option is to strip the dist value from the event in beforeSend:

Sentry.init({
  dsn: 'YOUR DSN',
  beforeSend: (event, hint) => {
    delete event.dist;
    return event;
  },
});
mokoshi commented 4 years ago

I'm facing with a same issue. I can see the release artifacts with the same release name as issues have, but the source map is not applied. The DISTRIBUTION column of the artifact is None (and as @nenjamin2405 says there is no option on sentry-cli to set it), so I've stripped the dist parameter from the event (referring to @lobsterkatie), but still the source map is not applied.

Edit Sorry, this finally worked. My problem was simply the release name was different between issues and artifacts. My working codes:

nathantqn commented 4 years ago

Hi @lobsterkatie. thanks for your suggestion, but the thing is, whenever I release a new build for both iOS and Android on production, Sentry automatically upload the source map with the dist option so if I get rid of the dist in all Sentry events then again I cannot map them together, so in summary, there are 2 cases:

  1. I initially release the build on Production (without any Codepush at that time), so the source map uploaded will have both version name and dist --> every time user has a problem in the app, Sentry will send the error event with both version and dist so that I can map them together, everything is fine in this case.

  2. I refine some javascript code in my app, publish a codepush update, after the codepush command is finished, the sentry-cli uploads new source map, but the source map is missing dist, then later on, every user whose app has been updated via Codepush and has issue in the app, the Sentry still send both version and dist as usual, but the codepush source map now doesn't have dist --> cannot map

Any idea on this :(

asiFarran commented 4 years ago

Based on the above two comments I've tried configure sentry to conditionally drop the dist field (i.e only when we know we're running a codepush update) but it seems the source maps still dont lineup for codepushed bundles even when the events have the correct release name and no dist property.

Has anyone been able to get this to work?

lobsterkatie commented 4 years ago

@nenjamin2405 - the above should do what you need (and allow you to stop stripping dist values in beforeSend). Can you please let me know if you're still running into problems?