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(sidebar-filter): measure when user types in the filter #10912

Merged
merged 2 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
24 changes: 23 additions & 1 deletion client/src/document/organisms/sidebar/filter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ import { Button } from "../../../ui/atoms/button";

import "./filter.scss";
import { useGleanClick } from "../../../telemetry/glean-context";
import { SIDEBAR_FILTER_FOCUS } from "../../../telemetry/constants";
import {
SIDEBAR_FILTER_FOCUS,
SIDEBAR_FILTER_TYPED,
} from "../../../telemetry/constants";

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

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

useEffect(() => {
if (hasTyped) {
gleanClick(SIDEBAR_FILTER_TYPED);
}
}, [gleanClick, hasTyped]);

useEffect(() => {
if (query) {
setTyped(true);
}
}, [query, setTyped]);
caugner marked this conversation as resolved.
Show resolved Hide resolved

useEffect(() => {
if (!isActive) {
setTyped(false);
}
}, [isActive, setTyped]);

return (
<section className="sidebar-filter-container">
<div className={`sidebar-filter ${query ? "has-input" : ""}`}>
Expand Down
1 change: 1 addition & 0 deletions client/src/telemetry/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export const OFFER_OVERVIEW_CLICK = "offer_overview_click";
export const SIDEBAR_CLICK = "sidebar_click";
export const SIDEBAR_CLICK_WITH_FILTER = "sidebar_click_with_filter";
export const SIDEBAR_FILTER_FOCUS = "sidebar_filter_focus";
export const SIDEBAR_FILTER_TYPED = "sidebar_filter_typed";
export const TOC_CLICK = "toc_click";
/** Replaced "top_nav_already_subscriber" in July 2023. */
export const TOP_NAV_LOGIN = "top_nav: login";
Expand Down
Loading