snowplow / snowplow-javascript-tracker

Snowplow event tracker for client-side and server-side JavaScript. Add analytics to your websites, web apps and servers.
http://snowplowanalytics.com
BSD 3-Clause "New" or "Revised" License
553 stars 222 forks source link

Pass clicked element to dynamic context functions for button click tracking plugin #1368

Open andrewlangston opened 3 weeks ago

andrewlangston commented 3 weeks ago

Is your feature request related to a problem? Please describe. But button click tracking plugin appears to have an undocumented (at least on docs.snowplow.io: https://docs.snowplow.io/docs/collecting-data/collecting-from-own-applications/javascript-trackers/web-tracker/tracking-events/button-click/) feature for attaching dynamic contexts to each button click, similar to the link click tracking plugin.

However, the button click tracking plugin's dynamic context functions take only the button click event as an argument: https://github.com/snowplow/snowplow-javascript-tracker/blob/master/plugins/browser-plugin-button-click-tracking/src/api.ts#L105. This is less flexible than the link click tracking plugin's ability to take the clicked element as an argument to dynamic context functions: https://github.com/snowplow/snowplow-javascript-tracker/blob/master/plugins/browser-plugin-link-click-tracking/src/index.ts#L279

Describe the solution you'd like

  1. Update the button click tracking plugin to pass the click element (rather than the button click event) to dynamic context functions
  2. Document this feature on docs.snowplow.io

Describe alternatives you've considered N/A

Additional context N/A

matus-tomlein commented 3 weeks ago

Hi @andrewlangston, thanks for the feature request, that makes sense!

Hopefully we can make this a non-breaking change – I was thinking that we could add the button element as the second argument in the callback, after the event.

andrewlangston commented 3 weeks ago

@matus-tomlein good call, makes sense!

irenehakes commented 3 days ago

I've submitted a PR with the change here

When that's released, where is the right place to update documentation? Is it https://github.com/snowplow/documentation/blob/main/docs/collecting-data/collecting-from-own-applications/javascript-trackers/web-tracker/tracking-events/button-click/index.md?