Skip to content

Commit

Permalink
fix: rattrape/consolide matomo
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurlbrjc committed May 30, 2024
1 parent 85719a7 commit 4aba6c1
Show file tree
Hide file tree
Showing 54 changed files with 255 additions and 287 deletions.
15 changes: 5 additions & 10 deletions app/(connected)/(with-sidebar)/(with-chat)/(index)/HomePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@ import { StructureConseiller } from 'interfaces/conseiller'
import { Agence } from 'interfaces/referentiel'
import { AlerteParam } from 'referentiel/alerteParam'
import { useAlerte } from 'utils/alerteContext'
import {
trackEvent,
trackPage,
userStructureDimensionString,
} from 'utils/analytics/matomo'
import { trackEvent, trackPage } from 'utils/analytics/matomo'
import useMatomo from 'utils/analytics/useMatomo'
import { useConseiller } from 'utils/conseiller/conseillerContext'
import { usePortefeuille } from 'utils/portefeuilleContext'
Expand Down Expand Up @@ -62,8 +58,6 @@ function HomePage({
const [trackingLabel, setTrackingLabel] = useState<string>(
'Pop-in sélection agence'
)
const aDesBeneficiaires = portefeuille.length === 0 ? 'non' : 'oui'

async function selectAgence(agence: {
id?: string
nom: string
Expand All @@ -86,14 +80,15 @@ function HomePage({
categorie: 'Contact Support',
action: 'Pop-in sélection ' + etablissement,
nom: '',
avecBeneficiaires: aDesBeneficiaires,
aDesBeneficiaires: portefeuille.length > 0,
})
}

function trackAccederImilo() {
trackPage({
structure: userStructureDimensionString(StructureConseiller.MILO),
structure: StructureConseiller.MILO,
customTitle: 'Accès i-milo',
aDesBeneficiaires: portefeuille.length > 0,
})
}

Expand All @@ -102,7 +97,7 @@ function HomePage({
redirectToUrl()
}, [showModaleOnboarding, showModaleAgence, showModaleEmail])

useMatomo(trackingLabel, aDesBeneficiaires)
useMatomo(trackingLabel, portefeuille.length > 0)

return (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ function AgendaPage({ onglet, periodeIndexInitial }: AgendaPageProps) {
const router = useRouter()
const [alerte] = useAlerte()

const aDesBeneficiaires = portefeuille.length === 0 ? 'non' : 'oui'

const ongletProps: {
[key in Onglet]: { queryParam: string; trackingLabel: string }
} = {
Expand Down Expand Up @@ -158,7 +156,7 @@ function AgendaPage({ onglet, periodeIndexInitial }: AgendaPageProps) {
return initialTracking + ' ' + ongletProps[tab].trackingLabel
}

useMatomo(trackingTitle, aDesBeneficiaires)
useMatomo(trackingTitle, portefeuille.length > 0)

return (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ function EtablissementPage() {

const conseillerEstMilo = estMilo(conseiller)

const aDesBeneficiaires = portefeuille.length === 0 ? 'non' : 'oui'

async function rechercherJeunes(input: string, page: number) {
if (!input) {
setResultatsRecherche(undefined)
Expand Down Expand Up @@ -83,7 +81,7 @@ function EtablissementPage() {
setTrackingTitle(initialTracking + ' - ' + trackingMessage)
}

useMatomo(trackingTitle, aDesBeneficiaires)
useMatomo(trackingTitle, portefeuille.length > 0)

return (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,7 @@ function PortefeuillePage({
})
}, [chatCredentials, conseillerJeunes])

const adesBeneficiaires = conseillerJeunes.length === 0 ? 'non' : 'oui'

useMatomo(trackingTitle, adesBeneficiaires)
useMatomo(trackingTitle, conseillerJeunes.length > 0)

return (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,6 @@ function FicheBeneficiairePage({
initialTracking += ' - Succès envoi message'

const [trackingLabel, setTrackingLabel] = useState<string>(initialTracking)
const aDesBeneficiaires = portefeuille.length === 0 ? 'non' : 'oui'

const totalFavoris = metadonneesFavoris
? metadonneesFavoris.offres.total + metadonneesFavoris.recherches.total
: 0
Expand Down Expand Up @@ -267,7 +265,7 @@ function FicheBeneficiairePage({
setIdCurrentJeune(undefined)
}

useMatomo(trackingLabel, aDesBeneficiaires)
useMatomo(trackingLabel, portefeuille.length > 0)

useEffect(() => {
if (!lectureSeule) setIdCurrentJeune(jeune.id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ function DetailActionPage({
lectureSeule ? ' - hors portefeuille' : ''
}`
const [trackingTitle, setTrackingTitle] = useState<string>(initialTracking)
const aDesBeneficiaires = portefeuille.length === 0 ? 'non' : 'oui'

const conseillerEstMilo = estMilo(conseiller)
const estAQualifier = conseillerEstMilo && statut === StatutAction.Terminee
const qualifiee = conseillerEstMilo && statut === StatutAction.Qualifiee
Expand Down Expand Up @@ -99,7 +97,7 @@ function DetailActionPage({
alerte && alerte.key === AlerteParam.envoiMessage
? `${trackingTitle} - Succès envoi message`
: trackingTitle,
aDesBeneficiaires
portefeuille.length > 0
)
return (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,11 @@ function InformationsPage({
const conseillersTracking = `Détail jeune – Historique conseillers${
lectureSeule ? ' - hors portefeuille' : ''
}`
const aDesBeneficiaires = portefeuille.length === 0 ? 'non' : 'oui'
const [tracking, setTracking] = useState<string | undefined>()
const [tracking, setTracking] = useState<string>(switchTracking(onglet))

function switchTracking(onglet: Onglet) {
return onglet === 'INFORMATIONS' ? situationsTracking : conseillersTracking
}

useEffect(() => {
if (
Expand All @@ -89,13 +92,11 @@ function InformationsPage({

useEffect(() => {
if (currentTab) {
setTracking(
currentTab === 'INFORMATIONS' ? situationsTracking : conseillersTracking
)
setTracking(switchTracking(onglet))
}
}, [currentTab])

useMatomo(tracking, aDesBeneficiaires)
useMatomo(tracking, portefeuille.length > 0)
const pathPrefix = usePathname()?.startsWith('etablissement')
? '/etablissement/beneficiaires'
: '/mes-jeunes'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ function RendezVousPassesPage({
const trackingLabel = `Détail jeune - Rendez-vous passés ${
lectureSeule ? ' - hors portefeuille' : ''
}`
const aDesBeneficiaires = portefeuille.length === 0 ? 'non' : 'oui'

useMatomo(trackingLabel, aDesBeneficiaires)
useMatomo(trackingLabel, portefeuille.length > 0)

return (
<TableauRdvsBeneficiaire
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ function CreationJeuneMiloPage() {
const [erreurDossier, setErreurDossier] = useState<string | undefined>()
const [erreurCreation, setErreurCreation] = useState<string | undefined>()

const aDesBeneficiaires = portefeuille.length === 0 ? 'non' : 'oui'

async function rechercherDossier(id: string) {
clearDossier()

Expand Down Expand Up @@ -67,7 +65,7 @@ function CreationJeuneMiloPage() {
erreurDossier
? 'Création jeune SIMILO – Etape 1 - récuperation du dossier jeune en erreur'
: 'Création jeune SIMILO – Etape 1 - récuperation du dossier jeune',
aDesBeneficiaires
portefeuille.length > 0
)

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ function PoleEmploiCreationJeune(): ReactElement {
}
}

useMatomo(creationError ? 'Création jeune PE en erreur' : 'Création jeune PE')
useMatomo(
creationError ? 'Création jeune PE en erreur' : 'Création jeune PE',
portefeuille.length > 0
)

return (
<FormulaireJeunePoleEmploi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function ListesDiffusionPage({ listesDiffusion }: ListesDiffusionPageProps) {
ALPHABETIQUE
)

const aDesBeneficiaires = portefeuille.length === 0 ? 'non' : 'oui'
const aDesBeneficiaires = portefeuille.length > 0

function inverserTri() {
const nouvelOrdre = tri === ALPHABETIQUE ? INVERSE : ALPHABETIQUE
Expand All @@ -49,7 +49,7 @@ function ListesDiffusionPage({ listesDiffusion }: ListesDiffusionPageProps) {
categorie: 'Listes de diffusion',
action: 'Tri',
nom: nouvelOrdre,
avecBeneficiaires: aDesBeneficiaires,
aDesBeneficiaires,
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ function RechercheOffresPage() {
initialTracking += ' - Partage critères recherche succès'
const [trackingTitle, setTrackingTitle] = useState<string>(initialTracking)

const aDesBeneficiaires = portefeuille.length === 0 ? 'non' : 'oui'

function switchTypeOffre(type: TypeOffre) {
nettoyerResultats()
setQueryOffresEmploi({ hasError: false })
Expand Down Expand Up @@ -290,7 +288,7 @@ function RechercheOffresPage() {
`Recherche d’offres ${typeOffre ? typeOffreToTitle(typeOffre) + ' ' : ''}- ${postfix}`
}, [typeOffre, pageCourante])

useMatomo(trackingTitle, aDesBeneficiaires)
useMatomo(trackingTitle, portefeuille.length > 0)

return (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ function OffrePage({ offre }: DetailOffreProps) {
const [portefeuille] = usePortefeuille()
const [labelMatomo, setLabelMatomo] = useState<string>('Détail offre')

const aDesBeneficiaires = portefeuille.length === 0 ? 'non' : 'oui'

function getDetailOffre() {
switch (offre.type) {
case TypeOffre.EMPLOI:
Expand All @@ -36,7 +34,7 @@ function OffrePage({ offre }: DetailOffreProps) {
}
}

useMatomo(labelMatomo, aDesBeneficiaires)
useMatomo(labelMatomo, portefeuille.length > 0)

return getDetailOffre()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ function PilotagePage({
pageTracking + ' - Consultation ' + ongletProps[currentTab].trackingLabel
)

const aDesBeneficiaires = portefeuille.length === 0 ? 'non' : 'oui'

async function chargerActions(options: {
page: number
tri?: TriActionsAQualifier
Expand Down Expand Up @@ -160,7 +158,7 @@ function PilotagePage({
}
}, [conseiller.agence?.id])

useMatomo(trackingLabel, aDesBeneficiaires)
useMatomo(trackingLabel, portefeuille.length > 0)

return (
<>
Expand Down
13 changes: 5 additions & 8 deletions app/(connected)/(with-sidebar)/(with-chat)/profil/ProfilPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@ import ExternalLink from 'components/ui/Navigation/ExternalLink'
import InformationMessage from 'components/ui/Notifications/InformationMessage'
import { estMilo, StructureConseiller } from 'interfaces/conseiller'
import { Agence } from 'interfaces/referentiel'
import {
trackEvent,
trackPage,
userStructureDimensionString,
} from 'utils/analytics/matomo'
import { trackEvent, trackPage } from 'utils/analytics/matomo'
import useMatomo from 'utils/analytics/useMatomo'
import { useConseiller } from 'utils/conseiller/conseillerContext'
import { usePortefeuille } from 'utils/portefeuilleContext'
Expand Down Expand Up @@ -58,7 +54,7 @@ function ProfilPage({ referentielAgences }: ProfilProps) {

const labelAgence = conseillerEstMilo ? 'Mission Locale' : 'agence'
const [trackingLabel, setTrackingLabel] = useState<string>('Profil')
const aDesBeneficiaires = portefeuille.length === 0 ? 'non' : 'oui'
const aDesBeneficiaires = portefeuille.length > 0

async function toggleNotificationsSonores(e: ChangeEvent<HTMLInputElement>) {
const conseillerMisAJour = {
Expand Down Expand Up @@ -119,14 +115,15 @@ function ProfilPage({ referentielAgences }: ProfilProps) {
categorie: 'Contact Support',
action: 'Profil',
nom: '',
avecBeneficiaires: aDesBeneficiaires,
aDesBeneficiaires,
})
}

function trackAccederAIMilo() {
trackPage({
structure: userStructureDimensionString(StructureConseiller.MILO),
customTitle: 'Accès i-milo',
structure: StructureConseiller.MILO,
aDesBeneficiaires,
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,6 @@ function ReaffectationPage({ estSuperviseurPEBRSA }: ReaffectationProps) {
'Réaffectation jeunes – Etape 1 – Saisie mail cons. ini.'
)

const aDesBeneficiaires = portefeuille.length === 0 ? 'non' : 'oui'

const numerosEtapes: NumeroEtape[] = estSuperviseurPEBRSA
? [2, 3, 4, 5]
: [1, 2, 3, 4]
Expand Down Expand Up @@ -340,7 +338,7 @@ function ReaffectationPage({ estSuperviseurPEBRSA }: ReaffectationProps) {
return !conseillerInitial.value && conseillerInitial.error
}

useMatomo(trackingTitle, aDesBeneficiaires)
useMatomo(trackingTitle, portefeuille.length > 0)

return (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function DetailsSessionPage({
const [portefeuille] = usePortefeuille()
const [conseiller] = useConseiller()

const aDesBeneficiaires = portefeuille.length === 0 ? 'non' : 'oui'
const aDesBeneficiaires = portefeuille.length > 0
const inputBeneficiaires = useRef<HTMLInputElement>(null)

const [visibiliteSession, setVisibiliteSession] = useState<boolean>(
Expand Down Expand Up @@ -127,7 +127,7 @@ function DetailsSessionPage({
categorie: 'Session i-milo',
action: 'clic visibilité agenda',
nom: '',
avecBeneficiaires: aDesBeneficiaires ? 'oui' : 'non',
aDesBeneficiaires,
})
}

Expand Down Expand Up @@ -272,11 +272,11 @@ function DetailsSessionPage({
categorie: 'Emargement',
action: 'Export des inscrits à une session',
nom: '',
avecBeneficiaires: aDesBeneficiaires,
aDesBeneficiaires,
})
}

useMatomo(trackingLabel)
useMatomo(trackingLabel, aDesBeneficiaires)

return (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { AlerteParam } from 'referentiel/alerteParam'
import { useAlerte } from 'utils/alerteContext'
import useMatomo from 'utils/analytics/useMatomo'
import { useConseiller } from 'utils/conseiller/conseillerContext'
import { usePortefeuille } from 'utils/portefeuilleContext'

type ClotureSessionProps = {
session: Session
Expand All @@ -40,6 +41,7 @@ function ClotureSessionPage({
const router = useRouter()
const [_, setAlerte] = useAlerte()
const [conseiller] = useConseiller()
const [portefeuille] = usePortefeuille()
const toutSelectionnerCheckboxRef = useRef<HTMLInputElement | null>(null)

const [idsSelectionnes, setIdsSelectionnes] = useState<string[]>([])
Expand Down Expand Up @@ -183,7 +185,7 @@ function ClotureSessionPage({
}
}

useMatomo(trackingLabel)
useMatomo(trackingLabel, portefeuille.length > 0)

return (
<>
Expand Down
Loading

0 comments on commit 4aba6c1

Please sign in to comment.