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 viewer CID opt-in #10519
Implement viewer CID opt-in #10519
Conversation
src/service/viewer-cid-api.js
Outdated
'googleanalytics': 'AMP_ECID_GOOGLE', | ||
}; | ||
|
||
export class ViewerCidApi { |
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.
Sprinkle some docs.
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.
done
src/service/viewer-cid-api.js
Outdated
return Promise.resolve(false); | ||
} | ||
|
||
return this.viewer_.getViewerOrigin().then(origin => { |
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.
Can't this viewer.isTrustedViewer
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 see you want it Google specific, 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.
right. impl is the same right now. not sure how soon it can diverge.
depending on how likely we'll be changing the impl of viewer.isTrustedViewer
?
for simplicity, i can change to isTrustedViewer for now if you like
src/service/viewer-cid-api.js
Outdated
/** | ||
* @return {!Promise<boolean>} | ||
*/ | ||
shouldGetScopedCid(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.
I think we should always get a scoped CID when the viewer supports it (and is trusted). The sScopeOptedInForCidApi_
should determine whether we request usage of the API.
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.
done.
PTAL |
}; | ||
|
||
/** | ||
* Exposes CID API if provided by the Viewer. |
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.
Also rename file to GoogleViewerCidApi
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.
shall we leave it for other Viewer integration?
src/service/viewer-cid-api.js
Outdated
getScopedCid(scope) { | ||
return this.shouldUseCidApi_(scope).then(clientIdApi => { | ||
return this.viewer_.sendMessageAwaitResponse('cid', dict({ | ||
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.
See lint error. Must be 'scope': 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.
done
src/service/viewer-cid-api.js
Outdated
* @returns {boolean} | ||
*/ | ||
isSupported() { | ||
return this.viewer_.hasCapability('cid'); |
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 also needs to be guarded by isTrustedViewer
.
shouldUseCidApi_
can then just be isScopeOptedInForCidApi_
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.
good point
Closes #10518