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

Send target element along with track call #50

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mmairs9-zz
Copy link
Contributor

We want to be able to default some track attributes based on the element type. If we have context of the clicked element we can begin auto tracking alot of data.

support to pass through clicked element on track call
Passing element which was clicked on track so we can add some auto tracking based on the element type.
@codecov
Copy link

codecov bot commented Aug 16, 2017

Codecov Report

Merging #50 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #50      +/-   ##
==========================================
+ Coverage    99.3%   99.31%   +<.01%     
==========================================
  Files          15       15              
  Lines         433      435       +2     
==========================================
+ Hits          430      432       +2     
  Misses          3        3
Impacted Files Coverage Δ
src/core/useTrackBindingPlugin.js 100% <100%> (ø) ⬆️
src/core/createMetrics.js 99.45% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 84f6ce3...9b7528d. Read the comment docs.

@@ -62,7 +63,8 @@ export class TrackBindingPlugin {
return;
}

let elem = event.target || event.srcElement;
var originalElem = event.target || event.srcElement;
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you need this new variable?
Just pass elem Into callback
Also, prefer let to var

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe we do need that variable as elem becomes reassigned and I want to be able to track data on the original element that was clicked. Happy to change to let

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah ok, you're right. Change to let and I'll merge. Thanks for the PR

@@ -371,11 +371,12 @@ export class Metrics extends EventEmitter {
* @returns {Promise}
* @private
*/
_addEventNameToPromise(eventName, promise, shouldMerge) {
_addEventNameToPromise(eventName, promise, shouldMerge, element) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Non blocking question... would it make sense to change the _addEventNameToPromise signature to use a single object argument instead of 4 arguments for legibility?

_addEventNameToPromise({eventName, promise, shouldMerge, element}) {

@potench
Copy link
Contributor

potench commented Nov 9, 2017

@mmairs9 I'm down to merge this if you can just make the couple small changes noted in the review.

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.

3 participants