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.
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.
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.
| ' source or canonical origin.'); | ||
| return; | ||
| } | ||
| if (element[ORIGINAL_HREF_PROPERTY] == null) { |
There was a problem hiding this comment.
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 |
| createCookieIfNotPresent: true, | ||
| }, consent); | ||
| }).then(cid => { | ||
| if (!clientIds) { |
There was a problem hiding this comment.
Why not just initialize it above? It's just one object.
There was a problem hiding this comment.
Please let me have my premature optimizations :)
| const supportedReplacements = { | ||
| 'CLIENT_ID': true, | ||
| 'QUERY_PARAM': true, | ||
| }; |
There was a problem hiding this comment.
We could reuse the same supportedReplacements by settings its values to false.
There was a problem hiding this comment.
Yeah, it also isn't actually used like that, i think. I don't care about allocation on click :)
- 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_PARAMandCLIENT_ID<a>tag.Fixes #4078