diff --git a/src/blocks/Icons/Icons.tsx b/src/blocks/Icons/Icons.tsx index 43ed83be2..1479e8f0e 100644 --- a/src/blocks/Icons/Icons.tsx +++ b/src/blocks/Icons/Icons.tsx @@ -1,8 +1,9 @@ -import React, {Fragment, useContext} from 'react'; +import React, {Fragment, useCallback, useContext} from 'react'; import {Image, Title} from '../../components'; import {LocationContext} from '../../context/locationContext'; -import {IconsBlockProps} from '../../models'; +import {useAnalytics} from '../../hooks'; +import {DefaultEventNames, IconsBlockProps} from '../../models'; import {block, getLinkProps} from '../../utils'; import './Icons.scss'; @@ -16,8 +17,12 @@ const getItemContent = (item: IconsBlockProps['items'][number]) => ( ); -const Icons = ({title, size = 's', items}: IconsBlockProps) => { +const Icons = ({title, size = 's', items, analyticsEvents, url: analyticsUrl}: IconsBlockProps) => { const {hostname} = useContext(LocationContext); + const handleAnalytics = useAnalytics(DefaultEventNames.Link, analyticsUrl); + const onClick = useCallback(() => { + handleAnalytics(analyticsEvents); + }, [handleAnalytics, analyticsEvents]); return (
@@ -33,6 +38,7 @@ const Icons = ({title, size = 's', items}: IconsBlockProps) => { aria-label={text} title={text} {...getLinkProps(url, hostname)} + onClick={onClick} > {itemContent} diff --git a/src/models/constructor-items/blocks.ts b/src/models/constructor-items/blocks.ts index 64197f25e..adc6b5ba4 100644 --- a/src/models/constructor-items/blocks.ts +++ b/src/models/constructor-items/blocks.ts @@ -2,6 +2,7 @@ import {ButtonSize} from '@gravity-ui/uikit'; import {GridColumnSize, GridColumnSizesType} from '../../grid/types'; import {ThemeSupporting} from '../../utils'; +import {AnalyticsEventsBase} from '../common'; import { AnchorProps, @@ -312,7 +313,7 @@ export interface FilterBlockProps extends Animatable, LoadableChildren { centered?: boolean; } -export interface IconsBlockProps { +export interface IconsBlockProps extends AnalyticsEventsBase { title?: string; size?: 's' | 'm' | 'l'; items: { @@ -320,6 +321,7 @@ export interface IconsBlockProps { text: string; src: string; }[]; + url?: string; } interface ContentLayoutBlockParams {