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

Implement viewer CID opt-in #10519

Merged
merged 13 commits into from Jul 19, 2017
Merged

Implement viewer CID opt-in #10519

merged 13 commits into from Jul 19, 2017

Conversation

lannka
Copy link
Contributor

@lannka lannka commented Jul 19, 2017

Closes #10518

'googleanalytics': 'AMP_ECID_GOOGLE',
};

export class ViewerCidApi {
Copy link
Member

Choose a reason for hiding this comment

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

Sprinkle some docs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

return Promise.resolve(false);
}

return this.viewer_.getViewerOrigin().then(origin => {
Copy link
Member

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

Copy link
Member

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?

Copy link
Contributor Author

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

/**
* @return {!Promise<boolean>}
*/
shouldGetScopedCid(scope) {
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

@lannka
Copy link
Contributor Author

lannka commented Jul 19, 2017

PTAL

};

/**
* Exposes CID API if provided by the Viewer.
Copy link
Member

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

Copy link
Contributor Author

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?

getScopedCid(scope) {
return this.shouldUseCidApi_(scope).then(clientIdApi => {
return this.viewer_.sendMessageAwaitResponse('cid', dict({
scope,
Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

* @returns {boolean}
*/
isSupported() {
return this.viewer_.hasCapability('cid');
Copy link
Member

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_

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point

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

4 participants