Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
@foo-software/lighthouse-persist
Advanced tools
Readme
@foo-software/lighthouse-persist
A tool for persisting Lighthouse audit results for website monitoring and analysis. Performance, SEO, progressive web app, best practices are exposed in a results object and included in an HTML report. Save reports locally or upload to your AWS S3 bucket.
See a full example report here. This HTML report is generated by lighthouse
.
output
option as html
.lighthouse
directly.npm install @foo-software/lighthouse-persist
Below are a few standard ways of using this module. See parametes and response payload for more details.
Note: to import in an ES Module enabled environment, you'll need to do something like this until we export an ES Module distribution:
import lighthousePersistPackage from '@foo-software/lighthouse-persist';
const { lighthousePersist } = lighthousePersistPackage;
const path = require('path');
const { lighthousePersist } = require('@foo-software/lighthouse-persist');
(async () => {
const { localReport, result } = await lighthousePersist({
url: 'https://www.foo.software',
// example if you have an "artifacts" directory in your root directory
outputDirectory: path.resolve('./artifacts')
});
console.log({ localReport, result });
})();
const { lighthousePersist } = require('@foo-software/lighthouse-persist');
(async () => {
const { report, result } = await lighthousePersist({
url: 'https://www.foo.software',
awsAccessKeyId: 'abc123',
awsBucket: 'myBucket',
awsRegion: 'us-east-1',
awsSecretAccessKey: 'def456'
});
console.log({ report, result });
})();
There are a few benefits of running Lighthouse via PageSpeed Insights API.
loadingExperience
and originLoadingExperience
from the CrUX API (under the hood).The downside is that you won't have all the configuration options by not using Lighthouse directly, like specific network settings and extraHeaders
. But in most cases, the default settings are all you need. You can still target mobile
or desktop
via strategy
. If using @foo-software/lighthouse-persist
strategy
will be derived from config.settings.emulatedFormFactor
and defaults to mobile
.
This module will get results from PageSpeed Insights API, and generate an HTML report (optionally), and provide the result consistently with the other examples. The only mandatory parameter to run with PageSpeed Insights API is psiKey
.
const lighthousePersist = require('@foo-software/lighthouse-persist').default;
(async () => {
const { loadingExperience, report, result } = await lighthousePersist({
url: 'https://www.foo.software',
awsAccessKeyId: 'abc123',
awsBucket: 'myBucket',
awsRegion: 'us-east-1',
awsSecretAccessKey: 'def456',
psiKey: 'ghi789',
});
console.log({ loadingExperience, report, result });
})();
There are two different ways to persist reports. Both ways have required params. Using both is also supported. The url
param is required always.
outputDirectory
param.awsAccessKeyId
, awsBucket
, awsRegion
, and awsSecretAccessKey
params.Name | Description | Type | Default |
---|---|---|---|
awsAccessKeyId | The AWS accessKeyId for an S3 bucket. | string | undefined |
awsBucket | The AWS Bucket for an S3 bucket. | string | undefined |
awsRegion | The AWS region for an S3 bucket. | string | undefined |
awsSecretAccessKey | The AWS secretAccessKey for an S3 bucket. | string | undefined |
config | The Lighthouse configuration. | object | The default config should align with Chrome DevTools. See the exact default config here or snapshot here. |
finalScreenshotAwsBucket | The AWS Bucket for an S3 bucket. If this is defined, the final screenshot will be uploaded here | string | undefined |
options | The Lighthouse programmatic options, similar to the CLI. | object | See the exact default options here or snapshot here. |
outputDirectory | An absolute directory path to output report. You can do this an an alternative or combined with an S3 upload. | string | undefined |
psiKey | To run Lighthouse via PageSpeed Insights API, provide your API key. WARNING: some Lighthouse options are not available with PageSpeed Insights (example: extraHeaders ). strategy will be derived from config.settings.emulatedFormFactor and defaults to mobile . | string | undefined |
url | The URL to run audits against. | string | undefined |
The result of calling the default function with the parameters above is an object with the below properties.
Name | Description | Type |
---|---|---|
finalScreenshot | A URL to the final screenshot image. This will only be defined if finalScreenshotAwsBucket parameter was. | string |
loadingExperience | If psiKey was specified and the PageSpeed Insights response includes loadingExperience as documented, then this will be populated with an object per the shape described in the documentation. It's possible this data will not exist for some URLs. Read more about the CrUX API. | object |
localReport | A local path to the report (if applicable). | string |
result | A comprehensive result - the equivalent of what is returned when using the lighthouse module directly. | object |
originLoadingExperience | If psiKey was specified and the PageSpeed Insights response includes originLoadingExperience as documented, then this will be populated with an object per the shape described in the documentation. It's possible this data will not exist for some URLs. Read more about the CrUX API. | object |
report | A URL to the report HTML file. | string |
If you're interested running Lighthouse audits on your web pages automatically - check out www.foo.software. Foo runs audits automatically, stores results and provides charts in a timeline view. You can also trigger runs via Foo's public REST API and tag (with a build number for example).
This package was brought to you by Foo - a website quality monitoring tool. Automatically test and monitor website performance, SEO and accessibility with Lighthouse. Analyze historical records of Lighthouse tests with automated monitoring. Report with confidence about SEO and performance improvements to stay on top of changes when they happen!
FAQs
A tool for persisting Lighthouse audit results used for website performance monitoring and analysis.
The npm package @foo-software/lighthouse-persist receives a total of 64 weekly downloads. As such, @foo-software/lighthouse-persist popularity was classified as not popular.
We found that @foo-software/lighthouse-persist demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.