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

chore(metrics): add metrics to track search query in AL #9235

Merged
merged 4 commits into from
Nov 30, 2023
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
17 changes: 11 additions & 6 deletions packages/client/components/ActivityLibrary/ActivityLibrary.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as ScrollArea from '@radix-ui/react-scroll-area'
import graphql from 'babel-plugin-relay/macro'
import clsx from 'clsx'
import React, {useMemo} from 'react'
import React, {useEffect, useMemo} from 'react'
import {PreloadedQuery, commitLocalUpdate, usePreloadedQuery} from 'react-relay'
import {Redirect} from 'react-router'
import {Link} from 'react-router-dom'
Expand All @@ -27,6 +27,7 @@ import CreateActivityCard from './CreateActivityCard'
import SearchBar from './SearchBar'
import useAtmosphere from '../../hooks/useAtmosphere'
import SendClientSideEvent from '../../utils/SendClientSideEvent'
import {useDebounce} from 'use-debounce'

graphql`
fragment ActivityLibrary_templateSearchDocument on MeetingTemplate {
Expand Down Expand Up @@ -204,11 +205,6 @@ export const ActivityLibrary = (props: Props) => {
if (!viewer) return
viewer.setValue(value, 'activityLibrarySearch')
})
if (value.length > 2) {
SendClientSideEvent(atmosphere, 'Activity Library Searched', {
queryString: value
})
}
}

const templates = useMemo(() => {
Expand All @@ -227,6 +223,15 @@ export const ActivityLibrary = (props: Props) => {
onQueryChange,
resetQuery
} = useSearchFilter(templates, getTemplateDocumentValue)
const [queryString] = useDebounce(searchQuery, 500)
tianrunhe marked this conversation as resolved.
Show resolved Hide resolved

useEffect(() => {
if (queryString) {
SendClientSideEvent(atmosphere, 'Activity Library Searched', {
queryString
})
}
}, [queryString])

const {match} = useRouter<{categoryId?: string}>()
const {
Expand Down
3 changes: 2 additions & 1 deletion packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@
"tayden-clusterfck": "^0.7.0",
"tlds": "^1.192.0",
"tslib": "^2.4.0",
"unicode-substring": "^1.0.0"
"unicode-substring": "^1.0.0",
"use-debounce": "^10.0.0"
}
}
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -23289,6 +23289,11 @@ use-composed-ref@^1.3.0:
resolved "https://registry.yarnpkg.com/use-composed-ref/-/use-composed-ref-1.3.0.tgz#3d8104db34b7b264030a9d916c5e94fbe280dbda"
integrity sha512-GLMG0Jc/jiKov/3Ulid1wbv3r54K9HlMW29IWcDFPEqFkSO2nS0MuefWgMJpeHQ9YJeXDL3ZUF+P3jdXlZX/cQ==

use-debounce@^10.0.0:
version "10.0.0"
resolved "https://registry.yarnpkg.com/use-debounce/-/use-debounce-10.0.0.tgz#5091b18d6c16292605f588bae3c0d2cfae756ff2"
integrity sha512-XRjvlvCB46bah9IBXVnq/ACP2lxqXyZj0D9hj4K5OzNroMDpTEBg8Anuh1/UfRTRs7pLhQ+RiNxxwZu9+MVl1A==

use-isomorphic-layout-effect@^1.1.1:
version "1.1.2"
resolved "https://registry.yarnpkg.com/use-isomorphic-layout-effect/-/use-isomorphic-layout-effect-1.1.2.tgz#497cefb13d863d687b08477d9e5a164ad8c1a6fb"
Expand Down
Loading