Pass `doc` to `on_before_dispatch`

This allows users to log outgoing documents before they are sent.