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

feat: add plausible tracking (#5614)

This commit is contained in:
Jaanus Sellin 2023-12-12 15:46:48 +02:00 committed by GitHub
parent 8e430810ef
commit 1c95029319
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 3 deletions

View File

@ -1,10 +1,10 @@
import { ComponentProps, FC } from 'react';
import {} from '../FilterItem.styles';
import { ArrowDropDown, Close, TopicOutlined } from '@mui/icons-material';
import { ConditionallyRender } from '../../ConditionallyRender/ConditionallyRender';
import { Chip, IconButton, styled } from '@mui/material';
import { FilterItemOperator } from './FilterItemOperator/FilterItemOperator';
import { FILTER_ITEM } from 'utils/testIds';
import { usePlausibleTracker } from 'hooks/usePlausibleTracker';
const StyledChip = styled(
({
@ -89,6 +89,18 @@ export const FilterItemChip: FC<IFilterItemChipProps> = ({
const maxExplicitOptions = 2;
const explicitOptions = selectedOptions.slice(0, maxExplicitOptions);
const remainingOptions = selectedOptions.length - maxExplicitOptions;
const { trackEvent } = usePlausibleTracker();
const onChange = (operator: string) => {
onChangeOperator(operator);
trackEvent('search-filter', {
props: {
label: label,
operator: operator,
},
});
};
return (
<StyledChip
@ -107,7 +119,7 @@ export const FilterItemChip: FC<IFilterItemChipProps> = ({
<FilterItemOperator
options={operatorOptions}
value={operator}
onChange={onChangeOperator}
onChange={onChange}
/>
<StyledOptions>
{explicitOptions.join(', ')}

View File

@ -50,7 +50,8 @@ export type CustomEvents =
| 'feature-naming-pattern'
| 'project-mode'
| 'dependent_features'
| 'playground_token_input_used';
| 'playground_token_input_used'
| 'search-filter';
export const usePlausibleTracker = () => {
const plausible = useContext(PlausibleContext);