Skip to content

Add interaction-tracking/subscriptions #13426

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

Merged
merged 6 commits into from
Aug 17, 2018

Conversation

bvaughn
Copy link
Contributor

@bvaughn bvaughn commented Aug 17, 2018

Follow up to PR #13234

  • Combine enableInteractionTracking and enableInteractionTrackingObserver feature flags
  • Added interaction-tracking/subscriptions bundle
  • Added multi-subscriber support
  • Fixed existing bug with wrapped function not being passed params (and added test)

@bvaughn bvaughn requested review from sebmarkbage and acdlite August 17, 2018 17:47
@bvaughn bvaughn changed the title Add interaction-tracker/observer Add interaction-tracking/subscriptions Aug 17, 2018
}

export function subscribe(subscriber: Subscriber): void {
subscribers.add(subscriber);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't these be noops if enableInteractionTracking is false?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yikes. Yup

}
}

__subscriberRef.current = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This shouldn't bother subscribing if enableInteractionTracking is false, right?

wrappedInteractions.forEach(interaction => {
interaction.__count--;
try {
returnValue = callback.apply(undefined, arguments);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just noticed this... wrapped is an arrow function here, so these are the arguments to the outer function. Need a test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch.

@pull-bot
Copy link

pull-bot commented Aug 17, 2018

Details of bundled changes.

Comparing: 5e0f073...f1a3d3c

interaction-tracking

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
interaction-tracking.development.js -12.6% -6.9% 8.2 KB 7.16 KB 2.33 KB 2.17 KB UMD_DEV
interaction-tracking.development.js -12.9% -7.2% 8 KB 6.97 KB 2.26 KB 2.1 KB NODE_DEV
interaction-tracking-subscriptions.development.js n/a n/a 0 B 5.16 KB 0 B 1.44 KB UMD_DEV
interaction-tracking-subscriptions.production.min.js n/a n/a 0 B 665 B 0 B 390 B UMD_PROD
interaction-tracking-subscriptions.development.js n/a n/a 0 B 4.9 KB 0 B 1.35 KB NODE_DEV
interaction-tracking-subscriptions.production.min.js n/a n/a 0 B 431 B 0 B 298 B NODE_PROD

Generated by 🚫 dangerJS

@@ -195,7 +195,7 @@ export function wrap(
interaction.__count++;
});

const wrapped = () => {
const wrapped = (...args) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

You could also change this to a normal function :D

Copy link
Collaborator

Choose a reason for hiding this comment

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

It's a nit. I'm just paranoid about the Babel output.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The Babel output is fine. I've checked it. 😄

But sure, I don't mind.

@bvaughn bvaughn merged commit 0da5102 into facebook:master Aug 17, 2018
@bvaughn bvaughn deleted the interaction-tracker/observer branch August 17, 2018 20:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants