ValueTrack`CollectTrackEvent
This helps with figuring out what caused a Dynamic to update:
a = 1;
f[x_] := a x^2
ValueTrack`CollectTrackEvent[True]
Dynamic[{ValueTrack`CollectTrackEvent[], f[2]}]
(* {{Hold[a, HoldComplete[a, 1, 2, OwnValues], {909089}]}, 8} *)
a = 2;
ValueTrack`CollectTrackEvent[False]
The functionality is enabled using ValueTrack`CollectTrackEvent[True] and disabled again using ValueTrack`CollectTrackEvent[False]. While it is enabled, ValueTrack`CollectTrackEvent[] will return a list of value changes that were tracked by some Dynamic (while disabled, it will return Null). Some notes:
ValueTrack`CollectTrackEvent[]will return the list of all value changes since the last time it was called. It does not matter whichDynamicwas updated, you simply get one long list.The format seems to be
{{sym_, update_, {boxIDs__}}...}where
symis the symbol causing the update,updateis a description of the update (which part was updated, old and new value, type of value). The format seems to be the same as for the"ValueChange"handler. Finally,boxIDsis a list of IDs of theDynamicBoxexpressions updated by that value change.
Credit goes to Kyle Martin (WRI) for showing this to me. - Thanks again!
There's also ValueTrack`GetTrackingState and ValueTrack`SetTrackingState, but I don't know what they do