Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[QA] Monitorer la plateforme et tracker les erreurs JS #2230

Merged
merged 5 commits into from
Feb 13, 2024

Conversation

sfinx13
Copy link
Collaborator

@sfinx13 sfinx13 commented Feb 8, 2024

Ticket

#894

Review app : https://histologe-staging-pr2230.osc-fr1.scalingo.io/

image

Description

Création d'un nouveau projet sentry afin de monitorer et tracker les erreurs histologe

Changements apportés

  • Installation de webpack-dotenv pour avoir accès aux variables d’environnement
  • Installation et configuration du SDK Sentry JS
  • Capturer les erreurs http
  • Ajout d'une nouvelle variable d'environnement sur le timeout Axios

Pré-requis

Ajout d'une nouvelle variable environnement

AXIOS_TIMEOUT=15000 # (Permettra d'être flexible, en cas de gros problème de validation)
SENTRY_DSN_FRONT=
SENTRY_ENVIRONMENT=dev
SENTRY_TRACES_SAMPLE_RATE=1.0
make npm-install
make npm-build ou make npm-watch

Tests

Documentation

https://www.npmjs.com/package/dotenv-webpack
https://docs.sentry.io/platforms/javascript/

SENTRY_ENVIRONMENT,
SENTRY_TRACES_SAMPLE_RATE,
AXIOS_TIMEOUT
};
Copy link
Collaborator Author

@sfinx13 sfinx13 Feb 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Les variables d'environnements ne sont pas tous exposé à travers process.env mais l'accès se fait directement à travers son nom (console.log(process.env) ne marchera pas)
  • Une fois le build effectué, seule la valeur est présente dans le fichier buildé
  • Exposer uniquement les données utile et non sensible (utilise le .env en locale)
    image

Pour en savoir plus
https://www.npmjs.com/package/dotenv-webpack#how-secure

doRequestGet (ajaxUrl: string, functionReturn: Function) {
axios
.get(ajaxUrl, { timeout: 15000 })
.get(ajaxUrl, { timeout: AXIOS_TIMEOUT })
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

J'ai pas appliqué la constante à tous les composants car l'enjeu est uniquement sur le formulaire


export const requests = {
// TODO : voir avec Emilien pour ne plus gérer via des callbacks mais faire de l'async pour rendre le code plus lisible
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Réflexion partagé cette été mais pas d'enjeu je supprime (une histoire d'habitude)

@@ -86,6 +88,9 @@ Encore
},
};
})
.addPlugin(new Dotenv({
path: isDev ? '.env.local' : '.env'
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Utilisation de .env.local avec make npm-watch et utilisation de .env avec make npm-build

SENTRY_TRACES_SAMPLE_RATE=
SENTRY_DSN_FRONT=https://06f9905de7b646ec902183ce78384f18@sentry.incubateur.net/142
SENTRY_ENVIRONMENT=prod
SENTRY_TRACES_SAMPLE_RATE=1.0
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finalement besoin de ces valeurs sur la phase de build js et y'a pas d'enjeu à exposer ces valeurs, faudra par contre filtrer les événements provenant de localhost sur le dashboard

@emilschn
Copy link
Collaborator

emilschn commented Feb 9, 2024

Relecture ok, mais blocage par uBlock :)

assets/vue/components/dashboard/requests.ts Outdated Show resolved Hide resolved
assets/vue/components/front-stats/requests.ts Outdated Show resolved Hide resolved
assets/vue/components/signalement-form/requests.ts Outdated Show resolved Hide resolved
assets/vue/components/stats/requests.ts Outdated Show resolved Hide resolved
@hmeneuvrier
Copy link
Collaborator

Test en local OK, une fois uBlock désactivé

Copy link
Collaborator

@hmeneuvrier hmeneuvrier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oki !

Copy link

sonarcloud bot commented Feb 13, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@numew numew merged commit b1c40e2 into develop Feb 13, 2024
4 checks passed
@sfinx13 sfinx13 deleted the feature/894-sentry-front branch February 13, 2024 21:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants