Disclaimer
This project is a work in progress - a pre-release version. Please do not attempt to use yet. The projected release date is middle of October, 2019.
@foo-software/lighthouse-trigger
An NPM module to trigger Lighthouse audits to be saved in the cloud. Triggers audits for URLs associated with a lighthouse-check.com account. Utilizing this module within a release or integration workflow would be a standard use case.
Install
npm install @foo-software/lighthouse-trigger
or
yarn add @foo-software/lighthouse-trigger
Usage
Calling lighthouseTrigger
in the example below will trigger Lighthouse audits for all URLs associated with the account having an API token of abc123
.
const { lighthouseTrigger } = require('@foo-software/lighthouse-trigger');
const init = async () => {
const response = await lighthouseTrigger({
apiToken: 'abc123'
});
console.log('response', response);
};
init();
To run Lighthouse audits on a subset of URLs, you can specify an array of URLs denoted by their respective API tokens. Example below.
lighthouseTrigger({
apiToken: 'abc123',
urls: ['cde456', 'fgh789']
});
Parameters
lighthouseTrigger
accepts a single configuration object with the below properties we can think of as parameters.
Name | Description | Type | Required |
---|---|---|---|
apiToken |
The lighthouse-check account API token found in the dashboard. | string |
yes |
urls |
An optional list of URLs represented by their respective API token. URL API tokens can be found in the dashboard. | array |
no |
tag |
An optional tag or name (example: build #2 or v0.0.2 ). |
string |
no |
Return Payload
It's important to note that lighthouseTrigger()
function is encapsulated by a try / catch, so an object should always be returned. Errors are caught, but populated in the return object below.
Name | Description | Type |
---|---|---|
code |
A code to signify failure or succes. |
oneOf(["SUCCESS", "ERROR_GENERIC", ...]) see errorCodes.js for all error codes. |
data |
An array of results returned by the API. | array |
error |
If there was a problem, this property will typically be populated with an error object. This field is only populated when an error was caught or the params didn't pass validation. |
object (typically an error object) |
message |
A message to elaborate on the code. This field isn't always populated. | string |
Credits
This package was brought to you by Foo - a website performance monitoring tool. Create a free account with standard performance testing. Automatic website performance testing, uptime checks, charts showing performance metrics by day, month, and year. Foo also provides real time notifications when performance and uptime notifications when changes are detected. Users can integrate email, Slack and PagerDuty notifications.