src/extensions/appscript-extension.js
/**
   * trackAction - Tracking with pageview
   *
   * @param {TrackingType} trackingType A TrackingType, e.g. TrackingType.RESULT.
   * @param {string} sheetId AppScript ID.
   * @param {object} result Processed Result object.
   */
Tracking with pageview
@param {TrackingType} trackingType A TrackingType, e.g.
Tracking with pageview @param { TrackingType } trackingType A TrackingType e . g .
trackAction(trackingType, sheetId, result) {
    let testedUrl = result.url || result.origin || 'No given URL';
    let referral = this.awpVersion || 'awp';
    let url;
    let dataSources = ['webpagetest', 'psi', 'cruxbigquery', 'cruxapi'];
    let activeDataSources = [];
    dataSources.forEach(dataSource => {
      if (result[dataSource]) {
        activeDataSources.push(dataSource);
      }
    });
    if (activeDataSources.length) {
      referral += '/' + activeDataSources.join('/');
    }
    if (this.isSendTrackEvent) {
      url = this.gaEventURL(sheetId, trackingType, testedUrl);
      this.apiHandler.fetch(url);
      if (this.debug) console.log(url);
    }
    let customValues = this.getCustomValues(trackingType, result) || {};
    url = this.gaPageViewURL(referral, sheetId, testedUrl, customValues);
    let response = this.apiHandler.fetch(url);
    if (this.debug) console.log('trackAction: ', url);
    if (this.debug && response.statusCode==200) {
      console.log('trackAction response: ', response.body);
    }
  }
trackAction ( trackingType , sheetId , result ) { let testedUrl = result . url || result . origin || 'No given URL' ; let referral = this . awpVersion || 'awp' ; let url ; let dataSources = [ 'webpagetest' , 'psi' , 'cruxbigquery' , 'cruxapi' ] ; let activeDataSources = [ ] ; dataSources . forEach ( dataSource => { if ( result [ dataSource ] ) { activeDataSources . push ( dataSource ) ; } } ) ; if ( activeDataSources . length ) { referral += '/' + activeDataSources . join ( '/' ) ; } if ( this . isSendTrackEvent ) { url = this . gaEventURL ( sheetId , trackingType , testedUrl ) ; this . apiHandler . fetch ( url ) ; if ( this . debug ) console . log ( url ) ; } let customValues = this . getCustomValues ( trackingType , result ) || { } ; url = this . gaPageViewURL ( referral , sheetId , testedUrl , customValues ) ; let response = this . apiHandler . fetch ( url ) ; if ( this . debug ) console . log ( 'trackAction: ' , url ) ; if ( this . debug && response . statusCode == 200 ) { console . log ( 'trackAction response: ' , response . body ) ; } }
trackAction - Tracking with pageview
 @param {TrackingType} trackingType A TrackingType, e.g.
trackAction - Tracking with pageview @param { TrackingType } trackingType A TrackingType e . g .
// FIXME: Load the list of data sources from awpConfig instead of hardcoded. // Record legacy GA event. // Record tests with perf budget with Pageview notation.