Skip to content

Commit

Permalink
feat: track search bar events (#6021)
Browse files Browse the repository at this point in the history
Adding tracking for 2 views, when users use the new search. 

For features view and project view.
  • Loading branch information
sjaanus committed Jan 24, 2024
1 parent 3310334 commit e4ca8a3
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
@@ -1,5 +1,5 @@
import { render } from 'utils/testRenderer';
import { screen, within } from '@testing-library/react';
import { screen } from '@testing-library/react';
import { StrategyDiff } from './StrategyTooltipLink';
import { IFeatureStrategy } from 'interfaces/strategy';
import { IChangeRequestUpdateStrategy } from 'component/changeRequest/changeRequest.types';
Expand Down
Expand Up @@ -286,7 +286,15 @@ const FeatureToggleListTableComponent: VFC = () => {
}
}, [isSmallScreen, isMediumScreen]);

const setSearchValue = (query = '') => setTableState({ query });
const setSearchValue = (query = '') => {
setTableState({ query });
trackEvent('search-bar', {
props: {
screen: 'features',
length: query.length,
},
});
};

const rows = table.getRowModel().rows;

Expand Down
Expand Up @@ -20,6 +20,7 @@ import { getCreateTogglePath } from 'utils/routePathHelpers';
import { CREATE_FEATURE } from 'component/providers/AccessProvider/permissions';
import { ExportDialog } from 'component/feature/FeatureToggleList/ExportDialog';
import { FeatureSchema } from 'openapi';
import { usePlausibleTracker } from 'hooks/usePlausibleTracker';

interface IProjectFeatureTogglesHeaderProps {
isLoading?: boolean;
Expand Down Expand Up @@ -53,8 +54,15 @@ export const ProjectFeatureTogglesHeader: VFC<
const featuresExportImportFlag = useUiFlag('featuresExportImport');
const [showExportDialog, setShowExportDialog] = useState(false);
const navigate = useNavigate();
const { trackEvent } = usePlausibleTracker();
const handleSearch = (query: string) => {
onChangeSearchQuery?.(query);
trackEvent('search-bar', {
props: {
screen: 'project',
length: query.length,
},
});
};

return (
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/hooks/usePlausibleTracker.ts
Expand Up @@ -56,7 +56,8 @@ export type CustomEvents =
| 'search-feature-buttons'
| 'new-strategy-form'
| 'feedback'
| 'feature-metrics';
| 'feature-metrics'
| 'search-bar';

export const usePlausibleTracker = () => {
const plausible = useContext(PlausibleContext);
Expand Down

0 comments on commit e4ca8a3

Please sign in to comment.