Skip to content

Commit 26ed0e5

Browse files
authored
feat(sidebar-filter): measure when user types in the filter (#10912)
Adds new measurement `sidebar_filter_typed` when the user enters a value into the sidebar filter.
1 parent 7374117 commit 26ed0e5

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

Diff for: client/src/document/organisms/sidebar/filter.tsx

+23-1
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@ import { Button } from "../../../ui/atoms/button";
44

55
import "./filter.scss";
66
import { useGleanClick } from "../../../telemetry/glean-context";
7-
import { SIDEBAR_FILTER_FOCUS } from "../../../telemetry/constants";
7+
import {
8+
SIDEBAR_FILTER_FOCUS,
9+
SIDEBAR_FILTER_TYPED,
10+
} from "../../../telemetry/constants";
811

912
export function SidebarFilter() {
1013
const [isActive, setActive] = useState<Boolean>(false);
14+
const [hasTyped, setTyped] = useState<Boolean>(false);
1115
const { query, setQuery, matchCount } = useSidebarFilter();
1216
const gleanClick = useGleanClick();
1317

@@ -17,6 +21,24 @@ export function SidebarFilter() {
1721
}
1822
}, [gleanClick, isActive]);
1923

24+
useEffect(() => {
25+
if (query) {
26+
setTyped(true);
27+
}
28+
}, [query, setTyped]);
29+
30+
useEffect(() => {
31+
if (hasTyped) {
32+
gleanClick(SIDEBAR_FILTER_TYPED);
33+
}
34+
}, [gleanClick, hasTyped]);
35+
36+
useEffect(() => {
37+
if (!isActive) {
38+
setTyped(false);
39+
}
40+
}, [isActive, setTyped]);
41+
2042
return (
2143
<section className="sidebar-filter-container">
2244
<div className={`sidebar-filter ${query ? "has-input" : ""}`}>

Diff for: client/src/telemetry/constants.ts

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export const OFFER_OVERVIEW_CLICK = "offer_overview_click";
44
export const SIDEBAR_CLICK = "sidebar_click";
55
export const SIDEBAR_CLICK_WITH_FILTER = "sidebar_click_with_filter";
66
export const SIDEBAR_FILTER_FOCUS = "sidebar_filter_focus";
7+
export const SIDEBAR_FILTER_TYPED = "sidebar_filter_typed";
78
export const TOC_CLICK = "toc_click";
89
/** Replaced "top_nav_already_subscriber" in July 2023. */
910
export const TOP_NAV_LOGIN = "top_nav: login";

0 commit comments

Comments
 (0)