diff --git a/assets/scripts/components/widgets/SearchBar.tsx b/assets/scripts/components/widgets/SearchBar.tsx index a5049e671..6eecb007b 100644 --- a/assets/scripts/components/widgets/SearchBar.tsx +++ b/assets/scripts/components/widgets/SearchBar.tsx @@ -1,5 +1,4 @@ import React, { useEffect, ChangeEvent, useState } from 'react'; -import { useLocation } from 'react-router-dom'; import styled from 'styled-components'; import { useSearchTerritoryQuery } from '@services/api'; import useDebounce from '@hooks/useDebounce'; @@ -8,6 +7,7 @@ import Loader from '@components/ui/Loader'; interface SearchBarProps { createUrl: string; + origin?: string; } export interface Territory { @@ -122,7 +122,7 @@ const NoResultsMessage = styled.div` text-align: center; `; -const SearchBar: React.FC = ({ createUrl }) => { +const SearchBar: React.FC = ({ createUrl, origin }) => { const [query, setQuery] = useState(''); const [isFocused, setIsFocused] = useState(false); const [data, setData] = useState(undefined); @@ -133,7 +133,6 @@ const SearchBar: React.FC = ({ createUrl }) => { const { data: queryData, isFetching } = useSearchTerritoryQuery(debouncedQuery, { skip: shouldQueryBeSkipped, }); - const location = useLocation(); useEffect(() => { if (shouldQueryBeSkipped || isFetching) { @@ -162,13 +161,13 @@ const SearchBar: React.FC = ({ createUrl }) => { setIsSubmitting(true); - if (location.pathname === "/" && window.trackEvent) { + if (origin === "home" && window.trackEvent) { window.trackEvent( 'north_star_activation_funnel', 'search_territory', 'step_1_north_star_activation_funnel' ); - } else if (location.pathname === "/rapport-local" && window.trackEvent) { + } else if (origin === "rapport-local" && window.trackEvent) { window.trackEvent( 'local_report_download_funnel', 'search_territory', diff --git a/assets/scripts/react-roots.tsx b/assets/scripts/react-roots.tsx index 2708e8613..a406a9377 100644 --- a/assets/scripts/react-roots.tsx +++ b/assets/scripts/react-roots.tsx @@ -11,9 +11,10 @@ const searchBar = document.getElementById('react-search-bar') if (searchBar) { const createUrl = searchBar.dataset.createUrl; + const origin = searchBar.dataset.origin; createRoot(searchBar).render( - + , ) } diff --git a/home/templates/home/home.html b/home/templates/home/home.html index 8e1cffb5a..c2be692f3 100644 --- a/home/templates/home/home.html +++ b/home/templates/home/home.html @@ -35,7 +35,7 @@

Mon Diagnostic Artificialisation vous aide à analyser et ma - + diff --git a/home/templates/home/home_rapport_local.html b/home/templates/home/home_rapport_local.html index 13b479738..b73516d36 100644 --- a/home/templates/home/home_rapport_local.html +++ b/home/templates/home/home_rapport_local.html @@ -34,7 +34,7 @@

Préparer le rapport triennal local de suivi de l’artifici - +