Skip to content

Commit 412c78c

Browse files
committed
add Sentry capture to config failures
1 parent ef41671 commit 412c78c

File tree

1 file changed

+23
-13
lines changed

1 file changed

+23
-13
lines changed

src/config.js

+23-13
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const ms = require('ms')
22
const { Context } = require('probot')
33
const merge = require('lodash.merge')
4+
const Sentry = require('@sentry/node')
45

56
const { CLOSE, MERGE, LABEL } = require('./constants')
67

@@ -49,23 +50,32 @@ function createGlobalConfig(context, owner, repo) {
4950
}
5051

5152
module.exports = async context => {
52-
let config = await context.config(CONFIG_FILE, defaultConfig)
53+
try {
54+
let config = await context.config(CONFIG_FILE, defaultConfig)
5355

54-
if (typeof config.uses === 'string' && config.uses.indexOf('/') > -1) {
55-
const [owner, repo] = config.uses.trim().split('/')
56-
config = await createGlobalConfig(context, owner, repo)
57-
}
56+
if (typeof config.uses === 'string' && config.uses.indexOf('/') > -1) {
57+
const [owner, repo] = config.uses.trim().split('/')
58+
config = await createGlobalConfig(context, owner, repo)
59+
}
5860

59-
if (typeof config.extends === 'string' && config.extends.indexOf('/') > -1) {
60-
const [owner, repo] = config.extends.trim().split('/')
61-
const globalConfig = await createGlobalConfig(context, owner, repo)
62-
config = merge(globalConfig, config)
63-
}
61+
if (typeof config.extends === 'string' && config.extends.indexOf('/') > -1) {
62+
const [owner, repo] = config.extends.trim().split('/')
63+
const globalConfig = await createGlobalConfig(context, owner, repo)
64+
config = merge(globalConfig, config)
65+
}
6466

65-
// merge defaults
66-
config.default = merge({}, defaultConfig.default, config.default)
67+
// merge defaults
68+
config.default = merge({}, defaultConfig.default, config.default)
6769

68-
return config
70+
return config
71+
} catch (err) {
72+
Sentry.configureScope(scope => {
73+
const id = context.payload && context.payload.installation && context.payload.installation.id
74+
scope.setUser({ id })
75+
Sentry.captureException(err)
76+
})
77+
throw err
78+
}
6979
}
7080

7181
// console.log(require('js-yaml').safeDump(defaultConfig))

0 commit comments

Comments
 (0)