Skip to content

# Sequence diagram for desktop navigation GA and Matomo tracking #51

@Dargon789

Description

@Dargon789

Reviewer's Guide

Implements GA4 and Matomo analytics events for desktop navigation activity and swap "to token" selection, centralizing desktop nav tracking and adding token selector callbacks for recent token interactions.

Sequence diagram for desktop navigation GA and Matomo tracking

sequenceDiagram
  actor User
  participant DesktopNav
  participant reportNavEvent
  participant matomoRequestEvent
  participant ga4

  User->>DesktopNav: navigate to new desktop route
  DesktopNav->>DesktopNav: compute currentPathname
  DesktopNav->>DesktopNav: activeNav = navs.find(item.key prefix)
  DesktopNav->>DesktopNav: useEffect on activeNav.eventKey
  alt activeNav has eventKey
    DesktopNav->>reportNavEvent: reportNavEvent(eventKey)
    Note over reportNavEvent: debounced 300ms
    reportNavEvent->>matomoRequestEvent: matomoRequestEvent({ category: RabbyWeb_Active, action: RabbyWeb_<eventKey> })
    reportNavEvent->>ga4: fireEvent(RabbyWeb_Active, { event_category: RabbyWeb_<eventKey> })
  else no eventKey
    DesktopNav-->>DesktopNav: no tracking
  end
Loading

Sequence diagram for swap to-token selection analytics

sequenceDiagram
  actor User
  participant SwapTokenItem
  participant TokenSelect
  participant TokenSelector
  participant matomoRequestEvent
  participant ga4

  User->>SwapTokenItem: click to select to-token
  alt TokenSelect closed
    SwapTokenItem->>TokenSelect: open token selector
    TokenSelect->>TokenSelect: setTokenSelectorVisible(true)
    TokenSelect->>TokenSelect: onOpenTokenModal()
    TokenSelect->>SwapTokenItem: onOpenTokenModal callback
    SwapTokenItem->>matomoRequestEvent: matomoRequestEvent({ category: TokenSelect, action: Swap_To_Token })
    SwapTokenItem->>ga4: fireEvent(Swap_To_Token, { event_category: TokenSelect })
  end

  User->>TokenSelector: click recent token
  TokenSelector->>TokenSelector: onConfirm(token)
  TokenSelector->>TokenSelector: onSelectRecentToken(token)
  TokenSelector->>TokenSelect: onConfirm(token)
  TokenSelector->>SwapTokenItem: onSelectRecentToken callback
  SwapTokenItem->>matomoRequestEvent: matomoRequestEvent({ category: TokenSelect, action: Swap_To_Token_Recent })
  SwapTokenItem->>ga4: fireEvent(Swap_To_Token_Recent, { event_category: TokenSelect })
Loading

Updated class diagram for desktop navigation and token selection tracking

classDiagram
  class DesktopNav {
    +DesktopNavAction action
    +boolean showRightItems
    +DesktopNavProps props
    -DesktopNavNavItem[] navs
    -DesktopNavNavItem activeNav
    +handleActionClick(nextAction DesktopNavAction) void
  }

  class DesktopNavNavItem {
    +string key
    +ReactComponentType icon
    +string title
    +boolean isSoon
    +string eventKey
  }

  class reportNavEvent {
    +reportNavEvent(eventKey string) void
  }

  class matomoRequestEvent {
    +matomoRequestEvent(options MatomoEventOptions) void
  }

  class ga4 {
    +fireEvent(name string, params GA4Params) void
  }

  class MatomoEventOptions {
    +string category
    +string action
  }

  class GA4Params {
    +string event_category
  }

  class SwapTokenItem {
    +boolean isFrom
    +onStartSelectChain() void
    +onOpenTokenModal() void
    +onSelectRecentToken(token TokenItem) void
  }

  class TokenSelect {
    +type TokenSelectType
    +onOpenTokenModal() void
    +onSelectRecentToken(token TokenItem) void
    +openTokenSelector() void
  }

  class TokenSelector {
    +onConfirm(token TokenItem) void
    +onSelectRecentToken(token TokenItem) void
  }

  class TokenItem {
    +string id
    +string symbol
    +string chain
  }

  DesktopNav "1" o-- "many" DesktopNavNavItem : navs
  DesktopNav --> reportNavEvent : uses
  reportNavEvent --> matomoRequestEvent : calls
  reportNavEvent --> ga4 : calls
  matomoRequestEvent --> MatomoEventOptions : parameter
  ga4 --> GA4Params : parameter

  SwapTokenItem --> TokenSelect : renders
  TokenSelect --> TokenSelector : renders
  TokenSelector --> TokenItem : selects

  SwapTokenItem --> matomoRequestEvent : onOpenTokenModal,onSelectRecentToken
  SwapTokenItem --> ga4 : onOpenTokenModal,onSelectRecentToken

  TokenSelect --> SwapTokenItem : callbacks
  TokenSelector --> SwapTokenItem : onSelectRecentToken callback
  TokenSelector --> TokenSelect : onConfirm callback
Loading

File-Level Changes

Change Details Files
Centralize and update desktop navigation analytics tracking
  • Import Matomo and GA4 helpers plus lodash.debounce into DesktopNav
  • Extend navigation config items with an eventKey identifier per nav entry
  • Add a debounced reportNavEvent helper that fires Matomo and GA4 events when active nav changes
  • Compute active nav via useMemo based on current pathname and trigger tracking in a useEffect
  • Remove legacy one-off portfolio tracking logic from DesktopProfile to rely on new nav-based tracking
src/ui/component/DesktopNav/index.tsx
src/ui/views/DesktopProfile/index.tsx
Track swap destination token selection via token selector hooks
  • Import Matomo and GA4 helpers into the swap token component
  • Extend TokenSelect props to accept onOpenTokenModal and onSelectRecentToken callbacks and wire them through to TokenSelector
  • Extend TokenSelector props to accept onSelectRecentToken and invoke it when a recent token is clicked
  • In SwapTokenItem, for the "to" token, fire Matomo and GA4 events when opening the token modal and when selecting a recent token
src/ui/views/Swap/Component/Token.tsx
src/ui/component/TokenSelector/index.tsx
src/ui/component/TokenSelect/index.tsx

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Originally posted by @sourcery-ai[bot] in #50 (comment)

Metadata

Metadata

Assignees

Labels

dependenciesPull requests that update a dependency filedocumentationImprovements or additions to documentationduplicateThis issue or pull request already existsenhancementNew feature or requestgood first issueGood for newcomershelp wantedExtra attention is neededinvalidThis doesn't seem rightjavascriptPull requests that update javascript codequestionFurther information is requested

Projects

Status

Backlog

Status

Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions