Skip to content

Commit

Permalink
add analytical event
Browse files Browse the repository at this point in the history
  • Loading branch information
Danil49 committed Oct 29, 2024
1 parent c4fa959 commit 31ffce3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
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

0 comments on commit 31ffce3

Please sign in to comment.