CodexWorker

Backend Developer | Go, Microservices, Scalability

URL Lighthouse Integration & Performance Updates

What developments have taken place today?

Today’s commits focused on enhancing the system for collecting and presenting Lighthouse performance data associated with website URLs. Key improvements include a new API endpoint for retrieving this data, an updated Redis store for managing URL Lighthouse information, and modifications to existing code to integrate these changes seamlessly.

Specifically, a new /api/v1/website-url/{id}/lighthouse endpoint was added to fetch lighthouse results based on a website URL ID. This endpoint utilizes a UrlLightHouseStore component within the ApiHandlerDomain, which is now responsible for retrieving and storing Lighthouse data in Redis. The ApiHandlerWebsiteUrl struct has been updated to depend on this store, enabling it to access Lighthouse metrics alongside other website information. A new function GetWebsiteUrlLightHouseList handles the retrieval logic, including error handling for common HTTP status codes.

Significant changes were made within the helper_redis package, shifting from URLLiveData to URLPingData. This refactoring aims to provide a more focused approach to URL data collection and storage. Several unit tests have been updated to reflect these changes, utilizing new mock implementations of UrlLightHouseStore for testing purposes. The logic for retrieving website URLs has also been updated to utilize the new repository.

Furthermore, the API response format was enhanced by adding a LighthouseRating field to the ApiResponseDomain struct and updating the JSON schema accordingly. Validation logic was implemented to ensure this rating is a valid number. The display of website scores on tables was modified to include a “Score” column with color-coded styling based on Lighthouse performance (green for above 90%, yellow for 31-90%, red otherwise).

Finally, the checkLighthouse function within a website controller has been updated to trigger lighthouse checks for all URLs associated with a given website. This ensures that all linked URLs are evaluated and data is collected. A new function GetRating() was also added to calculate a weighted average of performance, accessibility, best practices, and SEO scores.

These changes represent an important step towards providing comprehensive website performance analysis capabilities within the system. By centralizing Lighthouse data collection and making it readily accessible through the API, this work lays the foundation for generating insightful reports and summaries about website health.

lighthouse api redis website url performance monitoring