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:
parent
8e430810ef
commit
1c95029319
@ -1,10 +1,10 @@
|
|||||||
import { ComponentProps, FC } from 'react';
|
import { ComponentProps, FC } from 'react';
|
||||||
import {} from '../FilterItem.styles';
|
|
||||||
import { ArrowDropDown, Close, TopicOutlined } from '@mui/icons-material';
|
import { ArrowDropDown, Close, TopicOutlined } from '@mui/icons-material';
|
||||||
import { ConditionallyRender } from '../../ConditionallyRender/ConditionallyRender';
|
import { ConditionallyRender } from '../../ConditionallyRender/ConditionallyRender';
|
||||||
import { Chip, IconButton, styled } from '@mui/material';
|
import { Chip, IconButton, styled } from '@mui/material';
|
||||||
import { FilterItemOperator } from './FilterItemOperator/FilterItemOperator';
|
import { FilterItemOperator } from './FilterItemOperator/FilterItemOperator';
|
||||||
import { FILTER_ITEM } from 'utils/testIds';
|
import { FILTER_ITEM } from 'utils/testIds';
|
||||||
|
import { usePlausibleTracker } from 'hooks/usePlausibleTracker';
|
||||||
|
|
||||||
const StyledChip = styled(
|
const StyledChip = styled(
|
||||||
({
|
({
|
||||||
@ -89,6 +89,18 @@ export const FilterItemChip: FC<IFilterItemChipProps> = ({
|
|||||||
const maxExplicitOptions = 2;
|
const maxExplicitOptions = 2;
|
||||||
const explicitOptions = selectedOptions.slice(0, maxExplicitOptions);
|
const explicitOptions = selectedOptions.slice(0, maxExplicitOptions);
|
||||||
const remainingOptions = selectedOptions.length - maxExplicitOptions;
|
const remainingOptions = selectedOptions.length - maxExplicitOptions;
|
||||||
|
const { trackEvent } = usePlausibleTracker();
|
||||||
|
|
||||||
|
const onChange = (operator: string) => {
|
||||||
|
onChangeOperator(operator);
|
||||||
|
|
||||||
|
trackEvent('search-filter', {
|
||||||
|
props: {
|
||||||
|
label: label,
|
||||||
|
operator: operator,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<StyledChip
|
<StyledChip
|
||||||
@ -107,7 +119,7 @@ export const FilterItemChip: FC<IFilterItemChipProps> = ({
|
|||||||
<FilterItemOperator
|
<FilterItemOperator
|
||||||
options={operatorOptions}
|
options={operatorOptions}
|
||||||
value={operator}
|
value={operator}
|
||||||
onChange={onChangeOperator}
|
onChange={onChange}
|
||||||
/>
|
/>
|
||||||
<StyledOptions>
|
<StyledOptions>
|
||||||
{explicitOptions.join(', ')}
|
{explicitOptions.join(', ')}
|
||||||
|
@ -50,7 +50,8 @@ export type CustomEvents =
|
|||||||
| 'feature-naming-pattern'
|
| 'feature-naming-pattern'
|
||||||
| 'project-mode'
|
| 'project-mode'
|
||||||
| 'dependent_features'
|
| 'dependent_features'
|
||||||
| 'playground_token_input_used';
|
| 'playground_token_input_used'
|
||||||
|
| 'search-filter';
|
||||||
|
|
||||||
export const usePlausibleTracker = () => {
|
export const usePlausibleTracker = () => {
|
||||||
const plausible = useContext(PlausibleContext);
|
const plausible = useContext(PlausibleContext);
|
||||||
|
Loading…
Reference in New Issue
Block a user