1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-25 00:07:47 +01:00

feat: hours back feature metrics tracking (#5904)

This commit is contained in:
Mateusz Kwasniewski 2024-01-16 10:30:06 +01:00 committed by GitHub
parent 3b5b1ec020
commit dfeaea8ee9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View File

@ -5,6 +5,7 @@ import GeneralSelect, {
import { subWeeks, subMonths, differenceInHours } from 'date-fns'; import { subWeeks, subMonths, differenceInHours } from 'date-fns';
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig'; import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
import { useUiFlag } from 'hooks/useUiFlag'; import { useUiFlag } from 'hooks/useUiFlag';
import { usePlausibleTracker } from 'hooks/usePlausibleTracker';
const StyledTitle = styled('h2')(({ theme }) => ({ const StyledTitle = styled('h2')(({ theme }) => ({
margin: 0, margin: 0,
@ -25,8 +26,15 @@ export const FeatureMetricsHours = ({
hoursBack, hoursBack,
setHoursBack, setHoursBack,
}: IFeatureMetricsHoursProps) => { }: IFeatureMetricsHoursProps) => {
const { trackEvent } = usePlausibleTracker();
const onChange: IGeneralSelectProps['onChange'] = (key) => { const onChange: IGeneralSelectProps['onChange'] = (key) => {
setHoursBack(parseInt(key)); setHoursBack(parseInt(key));
trackEvent('feature-metrics', {
props: {
eventType: 'change-period',
hoursBack: key,
},
});
}; };
const { isEnterprise } = useUiConfig(); const { isEnterprise } = useUiConfig();
const extendedUsageMetrics = useUiFlag('extendedUsageMetricsUI'); const extendedUsageMetrics = useUiFlag('extendedUsageMetricsUI');

View File

@ -55,7 +55,8 @@ export type CustomEvents =
| 'scheduled-configuration-changes' | 'scheduled-configuration-changes'
| 'search-feature-buttons' | 'search-feature-buttons'
| 'new-strategy-form' | 'new-strategy-form'
| 'feedback'; | 'feedback'
| 'feature-metrics';
export const usePlausibleTracker = () => { export const usePlausibleTracker = () => {
const plausible = useContext(PlausibleContext); const plausible = useContext(PlausibleContext);