Skip to content

Commit a418c83

Browse files
fix(expo): Fetch org from expo config in expo upload sourcemaps (#3557)
1 parent 9c786a3 commit a418c83

File tree

2 files changed

+29
-10
lines changed

2 files changed

+29
-10
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
### Fixes
2323

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

2627
## 5.17.0
2728

scripts/expo-upload-sourcemaps.js

+28-10
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ const fs = require('fs');
44
const path = require('path');
55
const process = require('process');
66

7+
const SENTRY_ORG = 'SENTRY_ORG';
78
const SENTRY_PROJECT = 'SENTRY_PROJECT';
8-
// The sentry org is inferred from the auth token
99
const SENTRY_AUTH_TOKEN = 'SENTRY_AUTH_TOKEN';
1010
const SENTRY_CLI_EXECUTABLE = 'SENTRY_CLI_EXECUTABLE';
1111

@@ -101,25 +101,42 @@ function groupAssets(assetPaths) {
101101
return groups;
102102
}
103103

104+
let sentryOrg = getEnvVar(SENTRY_ORG);
104105
let sentryProject = getEnvVar(SENTRY_PROJECT);
105106
let authToken = getEnvVar(SENTRY_AUTH_TOKEN);
106107
const sentryCliBin = getEnvVar(SENTRY_CLI_EXECUTABLE) || require.resolve('@sentry/cli/bin/sentry-cli');
107108

108-
if (!sentryProject) {
109-
console.log(`🐕 Fetching ${SENTRY_PROJECT} from expo config...`);
109+
if (!sentryOrg || !sentryProject) {
110+
console.log('🐕 Fetching from expo config...');
110111
const pluginConfig = getSentryPluginPropertiesFromExpoConfig();
111112
if (!pluginConfig) {
112113
console.error("Could not fetch '@sentry/react-native' plugin properties from expo config.");
113114
process.exit(1);
114115
}
115-
if (!pluginConfig.project) {
116-
console.error(
117-
`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.`,
118-
);
119-
process.exit(1);
116+
117+
if (!sentryOrg) {
118+
if (!pluginConfig.organization) {
119+
console.error(
120+
`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.`,
121+
);
122+
process.exit(1);
123+
}
124+
125+
sentryOrg = pluginConfig.organization;
126+
console.log(`${SENTRY_ORG} resolved to ${sentryOrg} from expo config.`);
127+
}
128+
129+
if (!sentryProject) {
130+
if (!pluginConfig.project) {
131+
console.error(
132+
`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.`,
133+
);
134+
process.exit(1);
135+
}
136+
137+
sentryProject = pluginConfig.project;
138+
console.log(`${SENTRY_PROJECT} resolved to ${sentryProject} from expo config.`);
120139
}
121-
sentryProject = pluginConfig.project;
122-
console.log(`${SENTRY_PROJECT} resolved to ${sentryProject} from expo config.`);
123140
}
124141

125142
if (!authToken) {
@@ -158,6 +175,7 @@ for (const [assetGroupName, assets] of Object.entries(groupedAssets)) {
158175
env: {
159176
...process.env,
160177
[SENTRY_PROJECT]: sentryProject,
178+
[SENTRY_ORG]: sentryOrg,
161179
},
162180
stdio: 'inherit',
163181
});

0 commit comments

Comments
 (0)