Openverse is a search engine for openly-licensed media. This monorepo includes all application code.
Add an analytics event for search results count (#5109)
NulledNinjacd37dafd173c
diff --git a/frontend/src/stores/media/index.ts b/frontend/src/stores/media/index.tsindex 8b5379ba8..d8194a433 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_countlet 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.tsindex a5f64862d..3a1c4fb2f 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: