diff --git a/CHANGELOG.md b/CHANGELOG.md index ba1bed84..1c3b8f67 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,4 @@ + # [1.56.0](https://github.com/SocialGouv/nos1000jours-blues-epds-widget/compare/v1.55.1...v1.56.0) (2023-03-20) @@ -5,6 +6,7 @@ * changer le mail destiner a elise lors de la prise de contact ([#138](https://github.com/SocialGouv/nos1000jours-blues-epds-widget/issues/138)) ([6c68d00](https://github.com/SocialGouv/nos1000jours-blues-epds-widget/commit/6c68d0078338cdb49e18d5121c38843531027bfc)) + ## [1.55.1](https://github.com/SocialGouv/nos1000jours-blues-epds-widget/compare/v1.55.0...v1.55.1) (2023-03-20) diff --git a/__tests__/utils/contact.utils.test.js b/__tests__/utils/contact.utils.test.js index f5748282..4ab24a41 100644 --- a/__tests__/utils/contact.utils.test.js +++ b/__tests__/utils/contact.utils.test.js @@ -1,11 +1,12 @@ -import { RequestContact } from "../../src/constants/constants" +import { RequestContact, STORAGE_SOURCE } from "../../src/constants/constants" import * as ContactUtils from "../../src/utils/contact.utils" import * as TrackerUtils from "../../src/utils/tracker.utils" describe("Contact Utils", () => { describe("sendTrackerContactConfirmed", () => { let trackerSpy - + localStorage.setItem(STORAGE_SOURCE, "1000-premiers-jours") + const source = localStorage.getItem(STORAGE_SOURCE) beforeEach(() => { trackerSpy = jest.spyOn(TrackerUtils, "track") }) @@ -19,7 +20,7 @@ describe("Contact Utils", () => { expect(trackerSpy).toHaveBeenCalledWith( TrackerUtils.CATEG.contact, TrackerUtils.ACTION.contact_confirm_sent, - TrackerUtils.CONTACT_SENT.mail + `${TrackerUtils.CONTACT_SENT.mail} - ${source}` ) }) @@ -28,7 +29,7 @@ describe("Contact Utils", () => { expect(trackerSpy).toHaveBeenCalledWith( TrackerUtils.CATEG.contact, TrackerUtils.ACTION.contact_confirm_sent, - TrackerUtils.CONTACT_SENT.sms + `${TrackerUtils.CONTACT_SENT.sms} - ${source}` ) }) @@ -38,7 +39,7 @@ describe("Contact Utils", () => { expect(trackerSpy).toHaveBeenCalledWith( TrackerUtils.CATEG.contact, TrackerUtils.ACTION.contact_confirm_sent, - TrackerUtils.CONTACT_SENT.chat + `${TrackerUtils.CONTACT_SENT.chat} - ${source}` ) }) }) diff --git a/pages/contact/contact-form.js b/pages/contact/contact-form.js index baa7cfa7..26c2802b 100644 --- a/pages/contact/contact-form.js +++ b/pages/contact/contact-form.js @@ -163,19 +163,6 @@ 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, @@ -185,9 +172,9 @@ export default function ContactForm() { TrackerUtils.track( TrackerUtils.CATEG.contact, TrackerUtils.ACTION.contact_confirm_sent, - trackerContactName(typeContact) + `${ContactUtils.trackerContactName(typeContact)} - ${websiteSource}` ) - AbTestingUtils.trackerForAbTesting(trackerContactName(typeContact)) + AbTestingUtils.trackerForAbTesting(ContactUtils.trackerContactName(typeContact)) } } diff --git a/pages/contact/to-be-contacted.js b/pages/contact/to-be-contacted.js index ae3ca195..f39d3587 100644 --- a/pages/contact/to-be-contacted.js +++ b/pages/contact/to-be-contacted.js @@ -57,7 +57,6 @@ export default function ToBeContacted() { const [websiteSource, setWebsiteSource] = useState(false) const [isChatEnabled, setChatEnabled] = useState() - const [isChatActive, setChatActive] = useState() useEffect(() => { const source = readSourceInUrl() @@ -122,6 +121,7 @@ export default function ToBeContacted() { } const onValidate = async (_event) => { + const source = StorageUtils.getInLocalStorage(STORAGE_SOURCE) TrackerUtils.genericTracker( TrackerUtils.CATEG.contact, TrackerUtils.NAME.contact_type @@ -129,7 +129,7 @@ export default function ToBeContacted() { TrackerUtils.track( TrackerUtils.CATEG.contact, TrackerUtils.ACTION.contact_type, - itemValueType + `${itemValueType} - ${source}` ) AbTestingUtils.trackerForAbTesting(itemValueType) @@ -163,8 +163,11 @@ export default function ToBeContacted() { const { loading, error, data } = useQuery(GET_ACTIVATION_CHAT_STATUS, { client: client, }) - if (!loading && !error && data.activationChat) - setChatActive(data.activationChat.activation_chat) + + if (loading) return <> + if (error) return

