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

wip basic transactions

parent 803e69ec
No related branches found
No related tags found
1 merge request!27Resolve "Mise en place de sentry - sge"
Pipeline #47948 passed
{
"workbench.colorCustomizations": {
"activityBar.activeBackground": "#65c89b",
"activityBar.activeBorder": "#945bc4",
"activityBar.background": "#65c89b",
"activityBar.foreground": "#15202b",
"activityBar.inactiveForeground": "#15202b99",
"activityBarBadge.background": "#945bc4",
"activityBarBadge.foreground": "#e7e7e7",
"sash.hoverBorder": "#65c89b",
"statusBar.background": "#42b883",
"statusBar.foreground": "#15202b",
"statusBarItem.hoverBackground": "#359268",
"statusBarItem.remoteBackground": "#42b883",
"statusBarItem.remoteForeground": "#15202b",
"titleBar.activeBackground": "#42b883",
"titleBar.activeForeground": "#15202b",
"titleBar.inactiveBackground": "#42b88399",
"titleBar.inactiveForeground": "#15202b99"
},
}
\ No newline at end of file
"workbench.colorCustomizations": {
"activityBar.activeBackground": "#65c89b",
"activityBar.activeBorder": "#945bc4",
"activityBar.background": "#65c89b",
"activityBar.foreground": "#15202b",
"activityBar.inactiveForeground": "#15202b99",
"activityBarBadge.background": "#945bc4",
"activityBarBadge.foreground": "#e7e7e7",
"sash.hoverBorder": "#65c89b",
"statusBar.background": "#42b883",
"statusBar.foreground": "#15202b",
"statusBarItem.hoverBackground": "#359268",
"statusBarItem.remoteBackground": "#42b883",
"statusBarItem.remoteForeground": "#15202b",
"titleBar.activeBackground": "#42b883",
"titleBar.activeForeground": "#15202b",
"titleBar.inactiveBackground": "#42b88399",
"titleBar.inactiveForeground": "#15202b99"
},
"cSpell.words": ["enedissgegrandlyon", "grandlyon", "insee"]
}
......@@ -51,7 +51,7 @@
"langs": ["fr"],
"locales": {
"fr": {
"short_description": "Récupère vos donnéees de courbe de charge depuis l'API Enedis",
"short_description": "Récupère vos données de courbe de charge depuis l'API Enedis",
"long_description": "Ce connecteur récupère la courbe de charge électrique enregistrée par le compteur Linky",
"permissions": {
"enedis data": {
......
......@@ -33,8 +33,8 @@
"build": "webpack",
"clean": "rm -rf ./data",
"cozyPublish": "cozy-app-publish --token $REGISTRY_TOKEN --build-commit $(git rev-parse ${DEPLOY_BRANCH:-build})",
"deploy-dev": "git-directory-deploy --directory build/ --branch ${DEPLOY_BRANCH:-build-dev}",
"deploy": "git-directory-deploy --directory build/ --branch ${DEPLOY_BRANCH:-build}",
"deploy-dev": "git-directory-deploy --directory build/ --branch ${DEPLOY_BRANCH:-build-dev}",
"dev": "cozy-konnector-dev",
"lint": "eslint --fix .",
"onDeleteAccount:standalone": "cozy-konnector-standalone src/onDeleteAccount.js",
......@@ -48,6 +48,8 @@
"travisDeployKey": "./bin/generate_travis_deploy_key"
},
"dependencies": {
"@sentry/node": "^7.22.0",
"@sentry/tracing": "^7.22.0",
"axios": "^0.27.2",
"cozy-konnector-libs": "4.55.0",
"easy-soap-request": "^4.7.0",
......
......@@ -36,7 +36,9 @@ const {
getContractStartDate,
} = require('./core')
const { getAccount, saveAccountData } = require('./requests/cozy')
const { isLocal } = require('./helpers/env')
const { isLocal, isDev } = require('./helpers/env')
const Sentry = require('@sentry/node')
const { version } = require('../package.json')
moment.locale('fr') // set the language
moment.tz.setDefault('Europe/Paris') // set the timezone
......@@ -55,6 +57,22 @@ const ACCOUNT_ID = isLocal() ? 'default_account_id' : 'enedissgegrandlyon'
module.exports = new BaseKonnector(start)
/**
* Sentry
*/
Sentry.init({
dsn:
'https://18747a93401447f2a81b83cd8c4bbbdf@grandlyon.errors.cozycloud.cc/5',
// 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: true,
})
/**
* The start function is run by the BaseKonnector instance only when it got all the account
* information (fields). When you run this connector yourself in "standalone" mode or "dev" mode,
......@@ -66,7 +84,25 @@ module.exports = new BaseKonnector(start)
*/
async function start(fields, cozyParameters) {
log('info', 'Konnector configuration ...')
log('info', `isManual exectuion: ${manualExecution}`)
log('info', `isManual execution: ${manualExecution}`)
log('info', `konnector version : ${version}`)
// const transaction = Sentry.startTransaction({
// op: 'test',
// name: 'My First Test Transaction',
// })
Sentry.captureEvent({ message: 'konnector launch 3' })
setTimeout(() => {
try {
test()
} catch (e) {
Sentry.captureException(e)
} finally {
// transaction.finish()
}
}, 99)
const pointId = parseInt(fields.pointId)
let baseUrl = fields.wso2BaseUrl
......@@ -570,3 +606,7 @@ function isFirstStart(account) {
log('info', 'Konnector first start')
return true
}
function test() {
Sentry.captureException('capture exception inside test')
throw new Error('Function test not implemented.')
}
// @ts-check
const Sentry = require('@sentry/node')
const { default: axios } = require('axios')
const { log, errors } = require('cozy-konnector-libs')
......@@ -18,7 +19,7 @@ async function getInseeCode(postalCode, city) {
if (response.data.length === 1) {
return response.data[0].codeCommune
} else {
if (!city) throw errors.USER_ACTION_NEEDED
if (!city) throw new Error('No city')
const filteredResponse = response.data.filter(
town => town.nomCommune.toLowerCase() === city.toLowerCase()
......@@ -26,10 +27,9 @@ async function getInseeCode(postalCode, city) {
return filteredResponse[0].codeCommune
}
} catch (error) {
log(
'error',
`Query getInseeCode failed for postalCode ${postalCode} / ${city}`
)
const errorMessage = `Query getInseeCode failed for postalCode ${postalCode} / ${city}`
log('error', errorMessage)
Sentry.captureException(errorMessage)
throw errors.USER_ACTION_NEEDED
}
}
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment