With the upcoming update you can have in your custom route next to exports.handler an exports.before and exports.after where the before is like the handler and comes before the generated routes and the after comes after all the routes are generated.
If anyone stumbles upon this topic, it's important to note all instructions present in this topic are for Sentry version 7. It doesn't work on the latest version 8
This means when doing the npm install command, you need to select the Sentry version 7, something like:
npm install @sentry/node@7
(I don't know if the command above works, I'm just giving you the idea)