Skip to content

Add Track component#504

Open
perruche wants to merge 1 commit into
mainfrom
feature/shopify-track-component
Open

Add Track component#504
perruche wants to merge 1 commit into
mainfrom
feature/shopify-track-component

Conversation

@perruche

Copy link
Copy Markdown
Contributor

🔗 Linked issue

N/A

❓ Type of change

  • 📖 Documentation (updates to the documentation, readme
    or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality
    like performance)
  • ✨ New feature (a non-breaking change that adds
    functionality)
  • 🧹 Chore (updates to the build process or auxiliary
    tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause
    existing functionality to change)

📚 Description

Add a new Track component to publish Shopify analytics
events for a section of a page:

  • Publishes a viewed event (default: bento_section_viewed)
    the first time the root element enters the viewport, using
    withIntersectionObserver
  • Publishes a clicked event (default:
    bento_section_clicked) on click, with the current URL, the
    clicked element's tag name and its text content (truncated
    to 100 characters)
  • The event payload is defined in a <script data-ref="payload" type="application/json"> element, with a
    warning in debug mode when the JSON is invalid
  • Event names are configurable with the viewedEvent and
    clickedEvent options
  • Relies on the Shopify.analytics.publish API and warns in
    debug mode when it is not available
<div data-component="Track">
  <script data-ref="payload" type="application/json">
    {
      "name": "bloc-name",
      "template": {{ template.name | json }}
    }
  </script>
  <a href="#">Click me</a>
</div>

📝 Checklist

  • I have linked an issue or discussion.
  • I have added tests (if possible).
  • I have updated the documentation accordingly.

@codecov

codecov Bot commented Jun 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.04%. Comparing base (72920df) to head (7926fdd).

Additional details and impacted files
@@             Coverage Diff              @@
##               main     #504      +/-   ##
============================================
+ Coverage     73.82%   74.04%   +0.21%     
  Complexity      145      145              
============================================
  Files            93       94       +1     
  Lines          2663     2685      +22     
  Branches        445      448       +3     
============================================
+ Hits           1966     1988      +22     
  Misses          608      608              
  Partials         89       89              
Flag Coverage Δ
unittests 74.04% <100.00%> (+0.21%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
packages/ui/Track/Track.ts 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

Copy link
Copy Markdown

Export Size

@studiometa/ui

Name Size Diff
Track 429 B +429 B (+100.00%) 🔺
Unchanged

@studiometa/ui

Name Size Diff
AbstractFrameTrigger 1.74 kB -
AbstractPrefetch 366 B -
AbstractScrollAnimation 3.66 kB -
AbstractSliderChild 600 B -
Accordion 1.77 kB -
AccordionItem 1.75 kB -
Action 1.11 kB -
AnchorNav 3.85 kB -
AnchorNavLink 3.74 kB -
AnchorNavTarget 125 B -
AnchorScrollTo 2.53 kB -
animationScrollWithEase 763 B -
CircularMarquee 550 B -
Cursor 650 B -
DataBind 697 B -
DataComputed 856 B -
DataEffect 837 B -
DataModel 780 B -
Draggable 1.64 kB -
Fetch 2.34 kB -
Figure 1.72 kB -
FigureShopify 1.98 kB -
FigureTwicpics 2.26 kB -
FigureVideo 1.87 kB -
FigureVideoTwicpics 2.44 kB -
Frame 3.47 kB -
FrameAnchor 1.84 kB -
FrameForm 1.92 kB -
FrameLoader 1.45 kB -
FrameTarget 1.75 kB -
FrameTriggerLoader 1.46 kB -
Hoverable 953 B -
LargeText 713 B -
LazyInclude 322 B -
Menu 2.33 kB -
MenuBtn 140 B -
MenuList 1.9 kB -
Modal 1.99 kB -
ModalWithTransition 2.09 kB -
Panel 2.38 kB -
PrefetchWhenOver 408 B -
PrefetchWhenVisible 417 B -
ScrollAnimation 3.79 kB -
ScrollAnimationChild 3.91 kB -
ScrollAnimationChildWithEase 4.51 kB -
ScrollAnimationParent 3.98 kB -
ScrollAnimationTarget 3.85 kB -
ScrollAnimationTimeline 3.92 kB -
ScrollAnimationWithEase 4.39 kB -
ScrollReveal 1.63 kB -
Sentinel 129 B -
Slider 2.3 kB -
SliderBtn 817 B -
SliderCount 650 B -
SliderDots 1.86 kB -
SliderDrag 269 B -
SliderItem 998 B -
SliderProgress 961 B -
Sticky 771 B -
Tabs 1.38 kB -
Target 86 B -
Transition 1.41 kB -
withDeprecation 166 B -
withScrollAnimationDebug 2.04 kB -
withTransition 1.39 kB -

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.

1 participant