=== AC
[] Copy the algorithm in [[ https://gerrit.wikimedia.org/g/mediawiki/core/+/079ef4036912441a6e66425e84bed3ca586ba02b/resources/src/mediawiki.user.js#99 | mw.user.generateRandomSessionId ]] into the JS client library to generate pageview/session IDs
[] A unit test is added to test the distribution of pageview/session IDs generated by the algorithm (see note 2 below)
=== Notes
1. The algorithm would be best placed in `DefaultIntegration` (or nearby?) so that it's testable in isolation and so that `DefaultIntegration#getPageviewID()` and `#getSessionID()` get implementations!
2.
>>! In T304379#9400845, @mpopov wrote:
> - We don't actually need to test if ~10% of sessions are determined to be in sample when sample rate is 0.1, etc. – INSTEAD we just need to verify that the distribution of those N numbers (obtained from "normalizing" the randomly generated session IDs) is approximately Uniform(0,1).
> - Fortunately there's a statistical test for that – the [[ https://en.wikipedia.org/wiki/Kolmogorov%E2%80%93Smirnov_test | Kolmogorov–Smirnov test ]]. Actually, pages 139-140 of https://www.johndcook.com/Beautiful_Testing_ch10.pdf describe the procedure and suggests thresholds to use.
> - We can even use an existing library to accomplish this: https://www.npmjs.com/package/@stdlib/stats-kstest
> - PASS if `pValue >= 0.001` (fail to reject the null hypothesis that the two distributions are the same)
> - FAIL if `pValue < 0.001` (reject the null in favor of the alternative hypothesis that the two distributions are different)