All those things can be gathered from the initial request if you can set a cookie on the user's machine using a cookie header. If you're Firebase then you'd need a request for firebase-analytics.js to set the cookie, but the file itself could be empty.
Also useful to know what fraction of your users are recurring versus new users to tell whether people actually return to your site or if they just check it out once.
Once the cookie is set you can get all this from the server side logs.
Lastly, the refer stats can help you figure out what other sites and communities are interested in your project so that you can further engage with them.
Referers, if they're available at all, come in an HTTP header so once again server side logs would give you this data.
There is no reason to serve any JS for logging unless you want browser fingerprinting data like the user's window size. If your analytics script is more than 0kb then you're tracking people.
Remember awstats and jwstats?
But it doesn't take 50 kB of JS to be able to do that!
Also, believing a page is better because I spend 10 minutes on it rather than 5 is nonsensical. Am I reading everything (good) or am I hunting around for some piece content and not finding it (bad)?
Time on page is a stupid metric that doesn't measure anything useful.
It's not like this data gives you an immediate and perfect readout of the user's entire brain, but it's not useless either.
If you collect information about how often a user is moving their mouse and scrolling the page in order to tell how long someone has been on a page then you've moved from collecting what's useful to collecting everything you can just in case it's useful. That decision comes at the cost of invading everyone's privacy, and that needs to stop.