sentry-react-native: Sourcemaps not working (Metro bundler)
We’re at the 3rd attempt right now to get Sentry sourcemaps working for using expo export --platform web, which is running Metro bundler for web.
The screenshot below is a result from running sentry-cli sourcemaps explain <eventId>
This is our setup:
package.json > scripts
"exportWeb": "expo export --platform web --dump-sourcemap",
"uploadWebSourceMaps": "export EXPO_PUBLIC_SENTRY_RELEASE=web@$(git rev-parse HEAD); node ./scripts/uploadWebSourceMaps.js",
Our CI/CD triggers npm run exportWeb && npm run uploadWebSourceMaps
This is uploadWebSourceMaps.js
// Inspired by @see https://github.com/getsentry/action-release/
const path = require('path');
const dotenv = require('dotenv');
dotenv.config();
const { getJsonFileContent, checkEnvVars } = require('./utils/cli');
const { DIST_PATH } = require('./utils/paths');
const { createReleaseAndUploadSourcemaps } = require('./utils/sentry/cli');
const METADATA_PATH = path.resolve(DIST_PATH, 'metadata.json');
async function main() {
checkEnvVars([
'EXPO_PUBLIC_SENTRY_ENVIRONMENT',
'EXPO_PUBLIC_SENTRY_ORG',
'EXPO_PUBLIC_SENTRY_PROJECT',
'SENTRY_AUTH_TOKEN',
]);
process.env['SENTRY_ORG'] = process.env.EXPO_PUBLIC_SENTRY_ORG;
process.env['SENTRY_PROJECT'] = process.env.EXPO_PUBLIC_SENTRY_PROJECT;
process.env['SENTRY_ENVIRONMENT'] = process.env.EXPO_PUBLIC_SENTRY_ENVIRONMENT;
process.env['SENTRY_RELEASE'] = process.env.EXPO_PUBLIC_SENTRY_RELEASE;
const metadata = await getJsonFileContent(METADATA_PATH);
const bundleFileName = metadata.fileMetadata.web.bundle;
const bundlePath = path.resolve(DIST_PATH, bundleFileName);
await createReleaseAndUploadSourcemaps({
bundlePath,
});
}
void main();
This is utils/sentry/cli.js
const SentryCli = require('@sentry/cli');
const { checkEnvVars } = require('../cli');
let _cli;
function getCli() {
process.env['SENTRY_PIPELINE'] = 'rocko';
if (!_cli) {
_cli = new SentryCli().releases;
}
return _cli;
}
async function createReleaseAndUploadSourcemaps({ bundlePath }) {
checkEnvVars(['SENTRY_ORG', 'SENTRY_PROJECT', 'SENTRY_ENVIRONMENT', 'SENTRY_RELEASE', 'SENTRY_AUTH_TOKEN']);
const cli = getCli();
const version = process.env['SENTRY_RELEASE'];
await cli.new(version, {
projects: [process.env.EXPO_PUBLIC_SENTRY_PROJECT],
});
await cli.setCommits(version, {
auto: true,
});
await cli.uploadSourceMaps(version, {
include: [bundlePath],
});
await cli.newDeploy(version, {
env: process.env['SENTRY_ENVIRONMENT'],
});
await cli.finalize(version);
}
module.exports = {
getCli,
createReleaseAndUploadSourcemaps,
};
Any help / advise would be great.
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 2
- Comments: 20 (9 by maintainers)
hi there!
since expo sdk 49, we changed the bundle command from
react-native/cli.js bundleto@expo/cli/build/bin/cli export:embed. (#21396 #21397). however, the sentry-cli has the fixedbundlecheck.does it have a way to customize or add
export:embedto the checks in sentry-cli?@kahest , any ability to prioritize this would be appreciated. I imagine several other teams are also heavily impacted currently.
The original issue is about manual source maps upload, solution here.
The original issue is not related to the https://github.com/expo/sentry-expo/issues/364.
@krystofwoldrich Applied the fix, verified it’s uploading the source maps and bundle, still no working source maps, all events are still referring to scrambled source code.
@felix-lambert We are working on #3262, so feel free to open the issue here.