Skip to content
Snippets Groups Projects
Commit 10e11d4a authored by Bastien DUMONT's avatar Bastien DUMONT :angel:
Browse files

fix: missing startTransaction

parent 7d3f5571
Branches
Tags
1 merge request!43Merge dev into master
Pipeline #105014 passed
...@@ -87,58 +87,59 @@ async function createConsent({ ...@@ -87,58 +87,59 @@ async function createConsent({
boToken, boToken,
boUrlGRDF, boUrlGRDF,
}) { }) {
const transaction = Sentry.startTransaction({ return Sentry.startSpan(
op: 'konnector', {
name: 'createConsent', name: 'createConsent',
tags: { pce }, },
}) async span => {
const startDateString = moment(startDate).format('YYYY-MM-DD') const startDateString = moment(startDate).format('YYYY-MM-DD')
const endDateString = moment(endDate).format('YYYY-MM-DD') const endDateString = moment(endDate).format('YYYY-MM-DD')
// Handle some accounts running everyday with no consent (previous accounts from oauth) // Handle some accounts running everyday with no consent (previous accounts from oauth)
if (!lastname) { if (!lastname) {
log('error', 'No lastname provided, stopping consent creation') log('error', 'No lastname provided, stopping consent creation')
throw errors.USER_ACTION_NEEDED throw errors.USER_ACTION_NEEDED
} }
const { ID: consentId } = await createBoConsent({ const { ID: consentId } = await createBoConsent({
boUrlGRDF, boUrlGRDF,
boToken, boToken,
pce, pce,
firstname, firstname,
lastname, lastname,
postalCode, postalCode,
endDate, endDate,
}).catch(err => { }).catch(err => {
log('error', `Failed to create BO consent, ${err}`) log('error', `Failed to create BO consent, ${err}`)
throw errors.MAINTENANCE throw errors.MAINTENANCE
}) })
// Save BO consentId into account // Save BO consentId into account
const accountData = await getAccount(ACCOUNT_ID) const accountData = await getAccount(ACCOUNT_ID)
await saveAccountData(ACCOUNT_ID, { await saveAccountData(ACCOUNT_ID, {
...accountData.data, ...accountData.data,
consentId: consentId, consentId: consentId,
}) })
await createGRDFConsent({ await createGRDFConsent({
bearerToken, bearerToken,
email, email,
lastname, lastname,
pce, pce,
postalCode, postalCode,
startDate: startDateString, startDate: startDateString,
endDate: endDateString, endDate: endDateString,
}).catch(async err => { }).catch(async err => {
await deleteBoConsent({ await deleteBoConsent({
boUrlGRDF, boUrlGRDF,
boToken, boToken,
consentId: consentId, consentId: consentId,
}) })
throw err throw err
}) })
transaction.finish() throw errors.CHALLENGE_ASKED
throw errors.CHALLENGE_ASKED }
)
} }
module.exports = { handleConsents, createConsent } module.exports = { handleConsents, createConsent }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment