mirror of
https://github.com/Unleash/unleash.git
synced 2025-03-09 00:18:26 +01:00
chore: track personal dashboard navigation (#8417)
This PR adds plausible tracking for navigating to items from the personal dashboard. It tracks: - Navigating to projects from the list - Navigating to projects from the onboarding screen - Navigating to flags from the list - Opening the key concepts dialog
This commit is contained in:
parent
3427fd745c
commit
fcce0f852c
@ -1,4 +1,5 @@
|
|||||||
import { Button, styled, Typography } from '@mui/material';
|
import { Button, styled, Typography } from '@mui/material';
|
||||||
|
import { usePlausibleTracker } from 'hooks/usePlausibleTracker';
|
||||||
import type { FC } from 'react';
|
import type { FC } from 'react';
|
||||||
|
|
||||||
const TitleContainer = styled('div')(({ theme }) => ({
|
const TitleContainer = styled('div')(({ theme }) => ({
|
||||||
@ -45,6 +46,7 @@ const ActionBox = styled('div')(({ theme }) => ({
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
export const CreateFlag: FC<{ project: string }> = ({ project }) => {
|
export const CreateFlag: FC<{ project: string }> = ({ project }) => {
|
||||||
|
const { trackEvent } = usePlausibleTracker();
|
||||||
return (
|
return (
|
||||||
<ActionBox data-loading>
|
<ActionBox data-loading>
|
||||||
<TitleContainer>
|
<TitleContainer>
|
||||||
@ -56,7 +58,17 @@ export const CreateFlag: FC<{ project: string }> = ({ project }) => {
|
|||||||
<p>Create one to get started.</p>
|
<p>Create one to get started.</p>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<Button href={`projects/${project}`} variant='contained'>
|
<Button
|
||||||
|
href={`/projects/${project}`}
|
||||||
|
onClick={() => {
|
||||||
|
trackEvent('personal-dashboard', {
|
||||||
|
props: {
|
||||||
|
eventType: `Go to project from onboarding`,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
variant='contained'
|
||||||
|
>
|
||||||
Go to project
|
Go to project
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
@ -30,6 +30,7 @@ import {
|
|||||||
SpacedGridItem,
|
SpacedGridItem,
|
||||||
} from './Grid';
|
} from './Grid';
|
||||||
import { ContactAdmins, DataError } from './ProjectDetailsError';
|
import { ContactAdmins, DataError } from './ProjectDetailsError';
|
||||||
|
import { usePlausibleTracker } from 'hooks/usePlausibleTracker';
|
||||||
|
|
||||||
const ActiveProjectDetails: FC<{
|
const ActiveProjectDetails: FC<{
|
||||||
project: PersonalDashboardSchemaProjectsItem;
|
project: PersonalDashboardSchemaProjectsItem;
|
||||||
@ -70,6 +71,7 @@ const ProjectListItem: FC<{
|
|||||||
onClick: () => void;
|
onClick: () => void;
|
||||||
}> = ({ project, selected, onClick }) => {
|
}> = ({ project, selected, onClick }) => {
|
||||||
const activeProjectRef = useRef<HTMLLIElement>(null);
|
const activeProjectRef = useRef<HTMLLIElement>(null);
|
||||||
|
const { trackEvent } = usePlausibleTracker();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (activeProjectRef.current) {
|
if (activeProjectRef.current) {
|
||||||
@ -99,6 +101,13 @@ const ProjectListItem: FC<{
|
|||||||
href={`projects/${project.id}`}
|
href={`projects/${project.id}`}
|
||||||
size='small'
|
size='small'
|
||||||
sx={{ ml: 'auto' }}
|
sx={{ ml: 'auto' }}
|
||||||
|
onClick={() => {
|
||||||
|
trackEvent('personal-dashboard', {
|
||||||
|
props: {
|
||||||
|
eventType: `Go to project from list`,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<LinkIcon titleAccess={`projects/${project.id}`} />
|
<LinkIcon titleAccess={`projects/${project.id}`} />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
|
@ -35,6 +35,7 @@ import {
|
|||||||
} from './Grid';
|
} from './Grid';
|
||||||
import { ContentGridNoProjects } from './ContentGridNoProjects';
|
import { ContentGridNoProjects } from './ContentGridNoProjects';
|
||||||
import ExpandMore from '@mui/icons-material/ExpandMore';
|
import ExpandMore from '@mui/icons-material/ExpandMore';
|
||||||
|
import { usePlausibleTracker } from 'hooks/usePlausibleTracker';
|
||||||
|
|
||||||
export const StyledCardTitle = styled('div')<{ lines?: number }>(
|
export const StyledCardTitle = styled('div')<{ lines?: number }>(
|
||||||
({ theme, lines = 2 }) => ({
|
({ theme, lines = 2 }) => ({
|
||||||
@ -58,6 +59,7 @@ const FlagListItem: FC<{
|
|||||||
onClick: () => void;
|
onClick: () => void;
|
||||||
}> = ({ flag, selected, onClick }) => {
|
}> = ({ flag, selected, onClick }) => {
|
||||||
const activeFlagRef = useRef<HTMLLIElement>(null);
|
const activeFlagRef = useRef<HTMLLIElement>(null);
|
||||||
|
const { trackEvent } = usePlausibleTracker();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (activeFlagRef.current) {
|
if (activeFlagRef.current) {
|
||||||
@ -68,6 +70,7 @@ const FlagListItem: FC<{
|
|||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
const IconComponent = getFeatureTypeIcons(flag.type);
|
const IconComponent = getFeatureTypeIcons(flag.type);
|
||||||
|
const flagLink = `/projects/${flag.project}/features/${flag.name}`;
|
||||||
return (
|
return (
|
||||||
<ListItem
|
<ListItem
|
||||||
key={flag.name}
|
key={flag.name}
|
||||||
@ -85,13 +88,18 @@ const FlagListItem: FC<{
|
|||||||
<StyledCardTitle>{flag.name}</StyledCardTitle>
|
<StyledCardTitle>{flag.name}</StyledCardTitle>
|
||||||
<IconButton
|
<IconButton
|
||||||
component={Link}
|
component={Link}
|
||||||
href={`projects/${flag.project}/features/${flag.name}`}
|
href={flagLink}
|
||||||
|
onClick={() => {
|
||||||
|
trackEvent('personal-dashboard', {
|
||||||
|
props: {
|
||||||
|
eventType: `Go to flag from list`,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}}
|
||||||
size='small'
|
size='small'
|
||||||
sx={{ ml: 'auto' }}
|
sx={{ ml: 'auto' }}
|
||||||
>
|
>
|
||||||
<LinkIcon
|
<LinkIcon titleAccess={flagLink} />
|
||||||
titleAccess={`projects/${flag.project}/features/${flag.name}`}
|
|
||||||
/>
|
|
||||||
</IconButton>
|
</IconButton>
|
||||||
</ListItemBox>
|
</ListItemBox>
|
||||||
</ListItemButton>
|
</ListItemButton>
|
||||||
@ -256,6 +264,7 @@ const NoActiveFlagsInfo = styled('div')(({ theme }) => ({
|
|||||||
|
|
||||||
export const PersonalDashboard = () => {
|
export const PersonalDashboard = () => {
|
||||||
const { user } = useAuthUser();
|
const { user } = useAuthUser();
|
||||||
|
const { trackEvent } = usePlausibleTracker();
|
||||||
|
|
||||||
const name = user?.name;
|
const name = user?.name;
|
||||||
|
|
||||||
@ -306,7 +315,14 @@ export const PersonalDashboard = () => {
|
|||||||
}}
|
}}
|
||||||
size={'small'}
|
size={'small'}
|
||||||
variant='text'
|
variant='text'
|
||||||
onClick={() => setWelcomeDialog('open')}
|
onClick={() => {
|
||||||
|
trackEvent('personal-dashboard', {
|
||||||
|
props: {
|
||||||
|
eventType: 'open key concepts',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
setWelcomeDialog('open');
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
View key concepts
|
View key concepts
|
||||||
</ViewKeyConceptsButton>
|
</ViewKeyConceptsButton>
|
||||||
|
@ -68,7 +68,8 @@ export type CustomEvents =
|
|||||||
| 'search-opened'
|
| 'search-opened'
|
||||||
| 'events-exported'
|
| 'events-exported'
|
||||||
| 'event-timeline'
|
| 'event-timeline'
|
||||||
| 'onboarding';
|
| 'onboarding'
|
||||||
|
| 'personal-dashboard';
|
||||||
|
|
||||||
export const usePlausibleTracker = () => {
|
export const usePlausibleTracker = () => {
|
||||||
const plausible = useContext(PlausibleContext);
|
const plausible = useContext(PlausibleContext);
|
||||||
|
Loading…
Reference in New Issue
Block a user