Skip to content

Commit

Permalink
feat(expo): Dynamically resolve sentry-cli path in expo source maps u…
Browse files Browse the repository at this point in the history
…pload script (#3507)
  • Loading branch information
krystofwoldrich authored Jan 9, 2024
1 parent dc8966b commit 8d8a8a4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

This release is compatible with `[email protected]` and newer.

### Features

- `withSentryExpoSerializers` changes to `getSentryExpoConfig` ([#3501](https://github.com/getsentry/sentry-react-native/pull/3501))
- `getSentryExpoConfig` accepts the same parameters as `getDefaultConfig` from `expo/metro-config` and returns Metro configuration
- This also works for EAS Updates (and expo export). Debug ID is generated by `expo/metro-config` and used by Sentry.
Expand All @@ -13,10 +15,24 @@ This release is compatible with `[email protected]` and newer.
const config = getSentryExpoConfig(config);
```

- Add `scripts/expo-upload-sourcemaps.js` for simple EAS Update (expo export) source maps upload to Sentry ([#3491](https://github.com/getsentry/sentry-react-native/pull/3491))

```bash
SENTRY_PROJECT=project-slug \
SENTRY_ORG=org-slug \
SENTRY_AUTH_TOKEN=super-secret-token \
node node_modules/@sentry/react-native/scripts/expo-upload-sourcemaps.js dist
```

- Sentry CLI binary path in `scripts/expo-upload-sourcemaps.js` is resolved dynamically ([#3507](https://github.com/getsentry/sentry-react-native/pull/3507))
- Or can be overwritten by `SENTRY_CLI_EXECUTABLE` env

- Resolve Default Integrations based on current platform ([#3465](https://github.com/getsentry/sentry-react-native/pull/3465))
- Native Integrations are only added if Native Module is available
- Web Integrations only for React Native Web builds

### Fixes

- Includes fixes from version 5.15.2

## 5.15.2
Expand Down
6 changes: 3 additions & 3 deletions scripts/expo-upload-sourcemaps.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ const process = require('process');
const SENTRY_PROJECT = 'SENTRY_PROJECT';
// The sentry org is inferred from the auth token
const SENTRY_AUTH_TOKEN = 'SENTRY_AUTH_TOKEN';

const SENTRY_CLI = 'node_modules/@sentry/cli/bin/sentry-cli';
const SENTRY_CLI_EXECUTABLE = 'SENTRY_CLI_EXECUTABLE';

function getEnvVar(varname) {
return process.env[varname];
Expand Down Expand Up @@ -103,6 +102,7 @@ function groupAssets(assetPaths) {

let sentryProject = getEnvVar(SENTRY_PROJECT);
let authToken = getEnvVar(SENTRY_AUTH_TOKEN);
const sentryCliBin = getEnvVar(SENTRY_CLI_EXECUTABLE) || require.resolve('@sentry/cli/bin/sentry-cli');

if (!sentryProject) {
console.log(`🐕 Fetching ${SENTRY_PROJECT} from expo config...`);
Expand Down Expand Up @@ -147,7 +147,7 @@ for (const [assetGroupName, assets] of Object.entries(groupedAssets)) {
}
console.log(`⬆️ Uploading ${assetGroupName} bundle and sourcemap...`);
const isHermes = assets.find(asset => asset.endsWith('.hbc'));
execSync(`${SENTRY_CLI} sourcemaps upload ${isHermes ? '--debug-id-reference' : ''} ${assets.join(' ')}`, {
execSync(`${sentryCliBin} sourcemaps upload ${isHermes ? '--debug-id-reference' : ''} ${assets.join(' ')}`, {
env: {
...process.env,
[SENTRY_PROJECT]: sentryProject,
Expand Down

0 comments on commit 8d8a8a4

Please sign in to comment.