mirror of
https://github.com/Unleash/unleash.git
synced 2025-04-24 01:18:01 +02:00
feat: sdk reporting tracker (#6378)
This commit is contained in:
parent
df93827002
commit
84400323d6
@ -4,10 +4,11 @@ import { ConditionallyRender } from '../common/ConditionallyRender/Conditionally
|
|||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
import { FC, useLayoutEffect, useRef, useState } from 'react';
|
import { FC, useLayoutEffect, useRef, useState } from 'react';
|
||||||
import { ApplicationOverviewSchema } from '../../openapi';
|
import { ApplicationOverviewSchema } from '../../openapi';
|
||||||
import { useRequiredPathParam } from '../../hooks/useRequiredPathParam';
|
import { useRequiredPathParam } from 'hooks/useRequiredPathParam';
|
||||||
import { HelpIcon } from '../common/HelpIcon/HelpIcon';
|
import { HelpIcon } from '../common/HelpIcon/HelpIcon';
|
||||||
import { CloudCircle, Flag, WarningAmberRounded } from '@mui/icons-material';
|
import { CloudCircle, Flag, WarningAmberRounded } from '@mui/icons-material';
|
||||||
import TimeAgo from 'react-timeago';
|
import TimeAgo from 'react-timeago';
|
||||||
|
import { usePlausibleTracker } from 'hooks/usePlausibleTracker';
|
||||||
|
|
||||||
const StyledTable = styled('table')(({ theme }) => ({
|
const StyledTable = styled('table')(({ theme }) => ({
|
||||||
fontSize: theme.fontSizes.smallerBody,
|
fontSize: theme.fontSizes.smallerBody,
|
||||||
@ -161,7 +162,19 @@ const ApplicationCounters = ({
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const useTracking = () => {
|
||||||
|
const { trackEvent } = usePlausibleTracker();
|
||||||
|
return () => {
|
||||||
|
trackEvent('sdk-reporting', {
|
||||||
|
props: {
|
||||||
|
eventType: 'environment box clicked',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
export const ApplicationChart = ({ data }: IApplicationChartProps) => {
|
export const ApplicationChart = ({ data }: IApplicationChartProps) => {
|
||||||
|
const trackClick = useTracking();
|
||||||
const applicationName = useRequiredPathParam('name');
|
const applicationName = useRequiredPathParam('name');
|
||||||
const { elementRef, width } = useElementWidth();
|
const { elementRef, width } = useElementWidth();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
@ -239,6 +252,7 @@ export const ApplicationChart = ({ data }: IApplicationChartProps) => {
|
|||||||
key={environment.name}
|
key={environment.name}
|
||||||
sx={{ cursor: 'pointer' }}
|
sx={{ cursor: 'pointer' }}
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
|
trackClick();
|
||||||
navigate(
|
navigate(
|
||||||
`/applications/${applicationName}/instances?environment=${environment.name}`,
|
`/applications/${applicationName}/instances?environment=${environment.name}`,
|
||||||
);
|
);
|
||||||
|
@ -8,6 +8,8 @@ import { ApplicationChart } from './ApplicationChart';
|
|||||||
import TopicOutlinedIcon from '@mui/icons-material/TopicOutlined';
|
import TopicOutlinedIcon from '@mui/icons-material/TopicOutlined';
|
||||||
import { Badge } from '../common/Badge/Badge';
|
import { Badge } from '../common/Badge/Badge';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
import { usePlausibleTracker } from 'hooks/usePlausibleTracker';
|
||||||
|
import { useEffect } from 'react';
|
||||||
|
|
||||||
const StyledDivider = styled(Divider)(({ theme }) => ({
|
const StyledDivider = styled(Divider)(({ theme }) => ({
|
||||||
marginTop: theme.spacing(2),
|
marginTop: theme.spacing(2),
|
||||||
@ -31,8 +33,20 @@ const ProjectContainer = styled(Box)(({ theme }) => ({
|
|||||||
alignSelf: 'stretch',
|
alignSelf: 'stretch',
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
const useTracking = () => {
|
||||||
|
const { trackEvent } = usePlausibleTracker();
|
||||||
|
useEffect(() => {
|
||||||
|
trackEvent('sdk-reporting', {
|
||||||
|
props: {
|
||||||
|
eventType: 'application overview opened',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
|
};
|
||||||
|
|
||||||
const ApplicationOverview = () => {
|
const ApplicationOverview = () => {
|
||||||
usePageTitle('Applications - Overview');
|
usePageTitle('Applications - Overview');
|
||||||
|
useTracking();
|
||||||
const applicationName = useRequiredPathParam('name');
|
const applicationName = useRequiredPathParam('name');
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { data, loading } = useApplicationOverview(applicationName);
|
const { data, loading } = useApplicationOverview(applicationName);
|
||||||
|
@ -8,6 +8,7 @@ import { useConnectedInstances } from 'hooks/api/getters/useConnectedInstances/u
|
|||||||
import { ApplicationEnvironmentInstancesSchemaInstancesItem } from '../../../openapi';
|
import { ApplicationEnvironmentInstancesSchemaInstancesItem } from '../../../openapi';
|
||||||
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
|
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
|
||||||
import { StringParam, useQueryParam, withDefault } from 'use-query-params';
|
import { StringParam, useQueryParam, withDefault } from 'use-query-params';
|
||||||
|
import { usePlausibleTracker } from 'hooks/usePlausibleTracker';
|
||||||
|
|
||||||
const useEnvironments = (application: string) => {
|
const useEnvironments = (application: string) => {
|
||||||
const { data: applicationOverview } = useApplicationOverview(application);
|
const { data: applicationOverview } = useApplicationOverview(application);
|
||||||
@ -33,7 +34,26 @@ const useEnvironments = (application: string) => {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const useTracking = () => {
|
||||||
|
const { trackEvent } = usePlausibleTracker();
|
||||||
|
useEffect(() => {
|
||||||
|
trackEvent('sdk-reporting', {
|
||||||
|
props: {
|
||||||
|
eventType: 'connected instances opened',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
|
return () => {
|
||||||
|
trackEvent('sdk-reporting', {
|
||||||
|
props: {
|
||||||
|
eventType: 'connected instances environment changed',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
export const ConnectedInstances: FC = () => {
|
export const ConnectedInstances: FC = () => {
|
||||||
|
const trackEnvironmentChange = useTracking();
|
||||||
const name = useRequiredPathParam('name');
|
const name = useRequiredPathParam('name');
|
||||||
|
|
||||||
const { currentEnvironment, setCurrentEnvironment, environments } =
|
const { currentEnvironment, setCurrentEnvironment, environments } =
|
||||||
@ -82,6 +102,7 @@ export const ConnectedInstances: FC = () => {
|
|||||||
exclusive
|
exclusive
|
||||||
onChange={(event, value) => {
|
onChange={(event, value) => {
|
||||||
if (value !== null) {
|
if (value !== null) {
|
||||||
|
trackEnvironmentChange();
|
||||||
setCurrentEnvironment(value);
|
setCurrentEnvironment(value);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { useMemo } from 'react';
|
import { useEffect, useMemo } from 'react';
|
||||||
import { useRequiredPathParam } from 'hooks/useRequiredPathParam';
|
import { useRequiredPathParam } from 'hooks/useRequiredPathParam';
|
||||||
import { PageContent } from 'component/common/PageContent/PageContent';
|
import { PageContent } from 'component/common/PageContent/PageContent';
|
||||||
import { PageHeader } from 'component/common/PageHeader/PageHeader';
|
import { PageHeader } from 'component/common/PageHeader/PageHeader';
|
||||||
@ -27,10 +27,33 @@ import {
|
|||||||
} from 'hooks/api/getters/useProjectApplications/useProjectApplications';
|
} from 'hooks/api/getters/useProjectApplications/useProjectApplications';
|
||||||
import { StringArrayCell } from 'component/common/Table/cells/StringArrayCell';
|
import { StringArrayCell } from 'component/common/Table/cells/StringArrayCell';
|
||||||
import { SdkCell } from './SdkCell';
|
import { SdkCell } from './SdkCell';
|
||||||
|
import { usePlausibleTracker } from 'hooks/usePlausibleTracker';
|
||||||
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
|
||||||
const columnHelper = createColumnHelper<ProjectApplicationSchema>();
|
const columnHelper = createColumnHelper<ProjectApplicationSchema>();
|
||||||
|
|
||||||
|
const useTracking = () => {
|
||||||
|
const { trackEvent } = usePlausibleTracker();
|
||||||
|
useEffect(() => {
|
||||||
|
trackEvent('sdk-reporting', {
|
||||||
|
props: {
|
||||||
|
eventType: 'project applications opened',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
|
return () => {
|
||||||
|
trackEvent('sdk-reporting', {
|
||||||
|
props: {
|
||||||
|
eventType: 'project application clicked',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
export const ProjectApplications = () => {
|
export const ProjectApplications = () => {
|
||||||
|
const trackProjectApplicationClick = useTracking();
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const projectId = useRequiredPathParam('projectId');
|
const projectId = useRequiredPathParam('projectId');
|
||||||
|
|
||||||
const isSmallScreen = useMediaQuery(theme.breakpoints.down('md'));
|
const isSmallScreen = useMediaQuery(theme.breakpoints.down('md'));
|
||||||
@ -74,7 +97,10 @@ export const ProjectApplications = () => {
|
|||||||
cell: ({ row }) => (
|
cell: ({ row }) => (
|
||||||
<LinkCell
|
<LinkCell
|
||||||
title={row.original.name}
|
title={row.original.name}
|
||||||
to={`/applications/${row.original.name}`}
|
onClick={() => {
|
||||||
|
trackProjectApplicationClick();
|
||||||
|
navigate(`/applications/${row.original.name}`);
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
meta: {
|
meta: {
|
||||||
|
@ -56,7 +56,8 @@ export type CustomEvents =
|
|||||||
| 'new-strategy-form'
|
| 'new-strategy-form'
|
||||||
| 'feedback'
|
| 'feedback'
|
||||||
| 'feature-metrics'
|
| 'feature-metrics'
|
||||||
| 'search-bar';
|
| 'search-bar'
|
||||||
|
| 'sdk-reporting';
|
||||||
|
|
||||||
export const usePlausibleTracker = () => {
|
export const usePlausibleTracker = () => {
|
||||||
const plausible = useContext(PlausibleContext);
|
const plausible = useContext(PlausibleContext);
|
||||||
|
Loading…
Reference in New Issue
Block a user