Skip to content

Add toc analytics, add condition analytics track#599

Open
dvortsovs wants to merge 1 commit intomasterfrom
feat/add-toc-analytic
Open

Add toc analytics, add condition analytics track#599
dvortsovs wants to merge 1 commit intomasterfrom
feat/add-toc-analytic

Conversation

@dvortsovs
Copy link
Copy Markdown

@dvortsovs dvortsovs commented Apr 8, 2026

Analytics for clicks on Table of Contents (TOC) items and conditional event tracking

Description

This PR adds analytics tracking for clicks on Table of Contents (TOC) items and extends the analytics system with the ability to conditionally send events to specific adapters.

What has changed

Analytics in the TocItem component

  • The TocItem component now accepts the analyticsEvents prop (type AnalyticsEventsProp from @gravity-ui/page-constructor), allowing analytics events to be configured externally.
  • When a TOC item is clicked, the DOCS_TOC_ITEM_CLICK event is sent via the useAnalytics hook from @gravity-ui/page-constructor.
  • Analytics now works correctly for all interaction scenarios:
    • clicking a link
    • expanding/collapsing nested items
    • clicking items without an href

Conditional event tracking

  • The Analytics.track() method now includes an optional options: AnalyticsTrackOptions parameter, which allows filtering adapters when sending events:
    • includeKeys — send the event only to adapters with the specified keys
    • excludeKeys — exclude adapters with the specified keys from receiving the event
  • The AnalyticsAdapter interface now includes an optional key field, allowing adapters to be identified.
  • The YandexMetrikaAdapter now supports the key field in its configuration (by default, the string representation of the counter ID is used).

@dvortsovs dvortsovs requested a review from a team as a code owner April 8, 2026 08:34
@dvortsovs dvortsovs requested review from stenin-nikita and removed request for a team April 8, 2026 08:34
@yc-ui-bot
Copy link
Copy Markdown
Contributor

Visual Tests Report is ready.

@dvortsovs dvortsovs force-pushed the feat/add-toc-analytic branch from 0d48a8c to 867cc9c Compare April 8, 2026 08:47
@dvortsovs dvortsovs requested a review from a team April 8, 2026 09:20
@dvortsovs dvortsovs force-pushed the feat/add-toc-analytic branch from 867cc9c to 43c87b2 Compare April 13, 2026 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants