1

I have written a custom module that exports nodes in different formats. The module itself works great but now I would to count how often one of the custom routes is called.

The desired route in the routing.yml looks like this:

path: '/api/datasets/{uuid}'

Is there anything in the drupal api that I could use whenever something like /api/datasets/6c68978e-db0d-48d4-9750-73245d3e2cfb is called?

In the end, I would like generate a statistics file inside the module folder that counts the hits of this route per week. I just need some ideas how this could be realised. So far I couldn't find anything in the drupal api that would help me.

1
  • 1
    If this route is uncacheable you could count in the controller defined in the route. If there is caching involved you need to count in front of the cache. The core node statistic module counts in the browser to be in front of any cache, even the browser cache.
    – 4uk4
    Oct 4, 2022 at 9:17

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.