Skip to content

Commit

Permalink
Merge pull request #120 from gabriel-dantas98/feat/add-analytics-to-s…
Browse files Browse the repository at this point in the history
…earch-bar

feat: add analytics events to search
  • Loading branch information
drodil authored Feb 5, 2024
2 parents f897010 + 32b3195 commit 25f7977
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import FilterList from '@material-ui/icons/FilterList';
import { useSearchParams } from 'react-router-dom';
import { AskQuestionButton } from '../Buttons/AskQuestionButton';
import { EntityRefLink } from '@backstage/plugin-catalog-react';
import { useAnalytics } from '@backstage/core-plugin-api';

export interface QuestionsContainerProps {
tags?: string[];
Expand All @@ -40,6 +41,7 @@ export const QuestionsContainer = (props: QuestionsContainerProps) => {
showAskButton,
showNoQuestionsBtn,
} = props;
const analytics = useAnalytics();
const [page, setPage] = React.useState(1);
const [questionsPerPage, setQuestionsPerPage] = React.useState(10);
const [showFilterPanel, setShowFilterPanel] = React.useState(false);
Expand Down Expand Up @@ -87,6 +89,9 @@ export const QuestionsContainer = (props: QuestionsContainerProps) => {

const onSearchQueryChange = (event: React.ChangeEvent<HTMLInputElement>) => {
onPageChange(1);
if (event.target.value) {
analytics.captureEvent('qeta_search', event.target.value);
}
setSearchQuery(event.target.value);
};

Expand Down

0 comments on commit 25f7977

Please sign in to comment.