From 31ffce3f971278c07cc9133ebae1df4683ece814 Mon Sep 17 00:00:00 2001 From: Danil Date: Tue, 29 Oct 2024 12:24:28 +0100 Subject: [PATCH] add analytical event --- frontend/src/stores/media/index.ts | 9 +++++++++ frontend/src/types/analytics.ts | 15 +++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/frontend/src/stores/media/index.ts b/frontend/src/stores/media/index.ts index 8b5379ba89c..d4ef3529432 100644 --- a/frontend/src/stores/media/index.ts +++ b/frontend/src/stores/media/index.ts @@ -483,6 +483,15 @@ export const useMediaStore = defineStore("media", { } const mediaCount = data.result_count let errorData: FetchingError | undefined + + if (page == 1) { + $sendCustomEvent("GET_SEARCH_RESULTS", { + mediaType: mediaType, + query: queryParams.q, + resultsCount: mediaCount + }) + } + /** * When there are no results for a query, the API returns a 200 response. * In such cases, we show the "No results" client error page. diff --git a/frontend/src/types/analytics.ts b/frontend/src/types/analytics.ts index a5f64862d64..45a2dcf2f63 100644 --- a/frontend/src/types/analytics.ts +++ b/frontend/src/types/analytics.ts @@ -67,6 +67,21 @@ export type Events = { /** The search term */ query: string } + /** + * Description: Records the results returned for a user's search query + * Questions: + * - What popular searches yield no results? + * - How often are searches returning fewer than one page of results? + * - How many results do most searches yield? + */ + GET_SEARCH_RESULTS: { + /** the media type being searched */ + mediaType: SupportedMediaType + /** The search term */ + query: string, + /** The number of results found for this search */ + resultsCount: number + } /** * Description: The user clicks on one of the images in the gallery on the homepage. * Questions: