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
Implement outgoing link URL replacements. #5628
Conversation
@zhouyx please take a look |
One thing I don't understand. We still do lazy initialization. What I see here is that |
@zhouyx Could you rephrase your question? I'm not sure I understand. This is intended to only provide a CLIENT_ID into a link if there was another mechanism that previously requested it. |
I see, I thought we would need to wait and replace the URL in all cases. |
Replacement happens on click, while the other mechanisms (analytics) load on page view, so they will probably have run by the time of the click. |
if (!clientIds) { | ||
return null; | ||
} | ||
return clientIds[dev().assertString(scope)]; |
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 quite understand what's the scope here. Is it always the same as what we set clientIds[scope
above?
Would it be possible to getclientIds[scope] = null
here?
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.
scope is the param passed of CLIENT_ID(someScope)
. If the scope is the same, the client ID is the same, which should be what is achieved here. The return value of this statement is undefined
if no async request for the client id was made.
return; | ||
} | ||
if (element[ORIGINAL_HREF_PROPERTY] == null) { | ||
element[ORIGINAL_HREF_PROPERTY] = href; |
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.
where is this used?
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.
Line 647. I'll add a comment as to what this is for.
- Only exposes `QUERY_PARAM` and `CLIENT_ID` - Requires opt-in per `<a>` tag. - Only done for destinations going to the page's source or canonical origin. Fixes ampproject#4078
eb9bc6f
to
7a674bf
Compare
lgtm |
@@ -213,8 +221,22 @@ export class UrlReplacements { | |||
scope: dev().assertString(scope), | |||
createCookieIfNotPresent: true, | |||
}, consent); | |||
}).then(cid => { | |||
if (!clientIds) { |
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 not just initialize it above? It's just one object.
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.
Please let me have my premature optimizations :)
'CLIENT_ID': true, | ||
'QUERY_PARAM': true, | ||
}; | ||
const requestedReplacements = {}; |
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.
We could reuse the same supportedReplacements
by settings its values to false
.
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.
Yeah, it also isn't actually used like that, i think. I don't care about allocation on click :)
…mp_reddit_extension * 'master' of https://github.com/ampproject/amphtml: (63 commits) Position:relative on body (ampproject#5665) Fix for ampproject#5663 (ampproject#5664) Nokta Ad Server is added as an ad type (ampproject#5550) RFC: Separate the load phase of AMP into multiple chunks. (ampproject#5536) Add OWNERS files for A4A. (ampproject#5651) Update DEVELOPING.md Call original event add/remove via interceptor (ampproject#5650) Fix wording on confusing steps to protect against CSRF. (ampproject#5646) Install runtime CSS for all amp tests (ampproject#5642) Implement outgoing link URL replacements. (ampproject#5628) Wait for window to load before installing ServiceWorker. (ampproject#5638) iOS wrapper viewport implementation (ampproject#5629) Do not use AMP Version as RTV Versions (ampproject#5474) Purch Ad Support for Amp-Ads (ampproject#5464) A11Y fix for sticky ad close button. (ampproject#5640) Propagate ARIA attributes to real-elements (ampproject#5590) Ibillboard integration (ampproject#5392) Add some keywords to the NPM description of the validator. (ampproject#5633) PWA: messaging and broadcast (ampproject#5588) Carousel swipe not working well on Android Firefox (ampproject#5626) ...
- Only exposes `QUERY_PARAM` and `CLIENT_ID` - Requires opt-in per `<a>` tag. - Only done for destinations going to the page's source or canonical origin. Implements ampproject#4078
- Only exposes `QUERY_PARAM` and `CLIENT_ID` - Requires opt-in per `<a>` tag. - Only done for destinations going to the page's source or canonical origin. Implements ampproject#4078
QUERY_PARAM
andCLIENT_ID
<a>
tag.Fixes #4078