What you've described is basically a heat map data collection script, or part of one.
The script will capture the (x,y) coordinates and cache a running log of where events occurred. It's proxying the events and then forwarding them, so it can get inbetween the event and the outcome, and record the event's details with greater precision.
Since JavaScript events are asynchronous, one part of the heatmap recorder may have been decoupled and not directly connected to the rest of its sibling scripts in a very obvious way.
But anyway, to get to the point, these heatmap apparatuses do spew useless data, user by user, and can hog system resources in non-obvious ways, but in aggregate, across thousands or millions of users, develop a picture of how many users clicked directly on a button, in proximity to a button, and which button, out of a selection of buttons, was clicked in whichever order.
After deploying something like this, the raw (x,y) coordinate data is then collected, and used to generate an image. The image consists of they watthe webpage appeared to the user, and then a semi-transparent false-color overlay is placed as a layer over the appearance of the web page, and the (x,y) coordinates color the pixels red/hot for many clicks, and blue/cold for fewer clicks, like a topographical map.
See the results of similar scripts here:
https://duckduckgo.com?q=!googleimages+web+page+click+heatma...
Similar heatmaps are generated in more controlled environments, with eye motion tracking tests, where the user consents to sit in a room, in front of a computer, with a camera attached, and use a redesigned website or app, while the system records the specifics of their behavior, capturing not only clicks, but where they were looking, and how their eyes moved toward the elements that received clicks.
Testing processes like these can be really expensive to perform.
This is usually done to gather evidence of an effective design layout, among competing designs in an A/B test.
If you only noticed part of the script that proxies the click events, it may be that someone left part of an A/B test harness behind, by mistake, or that part of the harness was left out by mistake. These sorts of scripts definitely take the collected click coordinates, and forward them to the server, otherwise it's not possible to assemble the individual events into a heatmap.