I was actually mistaken. In the onMount for the main component (that doesn't change between routes) it won't remount between navigation, so this approach would be the most similar to React.
You have a problem here. First is that you are trying to log (which is a server side thing) and send analytics (which is client side) in the same function. It won't work in an onMount because of the logger, since onMount only runs on the client.