From 0c09852f5047975f49c91dbe92e1a290ceb84d08 Mon Sep 17 00:00:00 2001 From: Olga Bulat Date: Thu, 7 Nov 2024 10:57:01 +0300 Subject: [PATCH] Handle collections in GET_SEARCH_RESULTS --- frontend/src/stores/media/index.ts | 6 +++++- frontend/src/stores/search.ts | 2 +- frontend/src/types/analytics.ts | 4 +--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/frontend/src/stores/media/index.ts b/frontend/src/stores/media/index.ts index d8194a433a..ce6c0d906c 100644 --- a/frontend/src/stores/media/index.ts +++ b/frontend/src/stores/media/index.ts @@ -485,9 +485,13 @@ export const useMediaStore = defineStore("media", { let errorData: FetchingError | undefined if (page == 1) { + const searchStore = useSearchStore() + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const { searchType, ...paramsWithoutSearchType } = + searchStore.searchParamsForEvent $sendCustomEvent("GET_SEARCH_RESULTS", { + ...paramsWithoutSearchType, mediaType: mediaType, - query: queryParams.q, resultsCount: mediaCount, }) } diff --git a/frontend/src/stores/search.ts b/frontend/src/stores/search.ts index 82438409bc..4075e84ac4 100644 --- a/frontend/src/stores/search.ts +++ b/frontend/src/stores/search.ts @@ -244,7 +244,7 @@ export const useSearchStore = defineStore("search", { searchParamsForEvent(): SearchParamsForEvent { return { kind: this.strategy === "default" ? "search" : "collection", - query: this.searchTerm, + query: this.strategy === "default" ? this.searchTerm : "null", searchType: isSearchTypeSupported(this.searchType) ? this.searchType : ALL_MEDIA, diff --git a/frontend/src/types/analytics.ts b/frontend/src/types/analytics.ts index 7e63ac2878..006e18b25c 100644 --- a/frontend/src/types/analytics.ts +++ b/frontend/src/types/analytics.ts @@ -88,11 +88,9 @@ export type Events = { * - How often are searches returning fewer than one page of results? * - How many results do most searches yield? */ - GET_SEARCH_RESULTS: { + GET_SEARCH_RESULTS: Omit & { /** the media type being searched */ mediaType: SupportedMediaType - /** The search term */ - query: string /** The number of results found for this search */ resultsCount: number }