extensions/amp-consent/0.1/consent-state-manager.js
/**
   * send a POST request to the updateHref with userId with fixed scope
   * and consentInstanceIds
   * @param {!ConsentInfoDef} consentInfo
   */
send a POST request to the updateHref with userId with fixed scope
and consentInstanceIds
@param {!ConsentInfoDef} consentInfo
send a POST request to the updateHref with userId with fixed scope and consentInstanceIds @param { !ConsentInfoDef } consentInfo
sendUpdateHrefRequest_(consentInfo) {
    if (!this.onUpdateHref_) {
      return;
    }
    const consentState =
        calculateLegacyStateValue(consentInfo['consentState']);
    const cidPromise = Services.cidForDoc(this.ampdoc_).then(cid => {
      return cid.get({scope: CID_SCOPE, createCookieIfNotPresent: true},
          Promise.resolve());
    });
    cidPromise.then(userId => {
      const request =  ({
        'consentInstanceId': this.id_,
        'ampUserId': userId,
      });
      if (consentState != null) {
        request['consentState'] = consentState;
      }
      if (consentInfo['consentString']) {
        request['consentString'] = consentInfo['consentString'];
      }
      const init = {
        credentials: 'include',
        method: 'POST',
        body: request,
        ampCors: false,
      };
      Services.viewerForDoc(this.ampdoc_).whenFirstVisible().then(() => {
        Services.xhrFor(this.ampdoc_.win).fetchJson(
             (this.onUpdateHref_), init);
      });
    });
  }
sendUpdateHrefRequest_ ( consentInfo ) { if ( ! this . onUpdateHref_ ) { return ; } const consentState = calculateLegacyStateValue ( consentInfo [ 'consentState' ] ) ; const cidPromise = Services . cidForDoc ( this . ampdoc_ ) . then ( cid => { return cid . get ( { scope : CID_SCOPE , createCookieIfNotPresent : true } , Promise . resolve ( ) ) ; } ) ; cidPromise . then ( userId => { const request = ( { 'consentInstanceId' : this . id_ , 'ampUserId' : userId , } ) ; if ( consentState != null ) { request [ 'consentState' ] = consentState ; } if ( consentInfo [ 'consentString' ] ) { request [ 'consentString' ] = consentInfo [ 'consentString' ] ; } const init = { credentials : 'include' , method : 'POST' , body : request , ampCors : false , } ; Services . viewerForDoc ( this . ampdoc_ ) . whenFirstVisible ( ) . then ( ( ) => { Services . xhrFor ( this . ampdoc_ . win ) . fetchJson ( ( this . onUpdateHref_ ) , init ) ; } ) ; } ) ; }
send a POST request to the updateHref with userId with fixed scope
 and consentInstanceIds
 @param {!ConsentInfoDef} consentInfo
send a POST request to the updateHref with userId with fixed scope and consentInstanceIds @param { !ConsentInfoDef } consentInfo
/** @type {!JsonObject} */ // Unfortunately we need to keep the name to be backward compatible /** @type {string} */