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

fix(deps): revert sentry bump

parent da9fd0f7
No related branches found
No related tags found
No related merge requests found
Pipeline #108726 passed
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
"travisDeployKey": "./bin/generate_travis_deploy_key" "travisDeployKey": "./bin/generate_travis_deploy_key"
}, },
"dependencies": { "dependencies": {
"@sentry/node": "^8.17.0", "@sentry/node": "^7.113.0",
"@sentry/tracing": "^7.113.0", "@sentry/tracing": "^7.113.0",
"axios": "^1.7.2", "axios": "^1.7.2",
"cozy-client": "48.7.0", "cozy-client": "48.7.0",
......
// @ts-check // @ts-check
require('./instrument.js') // Sentry initialization
const { const {
BaseKonnector, BaseKonnector,
hydrateAndFilter, hydrateAndFilter,
...@@ -13,6 +12,9 @@ require('moment-timezone') ...@@ -13,6 +12,9 @@ require('moment-timezone')
moment.locale('fr') // set the language moment.locale('fr') // set the language
moment.tz.setDefault('Europe/Paris') // set the timezone moment.tz.setDefault('Europe/Paris') // set the timezone
const Sentry = require('@sentry/node') const Sentry = require('@sentry/node')
// eslint-disable-next-line
const Tracing = require('@sentry/tracing') // Needed for tracking performance in Sentry
const { version } = require('../package.json')
const { getConsents } = require('./requests/grdf') const { getConsents } = require('./requests/grdf')
const { handleConsents, createConsent } = require('./core/core') const { handleConsents, createConsent } = require('./core/core')
const { rangeDate } = require('./constants') const { rangeDate } = require('./constants')
...@@ -25,6 +27,25 @@ const { ...@@ -25,6 +27,25 @@ const {
const { formatData } = require('./helpers/format') const { formatData } = require('./helpers/format')
const { getGRDFAccessToken } = require('./requests/bo.js') const { getGRDFAccessToken } = require('./requests/bo.js')
const { getPrices, applyPrices } = require('./helpers/prices.js') const { getPrices, applyPrices } = require('./helpers/prices.js')
const { isDev } = require('./helpers/env.js')
Sentry.init({
dsn: 'https://fa503fe00434433f805d1c715999b7f5@grandlyon.errors.cozycloud.cc/3',
// Set tracesSampleRate to 1.0 to capture 100%
// of transactions for performance monitoring.
// We recommend adjusting this value in production
tracesSampleRate: 1.0,
release: version,
environment: isDev() ? 'development' : 'production',
debug: isDev(),
integrations: [
// enable HTTP calls tracing
new Sentry.Integrations.Http({ tracing: true }),
],
})
Sentry.setTag('method', 'TIERS-DIRECT')
const NO_DATA = process.env.NO_DATA === 'true' const NO_DATA = process.env.NO_DATA === 'true'
const manualExecution = process.env.COZY_JOB_MANUAL_EXECUTION === 'true' const manualExecution = process.env.COZY_JOB_MANUAL_EXECUTION === 'true'
...@@ -70,6 +91,11 @@ async function start(fields, cozyParameters) { ...@@ -70,6 +91,11 @@ async function start(fields, cozyParameters) {
log('info', `OAuth callback result found, using pce ${pce}`) log('info', `OAuth callback result found, using pce ${pce}`)
} }
const transaction = Sentry.startTransaction({
op: 'konnector',
name: 'start',
tags: { pce },
})
let boToken = '' let boToken = ''
let boBaseUrl = '' let boBaseUrl = ''
...@@ -118,6 +144,8 @@ async function start(fields, cozyParameters) { ...@@ -118,6 +144,8 @@ async function start(fields, cozyParameters) {
) )
if (grdfData.length == 0) { if (grdfData.length == 0) {
log('debug', 'No data found') log('debug', 'No data found')
transaction.setStatus(Tracing.SpanStatus.Ok)
transaction.finish()
return return
} }
...@@ -194,6 +222,9 @@ async function start(fields, cozyParameters) { ...@@ -194,6 +222,9 @@ async function start(fields, cozyParameters) {
rangeDate.year.doctype, rangeDate.year.doctype,
rangeDate.year.keys rangeDate.year.keys
) )
transaction.setStatus(Tracing.SpanStatus.Ok)
transaction.finish()
} catch (error) { } catch (error) {
log('error', 'Start failed', error) log('error', 'Start failed', error)
Sentry.captureException(error, { Sentry.captureException(error, {
...@@ -202,6 +233,7 @@ async function start(fields, cozyParameters) { ...@@ -202,6 +233,7 @@ async function start(fields, cozyParameters) {
pce, pce,
}, },
}) })
transaction.finish()
await Sentry.flush() await Sentry.flush()
throw error throw error
} }
...@@ -226,6 +258,11 @@ function buildGetDataUrl(idPCE, startDate, endDate) { ...@@ -226,6 +258,11 @@ function buildGetDataUrl(idPCE, startDate, endDate) {
* @param {string} endDate 'YYYY-MM-DD' * @param {string} endDate 'YYYY-MM-DD'
*/ */
async function getData(token, idPCE, startDate, endDate) { 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}`) log('debug', `getData from ${startDate} to ${endDate}`)
const url = buildGetDataUrl(idPCE, startDate, endDate) const url = buildGetDataUrl(idPCE, startDate, endDate)
...@@ -291,5 +328,6 @@ async function getData(token, idPCE, startDate, endDate) { ...@@ -291,5 +328,6 @@ async function getData(token, idPCE, startDate, endDate) {
) )
throw genError throw genError
} }
transaction.finish()
return formattedData return formattedData
} }
const Sentry = require('@sentry/node')
const { version } = require('../package.json')
const { isDev } = require('./helpers/env')
Sentry.init({
dsn:
'https://fa503fe00434433f805d1c715999b7f5@grandlyon.errors.cozycloud.cc/3',
// Set tracesSampleRate to 1.0 to capture 100%
// of transactions for performance monitoring.
// We recommend adjusting this value in production
tracesSampleRate: 1.0,
release: version,
environment: isDev() ? 'development' : 'production',
debug: isDev(),
autoSessionTracking: true,
})
Sentry.setTag('method', 'TIERS-DIRECT')
Sentry.setTag('instance', process.env.COZY_URL)
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment