Add the appstats recording middleware