{"id":18920422,"url":"https://github.com/uknmr/gas-webpagetest","last_synced_at":"2025-04-15T10:34:11.738Z","repository":{"id":33807805,"uuid":"103866108","full_name":"uknmr/gas-webpagetest","owner":"uknmr","description":null,"archived":false,"fork":false,"pushed_at":"2022-12-08T18:15:33.000Z","size":2399,"stargazers_count":78,"open_issues_count":18,"forks_count":15,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-28T20:36:15.132Z","etag":null,"topics":["clasp","data-studio","gas","typescript","webpagetest","webperf"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/uknmr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-17T22:21:07.000Z","updated_at":"2024-06-14T01:31:59.000Z","dependencies_parsed_at":"2023-01-15T02:45:24.442Z","dependency_job_id":null,"html_url":"https://github.com/uknmr/gas-webpagetest","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uknmr%2Fgas-webpagetest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uknmr%2Fgas-webpagetest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uknmr%2Fgas-webpagetest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uknmr%2Fgas-webpagetest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/uknmr","download_url":"https://codeload.github.com/uknmr/gas-webpagetest/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249052008,"owners_count":21204933,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clasp","data-studio","gas","typescript","webpagetest","webperf"],"created_at":"2024-11-08T10:43:14.489Z","updated_at":"2025-04-15T10:34:11.337Z","avatar_url":"https://github.com/uknmr.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gas-webpagetest\n\n\u003e ### *You can't control what you can't measure.*\n\u003e Tom DeMarco (1982) Controlling Software Projects.\n\nThis [Google Apps Scripts](https://developers.google.com/apps-script/) help to measure your website using [WebPagetest](https://www.webpagetest.org/).\n\n## Requirements\n\n- Node.js\n  - This script is written by Node.js\n- [Yarn](https://yarnpkg.com/)\n  - package manager\n  - This repository is managed by Yarn\n- Google Account\n  - Need to login with [clasp](https://github.com/google/clasp).\n  - `gas-webpagetest` is a Google Apps Script.\n- Google Spreadsheet\n  - `gas-webpagetest` record the result of WebPagetest to Google Spreadsheet\n  - 1 sheet = 1 site\n- WebPagetest API Key\n  - [WebPagetest - Get API Key](https://www.webpagetest.org/getkey.php)\n  - `gas-webpagetest` call WebPagetest API and record it.\n\n### Optional\n\n- [Google DataStudio](https://datastudio.google.com/)\n  - It help to visualize your data\n\n## Usage\n\n### Installation\n\n1. git clone this repository\n\n```\ngit clone https://github.com/uknmr/gas-webpagetest.git\ncd gas-webpagetest\n```\n\n2. Install dependencies by yarn\n\n\n```\nyarn install\n```\n\n\n3. If you never use `clasp`, please do `clasp login`\n\n```\nyarn clasp login\n# Login and Authorize clasp\n```\n\n### Integrate Google Spreadsheet with Google Apps Script(`gas-webpagetest`)\n\n4. Create empty spreadsheet that is recorded result of WebPagetest.\n  - You should copy spreadsheet id\n  - For example, your spreadsheet url is `https://docs.google.com/spreadsheets/d/asn__asxScJZi-2asd4242sd23HO441Ok/edit#gid=0`\n  - `asn__asxScJZi-2asd4242sdHOeB6t5XFdOk` is a **spreadsheet id** and copy it\n  \n5. Create new Google Apps Script and connect it your spreadsheet.\n\nRun following command:\n\n```\nyarn run create-gas \"\u003cscript title\u003e\" \"\u003cspreadsheet id\u003e\"\n# Example\n# yarn run create-gas \"gas-webpagetest\" \"asn__asxScJZi-2asd4242sdHOeB6t5XFdOk\"\n```\n\n`yarn run create-gas` command's arguments:\n\n- 1st argument is Google Apps Script title\n- 2nd argument is **spreadsheet id**\n\n:memo: If you met following error, you have to visit the url and enable the Apps Script API.\n\n\u003e Error: Permission denied. Enable the Apps Script API:\n\u003e https://script.google.com/home/usersettings\n\n6. Configure `.env` file\n\nYou have to change these values of `.env` file.\n\n- `WEBPAGETEST_API_KEY`: WebPagetest API key\n    - Get from [WebPagetest - Get API Key](https://www.webpagetest.org/getkey.php)\n- `RUN_TEST_URL`: Test target URL\n- `SHEET_NAME`: The name of Google Spread Sheet\n    - Sheet Name is bottom the spread sheet\n    - ![Sheet Name is Here](docs/img/spread-sheet-name.png)\n\n```.env\n# WebPagetest API Key\n## See https://www.webpagetest.org/getkey.php\nWEBPAGETEST_API_KEY=\u003cyour api key\u003e\n# Test Target URL\nRUN_TEST_URL=https://example.com\n# Run Test interval\n## Set run test interval by using Google Apps Script Time-Based Trigger\n## Execute runTest function every RUN_TEST_INTERVAL\n## Example:\n## `2h`, `1h`, or `30m`\n## Limitation:\n## - Can not combine hour with minutes\n##   - `1h30m` =\u003e Error\n## - Allow to set one of `1m`, `5m`, `15m`, `30m` as minutes\nRUN_TEST_INTERVAL=30m\n# Sheet name to record\nSHEET_NAME=Sheet1\n\n# WebPagetest Options\n# https://sites.google.com/a/webpagetest.org/docs/advanced-features/webpagetest-restful-apis\n## Number of test runs (1-10 on the public instance)\n## gas-webpagetest use median results\n....\n```\n\n\n7. Deploy the `gas-webpagetest` script to your Google Apps Script: `yarn run deploy`\n\nRun following command that deploy this apps script.\n\n```\nyarn run deploy\n```\n\n## Setup schedule for `gas-webpagetest` script\n\n`gas-webpagetest` provide these functions and you can invoke these functions from spreadsheet's menu.\n\n![spread sheet menu](docs/img/gas-webpagetest-menu.png)\n\n- Run Test\n  - Run test that call WebPagetest API\n- Get Test results\n  - Get results of the test and write it to spreadsheet\n- Update column titles\n  - Update spreadsheet title columns\n\nThese functions can be called manually.  \nHowever, These functions can be regularly called by **Time Trigger**.\n\nSo, you can set **Time Trigger** by the following function.\n\n- Set run test time triggers\n  - You can set time trigger like cron\n  - By default, it is per 30 minutes\n\n### Setup at first time \n\n0. Visit your google spread sheet\n1. Invoke \"Update column titles\" from spread sheet's menu\n2. Invoke \"Set run test time triggers\" from spread sheet's menu\n3. Complete!\n\nAfter that, `gas-webpagetest` run tests per 30 minutes and put the results to your spreadsheet.\n\n![spread-sheet-example.png](docs/img/spread-sheet-example.png)\n\n## Additional: WebPagetest script\n\nIf you want to use scripting for WebPagetest, uncomment `WEBPAGETEST_OPTIONS_SCRIPT_PATH` in `.env` and write script in `script.txt`.\n\n- \u003chttps://sites.google.com/a/webpagetest.org/docs/using-webpagetest/scripting\u003e\n\n```\n## WebPagetest Scripting Option\n## Set file path to scripting file\n## https://sites.google.com/a/webpagetest.org/docs/using-webpagetest/scripting\nWEBPAGETEST_OPTIONS_SCRIPT_PATH=./script.txt\n```\n\nExample: `script.txt`\n\n```\nlogData\t0\n\n// bring up the login screen\nnavigate\thttp://webmail.aol.com\n\nlogData\t1\n\n// log in\nsetValue\tname=loginId\tsomeuser@aol.com\nsetValue\tname=password\tsomepassword\nsubmitForm\tname=AOLLoginForm\n```\n\n## Optional: Visualization\n\n[Google DataStudio](https://datastudio.google.com) visualize your spreadsheet data.\n\n1. [Connect your spreadsheet](https://datastudio.google.com/data) to [Google DataStudio](https://datastudio.google.com)\n2. Open [Template Project](https://datastudio.google.com/open/16CAqnC3ErfJ_B0UypUq4zQzYdReuW24i)\n3. Click \"Create new report from the copy\" on menu\n    - Use your connected data\n\n![datastudio-example](./docs/img/datastudio-example.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuknmr%2Fgas-webpagetest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fuknmr%2Fgas-webpagetest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuknmr%2Fgas-webpagetest/lists"}