Skip to content

Commit 752e659

Browse files
authored
Two small fixes to EAS build hooks: (#5773)
- When a user explicitly adds up sentry-eas-build-on-success, it now does the right thing without needing an extra env var - Dynamic version of SDK gets attached to `sentry.javascript.react-native.eas-build-hooks` SDK name
1 parent 9ee3737 commit 752e659

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

packages/core/scripts/eas-build-hook.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,9 @@ const HOOK_CONFIGS = {
148148
successMessage: 'SENTRY_EAS_BUILD_SUCCESS_MESSAGE',
149149
captureSuccessfulBuilds: 'SENTRY_EAS_BUILD_CAPTURE_SUCCESS',
150150
},
151+
// When a user explicitly configures the on-success hook, they intend to
152+
// capture successful builds, so default captureSuccessfulBuilds to true.
153+
defaults: { captureSuccessfulBuilds: true },
151154
method: 'captureEASBuildSuccess',
152155
},
153156
};
@@ -169,11 +172,17 @@ async function runEASBuildHook(hookName) {
169172
loadEnv();
170173

171174
const hooks = loadHooksModule();
172-
const options = parseBaseOptions();
175+
const options = {
176+
...parseBaseOptions(),
177+
...config.defaults,
178+
};
173179

174180
for (const [optionKey, envKey] of Object.entries(config.envKeys)) {
175181
if (optionKey === 'captureSuccessfulBuilds') {
176-
options[optionKey] = process.env[envKey] === 'true';
182+
// Only override the default when the env var is explicitly set
183+
if (process.env[envKey] !== undefined) {
184+
options[optionKey] = process.env[envKey] === 'true';
185+
}
177186
} else if (process.env[envKey] !== undefined) {
178187
options[optionKey] = process.env[envKey];
179188
}

packages/core/src/js/tools/easBuildHooks.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import type { DsnComponents } from '@sentry/core';
1616
import { dsnToString, makeDsn, uuid4 } from '@sentry/core';
17+
import { SDK_VERSION } from '../version';
1718

1819
const SENTRY_DSN_ENV = 'SENTRY_DSN';
1920
const EAS_BUILD_ENV = 'EAS_BUILD';
@@ -179,7 +180,7 @@ function createBaseEvent(
179180
release: getReleaseFromEASEnv(env),
180181
tags: { ...createEASBuildTags(env), ...customTags },
181182
contexts: { eas_build: createEASBuildContext(env), runtime: { name: 'node', version: process.version } },
182-
sdk: { name: 'sentry.javascript.react-native.eas-build-hooks', version: '1.0.0' },
183+
sdk: { name: 'sentry.javascript.react-native.eas-build-hooks', version: SDK_VERSION },
183184
};
184185
}
185186

0 commit comments

Comments
 (0)