Track Errors in UI

I was thinking about tracking the errors a user encounters within the UI. The idea is that if I'm notified of such errors, I can start to see trends and correct major issues. Has anyone done this before?