Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(analytics): Track search events #241

Merged
merged 23 commits into from
Apr 25, 2023
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
da1b8ce
Implement new search UI
half0wl Apr 20, 2023
d07b7a7
Move "no results" into its own component
half0wl Apr 24, 2023
8020723
re-lock dependencies
half0wl Apr 24, 2023
bb09a55
Refactor: Move search logic into reusable hooks
half0wl Apr 24, 2023
0583ee8
Refactor: clean up, combine useSearchIndex
half0wl Apr 24, 2023
eec4afc
Refactor: Separate QueryInput, add ability to clear results
half0wl Apr 24, 2023
0eb5515
Cleanup
half0wl Apr 24, 2023
c5f4e0e
Tweak UI
half0wl Apr 24, 2023
3e4a77c
Cleanup: Remove unused types
half0wl Apr 24, 2023
b7d5546
feat(analytics): Track search events
half0wl Apr 24, 2023
011bdc4
Move searchParams out; lower debounce ms
half0wl Apr 24, 2023
3a36133
UI: Make "Clear" button smaller
half0wl Apr 24, 2023
035fc9a
Remove OpenSearchModalButton from mobile nav
half0wl Apr 24, 2023
fc48cae
Revert "Remove OpenSearchModalButton from mobile nav"
half0wl Apr 24, 2023
9f2ab5d
cleanup
half0wl Apr 24, 2023
427bf81
Merge branch 'feat/new-search-ui' into feat/search-analytics
half0wl Apr 24, 2023
5f05d07
Refactor to a generic response transformation method
half0wl Apr 24, 2023
c016b15
Remove redundant `Array.from`
half0wl Apr 24, 2023
82a2878
Remove baseUri from slug
half0wl Apr 24, 2023
1d7d8e8
fix: close modal on result click
half0wl Apr 24, 2023
e6494c8
Merge branch 'main' into feat/new-search-ui
half0wl Apr 25, 2023
2744558
Merge branch 'feat/new-search-ui' into feat/search-analytics
half0wl Apr 25, 2023
428f85c
Merge branch 'main' into feat/search-analytics
half0wl Apr 25, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/hooks/useDebouncedSearch.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { Search } from "@/types";
import { trackGoal } from "fathom-client";
import { MeiliSearch, SearchParams, SearchResponse } from "meilisearch";
import { useCallback, useEffect, useMemo, useState } from "react";

const FATHOM_SEARCH_PERFORMED_EVT_ID = "IMSTAYP4";

type Transformer<Source, Result extends any> = (
src: SearchResponse<Source>,
) => Result;
Expand Down Expand Up @@ -102,6 +105,7 @@ export const useDebouncedSearch = <
}
try {
const response = await index.search<Response>(query, params);
trackGoal(FATHOM_SEARCH_PERFORMED_EVT_ID, 0);
setResults(transformResponse(response));
} catch (e) {
console.error(`Search for query "${query}" failed (${e})`);
Expand Down