-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: evenement matomo pour les pages de détails
- Loading branch information
Showing
8 changed files
with
100 additions
and
75 deletions.
There are no files selected for viewing
62 changes: 62 additions & 0 deletions
62
ui/app/(accompagnateur)/context/FormationDetailsContext.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { createContext, useCallback, useContext, useEffect, useState } from "react"; | ||
import { FormationDetail } from "shared"; | ||
import { useMatomo } from "../hooks/useMatomo"; | ||
import { formationDetailToKey } from "../hooks/useFormationLink"; | ||
|
||
type DetailsHeaderSize = { | ||
headerHeight: number; | ||
resumeHeight: number; | ||
}; | ||
|
||
type DetailsHeaderSizeParams = { | ||
headerHeight?: number; | ||
resumeHeight?: number; | ||
}; | ||
|
||
const FormationDetailsContext = createContext<{ | ||
headersSize: DetailsHeaderSize; | ||
setHeadersSize: (params: DetailsHeaderSizeParams) => void; | ||
}>({ | ||
headersSize: { headerHeight: 0, resumeHeight: 0 }, | ||
setHeadersSize: (params: DetailsHeaderSizeParams) => {}, | ||
}); | ||
|
||
const FormationDetailsProvider = ({ | ||
formationDetail, | ||
children, | ||
}: { | ||
formationDetail: FormationDetail; | ||
children: React.ReactNode; | ||
}) => { | ||
const [headersSize, setHeadersSize] = useState({ headerHeight: 0, resumeHeight: 0 }); | ||
const matomo = useMatomo(); | ||
|
||
useEffect(() => { | ||
matomo.push(["trackEvent", "details", "uai", formationDetail.etablissement.uai]); | ||
matomo.push(["trackEvent", "details", "code", formationDetailToKey(formationDetail)]); | ||
}, [matomo, formationDetail]); | ||
|
||
const setHeaderSizeCb = useCallback( | ||
(newHeadersSize: DetailsHeaderSizeParams) => { | ||
setHeadersSize((prevState) => ({ ...prevState, ...newHeadersSize })); | ||
}, | ||
[setHeadersSize] | ||
); | ||
|
||
return ( | ||
<FormationDetailsContext.Provider | ||
value={{ | ||
headersSize, | ||
setHeadersSize: setHeaderSizeCb, | ||
}} | ||
> | ||
{children} | ||
</FormationDetailsContext.Provider> | ||
); | ||
}; | ||
|
||
export const useFormationsDetails = () => { | ||
return useContext(FormationDetailsContext); | ||
}; | ||
|
||
export default FormationDetailsProvider; |
47 changes: 0 additions & 47 deletions
47
ui/app/(accompagnateur)/context/FormationDetailsHeaderContext.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters