mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-04 00:18:01 +01:00
Adds tracking to maintenance feature (#2723)
Adds tracking with plausible to maintenance feature
This commit is contained in:
parent
5b66346e56
commit
e533b44c5b
@ -10,6 +10,7 @@ import {
|
|||||||
} from '@mui/material';
|
} from '@mui/material';
|
||||||
import { useMaintenance } from 'hooks/api/getters/useMaintenance/useMaintenance';
|
import { useMaintenance } from 'hooks/api/getters/useMaintenance/useMaintenance';
|
||||||
import { useMaintenanceApi } from 'hooks/api/actions/useMaintenanceApi/useMaintenanceApi';
|
import { useMaintenanceApi } from 'hooks/api/actions/useMaintenanceApi/useMaintenanceApi';
|
||||||
|
import { usePlausibleTracker } from 'hooks/usePlausibleTracker';
|
||||||
|
|
||||||
const StyledCard = styled(Card)(({ theme }) => ({
|
const StyledCard = styled(Card)(({ theme }) => ({
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
@ -38,7 +39,13 @@ const SwitchLabel = styled(Typography)(({ theme }) => ({
|
|||||||
export const MaintenanceToggle = () => {
|
export const MaintenanceToggle = () => {
|
||||||
const { enabled, refetchMaintenance } = useMaintenance();
|
const { enabled, refetchMaintenance } = useMaintenance();
|
||||||
const { toggleMaintenance } = useMaintenanceApi();
|
const { toggleMaintenance } = useMaintenanceApi();
|
||||||
|
const { trackEvent } = usePlausibleTracker();
|
||||||
const updateEnabled = async () => {
|
const updateEnabled = async () => {
|
||||||
|
trackEvent('maintenance', {
|
||||||
|
props: {
|
||||||
|
eventType: `maintenance ${enabled ? 'de' : ''}activated`,
|
||||||
|
},
|
||||||
|
});
|
||||||
await toggleMaintenance({ enabled: !enabled });
|
await toggleMaintenance({ enabled: !enabled });
|
||||||
refetchMaintenance();
|
refetchMaintenance();
|
||||||
};
|
};
|
||||||
|
@ -12,7 +12,8 @@ type CustomEvents =
|
|||||||
| 'invite'
|
| 'invite'
|
||||||
| 'upgrade_plan_clicked'
|
| 'upgrade_plan_clicked'
|
||||||
| 'change_request'
|
| 'change_request'
|
||||||
| 'favorite';
|
| 'favorite'
|
||||||
|
| 'maintenance';
|
||||||
|
|
||||||
export const usePlausibleTracker = () => {
|
export const usePlausibleTracker = () => {
|
||||||
const plausible = useContext(PlausibleContext);
|
const plausible = useContext(PlausibleContext);
|
||||||
|
Loading…
Reference in New Issue
Block a user