-
-
Notifications
You must be signed in to change notification settings - Fork 358
Expand file tree
/
Copy pathbuild-on-complete.js
More file actions
executable file
·53 lines (48 loc) · 1.77 KB
/
build-on-complete.js
File metadata and controls
executable file
·53 lines (48 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env node
/**
* EAS Build Hook: on-complete
*
* This script captures EAS build completion events and reports them to Sentry.
* It uses the EAS_BUILD_STATUS environment variable to determine whether
* the build succeeded or failed.
*
* Add it to your package.json scripts:
*
* "eas-build-on-complete": "sentry-eas-build-on-complete"
*
* NOTE: Use EITHER this hook OR the separate on-error/on-success hooks, not both.
* Using both will result in duplicate events being sent to Sentry.
*
* Required environment variables:
* - SENTRY_DSN: Your Sentry DSN
*
* Optional environment variables:
* - SENTRY_EAS_BUILD_CAPTURE_SUCCESS: Set to 'true' to also capture successful builds
* - SENTRY_EAS_BUILD_TAGS: JSON string of additional tags
* - SENTRY_EAS_BUILD_ERROR_MESSAGE: Custom error message for failed builds
* - SENTRY_EAS_BUILD_SUCCESS_MESSAGE: Custom success message for successful builds
*
* EAS Build provides:
* - EAS_BUILD_STATUS: 'finished' or 'errored'
*
* @see https://docs.expo.dev/build-reference/npm-hooks/
* @see https://docs.sentry.io/platforms/react-native/
*
*/
const { loadEnv, loadHooksModule, parseBaseOptions, runHook } = require('./utils');
async function main() {
loadEnv();
const hooks = loadHooksModule();
const options = {
...parseBaseOptions(),
errorMessage: process.env.SENTRY_EAS_BUILD_ERROR_MESSAGE,
successMessage: process.env.SENTRY_EAS_BUILD_SUCCESS_MESSAGE,
captureSuccessfulBuilds: process.env.SENTRY_EAS_BUILD_CAPTURE_SUCCESS === 'true',
};
await runHook('on-complete', () => hooks.captureEASBuildComplete(options));
}
main().catch(error => {
// eslint-disable-next-line no-console
console.error('[Sentry] Unexpected error in eas-build-on-complete hook:', error);
process.exit(1);
});