Improve tracking snowplow events for monitoring
Problem to solve
Investigate ways to intercept dispatched Vuex actions to further dispatch/handle custom snowplow events in an organized fashion, sort of a side effect. In the React world, this would be the job of a Redux middleware.
Currently, we have a monitoring tracking helper utility file that sort of does the job. However, it would be better to consolidate all such actions in one place and also make them so that they do not interfere with the existing flow.
This issue is a result of discussions over !19455 (comment 246996673) and !20818 (comment 251544626)
Proposal
"Vuex store accepts the plugin options that exposes hooks for each mutation" - https://vuex.vuejs.org/guide/plugins.html.
All Vuex actions that need to be tracked can carry that info in the payload. We could have a plugin that is essentially a middleware intercepting all actions and extract the telemetry part of the payload and call snowplow APIs.
Pros:
- Less intrusive to the existing flow.
- Minimal code changes to existing actions that need to be tracked.
- Because it is a middleware if snowplow actions fail that shouldn't stop the interrupt crucial actions.
Cons:
- I'm not sure about the performance impact.
- Depending on the implementation, it might not be very obvious if a particular action is being tracked.