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

✨ [amp-analytics] AT Internet - add default vars + new var pixelPath #19446

Merged
merged 3 commits into from Jan 15, 2019

Conversation

BenDz
Copy link
Contributor

@BenDz BenDz commented Nov 26, 2018

AT Internet improvements:

  • Add some default vars
  • Add a new pixelPath var

@BenDz
Copy link
Contributor Author

BenDz commented Nov 26, 2018

Oh yeah, got the build #50000!!
https://travis-ci.org/ampproject/amphtml/builds/459784803 ✨🎉

@BenDz BenDz changed the title ✨ [amp-analytics] AT Internet - add default vars + new var pixelPath ✨ [amp-analytics] AT Internet - add default vars + new var pixelPath Nov 26, 2018
@torch2424
Copy link
Contributor

Assigning to @zhouyx As I think you reviewed this last? 😄

@@ -24,8 +24,8 @@
"atinternet": {
"base": "https://!log!domain/hit.xiti?s=!site&ts=_timestamp_&r=_screen_width_x_screen_height_x_screen_color_depth_&re=_available_screen_width_x_available_screen_height_",
"suffix": "&medium=amp&&ref=_document_referrer_",
"pageview": "https://!log!domain/hit.xiti?s=!site&ts=_timestamp_&r=_screen_width_x_screen_height_x_screen_color_depth_&re=_available_screen_width_x_available_screen_height_&p=_title_&s2=!level2&medium=amp&&ref=_document_referrer_",
"click": "https://!log!domain/hit.xiti?s=!site&ts=_timestamp_&r=_screen_width_x_screen_height_x_screen_color_depth_&re=_available_screen_width_x_available_screen_height_&pclick=_title_&s2click=!level2&p=!label&s2=!level2Click&type=click&click=!type&medium=amp&&ref=_document_referrer_"
"pageview": "https://!log!domain/!pixelPath?s=!site&ts=_timestamp_&r=_screen_width_x_screen_height_x_screen_color_depth_&re=_available_screen_width_x_available_screen_height_&p=_title_&s2=!level2&medium=amp&&ref=_document_referrer_",
Copy link
Contributor

Choose a reason for hiding this comment

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

since you've added the default value to ${pixelPath} and ${domain}, these two variables can be replaced now. You'll need to change the !domain to the default replaced value to fix tests, same applies to !pixelPath. Thanks.

'requests': {
'base': 'https://${log}${domain}/hit.xiti?s=${site}&ts=${timestamp}&r=${screenWidth}x${screenHeight}x${screenColorDepth}&re=${availableScreenWidth}x${availableScreenHeight}',
'base': 'https://${log}${domain}/${pixelPath}?s=${site}&ts=${timestamp}&r=${screenWidth}x${screenHeight}x${screenColorDepth}&re=${availableScreenWidth}x${availableScreenHeight}',
Copy link
Contributor

Choose a reason for hiding this comment

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

If I understand this correctly, you want all the requests send to your server? Is there any reason to override the default domain? If not, why don't we encode it to the base request instead.

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 goal was to have a default value for the ${domain} variable, since it can be customized for some clients, but most of them will use our default domain (xiti.com).
I'm not sure I understood correctly how those default vars work though... Is it for this kind of use case? Same goes for ${pixelPath}. Thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@zhouyx just checking if you saw my answer. Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

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

@BenDz There is an issue with replacing the hostname. As all variables will by default be decoded. We are currently working on a fix to this issue.

Copy link
Contributor

@zhouyx zhouyx Dec 10, 2018

Choose a reason for hiding this comment

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

BTW: There's #19759 to track this issue.

Copy link
Contributor

Choose a reason for hiding this comment

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

@BenDz Sorry for the delay here. The team had some discussion on encoding the request domain. We think putting variables in the request domain is risky.

Your example with domain=.xiti.com works, because encodeURIComponent('.xiti.com') = 'xiti.com'. But the request will break if one put domain=.xiti.com/productPage because the request is encoded to xiti.com%2FproductPage. This type of issue will be very difficult to debug if happen.

#19759 is our attempt to fix this issue.

I understand that you have the best knowledge on the expecting value to the ${log} and ${domain}. If you think our concern won't be an issue with your use case and you want to continue with the current approach. We can definitely unblock this PR. But please document (a comment?) that the value for ${log} and ${domain} must equal itself after encoding.

Let me know if this sounds good, Thank you!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@zhouyx Thanks for the update. We do have the new ${pixelPath} that will take care of the path. Then, ${domain} should never contain encoded characters.
I can also add this to our documentation.

By the way, I will update the tests to fix it.

Thank you!

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good! Thank you.

@zhouyx zhouyx merged commit 8aa9e67 into ampproject:master Jan 15, 2019
@zhouyx
Copy link
Contributor

zhouyx commented Jan 15, 2019

LGTM. PR merged.

@BenDz BenDz deleted the at-vars branch January 21, 2019 10:44
noranazmy pushed a commit to noranazmy/amphtml that referenced this pull request Mar 22, 2019
…mpproject#19446)

* [amp-analytics] AT Internet - add default vars + new var pixelPath

* Fix atinternet tests
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.

None yet

5 participants