Skip to content

Commit

Permalink
feat: enlever csp pour la source 1000-premiers-jours (#141)
Browse files Browse the repository at this point in the history
* fix: chat desactiver après refresh de la page

* feat: enlever la page démo si source 1000-premiers-jours

* chore(release): 1.55.1

* feat: changer les tag des trackers en affichant la source

* fix: ajout des sources sur les trackers de mood + ab test + enlever le tracker demographique

* fix: test to match the source

* fix: remove unused package + variables

* fix: enlever les source du tracker de l'ab testing

* fix: unused import

* fix: source mal positionné sur le label

* fix: test

---------

Co-authored-by: Social Groovy Bot <[email protected]>
  • Loading branch information
mbarry-ippon and SocialGroovyBot authored Mar 21, 2023
1 parent 125674a commit 00ba18a
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 48 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@

# [1.56.0](https://github.com/SocialGouv/nos1000jours-blues-epds-widget/compare/v1.55.1...v1.56.0) (2023-03-20)


### Features

* 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)


Expand Down
11 changes: 6 additions & 5 deletions __tests__/utils/contact.utils.test.js
Original file line number Diff line number Diff line change
@@ -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")
})
Expand All @@ -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}`
)
})

Expand All @@ -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}`
)
})

Expand All @@ -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}`
)
})
})
Expand Down
17 changes: 2 additions & 15 deletions pages/contact/contact-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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))
}
}

Expand Down
11 changes: 7 additions & 4 deletions pages/contact/to-be-contacted.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -122,14 +121,15 @@ export default function ToBeContacted() {
}

const onValidate = async (_event) => {
const source = StorageUtils.getInLocalStorage(STORAGE_SOURCE)
TrackerUtils.genericTracker(
TrackerUtils.CATEG.contact,
TrackerUtils.NAME.contact_type
)
TrackerUtils.track(
TrackerUtils.CATEG.contact,
TrackerUtils.ACTION.contact_type,
itemValueType
`${itemValueType} - ${source}`
)
AbTestingUtils.trackerForAbTesting(itemValueType)

Expand Down Expand Up @@ -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 <p>Error</p>
const isChatActive = data.activationChat.activation_chat

return (
<>
{isChatEnabled && isChatActive && (
Expand Down
2 changes: 0 additions & 2 deletions pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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())
Expand Down
5 changes: 3 additions & 2 deletions pages/results.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 = () => (
<Row>
<div className="margin-bottom-8">
Expand Down Expand Up @@ -110,7 +111,7 @@ export default function Results() {
useEffect(() => {
if (levelMacaronText(scoreLevelForMood)) {
AbTestingUtils.trackerForAbTesting(
`Macaron Elise - ${levelMacaronText(scoreLevelForMood)}`
`Macaron Elise - ${levelMacaronText(scoreLevelForMood)} - ${source}`
)
}
}, [])
Expand Down
33 changes: 18 additions & 15 deletions pages/survey/before-survey.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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 () => {
Expand All @@ -31,17 +33,23 @@ export default function BeforeSurvey() {

const goToEpdsSurvey = async () => {
DemographicDataUtils.trackerForDemographie(
"Informations avant EPDS - Commencer le questionnaire"
`Informations avant EPDS - Commencer le questionnaire - ${source}`
)

router.push({
pathname: "/survey/epds-survey",
})
}

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)
}
Expand Down Expand Up @@ -69,16 +77,17 @@ export default function BeforeSurvey() {
<li className="item-information">
<img src={IMG_PRO} alt="" />
<div>
Ce questionnaire est utilisé par les <b>professionnels de santé.</b>
Ce questionnaire est utilisé par les{" "}
<b>professionnels de santé.</b>
</div>
</li>

<li className="item-information">
<img src={IMG_PARENTS} alt="" />
<div>
Depuis son lancement en juillet 2021, les parents ont complété
<b> {totalResultsCount.toLocaleString()} questionnaires </b>sur leur
état émotionnel.
<b> {totalResultsCount.toLocaleString()} questionnaires </b>sur
leur état émotionnel.
</div>
</li>

Expand All @@ -102,16 +111,10 @@ export default function BeforeSurvey() {
</div>

<div className="button-start-survey">
<button
className="fr-btn fr-btn--lg"
onClick={
demographicData?.buttonLabelInBeforeSurvey
? goToDemographicSurvey
: goToEpdsSurvey
}
>
{demographicData?.buttonLabelInBeforeSurvey ??
"Commencer le questionnaire"}
<button className="fr-btn fr-btn--lg" onClick={goToNextPage}>
{source === "1000-premiers-jours"
? "Commencer le questionnaire"
: "Suivant"}
</button>
</div>
</div>
Expand Down
5 changes: 4 additions & 1 deletion src/components/results/ContactMamanBlues.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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({
Expand Down
4 changes: 3 additions & 1 deletion src/utils/ab-testing/demographic-data.utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions src/utils/contact.utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -18,7 +19,7 @@ export const sendTrackerContactConfirmed = (contactType) => {
TrackerUtils.track(
TrackerUtils.CATEG.contact,
TrackerUtils.ACTION.contact_confirm_sent,
trackerContactName(contactType)
`${trackerContactName(contactType)} - ${source}`
)
}
}
Expand All @@ -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:
Expand Down

0 comments on commit 00ba18a

Please sign in to comment.