diff --git a/mon-entreprise/source/components/ShareSimulationBanner.tsx b/mon-entreprise/source/components/ShareSimulationBanner.tsx index a86c92ce0..8fe29312e 100644 --- a/mon-entreprise/source/components/ShareSimulationBanner.tsx +++ b/mon-entreprise/source/components/ShareSimulationBanner.tsx @@ -1,5 +1,6 @@ -import React, { useEffect, useState } from 'react' +import React, { useContext, useEffect, useState } from 'react' import { Trans, useTranslation } from 'react-i18next' +import { TrackerContext } from 'Components/utils/withTracker' import Animate from 'Components/ui/animate' import Banner from './Banner' import { LinkButton } from 'Components/ui/Button' @@ -11,6 +12,7 @@ export default function ShareSimulationBanner({ }) { const [opened, setOpened] = useState(false) const { t } = useTranslation() + const tracker = useContext(TrackerContext) const shareAPIAvailable = !!window?.navigator?.share @@ -22,7 +24,7 @@ export default function ShareSimulationBanner({ getShareSearchParams().toString(), ].join('') - const onClick = () => { + const startSharing = () => { if (shareAPIAvailable) { window.navigator.share({ title: document.title, @@ -64,7 +66,18 @@ export default function ShareSimulationBanner({ ) : ( Pour partager cette simulation :{' '} - Générer un lien dédié + { + tracker.push([ + 'trackEvent', + 'Partage simulation', + 'Partage démarré', + ]) + startSharing() + }} + > + Générer un lien dédié + )} @@ -75,6 +88,7 @@ function ShareSimulationPopup({ url }: { url: string }) { const inputRef: React.RefObject = React.createRef() const { t } = useTranslation() const [linkCopied, setLinkCopied] = useState(false) + const tracker = useContext(TrackerContext) const selectInput = () => inputRef.current?.select() useEffect(selectInput, []) @@ -98,6 +112,7 @@ function ShareSimulationPopup({ url }: { url: string }) { className="ui__ small simple link-button" style={{ marginLeft: '1rem' }} onClick={() => { + tracker.push(['trackEvent', 'Partage simulation', 'Texte copié']) navigator.clipboard.writeText(url) setLinkCopied(true) }}