docs: enable and send algolia events (#12416)

This commit is contained in:
Shahed Nasser
2025-05-08 18:59:21 +03:00
committed by GitHub
parent c2914f2ebd
commit 7c7e44d9fe
3 changed files with 3 additions and 165 deletions
@@ -102,7 +102,7 @@ export const SearchHits = ({
setNoResults,
checkInternalPattern,
}: SearchHitsProps) => {
const { items: hits } = useHits<HitType>()
const { items: hits, sendEvent } = useHits<HitType>()
const { status } = useInstantSearch()
const { setIsOpen } = useSearch()
@@ -182,6 +182,7 @@ export const SearchHits = ({
className="absolute top-0 left-0 h-full w-full"
target="_self"
onClick={(e) => {
sendEvent("click", item, "Search Result Clicked")
if (checkIfInternal(item.url)) {
e.preventDefault()
window.location.href = item.url
@@ -107,6 +107,7 @@ export const Search = ({
future={{
preserveSharedStateOnUnmount: true,
}}
insights={true}
>
<div className={clsx("bg-medusa-bg-base flex z-[1]")}>
{/* @ts-expect-error React v19 doesn't see this type as a React element */}