/pagespeed_api_apps_script

This is the repo with the code snippets that supply the "Monitor your Page Speed Insights score using Google Sheets" post regarding getting data off of Google's Pagespeed Insights API into a Google Sheet.

Primary LanguageJavaScript

Page Speed API querying

Page Speed Insights API Apps Script is an application developed by IronistM. It implements two API changes (see details below) that I use as a use-case to evaluate the evolvable-by-design approach that I created.

In this repository, the evolvable-by-design approach is implemented. Other projects are used as use cases, see the evolvable-by-design organization.

Info: this code does not have a frontend. Yet, the evolvable-by-design approach is applicable here because the two types of changes are the base URL and the type of the returned value. Indeed, only a change of the input parameters require a user interface to let the user input the parameters manually.

Repositories

Amount of changes: 2

Types of changes:

  • Change model of returned data (n°3)
  • Rename method (n°5)

Commit with the changes: cb536a

Description of the work done:

  1. Fork the project here
  2. Create an evolvable-by-design branch from the commit before the one introducing the two evolutions
  3. Adapt the application to run locally, because it is initially a Google App Script app (commit)
  4. Create a mock server for both version of the API along with the v1 documentation, because it is not online anymore (commit)
  5. Implements the evolvable-by-design approach in a single commit
  6. Replay the API evolutions (already done in the mock server commit)
  7. Adapt the server to easily change the version 3dceefd
  8. Verify that the client code does not need to be modified in order to continue working -> SUCCESS

Report

  • How many evolutions? ➜ 2 (from v1 to v2)
  • Types of evolutions ➜ change type of return value (n°3) + rename method (n°5)
  • One or several commits? ➜ 1
  • How many lines per commit for the original evolution? ➜ 2 (for a 63 lines program)
  • How many lines of code to implement the approach on the frontend? ➜ 15
  • One or several developers ➜ 1
  • If tests, broken? ➜ no tests
  • Covered or not covered? Covered

How to test the evolution

  1. Clone the repository.
  2. Open server/index.js and set const VERSION = 1 in the beginning of the file.
  3. Start the server node server/index.js.
  4. Starts the scripts node run.js -> it should display 80 at then end.
  5. Stop the server with ctrl+c in the window where you launched it.
  6. In the server/index.js set const VERSION = 2 in the beginning of the file
  7. Start the server node server/index.js.
  8. Starts the scripts node run.js -> it should display 70 at then end.
  9. Stop the server with ctrl+c in the window where you launched it.

Original README

Query page speed api using apps script

Example Google Sheet : https://docs.google.com/a/pamediakopes.gr/spreadsheets/d/1snTlcMwaOqk5Km0MeZ8DIbii-NZvWSoFb_Cuhxd3IEU/edit#gid=0