-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Normalize Referrer classes across devices #1270
Normalize Referrer classes across devices #1270
Conversation
bcb0f01
to
7b8fba5
Compare
7b8fba5
to
6150942
Compare
describe('dynamic classes are inserted at runtime', () => { | ||
let documentElement, win; | ||
beforeEach(() => { | ||
describe.only('dynamic classes are inserted at runtime', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove the only
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
b6d8179
to
2ea67d6
Compare
Assigning to @cramforce, need to know what other apps we want to support. |
|
||
**amp-ua-*** | ||
|
||
A User Agent class will be added when we detect that the document is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
document where the class would be added. (body/documentElement? )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM |
My main question is whether the distinction between referrer and UA is apparent enough. A lot of times, I assume, these could mean the same thing, especially when the document is shown in the iframe. I think it's critical we clarify the distinction between the two or remove it entirely. |
@@ -27,8 +27,8 @@ export class Platform { | |||
* @param {!Window} win | |||
*/ | |||
constructor(win) { | |||
/** @const {!Window} */ | |||
this.win = win; | |||
/** @const {string} */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not a string, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops, fixed.
5ea0456
to
a9ddbc6
Compare
|
||
function addUserAgentClasses(win) { | ||
const classes = ['Facebook', 'Twitter', 'Pinterest'].filter(service => { | ||
return platform[`is${service}`](); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This pattern does not work with closure compiler advanced optimizations.
a9ddbc6
to
ef823f3
Compare
Updated code, please take another look. Will update the docs tomorrow. |
Code looks good. |
|
||
// Normalize t.co names to twitter.com | ||
if (referrer === 't.co') { | ||
referrers = referrers.concat(referrers_('twitter.com')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, we will have both, "t-co" and "twitter-com"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, this will include the both of them. Per my talk with @cramforce yesterday:
Should we normalize
t.co
links totwitter.com
?That would be cool, yeah
Because I want them to get rid of t.co
And if they did we likely would put the opposite hack on our side
So it seems to me we should allow people to use t.co
if they're aware of twitter's short links, or twitter.com
if they're not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd actually prefer to use twitter.com exclusively.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't you think that'll be confusing for the people who are expecting t.co
links?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They can always just see which classes are present in the cases they are testing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
5f5245c
to
9bb543a
Compare
it('should normalize twitter shortlinks to twitter', () => { | ||
return setup(true, '', tcoReferrer).then(() => { | ||
expect(documentElement).to.have.class('amp-referrer-co'); | ||
expect(documentElement).to.have.class('amp-referrer-t-co'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this still being added?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forgot to remove it, sorry.
Do you still have it on your radar to make this extension block the page from unhiding the body before it ran? |
9bb543a
to
758be54
Compare
LGTM |
Added #1415 to track the FOUC issue. |
758be54
to
19d4dc7
Compare
- We normalize `t.co` referrers to `twitter.com` - We add a `www.pinterest.com` referrer when inside the Android Pinterest app.
19d4dc7
to
8e71f6f
Compare
Normalize Referrer classes across devices
For now, these include Facebook, Twitter, and Pinterest with
amp-ua-${SERVICE}
.Fixes #1263.