Skip to content

Commit 85dfa43

Browse files
authored
[AI Search] debounce time 1ms -> 250ms + reduce frequency of search event instrumentation (#54755)
1 parent bd827f4 commit 85dfa43

3 files changed

Lines changed: 9 additions & 15 deletions

File tree

src/search/components/helpers/execute-search-actions.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -80,17 +80,7 @@ export async function executeCombinedSearch(
8080
query: string,
8181
debug = false,
8282
abortSignal?: AbortSignal,
83-
eventGroupId?: string,
8483
) {
85-
sendEvent({
86-
type: EventType.search,
87-
// TODO: Remove PII so we can include the actual query
88-
search_query: 'REDACTED',
89-
search_context: COMBINED_SEARCH_CONTEXT,
90-
eventGroupKey: SEARCH_OVERLAY_EVENT_GROUP,
91-
eventGroupId: eventGroupId,
92-
})
93-
9484
let language = router.locale || 'en'
9585

9686
const params = new URLSearchParams({ query: query, version, language })

src/search/components/hooks/useAISearchAutocomplete.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ type UseCombinedSearchProps = {
1414
router: NextRouter
1515
currentVersion: string
1616
debug: boolean
17-
eventGroupIdRef: React.MutableRefObject<string>
1817
}
1918

2019
type UseCombinedSearchReturn = {
@@ -26,7 +25,7 @@ type UseCombinedSearchReturn = {
2625
clearAutocompleteResults: () => void
2726
}
2827

29-
const DEBOUNCE_TIME = 1 // In milliseconds
28+
const DEBOUNCE_TIME = 250 // In milliseconds
3029

3130
// Results are only cached for the current session
3231
// We cache results so if a user presses backspace, we can show the results immediately without burdening the API
@@ -46,7 +45,6 @@ export function useCombinedSearchResults({
4645
router,
4746
currentVersion,
4847
debug,
49-
eventGroupIdRef,
5048
}: UseCombinedSearchProps): UseCombinedSearchReturn {
5149
const [searchOptions, setSearchOptions] = useState<SearchOptions>({
5250
aiAutocompleteOptions: [],
@@ -102,7 +100,6 @@ export function useCombinedSearchResults({
102100
queryValue,
103101
debug,
104102
controller.signal, // Pass in the signal to allow the request to be aborted
105-
eventGroupIdRef.current,
106103
)
107104

108105
const results = {

src/search/components/input/SearchOverlay.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ export function SearchOverlay({
105105
router,
106106
currentVersion,
107107
debug,
108-
eventGroupIdRef: searchEventGroupId,
109108
})
110109

111110
const { aiAutocompleteOptions, generalSearchResults, totalGeneralSearchResults } =
@@ -275,6 +274,14 @@ export function SearchOverlay({
275274

276275
// When a general option is selected, open the article in the current window
277276
const generalSearchResultOnSelect = (selectedOption: GeneralSearchHit) => {
277+
sendEvent({
278+
type: EventType.search,
279+
// TODO: Remove PII so we can include the actual query
280+
search_query: 'REDACTED',
281+
search_context: GENERAL_SEARCH_CONTEXT,
282+
eventGroupKey: SEARCH_OVERLAY_EVENT_GROUP,
283+
eventGroupId: searchEventGroupId.current,
284+
})
278285
sendEvent({
279286
type: EventType.searchResult,
280287
search_result_query: urlSearchInputQuery,

0 commit comments

Comments
 (0)