Skip to content

Commit

Permalink
feat: start tracking project tab navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
sjaanus committed Oct 25, 2024
1 parent bd44023 commit ff6ca92
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
13 changes: 12 additions & 1 deletion frontend/src/component/project/Project/Project.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import { ProjectApplications } from '../ProjectApplications/ProjectApplications'
import { ProjectInsights } from './ProjectInsights/ProjectInsights';
import useProjectOverview from 'hooks/api/getters/useProjectOverview/useProjectOverview';
import { ProjectArchived } from './ArchiveProject/ProjectArchived';
import { usePlausibleTracker } from '../../../hooks/usePlausibleTracker';

const StyledBadge = styled(Badge)(({ theme }) => ({
position: 'absolute',
Expand All @@ -65,6 +66,7 @@ interface ITab {

export const Project = () => {
const projectId = useRequiredPathParam('projectId');
const { trackEvent } = usePlausibleTracker();
const params = useQueryParams();
const { project, loading, error, refetch } = useProjectOverview(projectId);
const ref = useLoading(loading, '[data-loading-project=true]');
Expand Down Expand Up @@ -252,7 +254,16 @@ export const Project = () => {
key={tab.title}
label={tab.title}
value={tab.path}
onClick={() => navigate(tab.path)}
onClick={() => {
if (tab.title !== 'Flags') {
trackEvent('project-navigation', {
props: {
eventType: tab.title,
},
});
}
navigate(tab.path);
}}
data-testid={`TAB_${tab.title}`}
iconPosition={
tab.isEnterprise ? 'end' : undefined
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/hooks/usePlausibleTracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ export type CustomEvents =
| 'onboarding'
| 'personal-dashboard'
| 'order-environments'
| 'unleash-ai-chat';
| 'unleash-ai-chat'
| 'project-navigation';

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

0 comments on commit ff6ca92

Please sign in to comment.