[nav_timing] client-side timing as an extension

This commit is contained in:
Shish 2024-01-12 12:37:33 +00:00
parent f210716bf5
commit 8308a21cb1
2 changed files with 22 additions and 0 deletions

16
ext/nav_timing/info.php Normal file
View file

@ -0,0 +1,16 @@
<?php
declare(strict_types=1);
namespace Shimmie2;
class NavTimingInfo extends ExtensionInfo
{
public const KEY = "nav_timing";
public string $key = self::KEY;
public string $name = "Nav Timing";
public array $authors = self::SHISH_AUTHOR;
public string $license = self::LICENSE_GPLV2;
public string $description = "Log navigation timing data";
}

6
ext/nav_timing/init.js Normal file
View file

@ -0,0 +1,6 @@
const observer = new PerformanceObserver((list) => {
list.getEntries().forEach((entry) => {
shm_log("timing", {"v": 2, ...entry.toJSON()});
});
});
observer.observe({ entryTypes: ["navigation"] });