State, when state? - answering the (sometimes) unanswerable

Sometimes, during the lifetime of your application, you might like to know answers to questions such as:

How many times has the product X been added to the cart but not bought during last year. Or, what products the user Y added to cart but never bought?

How much units of value did User Y spend during February last year?

What was the exact state prior to crash happening?

While some of these could be answered by looking at system logs, provided those existed and were detailed enough, there is another way you could approach maintaining the state which can all but guarantee you will get questions similar to these answered.