-
-
Notifications
You must be signed in to change notification settings - Fork 359
Expand file tree
/
Copy pathbuild-on-error.js
More file actions
executable file
·42 lines (37 loc) · 1.22 KB
/
build-on-error.js
File metadata and controls
executable file
·42 lines (37 loc) · 1.22 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
#!/usr/bin/env node
/**
* EAS Build Hook: on-error
*
* This script captures EAS build failures and reports them to Sentry.
* Add it to your package.json scripts:
*
* "eas-build-on-error": "sentry-eas-build-on-error"
*
* NOTE: Use EITHER this hook (with on-success) OR the on-complete hook, 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_TAGS: JSON string of additional tags
* - SENTRY_EAS_BUILD_ERROR_MESSAGE: Custom error message
*
* @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,
};
await runHook('on-error', () => hooks.captureEASBuildError(options));
}
main().catch(error => {
// eslint-disable-next-line no-console
console.error('[Sentry] Unexpected error in eas-build-on-error hook:', error);
process.exit(1);
});