guillaumeparis2000 / react-piwik

Library that allow to connect piwik with the react-router and track custom events
31 stars 17 forks source link

set enableLinkTracking to false by default or to true for all renders #26

Open aarowman opened 4 years ago

aarowman commented 4 years ago

Currently enableLinkTracking is set to true by default (per the doc of this library), but we still have issues like #25 since this is normally an issue with SPAs. Anytime React components re-render, then the event listener is lost and those links aren't tracked anymore.

This results in inconsistent behavior (links are tracked on initial page load, but they're not tracked if a user navigates the site and causes component re-renders)

So we either have to:

  1. Call enableLinkTracking again for each render (basically every component that has a link), which gets tedious and has inconsistent behavior if missed.. or
  2. Call trackLink explicitly using our own onClick handler, which is also tedious

I suggest we set it to false by default and let the client decide how to proceed, or somehow enable this to be set again even on re-renders

guillaumeparis2000 commented 4 years ago

I'm short of time for the moment, feel free to open a PR. Thanks