add a function for recording events