Skip to content
Snippets Groups Projects
Commit 4b0ee263 authored by Rémi PAILHAREY's avatar Rémi PAILHAREY :fork_knife_plate:
Browse files

feat: better sentry logs

parent 1a3c664f
No related branches found
No related tags found
2 merge requests!322.0 Release,!25chore(sentry): add section tag in logs
......@@ -136,7 +136,11 @@ async function start(fields, cozyParameters) {
}
} catch (error) {
log('error', 'Start failed', error)
Sentry.captureException(error)
Sentry.captureException(error, {
tags: {
section: 'start'
}
})
await Sentry.flush()
throw error
}
......@@ -199,7 +203,12 @@ async function getData(token, idPCE, startDate, endDate) {
result.periode.date_fin
)
Sentry.captureMessage(
`Get data threw an error: ${result.statut_restitution.code} - ${result.statut_restitution.message}`
`Get data threw an error: ${result.statut_restitution.code} - ${result.statut_restitution.message}`,
{
tags: {
section: 'getData'
}
}
)
throw genError
} else {
......
......@@ -20,7 +20,11 @@ onDeleteAccount().then(
err => {
const errorMessage = `onDeleteAccount GRDF: An error occurred during script: ${err.message}`
log('error', errorMessage)
Sentry.captureException(errorMessage)
Sentry.captureException(errorMessage, {
tags: {
section: 'onDeleteAccount'
}
})
}
)
......
......@@ -30,6 +30,11 @@ async function getAuthToken(client_id, client_secret) {
return response.data
} catch (error) {
log('error', 'Error inside getAuthToken', error)
Sentry.captureException('Error while getting auth token', {
tags: {
section: 'getAuthToken'
}
})
throw errors.VENDOR_DOWN
}
}
......@@ -69,6 +74,11 @@ async function getConsents(bearerToken, pce) {
} catch (error) {
log('error', 'Error while getting consent')
log('error', error)
Sentry.captureException('Error while getting consent', {
tags: {
section: 'getConsents'
}
})
throw errors.VENDOR_DOWN
}
}
......@@ -110,7 +120,11 @@ async function createGRDFConsent({
} catch (error) {
log('error', `Failed to create GRDF consent`)
log('error', error.response.data)
Sentry.captureException('Failed to create GRDF consent')
Sentry.captureException('Failed to create GRDF consent', {
tags: {
section: 'createGRDFConsent'
}
})
throw errors.USER_ACTION_NEEDED_CGU_FORM
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment