Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an analytics event for search results count #5109

Merged
merged 4 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions frontend/src/stores/media/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
15 changes: 15 additions & 0 deletions frontend/src/types/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading