Skip to content

Commit

Permalink
fix(expo): Fetch org from expo config in expo upload sourcemaps (#3557)
Browse files Browse the repository at this point in the history
  • Loading branch information
LegendEffects authored Jan 31, 2024
1 parent 9c786a3 commit a418c83
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
### Fixes

- Prevent pod install crash when visionos is not present ([#3548](https://github.com/getsentry/sentry-react-native/pull/3548))
- Fetch Organization slug from `@sentry/react-native/expo` config when uploading artifacts ([#3557](https://github.com/getsentry/sentry-react-native/pull/3557))

## 5.17.0

Expand Down
38 changes: 28 additions & 10 deletions scripts/expo-upload-sourcemaps.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ const fs = require('fs');
const path = require('path');
const process = require('process');

const SENTRY_ORG = 'SENTRY_ORG';
const SENTRY_PROJECT = 'SENTRY_PROJECT';
// The sentry org is inferred from the auth token
const SENTRY_AUTH_TOKEN = 'SENTRY_AUTH_TOKEN';
const SENTRY_CLI_EXECUTABLE = 'SENTRY_CLI_EXECUTABLE';

Expand Down Expand Up @@ -101,25 +101,42 @@ function groupAssets(assetPaths) {
return groups;
}

let sentryOrg = getEnvVar(SENTRY_ORG);
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...`);
if (!sentryOrg || !sentryProject) {
console.log('🐕 Fetching from expo config...');
const pluginConfig = getSentryPluginPropertiesFromExpoConfig();
if (!pluginConfig) {
console.error("Could not fetch '@sentry/react-native' plugin properties from expo config.");
process.exit(1);
}
if (!pluginConfig.project) {
console.error(
`Could not resolve sentry project, set it in the environment variable ${SENTRY_PROJECT} or in the '@sentry/react-native' plugin properties in your expo config.`,
);
process.exit(1);

if (!sentryOrg) {
if (!pluginConfig.organization) {
console.error(
`Could not resolve sentry org, set it in the environment variable ${SENTRY_ORG} or in the '@sentry/react-native' plugin properties in your expo config.`,
);
process.exit(1);
}

sentryOrg = pluginConfig.organization;
console.log(`${SENTRY_ORG} resolved to ${sentryOrg} from expo config.`);
}

if (!sentryProject) {
if (!pluginConfig.project) {
console.error(
`Could not resolve sentry project, set it in the environment variable ${SENTRY_PROJECT} or in the '@sentry/react-native' plugin properties in your expo config.`,
);
process.exit(1);
}

sentryProject = pluginConfig.project;
console.log(`${SENTRY_PROJECT} resolved to ${sentryProject} from expo config.`);
}
sentryProject = pluginConfig.project;
console.log(`${SENTRY_PROJECT} resolved to ${sentryProject} from expo config.`);
}

if (!authToken) {
Expand Down Expand Up @@ -158,6 +175,7 @@ for (const [assetGroupName, assets] of Object.entries(groupedAssets)) {
env: {
...process.env,
[SENTRY_PROJECT]: sentryProject,
[SENTRY_ORG]: sentryOrg,
},
stdio: 'inherit',
});
Expand Down

0 comments on commit a418c83

Please sign in to comment.