HTTPArchive / custom-metrics

Custom metrics to use with WebPageTest agents
Apache License 2.0
19 stars 21 forks source link

Detect WordPress content type #96

Closed felixarntz closed 1 year ago

felixarntz commented 1 year ago

In WordPress specific HTTP Archive research, we've so far typically relied on only home pages of each origin. However, home pages tend to have different layout than many other pages have, and our assumptions on e.g. performance are not segmented in any way regarding content type. It would be helpful to e.g. differentiate between specific performance patterns commonly applied on home pages vs on singular posts.

Therefore this PR introduces a WordPress specific content type detection, based on the body classes that the CMS outputs by default. The PR adds 3 fields with information:

Some WebPageTest tests with this logic (using @westonruter's site as test candidate):

Test websites:

felixarntz commented 1 year ago

cc @tunetheweb @westonruter

max-ostapenko commented 1 year ago

@felixarntz I added a list of tested websites to the PR description to check our test action. (see here)

felixarntz commented 1 year ago

@tunetheweb @max-ostapenko I'm not sure what's going on with the tests in https://github.com/HTTPArchive/custom-metrics/actions/runs/6629171971/job/18007857722?pr=96 Looking at the CI failures, the test code seems to assume it needs to run some of the returned values from this check as commands (which is not the case)? 🤔

Can you advise on that, or is there any documentation on how I should amend those tests?

tunetheweb commented 1 year ago

Just merged a fix to main for this so just updated this branch. Fingers crossed it works now!

tunetheweb commented 1 year ago

Tests now pass. And it automatically comments with the custom metrics for any URLs mentioned in the issue. Saving you the need to run these manually. You can check them to make sure your custom metric change is working as intended.

felixarntz commented 1 year ago

@tunetheweb @max-ostapenko I'm not sure I understand how the automated tests are supposed to work. Looking at the results in https://github.com/HTTPArchive/custom-metrics/pull/96#issuecomment-1777769835, for example https://webpagetest.httparchive.org/details.php?test=231024_AD_V&run=1&cached=0#:~:text=cms-,%7B%22wordpress%22%3A%7B%22block_theme%22%3Afalse%2C%22has_embed_block,-%22%3Afalse%2C%22embed_block_count%22%3A%7B%22total, I don't see the metrics from this PR being added at all.

If they were incorrect, I would assume there may be a problem with the PR, but given that the field that this PR is adding is missing entirely, I wonder whether the tests are working as intended. The cms.wordpress object should have a content_type property, but that is not the case, which makes me think this is not using the latest JS from this branch.

max-ostapenko commented 1 year ago

@felixarntz The tested custom metric is called _cms, so you should look for _cms.wordpress.content_type.

The other cms custom metrics I believe are the ones used in production currently.

Screenshot 2023-10-24 at 22 41 23

tunetheweb commented 1 year ago

They should show in "Changed custom metrics values:" section though, which I believe @max-ostapenko is looking at in #100. Will see if we can get that merged first to test on this PR.

github-actions[bot] commented 1 year ago
Custom metrics for https://almanac.httparchive.org/en/2022/ WPT test run results: http://webpagetest.httparchive.org/results.php?test=231024_MZ_1T
Custom metrics for https://weston.ruter.net/ WPT test run results: http://webpagetest.httparchive.org/results.php?test=231024_KD_1V Changed custom metrics values: ```json { "_cms": { "wordpress": { "block_theme": false, "has_embed_block": false, "embed_block_count": { "total": 0, "total_by_type": [] }, "scripts": [], "content_type": { "template": "home-blog", "post_type": "post", "taxonomy": "" } } } } ```
Custom metrics for https://weston.ruter.net/about/ WPT test run results: http://webpagetest.httparchive.org/results.php?test=231024_R4_1W Changed custom metrics values: ```json { "_cms": { "wordpress": { "block_theme": false, "has_embed_block": false, "embed_block_count": { "total": 0, "total_by_type": [] }, "scripts": [], "content_type": { "template": "singular", "post_type": "page", "taxonomy": "" } } } } ```
Custom metrics for https://weston.ruter.net/category/wordpress/ WPT test run results: http://webpagetest.httparchive.org/results.php?test=231024_2R_1X Changed custom metrics values: ```json { "_cms": { "wordpress": { "block_theme": false, "has_embed_block": false, "embed_block_count": { "total": 0, "total_by_type": [] }, "scripts": [], "content_type": { "template": "archive", "post_type": "", "taxonomy": "category" } } } } ```
Custom metrics for https://weston.ruter.net/2023/07/01/running-the-wordpress-plugin-directory-slurper/ WPT test run results: http://webpagetest.httparchive.org/results.php?test=231024_T8_1Y Changed custom metrics values: ```json { "_cms": { "wordpress": { "block_theme": false, "has_embed_block": false, "embed_block_count": { "total": 0, "total_by_type": [] }, "scripts": [ { "handle": "comment-reply", "src": "https://weston.ruter.net/wp-includes/js/comment-reply.min.js?ver=6.4-RC2", "in_footer": true, "async": true, "defer": true, "intended_strategy": "async", "after_script_size": null, "before_script_size": null, "extra_script_size": null, "translations_script_size": null } ], "content_type": { "template": "singular", "post_type": "post", "taxonomy": "" } } } } ```
tunetheweb commented 1 year ago

They should show in "Changed custom metrics values:" section though, which I believe @max-ostapenko is looking at in #100. Will see if we can get that merged first to test on this PR.

This is fixed now and seems to be working. Thanks @max-ostapenko !