Based off of #18104
Migrate piwik service + test.
Note: there are some changes regarding how globals are accessed. These are mostly for tests, since the tests are invoked within node.js (so globals are set via the
global object), so we have to access them from
window rather than just using them.