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

Added code to validate visibilitySpec in amp-analytics. #2743

Merged
merged 1 commit into from
Apr 11, 2016

Conversation

avimehta
Copy link
Contributor

Part of #1297

@dvoytenko
Copy link
Contributor

@avimehta Is this ready to be reviewed?

@avimehta
Copy link
Contributor Author

avimehta commented Apr 1, 2016

@dvoytenko ready for review.

@dvoytenko
Copy link
Contributor

/to @cramforce for review

// TODO(avimehta, #1297): Add all the listeners so that visibility
// conditions are monitored and callback is called when the conditions
// are met.
if (this.viewer_.isVisible()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

These two code paths aren't quite similar. The consequent will only call callback once, the alternate will call it every time the visibility changes to visible. Is that intended?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for pointing out. Since this PR is about visibilitySpec, I'll not touch the bug(unless you insist). I'll send out another PR with the fix for this bug.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, I see this was moved. Another PR would be perfect.

@avimehta
Copy link
Contributor Author

avimehta commented Apr 6, 2016

ptal.

const ttMin = spec['totalTimeMin'];

// "", 1, 0, undefined, 100, 101 are positive. -1, NaN are not.
function isPositiveNumber(num) {
Copy link
Contributor

Choose a reason for hiding this comment

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

isPositiveNumber and isValidPercentage can be hoisted outside of this function to avoid recreating them every time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done. Also added tests.

I was considering putting them outside the class but then I can't add tests. Static functions was an option but since instrumentation class has only one instance, static vs non-static was not important here.

@avimehta
Copy link
Contributor Author

@jridgewell ptal

@jridgewell
Copy link
Contributor

LGTM.

@avimehta
Copy link
Contributor Author

When I try to merge this PR I get :

Merge attempt failed
2 of 2 required status checks are expected

Any idea what is wrong?

@jridgewell
Copy link
Contributor

No idea, they never pass for me.

@avimehta
Copy link
Contributor Author

I was running a final check locally and found a missing import. Added that. running tests again. will merge from command line once that is done.

@avimehta
Copy link
Contributor Author

@cramforce I can't seem to merge this PR. Can you take a look?

Thanks

@cramforce cramforce merged commit a79c17d into ampproject:master Apr 11, 2016
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.

4 participants