{"id":16251987,"url":"https://github.com/robinglen/lighthouse-cron","last_synced_at":"2025-03-19T20:31:08.958Z","repository":{"id":89921001,"uuid":"86829071","full_name":"robinglen/lighthouse-cron","owner":"robinglen","description":"Tool to run light house cron jobs on multiple urls and ship results","archived":false,"fork":false,"pushed_at":"2022-12-19T18:27:04.000Z","size":135,"stargazers_count":44,"open_issues_count":2,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-17T10:51:36.216Z","etag":null,"topics":["audit","ci-cd","lighthouse","lighthouse-audits","performance","performance-metrics","pwa","synthetic-test"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/robinglen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2017-03-31T14:38:49.000Z","updated_at":"2023-11-16T02:40:40.000Z","dependencies_parsed_at":"2023-06-03T16:30:08.881Z","dependency_job_id":null,"html_url":"https://github.com/robinglen/lighthouse-cron","commit_stats":null,"previous_names":["thearegee/lighthouse-cron"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robinglen%2Flighthouse-cron","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robinglen%2Flighthouse-cron/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robinglen%2Flighthouse-cron/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robinglen%2Flighthouse-cron/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robinglen","download_url":"https://codeload.github.com/robinglen/lighthouse-cron/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244501260,"owners_count":20462833,"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":["audit","ci-cd","lighthouse","lighthouse-audits","performance","performance-metrics","pwa","synthetic-test"],"created_at":"2024-10-10T15:11:59.999Z","updated_at":"2025-03-19T20:31:08.613Z","avatar_url":"https://github.com/robinglen.png","language":"JavaScript","readme":"# Lighthouse Cron\n\u003e Cron multiple batch [Lighthouse](https://github.com/googlechrome/lighthouse) audits and emit results for sending to remote server.\n\nWant to track your Lighthouse scores and metrics overtime? This module will allow you to write a simple script to perform multiple audits over time and allow you to transport the results.\n\n## Set up\n\n```Bash\nnpm install --save lighthouse-cron\n```\n\n## Usage\n```Javascript\nconst LighthouseCron = require('lighthouse-cron');\nconst lighthouseCron = new LighthouseCron(\n  [\n    {\n      url: 'https://www.google.com/'\n    }\n  ],\n  '00 00,15,30,45 * * * 0-6'\n);\n\nlighthouseCron.on('auditComplete', audit =\u003e {\n  console.log(audit);\n});\n\nlighthouseCron.init();\n```\n\n### Reference\n\n#### `new LighthouseCron(urls, cron, timezone, chromeFlags, lighthouseFlags, lighthouseConfig)`\nCreate a new instance of lighthouse cron.\n\n##### Parameters\n* `urls` - **Required.** Array of objects including the url as a property.\n* `cron` - String for cron pattern *(Default: '00 00 * * * 0-6')*\n* `timezone` - String for cron timezone *(Default: 'Europe/London')*\n* `chromeFlags` - Array of Chrome flags e.g. `['--headless']`\n* `lighthouseFlags` - Object to enable Lighthouse flags\n* `lighthouseConfig` - Object describe custom configurations for lighthouse runs\n\n#### `init(autorun)`\nInitialise lighthouse cron.\n\n##### Parameters\n* `autorun` - Boolean for if cron should do first run instantly *(Default: false)*\n\n### Events\n\n#### `auditComplete`\nAfter a lighthouse audit is complete on a url this event returns the results.\n\n#### `cronCycleComplete`\nAfter the cron job has been complete an event is emitted.\n\n#### `allAuditsComplete`\nAfter all lighthouse audits are complete an event is emitted.\n\n#### `error`\nIf a an error occurs an event is emitted with the error returned.\n\n## Examples\nBelow is an example of how you could report performance metrics and lighthouse scores to the data analytics platform [Keen.io](https://keen.io/).\n\n```Javascript\nconst KeenTracking = require('keen-tracking');\nconst LighthouseCron = require('lighthouse-cron');\n\n// Configuring Keen client\nconst keenClient = new KeenTracking({\n  projectId: 'Your Project Id',\n  writeKey: 'Your Write Key'\n});\n\n// Additional website and description fields added to improve your dashboards\nconst lighthouseCron = new LighthouseCron(\n  [\n    {\n      website: 'Google',\n      description: 'Homepage',\n      url: 'https://www.google.com'\n    },\n    {\n      website: 'YouTube',\n      description: 'Homepage',\n      url: 'https://www.youtube.com'\n    }\n  ],\n  '00 00 * * * 0-6'\n);\n\n// listening for each audit to be complete\nlighthouseCron.on('auditComplete', audit =\u003e {\n  const report = generateTrackableReport(audit);\n  keenClient.recordEvent('lighthouse audits', report);\n});\n\n\n// Pulling out the metrics we are interested in\nfunction generateTrackableReport(audit) {\n  const reports = [\n    'first-meaningful-paint',\n    'speed-index-metric',\n    'estimated-input-latency',\n    'time-to-interactive',\n    'total-byte-weight',\n    'dom-size'\n  ];\n\n  const obj = {\n    metadata: audit.metadata,\n    score: Math.round(audit.score),\n    results: {}\n  };\n\n  reports.forEach(report =\u003e {\n    obj.results[report] = getRequiredAuditMetrics(audit.results.audits[report]);\n  });\n  return obj;\n}\n\n// getting the values we interested in\nfunction getRequiredAuditMetrics(metrics) {\n  return {\n    score: metrics.score,\n    value: metrics.rawValue,\n    optimal: metrics.optimalValue\n  };\n}\n\nlighthouseCron.init();\n```\n\nThis demo is also available to be run from this module however instead of reporting the metrics to [Keen.io](https://keen.io/) they are just printed to console.\n\n```Bash\nnpm run demo\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobinglen%2Flighthouse-cron","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobinglen%2Flighthouse-cron","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobinglen%2Flighthouse-cron/lists"}