Skip to content

Commit

Permalink
feat: add ga4 events
Browse files Browse the repository at this point in the history
  • Loading branch information
iso9000t committed Jan 31, 2025
1 parent 77cbb28 commit edb6c10
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,19 @@ export const DASHBOARD_EVENTS = {
number: dashboardId,
}),

clickOnDropdownOption: (option) => ({
...getBasicClickEventParameters(DASHBOARDS),
element_name: option,
}),

clickOnBtnInModalDuplicateDashboard: (dashboardId, isDescriptionEdited) => ({
...getBasicClickEventParameters(DASHBOARDS),
element_name: 'duplicate',
modal: 'duplicate_dashboard',
link_name: isDescriptionEdited,
number: dashboardId,
}),

clickOnButtonUpdateInModalEditDashboard: (dashboardId, linkName) => ({
...getBasicClickEventParameters(DASHBOARDS),
element_name: 'update',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ OwnerColumn.defaultProps = {
export const DuplicateColumn = track()(
injectIntl(({ value, customProps, className, tracking: { trackEvent }, intl }) => {
const [opened, setOpened] = useState(false);
const { id } = value;

useEffect(() => {
const handleOutsideClick = (e) => {
Expand All @@ -96,22 +97,30 @@ export const DuplicateColumn = track()(
return () => document.removeEventListener('click', handleOutsideClick);
}, [opened]);

const handleDuplicate = () => {
const { id } = value;
const handleClick = (e) => {
e.stopPropagation();
trackEvent(DASHBOARD_EVENTS.clickOnIconDashboard('duplicate', id));
setOpened(!opened);
};

const handleDuplicate = (e) => {
e.stopPropagation();
trackEvent(DASHBOARD_EVENTS.clickOnDropdownOption('duplicate'));
customProps.onDuplicate(value);
setOpened(false);
};

const handleCopyConfig = () => {
// TODO: Copy configuration functionality will be added later
const handleCopyConfig = (e) => {
e.stopPropagation();
trackEvent(DASHBOARD_EVENTS.clickOnDropdownOption('copy_dashboard'));
// TODO: Implement copy configuration functionality
setOpened(false);
};

return (
<div className={cx(className, 'icon-cell', 'with-button')}>
<div className={cx('icon-holder', 'no-border')}>
<div className={cx('duplicate-dropdown')} onClick={() => setOpened(!opened)}>
<div className={cx('duplicate-dropdown')} onClick={handleClick}>
<div className={cx('duplicate-icon')}>
{Parser(IconDuplicate.replace('stroke="#999999"', 'stroke="currentColor"'))}
</div>
Expand Down Expand Up @@ -145,6 +154,18 @@ DuplicateColumn.defaultProps = {
className: '',
};

DuplicateColumn.propTypes = {
value: PropTypes.object,
customProps: PropTypes.object,
className: PropTypes.string,
};

DuplicateColumn.defaultProps = {
value: {},
customProps: {},
className: '',
};

export const EditColumn = track()(({ value, customProps, className, tracking: { trackEvent } }) => {
const { onEdit } = customProps;
const { id } = value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export class AddEditModal extends Component {
);
break;
case 'duplicate':
dashboardEvent = DASHBOARD_EVENTS.clickOnButtonInModalAddNewDashboard(
dashboardEvent = DASHBOARD_EVENTS.clickOnBtnInModalDuplicateDashboard(
dashboardId,
isChangedDescription,
);
Expand Down

0 comments on commit edb6c10

Please sign in to comment.