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 TOGGLE_FILTER_SIDEBAR analytics event #2405

Merged
merged 8 commits into from
Jun 27, 2023
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ frontend/storybook-static
!frontend/.storybook

!.pnpmfile.cjs

frontend/src/locales
16 changes: 13 additions & 3 deletions frontend/src/components/VHeader/VHeaderDesktop.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ import VLogoButton from "~/components/VHeader/VLogoButton.vue"
import VSearchBarButton from "~/components/VHeader/VHeaderMobile/VSearchBarButton.vue"
import VSearchTypePopover from "~/components/VContentSwitcher/VSearchTypePopover.vue"

import type { Ref } from "vue"

/**
* The desktop search header.
*/
Expand All @@ -85,8 +87,8 @@ export default defineComponent({
const searchStore = useSearchStore()
const uiStore = useUiStore()

const isHeaderScrolled = inject(IsHeaderScrolledKey)
const isSidebarVisible = inject(IsSidebarVisibleKey)
const isHeaderScrolled = inject<Ref<boolean>>(IsHeaderScrolledKey)
const isSidebarVisible = inject<Ref<boolean>>(IsSidebarVisibleKey)

const isFetching = computed(() => mediaStore.fetchState.isFetching)

Expand All @@ -106,11 +108,19 @@ export default defineComponent({
document.activeElement?.blur()
updateSearchState()
}

const areFiltersDisabled = computed(
() => !searchStore.searchTypeIsSupported
)

const toggleSidebar = () => uiStore.toggleFilters()
const toggleSidebar = () => {
const state = isSidebarVisible?.value ? "closed" : "opened"
sendCustomEvent("TOGGLE_FILTER_SIDEBAR", {
mediaType: searchStore.searchType,
state,
zackkrida marked this conversation as resolved.
Show resolved Hide resolved
})
uiStore.toggleFilters()
}

const isXl = computed(() => uiStore.isBreakpoint("xl"))

Expand Down
11 changes: 11 additions & 0 deletions frontend/src/types/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,17 @@ export type Events = {
/** The name of the Vue component used to switch content types. */
component: string
}
/**
* Description: The visibility of the filter sidebar on desktop is toggled
* Questions:
* - Do a majority users prefer the sidebar visible or hidden?
*/
TOGGLE_FILTER_SIDEBAR: {
/** The media type being searched */
mediaType: SearchType
zackkrida marked this conversation as resolved.
Show resolved Hide resolved
/** The state of the filter sidebar after the user interaction. */
toState: "open" | "closed"
}
/**
* Description: The user clicks to a link outside of Openverse.
* Questions:
Expand Down