Error

+ const isChatActive = data.activationChat.activation_chat + return ( <> {isChatEnabled && isChatActive && ( diff --git a/pages/index.js b/pages/index.js index 36eee2a9..55a7cc4f 100644 --- a/pages/index.js +++ b/pages/index.js @@ -22,7 +22,6 @@ import { import { LocaleButton } from "../src/components/LocaleButton" import { CarouselCustom } from "../src/components/CarouselCustom" import * as AbTestingUtils from "../src/utils/ab-testing/ab-testing.utils" -import * as DemographicDataUtils from "../src/utils/ab-testing/demographic-data.utils" import * as TrackerUtils from "../src/utils/tracker.utils" export default function Home() { @@ -74,7 +73,6 @@ export default function Home() { TrackerUtils.EVENT_CLICK, `Commencer le test - ${source}` ) - DemographicDataUtils.trackerForDemographie("Home - Commencer") localStorage.setItem(STORAGE_SOURCE, source) localStorage.setItem(STORAGE_TEST_ABC, AbTestingUtils.generateRandomTest()) diff --git a/pages/results.js b/pages/results.js index e3465493..ef45c5eb 100644 --- a/pages/results.js +++ b/pages/results.js @@ -9,6 +9,7 @@ import { STORAGE_SCORE_LEVEL_MACARON, STORAGE_SCORE_LEVEL_MOOD, STORAGE_SCORE_LEVEL_TEXTS, + STORAGE_SOURCE, } from "../src/constants/constants" import { EpdsResultsComments, Labels } from "../src/constants/specificLabels" import * as StorageUtils from "../src/utils/storage.utils" @@ -43,7 +44,7 @@ export default function Results() { const scoreLevelForMacaron = parseInt( StorageUtils.getInLocalStorage(STORAGE_SCORE_LEVEL_MACARON) ) - + const source = StorageUtils.getInLocalStorage(STORAGE_SOURCE) const DescriptionAndConclusion = () => (
@@ -110,7 +111,7 @@ export default function Results() { useEffect(() => { if (levelMacaronText(scoreLevelForMood)) { AbTestingUtils.trackerForAbTesting( - `Macaron Elise - ${levelMacaronText(scoreLevelForMood)}` + `Macaron Elise - ${levelMacaronText(scoreLevelForMood)} - ${source}` ) } }, []) diff --git a/pages/survey/before-survey.js b/pages/survey/before-survey.js index 7223023d..ee32a1a0 100644 --- a/pages/survey/before-survey.js +++ b/pages/survey/before-survey.js @@ -4,6 +4,7 @@ import { useEffect, useState } from "react" import { client, GET_RESUTLATS_COUNT } from "../../apollo-client" import { ContentLayout } from "../../src/components/Layout" import { WidgetHeader } from "../../src/components/WidgetHeader" +import { STORAGE_SOURCE } from "../../src/constants/constants" import * as DemographicDataUtils from "../../src/utils/ab-testing/demographic-data.utils" import * as StorageUtils from "../../src/utils/storage.utils" @@ -21,6 +22,7 @@ export default function BeforeSurvey() { const localeSelected = StorageUtils.getLocaleInLocalStorage() const demographicData = DemographicDataUtils.getDemographicBeforeEpds() + const source = StorageUtils.getInLocalStorage(STORAGE_SOURCE) useEffect(() => { const resultatsCountQuery = async () => { @@ -31,7 +33,7 @@ export default function BeforeSurvey() { const goToEpdsSurvey = async () => { DemographicDataUtils.trackerForDemographie( - "Informations avant EPDS - Commencer le questionnaire" + `Informations avant EPDS - Commencer le questionnaire - ${source}` ) router.push({ @@ -39,9 +41,15 @@ export default function BeforeSurvey() { }) } + const goToNextPage = async () => { + source === "1000-premiers-jours" + ? await goToEpdsSurvey() + : await goToDemographicSurvey() + } + const goToDemographicSurvey = async () => { DemographicDataUtils.trackerForDemographie( - `Informations avant EPDS - ${demographicData?.buttonLabelInBeforeSurvey}` + `Informations avant EPDS - ${demographicData?.buttonLabelInBeforeSurvey} - ${source}` ) DemographicDataUtils.goToDemographicSurvey(router) } @@ -69,7 +77,8 @@ export default function BeforeSurvey() {
  • - Ce questionnaire est utilisé par les professionnels de santé. + Ce questionnaire est utilisé par les{" "} + professionnels de santé.
  • @@ -77,8 +86,8 @@ export default function BeforeSurvey() {
    Depuis son lancement en juillet 2021, les parents ont complété - {totalResultsCount.toLocaleString()} questionnaires sur leur - état émotionnel. + {totalResultsCount.toLocaleString()} questionnaires sur + leur état émotionnel.
    @@ -102,16 +111,10 @@ export default function BeforeSurvey() {
    -
    diff --git a/src/components/results/ContactMamanBlues.js b/src/components/results/ContactMamanBlues.js index 82261874..1352ab7e 100644 --- a/src/components/results/ContactMamanBlues.js +++ b/src/components/results/ContactMamanBlues.js @@ -2,7 +2,9 @@ import React from "react" import { Row } from "react-bootstrap" import {} from "@dataesr/react-dsfr" import { useRouter } from "next/router" +import { STORAGE_SOURCE } from "../../constants/constants" import * as TrackerUtils from "../../utils/tracker.utils" +import * as StorageUtils from "../../utils/storage.utils" export const buttonLabel = "Je veux être accompagné.e" @@ -25,10 +27,11 @@ export function ContactMamanBlues({ scoreLevel }) { } const goToBeContacted = async (event) => { + const source = StorageUtils.getInLocalStorage(STORAGE_SOURCE) TrackerUtils.track( TrackerUtils.CATEG.contact, `Macaron d'Elise ${TrackerUtils.EVENT_CLICK}`, - buttonLabel + `${buttonLabel} - ${source}` ) router.push({ diff --git a/src/utils/ab-testing/demographic-data.utils.js b/src/utils/ab-testing/demographic-data.utils.js index 8aaa3628..daf56a5a 100644 --- a/src/utils/ab-testing/demographic-data.utils.js +++ b/src/utils/ab-testing/demographic-data.utils.js @@ -98,7 +98,9 @@ export const availableRelativesValues = [ export const convertArraySituationsToString = (situations) => { let situationsString = "" situations.forEach((element) => { - situationsString += `${situationsString.length > 0 ? " / " : ""}${element.text}` + situationsString += `${situationsString.length > 0 ? " / " : ""}${ + element.text + }` }) return situationsString diff --git a/src/utils/contact.utils.js b/src/utils/contact.utils.js index fb32925e..107f5df4 100644 --- a/src/utils/contact.utils.js +++ b/src/utils/contact.utils.js @@ -10,6 +10,7 @@ import { * @param {RequestContact.type} contactType */ export const sendTrackerContactConfirmed = (contactType) => { + const source = StorageUtils.getInLocalStorage(STORAGE_SOURCE) TrackerUtils.genericTracker( TrackerUtils.CATEG.contact, TrackerUtils.NAME.contact_confirm_sent @@ -18,7 +19,7 @@ export const sendTrackerContactConfirmed = (contactType) => { TrackerUtils.track( TrackerUtils.CATEG.contact, TrackerUtils.ACTION.contact_confirm_sent, - trackerContactName(contactType) + `${trackerContactName(contactType)} - ${source}` ) } } @@ -40,8 +41,8 @@ export const sendTrackerContactType = (contactType) => { } } -const trackerContactName = (contactType) => { - switch (contactType) { +export const trackerContactName = (typeContact) => { + switch (typeContact) { case RequestContact.type.email: return TrackerUtils.CONTACT_SENT.mail case RequestContact.type.sms: