Notice when user changes tab / page gets hidden / page visibility change

How do I listen for this event?

More precisely: Notice when user leaves the page and switches to another tab. I already found https://cookbook.vaadin.com/notice-closed but this isn’t exactly what I need.

Notice when user changes tab / page gets hidden / page visibility change

https://developer.mozilla.org/en-US/docs/Web/API/Page_Visibility_API

So I assume there is no built-in function in vaadin?

Correct