Finding average of stream of numbers
This is a good first-cut solution to the functional requirement of stated question. However, when you look at it as production code related to two companies (X and Y) these points arise:


Monolithic: The code should be well demarcated across X and Y company logic. A single analytics function is processing all of the logic with an (admittedly, nice) value control. This has merged the implementation into one piece of code. Say, Y no longer needs the average or, maybe needs something else. Change in code for Y will need to engage with the primary logic of X's code.
Scaling: Imagine a new company Z wants to get not just the average but also the number of data points seen by X (the totalPoints). Changing this monolithic analytics code would engage with all of the existing logic.


These are probably not the only points (and they are also both associated with monolithic and scaling issues). I am just trying to imagine some scaling paths and outline the monolithic-nature of this solution.

To get a fair view of this, consider some changes in the requirements and attempt to modify the code to incorporate them. The complexity required in the edit should be reasonably comparable to the requirement (not higher). Contact of the edit with other parts of the implementation should be minimal.

From a different standpoint, this code would be called a prototype of the logic. The production version would need to handle aspects beyond functionality (like: maintainability, scaling, business-logic separation, readability too).

I wonder if you were asked further questions by the interviewer after reading this program. Were they alluding towards these points.