diff --git a/index.js b/index.js index 42591b833ec716aae6b1c174bcaa96763d0aaf39..9e642c8077bc7bb3fd4dd98a95e25768f89f7c97 100644 --- a/index.js +++ b/index.js @@ -74,6 +74,11 @@ async function start(fields, cozyParameters) { const { pce, email, firstname, lastname, postalCode } = fields + const transaction = Sentry.startTransaction({ + op: 'konnector', + name: 'start', + tags: { pce } + }) let boToken = '' let boBaseUrl = '' let grdfId = '' @@ -134,9 +139,11 @@ async function start(fields, cozyParameters) { log('error', 'Start failed', error) Sentry.captureException(error, { tags: { - section: 'start' + section: 'start', + pce } }) + transaction.finish() await Sentry.flush() throw error } @@ -161,6 +168,11 @@ function buildGetDataUrl(idPCE, startDate, endDate) { * @param {string} endDate 'YYYY-MM-DD' */ async function getData(token, idPCE, startDate, endDate) { + const transaction = Sentry.startTransaction({ + op: 'konnector', + name: 'getData', + tags: { pce: idPCE } + }) log('debug', `getData from ${startDate} to ${endDate}`) const url = buildGetDataUrl(idPCE, startDate, endDate) log('debug', url) @@ -227,6 +239,7 @@ async function getData(token, idPCE, startDate, endDate) { const filteredRep = response.filter(function(el) { return el.energie != null || el.volume_brut != null }) + transaction.finish() return filteredRep } @@ -249152,6 +249165,7 @@ const { deleteBoConsent, createBoConsent } = __webpack_require__(1776) const moment = __webpack_require__(1467) const { isLocal } = __webpack_require__(1466) const { createGRDFConsent } = __webpack_require__(1729) +const Sentry = __webpack_require__(1607) __webpack_require__(1604) moment.locale('fr') // set the language moment.tz.setDefault('Europe/Paris') // set the timezone @@ -249232,6 +249246,11 @@ async function createConsent({ boToken, boUrlGRDF }) { + const transaction = Sentry.startTransaction({ + op: 'konnector', + name: 'createConsent', + tags: { pce } + }) const startDateString = moment(startDate).format('YYYY-MM-DD') const endDateConsent = moment(endDate).add(1, 'year') const endDateString = endDateConsent.format('YYYY-MM-DD') @@ -249272,6 +249291,7 @@ async function createConsent({ }) throw err }) + transaction.finish() throw errors.CHALLENGE_ASKED }