Here's a reusable object (agent class) StateStatistics that preforms the statistics collection on mutually exclusive states, you can download the source code from https://cloud.anylogic.com/model/859441d5-8848-4e81-b414-ea918cc7a172
The states can be anything (equipment states, client states, staff states, statechart states, etc.) and can be of any type (Object). The statistics collected includes: Total Time in State, # of Occurrences of a State, Average Time in State, Percentage of Time in State. In the example model, a hypothetical statechart is used to generate state changes, and an Option List is the type of states.
I would vote for including such or similar object into AnyLogic.