sitespeedio / sitespeed.io

sitespeed.io is an open-source tool for comprehensive web performance analysis, enabling you to test, monitor, and optimize your website’s speed using real browsers in various environments.
https://www.sitespeed.io/
MIT License
4.75k stars 603 forks source link

Retrieve a run context inside a pre/post script #4274

Open Amerousful opened 1 month ago

Amerousful commented 1 month ago

Feature/improvement

According to the fact that a pre/post-script runs for each URL, it would be useful to have the ability to retrieve the context of the run, such as the URL. My real-life example is that I have logic in a pre-script with try-catch, and there's no way to log details about which specific URL the error occurred on.


fileWithUrls.txt:

https://www.sitespeed.io/
https://www.sitespeed.io/examples/
https://www.sitespeed.io/documentation/
https://www.sitespeed.io/blog/

Command for run:

sitespeed.io --target fileWithUrls.txt --preScript someScript.mjs 
soulgalore commented 1 month ago

Thank you @Amerousful for creating this. I need to think a couple of days how we can fix this the easiest way.

Amerousful commented 1 month ago

Many thanks. I wouldn't call it a fix, it's more about improvements)

soulgalore commented 1 month ago

That part of the code is something I'm not proud of so it's time to clean that up and make it possible to add some smarter logging. I don't like when you cannot log what you need :)