Skip to content

Commit

Permalink
Nettoyage AB testing Recap email (#4702)
Browse files Browse the repository at this point in the history
* feat: nettoyage de l'ab testing dans le recap mail

* feat: oublie d'un autre aspect d'ABtesting

* feat: supprime les imports inutiles

* feat: mise à jour des tests unitaires

* fix: prettier clean
  • Loading branch information
jenovateurs authored Nov 7, 2024
1 parent e24d76d commit 1c3d434
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 61 deletions.
8 changes: 6 additions & 2 deletions cypress/utils/results.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,9 @@ const receiveResultsEmail = () => {

const email = "[email protected]"
cy.get("input#email").should("be.visible").type(email)
cy.get(".fr-btn:contains(J'accepte d'être recontacté ou recontactée)")
cy.get(
".fr-btn:contains(Je reçois mon récapitulatif et je me fais accompagner par téléphone)"
)
.should("be.visible")
.click()

Expand Down Expand Up @@ -296,7 +298,9 @@ const receiveResultsSms = () => {
.click()
// scroll to input#phone
cy.get("input#phone").scrollIntoView().should("be.visible").type(phone)
cy.get(".fr-btn:contains(J'accepte d'être recontacté ou recontactée)")
cy.get(
".fr-btn:contains(Je reçois mon récapitulatif et je me fais accompagner par téléphone)"
)
.should("be.visible")
.click()

Expand Down
2 changes: 0 additions & 2 deletions lib/enums/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ export enum EventAction {
FormulaireAffiche = "Formulaire affiché",
FormulaireEmailInvalide = "Invalid email form",
FormulaireTelephoneInvalide = "Invalid phone form",
FormulaireValideAvecRecontact = "Formulaire validé avec recontact",
FormulaireValideSansRecontact = "Formulaire validé sans recontact",
Instructions = CTALabel.Instructions,
JeDonneMonAvis = "Je donne mon avis",
Link = "link",
Expand Down
4 changes: 1 addition & 3 deletions src/components/modals/recap-email-and-sms-modal.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
<script setup lang="ts">
import RecapEmailAndSmsForm from "@/components/recap-email-and-sms-form.vue"
import { computed } from "vue"
import ABTestingService from "@/plugins/ab-testing-service.js"
const headerTitle = computed(() => {
return process.env.VITE_SHOW_SMS_TAB &&
ABTestingService.getValues().Followup_SMS === "show"
return process.env.VITE_SHOW_SMS_TAB
? "Recevoir les résultats par email/SMS"
: "Recevoir les résultats par email"
})
Expand Down
35 changes: 2 additions & 33 deletions src/components/recap-email-and-sms-form.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { useRouter } from "vue-router"
import * as Sentry from "@sentry/vue"
import StatisticsMixin from "@/mixins/statistics.js"
import { EventCategory, EventAction } from "@lib/enums/event.js"
import ABTestingService from "@/plugins/ab-testing-service.js"
const router = useRouter()
const store = useStore()
Expand Down Expand Up @@ -36,15 +35,7 @@ const inputPhonePattern = computed(() => {
return `^(((\\+?|00)(${diallingCodes})\\s?|0)[67])([\\s\\.\\-]?\\d{2}){4}`
})
const showSms =
process.env.VITE_SHOW_SMS_TAB &&
ABTestingService.getValues().Followup_SMS === "show"
StatisticsMixin.methods.sendEventToMatomo(
EventCategory.Followup,
EventAction.FormulaireAffiche,
ABTestingService.getValues().CTA_EmailRecontact
)
const showSms = process.env.VITE_SHOW_SMS_TAB
const sendRecap = async (surveyOptin) => {
try {
Expand All @@ -66,21 +57,6 @@ const sendRecap = async (surveyOptin) => {
phoneInputErrorMessage.value = true
emailInputErrorMessage.value = true
}
const hasInputErrorMessage =
phoneInputErrorMessage.value || emailInputErrorMessage.value
if (!hasInputErrorMessage) {
const eventAction = surveyOptin
? EventAction.FormulaireValideAvecRecontact
: EventAction.FormulaireValideSansRecontact
StatisticsMixin.methods.sendEventToMatomo(
EventCategory.Followup,
eventAction,
ABTestingService.getValues().CTA_EmailRecontact
)
}
} catch (error: any) {
const errorMessage = error?.response?.data?.toString() || ""
if (!errorMessage.includes("Invalid destination address")) {
Expand Down Expand Up @@ -193,14 +169,7 @@ const sendRecapByEmail = async (surveyOptin) => {
}
function computeCtaText() {
const ctaVersion = ABTestingService.getValues().CTA_EmailRecontact
if (ctaVersion === "version_test_1") {
return "J’accepte qu’on me recontacte pour faire le point sur mes démarches"
} else if (ctaVersion === "version_test_2") {
return "Je reçois mon récapitulatif et je me fais accompagner par téléphone"
} else {
return "J'accepte d'être recontacté ou recontactée"
}
return "Je reçois mon récapitulatif et je me fais accompagner par téléphone"
}
const ctaText = ref(computeCtaText())
Expand Down
6 changes: 1 addition & 5 deletions src/components/titre-chapitre.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import SendRecapButton from "@/components/buttons/send-recap-button.vue"
import { useStore } from "@/stores/index.js"
import { useRouter } from "vue-router"
import { useResultsStore } from "@/stores/results.js"
import ABTestingService from "@/plugins/ab-testing-service.js"
export default {
name: "TitreChapitre",
Expand All @@ -65,10 +64,7 @@ export default {
return this.resultsStore.shouldDisplayResults
},
showSMS() {
return (
process.env.VITE_SHOW_SMS_TAB &&
ABTestingService.getValues().Followup_SMS === "show"
)
return process.env.VITE_SHOW_SMS_TAB
},
title() {
return this.getTitleByRoute(this.$route)
Expand Down
13 changes: 0 additions & 13 deletions src/plugins/ab-testing-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,6 @@ function getEnvironment() {
ABTestingEnvironment.plans_to_ask_question.value ||
(Math.random() > 0.5 ? "show" : "hidden")

const versions = ["version_actuelle", "version_test_1", "version_test_2"]
const ctaEmailRecontact = ABTestingEnvironment.CTA_EmailRecontact || {}
ctaEmailRecontact.index ||= 5
ctaEmailRecontact.value ||=
versions[Math.floor(Math.random() * versions.length)]
ABTestingEnvironment.CTA_EmailRecontact = ctaEmailRecontact

ABTestingEnvironment.Followup_SMS = ABTestingEnvironment.Followup_SMS || {}
ABTestingEnvironment.Followup_SMS.index = 2
ABTestingEnvironment.Followup_SMS.value =
ABTestingEnvironment.Followup_SMS.value ||
(Math.random() > 0.5 ? "show" : "hide")

storageService.local.setItem("ABTesting", ABTestingEnvironment)
return ABTestingEnvironment
}
Expand Down
2 changes: 0 additions & 2 deletions src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,12 +279,10 @@ const router = createRouter({
path: "/init-ci",
name: "init-ci",
redirect: () => {
ABTestingService.setVariant("CTA_EmailRecontact", "version_actuelle")
ABTestingService.setVariant(
"aides_bafa",
"aides_bafa_fusionnees_conserve_position"
)
ABTestingService.setVariant("Followup_SMS", "show")
return "/"
},
},
Expand Down
5 changes: 4 additions & 1 deletion tools/views/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ <h1>Service d'email local</h1>
<p>
Pour ajouter un suivi, effectuer une simulation jusqu'au bout, cliquer
sur le bouton <b>"Recevoir les résultats par email"</b> et enfin sur
<b>"j'accepte d'être recontacté ou recontactée par email"</b></p
<b
>"Je reçois mon récapitulatif et je me fais accompagner par
téléphone"</b
></p
>
</span>
<ul v-if="followups && typeKeys">
Expand Down

0 comments on commit 1c3d434

Please sign in to comment.