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
Branches
Tags
2 merge requests!322.0 Release,!25chore(sentry): add section tag in logs
...@@ -136,7 +136,11 @@ async function start(fields, cozyParameters) { ...@@ -136,7 +136,11 @@ async function start(fields, cozyParameters) {
} }
} catch (error) { } catch (error) {
log('error', 'Start failed', error) log('error', 'Start failed', error)
Sentry.captureException(error) Sentry.captureException(error, {
tags: {
section: 'start'
}
})
await Sentry.flush() await Sentry.flush()
throw error throw error
} }
...@@ -199,7 +203,12 @@ async function getData(token, idPCE, startDate, endDate) { ...@@ -199,7 +203,12 @@ async function getData(token, idPCE, startDate, endDate) {
result.periode.date_fin result.periode.date_fin
) )
Sentry.captureMessage( 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 throw genError
} else { } else {
......
...@@ -20,7 +20,11 @@ onDeleteAccount().then( ...@@ -20,7 +20,11 @@ onDeleteAccount().then(
err => { err => {
const errorMessage = `onDeleteAccount GRDF: An error occurred during script: ${err.message}` const errorMessage = `onDeleteAccount GRDF: An error occurred during script: ${err.message}`
log('error', errorMessage) log('error', errorMessage)
Sentry.captureException(errorMessage) Sentry.captureException(errorMessage, {
tags: {
section: 'onDeleteAccount'
}
})
} }
) )
......
...@@ -30,6 +30,11 @@ async function getAuthToken(client_id, client_secret) { ...@@ -30,6 +30,11 @@ async function getAuthToken(client_id, client_secret) {
return response.data return response.data
} catch (error) { } catch (error) {
log('error', 'Error inside getAuthToken', error) log('error', 'Error inside getAuthToken', error)
Sentry.captureException('Error while getting auth token', {
tags: {
section: 'getAuthToken'
}
})
throw errors.VENDOR_DOWN throw errors.VENDOR_DOWN
} }
} }
...@@ -69,6 +74,11 @@ async function getConsents(bearerToken, pce) { ...@@ -69,6 +74,11 @@ async function getConsents(bearerToken, pce) {
} catch (error) { } catch (error) {
log('error', 'Error while getting consent') log('error', 'Error while getting consent')
log('error', error) log('error', error)
Sentry.captureException('Error while getting consent', {
tags: {
section: 'getConsents'
}
})
throw errors.VENDOR_DOWN throw errors.VENDOR_DOWN
} }
} }
...@@ -110,7 +120,11 @@ async function createGRDFConsent({ ...@@ -110,7 +120,11 @@ async function createGRDFConsent({
} catch (error) { } catch (error) {
log('error', `Failed to create GRDF consent`) log('error', `Failed to create GRDF consent`)
log('error', error.response.data) 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 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