Custom patch advice please?

I want advice on implimenting my Mautic patch please. So I edited “app\bundles\PageBundle\Model\PageModel.php” and changed something in the “hitPage(” function i commented out the “return” in this operation


        // Don't skew results with user hits
        if (!$this->security->isAnonymous()) {
            // return;
        }

So the reason i did that was because I am implimenting that function in a custom api endpoint i made and since the api agent is considered a logged in user the function will be aborted because of the above logic and return operation.
The reason I have exposed this function in an endpoint is because i want to track external event data (as well as internal events)/