mirror of
https://github.com/Unleash/unleash.git
synced 2025-10-18 11:14:57 +02:00
chore: add project-list-view-toggle Plausible event (#10468)
https://linear.app/unleash/issue/2-3754/add-plausible-event-project-list-view-toggle-with-view Adds a `project-list-view-toggle` Plausible event with a `view` prop so we can track if and how the new toggle is used.
This commit is contained in:
parent
18c9ea1d7d
commit
54a0f68c9c
@ -2,6 +2,7 @@ import { IconButton, Tooltip } from '@mui/material';
|
|||||||
import type { ProjectsListView } from '../hooks/useProjectsListState.js';
|
import type { ProjectsListView } from '../hooks/useProjectsListState.js';
|
||||||
import FormatListBulletedIcon from '@mui/icons-material/FormatListBulleted';
|
import FormatListBulletedIcon from '@mui/icons-material/FormatListBulleted';
|
||||||
import GridViewIcon from '@mui/icons-material/GridView';
|
import GridViewIcon from '@mui/icons-material/GridView';
|
||||||
|
import { usePlausibleTracker } from 'hooks/usePlausibleTracker.js';
|
||||||
|
|
||||||
type ProjectsListViewToggleProps = {
|
type ProjectsListViewToggleProps = {
|
||||||
view: ProjectsListView;
|
view: ProjectsListView;
|
||||||
@ -12,11 +13,21 @@ export const ProjectsListViewToggle = ({
|
|||||||
view,
|
view,
|
||||||
setView,
|
setView,
|
||||||
}: ProjectsListViewToggleProps) => {
|
}: ProjectsListViewToggleProps) => {
|
||||||
|
const { trackEvent } = usePlausibleTracker();
|
||||||
const nextView = view === 'list' ? 'cards' : 'list';
|
const nextView = view === 'list' ? 'cards' : 'list';
|
||||||
|
|
||||||
|
const onSetView = (newView: ProjectsListView) => {
|
||||||
|
setView(newView);
|
||||||
|
trackEvent('project-list-view-toggle', {
|
||||||
|
props: {
|
||||||
|
view: newView,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Tooltip title={`Switch to ${nextView} view`} arrow>
|
<Tooltip title={`Switch to ${nextView} view`} arrow>
|
||||||
<IconButton size='small' onClick={() => setView(nextView)}>
|
<IconButton size='small' onClick={() => onSetView(nextView)}>
|
||||||
{nextView === 'list' ? (
|
{nextView === 'list' ? (
|
||||||
<FormatListBulletedIcon />
|
<FormatListBulletedIcon />
|
||||||
) : (
|
) : (
|
||||||
|
@ -74,7 +74,8 @@ export type CustomEvents =
|
|||||||
| 'project-navigation'
|
| 'project-navigation'
|
||||||
| 'productivity-report'
|
| 'productivity-report'
|
||||||
| 'release-management'
|
| 'release-management'
|
||||||
| 'feature-links';
|
| 'feature-links'
|
||||||
|
| 'project-list-view-toggle';
|
||||||
|
|
||||||
export const usePlausibleTracker = () => {
|
export const usePlausibleTracker = () => {
|
||||||
const plausible = useContext(PlausibleContext);
|
const plausible = useContext(PlausibleContext);
|
||||||
|
Loading…
Reference in New Issue
Block a user