Code Insights: Fix bad overcount FE pings about additional and removal insight events
Created by: vovakulikov
Background
On the FE we have some pings-related code that supposes to track changes in the setting cascade then calculate the difference between two versions of the cascade (before changes and after) and run or not some ping track.
You can find this logic here → https://sourcegraph.com/github.com/sourcegraph/sourcegraph/-/blob/client/web/src/insights/analytics.ts?L30&subtree=true
Execution of that is placed here → https://sourcegraph.com/github.com/sourcegraph/sourcegraph@f0e6c5298df55ff77316c49b834d2805ce735236/-/blob/client/web/src/SourcegraphWebApp.tsx?L355&subtree=true
The problem that we currently have is that we also have a persistence cache system around setting cascade in our local storage. It turned out that it broke Code Insights Pings
Here is the flow of the problem
- User A changes something via the creation UI
- Creation UI change the setting cascade and save it in our BE
- User B opens the page
- Our persistence cache loads setting cascade from the local storage first, settings without changes from User A
- Then request for the latest settings to the BE has been resolved and we've got two versions of settings (local storage and the latest from the backend)
- Our ping will track this since we've got two versions of the setting cascade
As a result, this problem makes that each user tracks changes from other users thus we have a huge overcount problem.