From 31ffce3f971278c07cc9133ebae1df4683ece814 Mon Sep 17 00:00:00 2001 From: Danil Date: Tue, 29 Oct 2024 12:24:28 +0100 Subject: [PATCH 1/2] 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: From 1813bf076fb178805093f3831e5dea91ec4cddb9 Mon Sep 17 00:00:00 2001 From: Danil Date: Fri, 1 Nov 2024 17:29:31 +0100 Subject: [PATCH 2/2] fix: lint files --- frontend/src/stores/media/index.ts | 2 +- frontend/src/types/analytics.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/stores/media/index.ts b/frontend/src/stores/media/index.ts index d4ef3529432..d8194a433ad 100644 --- a/frontend/src/stores/media/index.ts +++ b/frontend/src/stores/media/index.ts @@ -488,7 +488,7 @@ export const useMediaStore = defineStore("media", { $sendCustomEvent("GET_SEARCH_RESULTS", { mediaType: mediaType, query: queryParams.q, - resultsCount: mediaCount + resultsCount: mediaCount, }) } diff --git a/frontend/src/types/analytics.ts b/frontend/src/types/analytics.ts index 45a2dcf2f63..3a1c4fb2f35 100644 --- a/frontend/src/types/analytics.ts +++ b/frontend/src/types/analytics.ts @@ -78,7 +78,7 @@ export type Events = { /** the media type being searched */ mediaType: SupportedMediaType /** The search term */ - query: string, + query: string /** The number of results found for this search */ resultsCount: number }