From 11f6c94357cecc323db67a36954407ecde491b2e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?R=C3=A9mi=20Pailharey?= <rpailharey@grandlyon.com>
Date: Thu, 11 Apr 2024 10:00:17 +0200
Subject: [PATCH] add section tag

---
 src/index.js           | 13 +++++++++++--
 src/onDeleteAccount.js |  6 +++++-
 src/requests/grdf.js   |  6 +++++-
 3 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/src/index.js b/src/index.js
index e52f5f4..8161f5b 100755
--- a/src/index.js
+++ b/src/index.js
@@ -136,7 +136,11 @@ async function start(fields, cozyParameters) {
     }
   } catch (error) {
     log('error', 'Start failed', error)
-    Sentry.captureException(error)
+    Sentry.captureException(error, {
+      tags: {
+        section: 'start'
+      }
+    })
     await Sentry.flush()
     throw error
   }
@@ -199,7 +203,12 @@ async function getData(token, idPCE, startDate, endDate) {
                 result.periode.date_fin
             )
             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
           } else {
diff --git a/src/onDeleteAccount.js b/src/onDeleteAccount.js
index 081a184..77dc550 100644
--- a/src/onDeleteAccount.js
+++ b/src/onDeleteAccount.js
@@ -20,7 +20,11 @@ onDeleteAccount().then(
   err => {
     const errorMessage = `onDeleteAccount GRDF: An error occurred during script: ${err.message}`
     log('error', errorMessage)
-    Sentry.captureException(errorMessage)
+    Sentry.captureException(errorMessage, {
+      tags: {
+        section: 'onDeleteAccount'
+      }
+    })
   }
 )
 
diff --git a/src/requests/grdf.js b/src/requests/grdf.js
index 86d9083..374195d 100644
--- a/src/requests/grdf.js
+++ b/src/requests/grdf.js
@@ -110,7 +110,11 @@ async function createGRDFConsent({
   } catch (error) {
     log('error', `Failed to create GRDF consent`)
     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
   }
 }
-- 
GitLab