Skip to content

Commit

Permalink
feat: capture tab changes to analytics
Browse files Browse the repository at this point in the history
closes #29
  • Loading branch information
drodil committed Mar 27, 2023
1 parent 444e53d commit b36b061
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions plugins/toolbox/src/components/Root/ToolsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { defaultTools } from './tools';
import OpenInNew from '@material-ui/icons/OpenInNew';
import { FavoriteButton } from '../Buttons/FavoriteButton';
import { useLocation, useNavigate } from 'react-router-dom';
import { useAnalytics } from '@backstage/core-plugin-api';

export type Tool = {
id: string;
Expand Down Expand Up @@ -59,6 +60,7 @@ export const ToolsPage = (props: ToolsPageProps) => {
const { extraTools } = props;
const { hash } = useLocation();
const navigate = useNavigate();
const analytics = useAnalytics();
const [value, setValue] = React.useState(1);
const [search, setSearch] = React.useState('');
const favorites = useFavoriteStorage();
Expand Down Expand Up @@ -153,6 +155,9 @@ export const ToolsPage = (props: ToolsPageProps) => {
const handleChange = (_: any, newValue: number) => {
const tab = tabs[newValue];
if (tab) {
analytics.captureEvent('click', tab.id, {
attributes: { toolName: tab.title },
});
navigate(`#${tab.id}`);
}
};
Expand Down

0 comments on commit b36b061

Please sign in to comment.