src/extensions/appscript-extension.js
/**
   * afterRun - Convert location id to name based on location tab.
   * @param {object} context Context object that contains Test and Result objects.
   */
Convert location id to name based on location tab.
@param {object} context Context object that contains Test and Result objects.
Convert location id to name based on location tab . @param { object } context Context object that contains Test and Result objects .
afterRun(context, options) {
    let test = context.test;
    let result = context.result;
    if (test.webpagetest && test.webpagetest.settings) {
      this.locations = this.locations || this.connector.getList('locationsTab');
      this.locations.forEach(location => {
        if (test.webpagetest.settings.locationId === location.id) {
          test.webpagetest.settings.location = location.name;
        }
      });
    }
    if (test.recurring) {
      if (test.recurring.nextTriggerTimestamp) {
        test.recurring.nextTriggerTime = AppScriptHelper.getFormattedDate(
            new Date(test.recurring.nextTriggerTimestamp), this.userTimeZone);
      } else {
        test.recurring.nextTriggerTime = '';
      }
    }
    if (result) {
      if (result.createdTimestamp) {
        result.createdDate = AppScriptHelper.getFormattedDate(
            new Date(result.createdTimestamp), this.userTimeZone, 'MM/dd/YYYY HH:mm:ss');
      }
      if (result.modifiedTimestamp) {
        result.modifiedDate = AppScriptHelper.getFormattedDate(
            new Date(result.modifiedTimestamp), this.userTimeZone, 'MM/dd/YYYY HH:mm:ss');
      }
      let type = result.type === TestType.SINGLE ?
          TrackingType.SUBMIT_SINGLE_TEST : TrackingType.SUBMIT_RECURRING_TEST;
      this.trackAction(type, this.spreadsheetId, result);
      if (result.status === Status.RETRIEVED) {
        this.trackAction(TrackingType.RESULT, this.spreadsheetId, result);
      }
      Object.keys(this.defaultResultValues).forEach(key => {
        if (!result[key]) result[key] = this.defaultResultValues[key];
      });
    }
  }
afterRun ( context , options ) { let test = context . test ; let result = context . result ; if ( test . webpagetest && test . webpagetest . settings ) { this . locations = this . locations || this . connector . getList ( 'locationsTab' ) ; this . locations . forEach ( location => { if ( test . webpagetest . settings . locationId === location . id ) { test . webpagetest . settings . location = location . name ; } } ) ; } if ( test . recurring ) { if ( test . recurring . nextTriggerTimestamp ) { test . recurring . nextTriggerTime = AppScriptHelper . getFormattedDate ( new Date ( test . recurring . nextTriggerTimestamp ) , this . userTimeZone ) ; } else { test . recurring . nextTriggerTime = '' ; } } if ( result ) { if ( result . createdTimestamp ) { result . createdDate = AppScriptHelper . getFormattedDate ( new Date ( result . createdTimestamp ) , this . userTimeZone , 'MM/dd/YYYY HH:mm:ss' ) ; } if ( result . modifiedTimestamp ) { result . modifiedDate = AppScriptHelper . getFormattedDate ( new Date ( result . modifiedTimestamp ) , this . userTimeZone , 'MM/dd/YYYY HH:mm:ss' ) ; } let type = result . type === TestType . SINGLE ? TrackingType . SUBMIT_SINGLE_TEST : TrackingType . SUBMIT_RECURRING_TEST ; this . trackAction ( type , this . spreadsheetId , result ) ; if ( result . status === Status . RETRIEVED ) { this . trackAction ( TrackingType . RESULT , this . spreadsheetId , result ) ; } Object . keys ( this . defaultResultValues ) . forEach ( key => { if ( ! result [ key ] ) result [ key ] = this . defaultResultValues [ key ] ; } ) ; } }
afterRun - Convert location id to name based on location tab.
afterRun - Convert location id to name based on location tab .
// Update locations if there's WPT settings. // Replace locationId with location name. // Format recurring.nextTrigger with user's timezone. // Format createdDate // Format modifiedDate // Send action to Google Analytics // Send retrieved action to Google Analytics. // Set default values if there's no value assigned for specific properties.