Skip to content

Commit

Permalink
fix search item select event capturing
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-fornefeld committed Jan 12, 2025
1 parent 2d47c15 commit c5ade2f
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions apps/web/src/components/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,26 @@ function useAutocomplete({ close }: { close: () => void }) {
500
)

function navigate({ itemUrl }: { itemUrl?: string }) {
const navigate = ({
itemUrl,
state,
}: {
itemUrl?: string
state: AutocompleteState<Result>
}) => {
if (!itemUrl) {
return
}

console.log('query', state.query)

itemUrl = itemUrl.replace('(docs)/', '')

posthog.capture('docs search result click', {
query: autocompleteState.query,
query: state.query,
selected_url: itemUrl,
})

itemUrl = itemUrl.replace('(docs)/', '')
router.push(itemUrl)

if (
Expand Down

0 comments on commit c5ade2f

Please sign in to comment.