Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
Nov 22, 2024

Conversation

irenehakes
Copy link

Relates to Issue 1368

The button click tracking plugin appears to have an undocumented feature for attaching dynamic contexts to each button click, similar to link click tracking plugin.

The button click tracking plugin's dynamic context function, however, only takes the button click event as an argument. This PR updates this call to also pass in the clicked element.

…lugin-button-click-tracking to fully enable dynamic contexts in button clicks
@snowplowcla
Copy link

Thanks for your pull request. Is this your first contribution to a Snowplow open source project? Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://docs.snowplowanalytics.com/docs/contributing/contributor-license-agreement/ to learn more and sign.

Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks.

@snowplowcla snowplowcla added the cla:no [Auto generated] Snowplow Contributor License Agreement has not been signed. label Nov 21, 2024
@irenehakes
Copy link
Author

Thanks for your pull request. Is this your first contribution to a Snowplow open source project? Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://docs.snowplowanalytics.com/docs/contributing/contributor-license-agreement/ to learn more and sign.

Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks.

I signed it

@snowplowcla
Copy link

Confirmed! @irenehakes has signed the Contributor License Agreement. Thanks so much.

@snowplowcla snowplowcla added cla:yes [Auto generated] Snowplow Contributor License Agreement has been signed. and removed cla:no [Auto generated] Snowplow Contributor License Agreement has not been signed. labels Nov 21, 2024
Copy link
Contributor

@jethron jethron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

It's unfortunate we couldn't fit this into v4 as a breaking change, the resulting API inconsistency with the other plugins will be a bit awkward to resolve now.

Plugin Context Arg 1 Context Arg 2 Context Arg 3
Button Event Payload - (Element in this PR) -
Link Element - -
Form (Change/Focus) Element Element Type Element Value
Form (Submit) Element ElementData[] -

It might be worth planning for v5 to unify plugins onto a single object param for dynamic contexts so we can be a bit looser with the interface. For Link and Button at least, getting the actual MouseEvent/PointerEvent for information on the type of click, modifier keys, coordinates, pressure used, etc could be useful in some use cases (as suggested in #1368) so would be nice to add in at some point.

Copy link
Contributor

@matus-tomlein matus-tomlein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you for the contribution @irenehakes!

May I just ask you to add the attached change file to the PR? You can add it at the location:

common/changes/@snowplow/browser-plugin-button-click-tracking/issue-1368_2024-11-22-08-27.json

Good point, @jethron! Have made an issue for the unification in v5, #1390

issue-1368_2024-11-22-08-27.json

@irenehakes
Copy link
Author

@matus-tomlein I just pushed up that change file. Let me know if there's anything else.

@matus-tomlein matus-tomlein changed the base branch from master to release/4.1.0 November 22, 2024 15:15
@matus-tomlein matus-tomlein merged commit f7ee77a into snowplow:release/4.1.0 Nov 22, 2024
1 check passed
Copy link

bundlemon bot commented Nov 22, 2024

BundleMon

Files added (6)
Status Path Size Limits
trackers/javascript-tracker/dist/sp.js
+24.47KB 30KB / +10%
libraries/browser-tracker-core/dist/index.mod
ule.js
+23.48KB 25KB / +10%
libraries/tracker-core/dist/index.module.js
+19.42KB 20KB / +10%
trackers/browser-tracker/dist/index.umd.min.j
s
+17.37KB 20KB / +10%
trackers/javascript-tracker/dist/sp.lite.js
+17.31KB 20KB / +10%
trackers/browser-tracker/dist/index.module.js
+3.49KB 5KB / +10%

Total files change +105.54KB 0%

Final result: ✅

View report in BundleMon website ➡️


Current branch size history

@irenehakes irenehakes deleted the issue-1368 branch November 22, 2024 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla:yes [Auto generated] Snowplow Contributor License Agreement has been signed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants