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

feat: ab testing contact elise #134

Merged
merged 19 commits into from
Mar 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
56638d8
feat: ajout de l'AB testing sur la prise de contact + ajout du bouton…
MinaBarry Feb 21, 2023
99ff78b
feat: ajout de l'ab testing pour les categories test et contact + ajo…
MinaBarry Feb 23, 2023
707690e
fix: ab testing
MinaBarry Feb 27, 2023
31d6b5e
fix: demande de contact sauvegarder correctement avec le type rdv
mbarry-ippon Mar 6, 2023
21af2f8
fix: enlever le test D pour la demande de contact
mbarry-ippon Mar 6, 2023
91d2a56
fix: tracker du type de contact ne retourne plus null
mbarry-ippon Mar 6, 2023
3b7bb4e
fix: tracker des ressources envoyer lors du click
mbarry-ippon Mar 7, 2023
1ccd58e
fix: tracker pour les contact bien ordonnés
mbarry-ippon Mar 7, 2023
4ac5831
fix: remove unused import and fix duplicate variable
mbarry-ippon Mar 7, 2023
33519da
fix: ajouter les trackers pour les parcours A B C de la prise de cont…
mbarry-ippon Mar 7, 2023
0106a55
fix: remove ressource test
mbarry-ippon Mar 7, 2023
19e91ba
fix: ajouter l'import de la fonction utils
mbarry-ippon Mar 7, 2023
9b2ec7c
fix: enelver les doublons du trackers de contact
mbarry-ippon Mar 7, 2023
c0e6316
fix: tracker renvoie la bonne categorie pour la prise de contact
mbarry-ippon Mar 8, 2023
ce5dd78
fix: remove most code smells
mbarry-ippon Mar 8, 2023
8a04ce4
fox: ajout du lien calendly valide + enlever la partie afficher les r…
mbarry-ippon Mar 16, 2023
0998ca4
fix: ajout du tracker pour les ressource par mail uniquement
mbarry-ippon Mar 16, 2023
24cfe57
fix: ajout de l'import de utils
mbarry-ippon Mar 16, 2023
b3e62de
fix: mauvais path de l'import
mbarry-ippon Mar 16, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions __tests__/components/ab-testing/give-access-to-resources.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import * as AbTestingUtils from "../../../src/utils/ab-testing/ab-testing.utils"
describe("UI de GiveAccessToResources", () => {
describe("TEST A/B/C/D", () => {
const mailBtnText = "Je souhaite recevoir les ressources par mail"
const linkBtnText = "Afficher les ressources disponibles"

test("Should return modal with email when test is A", async () => {
localStorage.setItem(STORAGE_TEST_ABC, AbTestingUtils.TEST.A)
Expand All @@ -29,21 +28,5 @@ describe("UI de GiveAccessToResources", () => {
fireEvent.click(button)
expect(await screen.queryByText("Fermer")).toBeInTheDocument()
})

test("Should return link when test is C", async () => {
localStorage.setItem(STORAGE_TEST_ABC, AbTestingUtils.TEST.C)
render(<GiveAccessToResources />)

const button = screen.getByRole("button", { name: linkBtnText })
expect(button).toBeInTheDocument()
})

test("Should return link when test is D", async () => {
localStorage.setItem(STORAGE_TEST_ABC, AbTestingUtils.TEST.D)
render(<GiveAccessToResources />)

const button = screen.getByRole("button", { name: linkBtnText })
expect(button).toBeInTheDocument()
})
})
})
5 changes: 0 additions & 5 deletions __tests__/utils/ab-testing/contact-button-label.utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,5 @@ describe("Contact button label Utils", () => {
localStorage.setItem(STORAGE_TEST_ABC, "C")
expect(getContactButtonLabelByTest()).toEqual("Parler à Élise")
})

test("Should return `Obtenir de l'aide` when it's test D", () => {
localStorage.setItem(STORAGE_TEST_ABC, "D")
expect(getContactButtonLabelByTest()).toEqual("Obtenir de l'aide")
})
})
})
2 changes: 1 addition & 1 deletion apollo-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export const UPDATE_REPONSES_EPDS_ID_IN_INFORMATION_DEMOGRAPHIQUES = gql`

/**
* Enregistre la demande de contact dans la collection "Demande de contacts"
* ENUM_DEMANDEDECONTACT_TYPE_DE_CONTACT { sms, email, chat }
* ENUM_DEMANDEDECONTACT_TYPE_DE_CONTACT { sms, email, chat, rendezvous }
*/
export const SAVE_DEMANDE_DE_CONTACT = gql`
mutation (
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"react": "17.0.2",
"react-bootstrap": "^2.1.0",
"react-bootstrap-icons": "^1.7.2",
"react-calendly": "^4.1.1",
"react-dom": "17.0.2",
"sass": "^1.48.0",
"swr": "^1.3.0"
Expand Down
11 changes: 7 additions & 4 deletions pages/contact/contact-confirmed.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
STORAGE_CONTACT_TYPE,
STORAGE_SOURCE,
} from "../../src/constants/constants"
import { } from "@dataesr/react-dsfr"
import {} from "@dataesr/react-dsfr"
import { WidgetHeader } from "../../src/components/WidgetHeader"
import * as StorageUtils from "../../src/utils/storage.utils"

