Resolve "Update usage metrics: Matomo event queue"
Closes #1034 (closed)
Main content of this MR is the integration of MatomoService with the RccUsageLoggingQueue. (The UsageloggingQueue and the persistent queue it is based on are subject of Usage Logging Queue: Intermediate work for 1034 (!923 - merged) and Prework for #1034 - PersistentQueue (!914 - merged) respectively)
How to test?
There's two ways to go about this:
- Add `import { ConsoleAsUsageLoggingEndpointModule } from '@rcc/examples' to the base_features file of either HCP or PAT – and then angular-import the module. This will give you a little tool on the browser console, that lets you trigger usage logging events:
consoleUsageLogging.job.tick$.next({}) // trigger a new event
consoleUsageLogging.fail=false // simulate failed post attempts for the mock consoleEndpoint
consoleUsageLogging.fail=true // default, simulate successful post attempts for the mock consoleEndpoint
It should tell you what happened to the usage data just triggered and the current size of the queue (If the size is off by a little, it might be due to timing issues, it takes a few milliseconds before changes take effect)
- `import { MockRccPublicRuntimeConfigModule } from '@rcc/examples' and serve the app with production configuration (e.g, can skip --live-reload=false):
ng serve @rcc/app -c=pat-production --ssl --live-reload=false
This will setup Matomo to actually post to the dev site (configured in Matomo, id:2). Serving in dev-configuration, this wouldn't work because Matomo is disabled in dev environment. You can then check the network panel in your dev tools. Switching tabs will trigger one of the logging jobs. You should see request in the network tab. Switching off your connection should let those requests fail.
- Switch to another tab and come back
- Check network tab (should have at least one successful post to Matomo)
- Disconnect from the net or use dev tools to go offline
- Switch tabs back and forth a couple of times while offline
- Wait 70 seconds
- go back online, switch tabs again
- Check network tab (should have one successful post per tab switch)
Imports for both ways from above are part of an earlier commit, in case you want to checkout the base_features file from there.