From fd4a1b93ffb759f703bb769d1a4cd138cff6d252 Mon Sep 17 00:00:00 2001 From: Hailey Date: Wed, 18 Sep 2024 14:31:42 -0700 Subject: [PATCH 1/4] update sentry config --- app.config.js | 13 +++++++++++-- patches/@sentry+react-native+5.32.0.patch | 21 +++++++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/app.config.js b/app.config.js index ddd72f75f0f..b4d2d81be7f 100644 --- a/app.config.js +++ b/app.config.js @@ -55,6 +55,7 @@ module.exports = function (config) { : undefined const UPDATES_ENABLED = !!UPDATES_CHANNEL + const USE_SENTRY = Boolean(process.env.SENTRY_AUTH_TOKEN) const SENTRY_DIST = `${PLATFORM}.${VERSION}.${IS_TESTFLIGHT ? 'tf' : ''}${ IS_DEV ? 'dev' : '' }` @@ -186,7 +187,15 @@ module.exports = function (config) { }, plugins: [ 'expo-localization', - Boolean(process.env.SENTRY_AUTH_TOKEN) && 'sentry-expo', + [ + '@sentry/react-native/expo', + { + organization: 'blueskyweb', + project: 'react-native', + release: VERSION, + dist: SENTRY_DIST, + }, + ], [ 'expo-build-properties', { @@ -263,7 +272,7 @@ module.exports = function (config) { * @see https://docs.expo.dev/guides/using-sentry/#app-configuration */ { - file: 'sentry-expo/upload-sourcemaps', + file: '@sentry/react-native/scripts/expo-post-publish', config: { organization: 'blueskyweb', project: 'react-native', diff --git a/patches/@sentry+react-native+5.32.0.patch b/patches/@sentry+react-native+5.32.0.patch index 2962aa44c2c..a5ccecc21a1 100644 --- a/patches/@sentry+react-native+5.32.0.patch +++ b/patches/@sentry+react-native+5.32.0.patch @@ -13,3 +13,24 @@ index 7e0b4cd..177454c 100644 } //# sourceMappingURL=ignorerequirecyclelogs.js.map \ No newline at end of file +diff --git a/node_modules/@sentry/react-native/scripts/expo-upload-sourcemaps.js b/node_modules/@sentry/react-native/scripts/expo-upload-sourcemaps.js +index 0f244f2..ae7dfb3 100755 +--- a/node_modules/@sentry/react-native/scripts/expo-upload-sourcemaps.js ++++ b/node_modules/@sentry/react-native/scripts/expo-upload-sourcemaps.js +@@ -174,6 +174,7 @@ if (!outputDir) { + process.exit(1); + } + ++const otherArgs = process.argv.slice(3); + const files = getAssetPathsSync(outputDir); + const groupedAssets = groupAssets(files); + +@@ -195,7 +196,7 @@ for (const [assetGroupName, assets] of Object.entries(groupedAssets)) { + + const isHermes = assets.find(asset => asset.endsWith('.hbc')); + const windowsCallback = process.platform === "win32" ? 'node ' : ''; +- execSync(`${windowsCallback}${sentryCliBin} sourcemaps upload ${isHermes ? '--debug-id-reference' : ''} ${assets.join(' ')}`, { ++ execSync(`${windowsCallback}${sentryCliBin} sourcemaps upload ${isHermes ? '--debug-id-reference' : ''} ${assets.join(' ')} ${otherArgs.join(' ')}`, { + env: { + ...process.env, + [SENTRY_PROJECT]: sentryProject, From fb559b12e1955ec32a923f94284663a0b9bb19cf Mon Sep 17 00:00:00 2001 From: Hailey Date: Wed, 18 Sep 2024 14:38:53 -0700 Subject: [PATCH 2/4] add posthook --- postHooks/uploadSentrySourcemapsPostHook.js | 34 +++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 postHooks/uploadSentrySourcemapsPostHook.js diff --git a/postHooks/uploadSentrySourcemapsPostHook.js b/postHooks/uploadSentrySourcemapsPostHook.js new file mode 100644 index 00000000000..756e64253c0 --- /dev/null +++ b/postHooks/uploadSentrySourcemapsPostHook.js @@ -0,0 +1,34 @@ +const exec = require('child_process').execSync + +const SENTRY_AUTH_TOKEN = process.env.SENTRY_AUTH_TOKEN + +module.exports = ({config}) => { + if (!SENTRY_AUTH_TOKEN) { + console.log( + 'SENTRY_AUTH_TOKEN environment variable must be set to upload sourcemaps. Skipping.', + ) + return + } + + const org = config.organization + const project = config.project + const release = config.release + const dist = config.dist + + if (!org || !project || !release || !dist) { + console.log( + '"organization", "project", "release", and "dist" must be set in the hook config to upload sourcemaps. Skipping.', + ) + return + } + + try { + console.log('Uploading sourcemaps to Sentry...') + exec( + `node node_modules/@sentry/react-native/scripts/expo-upload-sourcemaps dist --url https://sentry.io/ -o ${org} -p ${project} -r ${release} -d ${dist}`, + ) + console.log('Sourcemaps uploaded to Sentry.') + } catch (e) { + console.error('Error uploading sourcemaps to Sentry:', e) + } +} From fab6c16a8f1d764608ac5ccb2db304d9ccd0cad0 Mon Sep 17 00:00:00 2001 From: Hailey Date: Wed, 18 Sep 2024 14:40:16 -0700 Subject: [PATCH 3/4] update config --- app.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.config.js b/app.config.js index b4d2d81be7f..caeb8c395bd 100644 --- a/app.config.js +++ b/app.config.js @@ -272,7 +272,7 @@ module.exports = function (config) { * @see https://docs.expo.dev/guides/using-sentry/#app-configuration */ { - file: '@sentry/react-native/scripts/expo-post-publish', + file: './postHooks/uploadSentrySourcemapsPostHook', config: { organization: 'blueskyweb', project: 'react-native', From bea34fb680e495bca6515ee7ddaae77c81c635fe Mon Sep 17 00:00:00 2001 From: Hailey Date: Wed, 18 Sep 2024 14:48:16 -0700 Subject: [PATCH 4/4] only add expo config plugin when var is set --- app.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.config.js b/app.config.js index caeb8c395bd..ecc7e4d40cb 100644 --- a/app.config.js +++ b/app.config.js @@ -187,7 +187,7 @@ module.exports = function (config) { }, plugins: [ 'expo-localization', - [ + USE_SENTRY && [ '@sentry/react-native/expo', { organization: 'blueskyweb',