Expand Down Expand Up @@ -46,9 +46,12 @@ export default function ContactConfirmed() {
<b>Votre demande de contact a bien été prise en compte.</b>
</p>
<p>
{contactType == RequestContact.type.email
? "Vous devriez recevoir un email d’Elise dans les 48h. Pensez bien à vérifier dans vos spams."
: "Vous devriez recevoir un SMS d’Elise dans les 48h en fonction des disponibilités sélectionnées."}
{contactType === RequestContact.type.email &&
"Vous devriez recevoir un email d’Elise dans les 48h. Pensez bien à vérifier dans vos spams."}
{contactType === RequestContact.type.sms &&
"Vous devriez recevoir un SMS d’Elise dans les 48h en fonction des disponibilités sélectionnées."}
{contactType === RequestContact.type.rendezvous &&
"Vous serez contacté sur le numéro de téléphone que vous avez communiqué."}
</p>

{websiteSource !== OPEN_CONTACT_FROM_EMAIL && (
Expand Down
72 changes: 65 additions & 7 deletions pages/contact/contact-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
import React, { useEffect, useState } from "react"
import { Col } from "react-bootstrap"
import { ContentLayout } from "../../src/components/Layout"
import { useCalendlyEventListener, InlineWidget } from "react-calendly"
import { } from "@dataesr/react-dsfr"

import {
PATTERN_EMAIL,
RequestContact,
Expand All @@ -26,6 +28,8 @@ import { useRouter } from "next/router"
import { WidgetHeader } from "../../src/components/WidgetHeader"
import { Form } from "../../src/constants/specificLabels"
import * as ContactUtils from "../../src/utils/contact.utils"
import * as TrackerUtils from "../../src/utils/tracker.utils"
import * as AbTestingUtils from "../../src/utils/ab-testing/ab-testing.utils"

export default function ContactForm() {
const router = useRouter()
Expand All @@ -36,6 +40,7 @@ export default function ContactForm() {
const [childBirthDate, setChildBirthDate] = useState("")
const [numberOfChildren, setNumberOfChildren] = useState(0)
const [isLoading, setLoading] = useState(false)
const [isCalendlyValide, setCalendlyValide] = useState(false)

const contactType = StorageUtils.getInLocalStorage(STORAGE_CONTACT_TYPE)
const contactHours = StorageUtils.getInLocalStorage(STORAGE_CONTACT_HOURS)
Expand All @@ -49,7 +54,6 @@ export default function ContactForm() {
const [sendEmailContactQuery] = useMutation(EPDS_CONTACT_INFORMATION, {
client: client,
onCompleted: () => {
ContactUtils.sendTrackerContactConfirmed(contactType)
ContactUtils.saveContactRequest(contactType, sendContactQuery)

setLoading(false)
Expand Down Expand Up @@ -156,6 +160,42 @@ export default function ContactForm() {
})
}

const trackerContactName = (typeContact) => {
switch (typeContact) {
case RequestContact.type.email:
return TrackerUtils.CONTACT_SENT.mail
case RequestContact.type.sms:
return TrackerUtils.CONTACT_SENT.sms
case RequestContact.type.chat:
return TrackerUtils.CONTACT_SENT.chat
case RequestContact.type.rendezvous:
return TrackerUtils.CONTACT_SENT.rendezvous
}
}

const sendTrackerContactType = (typeContact) => {
TrackerUtils.genericTracker(
TrackerUtils.CATEG.contact,
TrackerUtils.NAME.contact_confirm_sent
)
if (typeContact) {
TrackerUtils.track(
TrackerUtils.CATEG.contact,
TrackerUtils.ACTION.contact_confirm_sent,
trackerContactName(typeContact)
)
AbTestingUtils.trackerForAbTesting(trackerContactName(typeContact))
}
}

useCalendlyEventListener({
onEventScheduled: (_e) => {
sendTrackerContactType(contactType)
setCalendlyValide(true)
},
})


const emailInput = (isRequired) => (
<div
className={`form-group fr-input-group ${isEmailValid ? "fr-input-group--valid" : ""
Expand Down Expand Up @@ -204,6 +244,10 @@ export default function ContactForm() {
</div>
)

if (isCalendlyValide) {
goToConfirmation()
}

const setOrderPhoneAndEmailInputs = () => {
if (contactType == RequestContact.type.email) {
return (
Expand All @@ -221,7 +265,6 @@ export default function ContactForm() {
</>
)
}

return null
}

Expand Down Expand Up @@ -256,8 +299,8 @@ export default function ContactForm() {
return (
<ContentLayout>
<WidgetHeader title="être contacté(e)" locale={localeSelected} />

<form className="contact-form" onSubmit={sendForm}>
{contactType !== RequestContact.type.rendezvous && (
<form className="contact-form" onSubmit={sendForm}>
<div className={`form-group fr-input-group`}>
<label htmlFor="inputName">Votre prénom :</label>
<input
Expand All @@ -266,14 +309,14 @@ export default function ContactForm() {
id="inputName"
name="inputName"
placeholder={Form.placeholder.name}
/>
/>
</div>

{setOrderPhoneAndEmailInputs()}
<ChildCounter />
{numberOfChildren > 0 ? (
<DatePickerLastChild onChange={(date) => setChildBirthDate(date)} />
) : null}
) : null}

<Col className="be-contacted-bottom-buttons">
<button className="fr-btn fr-btn--secondary" onClick={cancel}>
Expand All @@ -283,12 +326,27 @@ export default function ContactForm() {
className="fr-btn"
type="submit"
disabled={!canSend || isLoading}
>
onClick={()=>sendTrackerContactType(contactType)}
>
Valider
{isLoading ? <LoaderFoButton /> : null}
</button>
</Col>
</form>
)
}
{contactType === RequestContact.type.rendezvous && (
<>
<InlineWidget
url="https://calendly.com/rdv-nos1000jours/30min"
/>
<Col className="be-contacted-bottom-buttons">
<button className="fr-btn fr-btn--secondary" onClick={cancel}>
Annuler
</button>
</Col>
</>
)}
</ContentLayout>
)
}
Expand Down
Loading