mirror of
https://github.com/Unleash/unleash.git
synced 2025-09-19 17:52:45 +02:00
Measure adoption of a reminder for project cleanup (#10502)
This commit is contained in:
parent
32ddf1487b
commit
7f6b09fa1e
@ -7,10 +7,7 @@ import { subDays, formatISO } from 'date-fns';
|
|||||||
import { useReminders } from 'component/feature/FeatureView/CleanupReminder/useReminders';
|
import { useReminders } from 'component/feature/FeatureView/CleanupReminder/useReminders';
|
||||||
import { useHasRootAccess } from 'hooks/useHasAccess';
|
import { useHasRootAccess } from 'hooks/useHasAccess';
|
||||||
import { DELETE_FEATURE } from 'component/providers/AccessProvider/permissions';
|
import { DELETE_FEATURE } from 'component/providers/AccessProvider/permissions';
|
||||||
|
import { usePlausibleTracker } from 'hooks/usePlausibleTracker';
|
||||||
const StyledBox = styled(Box)(({ theme }) => ({
|
|
||||||
marginBottom: theme.spacing(2),
|
|
||||||
}));
|
|
||||||
|
|
||||||
const ActionsBox = styled(Box)(({ theme }) => ({
|
const ActionsBox = styled(Box)(({ theme }) => ({
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
@ -38,6 +35,7 @@ export const ProjectCleanupReminder: FC<{
|
|||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { shouldShowReminder, snoozeReminder } = useReminders();
|
const { shouldShowReminder, snoozeReminder } = useReminders();
|
||||||
const hasAccess = useHasRootAccess(DELETE_FEATURE, projectId);
|
const hasAccess = useHasRootAccess(DELETE_FEATURE, projectId);
|
||||||
|
const { trackEvent } = usePlausibleTracker();
|
||||||
|
|
||||||
const reminderKey = `project-cleanup-${projectId}`;
|
const reminderKey = `project-cleanup-${projectId}`;
|
||||||
const query = getQuery(projectId);
|
const query = getQuery(projectId);
|
||||||
@ -51,12 +49,22 @@ export const ProjectCleanupReminder: FC<{
|
|||||||
}
|
}
|
||||||
|
|
||||||
const handleViewFlags = () => {
|
const handleViewFlags = () => {
|
||||||
|
trackEvent('project-cleanup', {
|
||||||
|
props: {
|
||||||
|
eventType: 'view flags clicked',
|
||||||
|
},
|
||||||
|
});
|
||||||
navigate(
|
navigate(
|
||||||
`/projects/${projectId}/features?${new URLSearchParams(query).toString()}`,
|
`/projects/${projectId}/features?${new URLSearchParams(query).toString()}`,
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDismiss = () => {
|
const handleDismiss = () => {
|
||||||
|
trackEvent('project-cleanup', {
|
||||||
|
props: {
|
||||||
|
eventType: 'remind me later',
|
||||||
|
},
|
||||||
|
});
|
||||||
snoozeReminder(reminderKey, snoozeReminderDays);
|
snoozeReminder(reminderKey, snoozeReminderDays);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -132,6 +132,13 @@ export const ProjectFeatureToggles = ({
|
|||||||
},
|
},
|
||||||
[projectId, refetch],
|
[projectId, refetch],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// TODO: remove tracking after `filterFlagsToArchive` flag
|
||||||
|
const trackArchiveAction = (eventType = 'archived flag') => {
|
||||||
|
trackEvent('project-cleanup', {
|
||||||
|
props: { eventType, showCleanupReminder },
|
||||||
|
});
|
||||||
|
};
|
||||||
const { isChangeRequestConfigured } = useChangeRequestsEnabled(projectId);
|
const { isChangeRequestConfigured } = useChangeRequestsEnabled(projectId);
|
||||||
const { onToggle: onFeatureToggle, modals: featureToggleModals } =
|
const { onToggle: onFeatureToggle, modals: featureToggleModals } =
|
||||||
useFeatureToggleSwitch(projectId);
|
useFeatureToggleSwitch(projectId);
|
||||||
@ -142,7 +149,7 @@ export const ProjectFeatureToggles = ({
|
|||||||
setShowMarkCompletedDialogue,
|
setShowMarkCompletedDialogue,
|
||||||
setShowFeatureReviveDialogue,
|
setShowFeatureReviveDialogue,
|
||||||
setShowFeatureDeleteDialogue,
|
setShowFeatureDeleteDialogue,
|
||||||
} = useRowActions(refetch, projectId);
|
} = useRowActions(refetch, projectId, trackArchiveAction);
|
||||||
|
|
||||||
const isPlaceholder = Boolean(initialLoad || (loading && total));
|
const isPlaceholder = Boolean(initialLoad || (loading && total));
|
||||||
|
|
||||||
@ -630,6 +637,7 @@ export const ProjectFeatureToggles = ({
|
|||||||
onConfirm={() => {
|
onConfirm={() => {
|
||||||
refetch();
|
refetch();
|
||||||
table.resetRowSelection();
|
table.resetRowSelection();
|
||||||
|
trackArchiveAction('bulk archived');
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
|
@ -5,7 +5,11 @@ import { MarkCompletedDialogue } from 'component/feature/FeatureView/FeatureOver
|
|||||||
import { ArchivedFeatureDeleteConfirm } from '../../../../archive/ArchiveTable/ArchivedFeatureActionCell/ArchivedFeatureDeleteConfirm/ArchivedFeatureDeleteConfirm.tsx';
|
import { ArchivedFeatureDeleteConfirm } from '../../../../archive/ArchiveTable/ArchivedFeatureActionCell/ArchivedFeatureDeleteConfirm/ArchivedFeatureDeleteConfirm.tsx';
|
||||||
import { ArchivedFeatureReviveConfirm } from '../../../../archive/ArchiveTable/ArchivedFeatureActionCell/ArchivedFeatureReviveConfirm/ArchivedFeatureReviveConfirm.tsx';
|
import { ArchivedFeatureReviveConfirm } from '../../../../archive/ArchiveTable/ArchivedFeatureActionCell/ArchivedFeatureReviveConfirm/ArchivedFeatureReviveConfirm.tsx';
|
||||||
|
|
||||||
export const useRowActions = (onChange: () => void, projectId: string) => {
|
export const useRowActions = (
|
||||||
|
onChange: () => void,
|
||||||
|
projectId: string,
|
||||||
|
onArchiveConfirm?: () => void,
|
||||||
|
) => {
|
||||||
const [featureArchiveState, setFeatureArchiveState] = useState<
|
const [featureArchiveState, setFeatureArchiveState] = useState<
|
||||||
string | undefined
|
string | undefined
|
||||||
>();
|
>();
|
||||||
@ -52,7 +56,10 @@ export const useRowActions = (onChange: () => void, projectId: string) => {
|
|||||||
|
|
||||||
<FeatureArchiveDialog
|
<FeatureArchiveDialog
|
||||||
isOpen={Boolean(featureArchiveState)}
|
isOpen={Boolean(featureArchiveState)}
|
||||||
onConfirm={onChange}
|
onConfirm={() => {
|
||||||
|
onChange();
|
||||||
|
onArchiveConfirm?.();
|
||||||
|
}}
|
||||||
onClose={() => {
|
onClose={() => {
|
||||||
setFeatureArchiveState(undefined);
|
setFeatureArchiveState(undefined);
|
||||||
}}
|
}}
|
||||||
|
@ -75,6 +75,7 @@ export type CustomEvents =
|
|||||||
| 'productivity-report'
|
| 'productivity-report'
|
||||||
| 'release-management'
|
| 'release-management'
|
||||||
| 'feature-links'
|
| 'feature-links'
|
||||||
|
| 'project-cleanup'
|
||||||
| 'project-list-view-toggle';
|
| 'project-list-view-toggle';
|
||||||
|
|
||||||
export const usePlausibleTracker = () => {
|
export const usePlausibleTracker = () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user