1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-02-14 00:19:16 +01:00

Tracking for default strategy (#3800)

This commit is contained in:
Tymoteusz Czech 2023-05-19 12:47:55 +02:00 committed by GitHub
parent 896b63616d
commit d1c3be3b9e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 42 deletions

View File

@ -42,45 +42,8 @@ const EditDefaultStrategy = ({ strategy }: EditDefaultStrategyProps) => {
const { unleashUrl } = uiConfig;
const navigate = useNavigate();
const [previousTitle] = useState<string>('');
const { trackEvent } = usePlausibleTracker();
const trackTitle = (title: string = '') => {
// don't expose the title, just if it was added, removed, or edited
if (title === previousTitle) {
trackEvent('strategyTitle', {
props: {
action: 'none',
on: 'edit',
},
});
}
if (previousTitle === '' && title !== '') {
trackEvent('strategyTitle', {
props: {
action: 'added',
on: 'edit',
},
});
}
if (previousTitle !== '' && title === '') {
trackEvent('strategyTitle', {
props: {
action: 'removed',
on: 'edit',
},
});
}
if (previousTitle !== '' && title !== '' && title !== previousTitle) {
trackEvent('strategyTitle', {
props: {
action: 'edited',
on: 'edit',
},
});
}
};
const {
segments: allSegments,
refetchSegments: refetchSavedStrategySegments,
@ -110,10 +73,12 @@ const EditDefaultStrategy = ({ strategy }: EditDefaultStrategyProps) => {
) => {
await updateDefaultStrategy(projectId, environmentId, payload);
if (uiConfig?.flags?.strategyImprovements && strategy.title) {
// NOTE: remove tracking when feature flag is removed
trackTitle(strategy.title);
}
trackEvent('default_strategy', {
props: {
action: 'edit',
hasTitle: Boolean(payload.title),
},
});
await refetchSavedStrategySegments();
setToastData({

View File

@ -25,7 +25,8 @@ export type CustomEvents =
| 'notifications'
| 'batch_operations'
| 'strategyTitle'
| 'demo';
| 'demo'
| 'default_strategy';
export const usePlausibleTracker = () => {
const plausible = useContext(PlausibleContext);