Where would I put a piece of code that I want to execute on entry to every route?

I want to log the user and current route every time a route is visited.

I am sure there are other ways but we do ember-cli-analytics in router.js init


const Router = EmberRouter.extend( {

  init() {
   // do your thing


Yeah there are a number of ways you could do it but I think @broerseā€™s suggestion of the router makes the most sense. Iā€™d probably use the didTransition hook on the router personally (docs here).

1 Like

Thanks guys never thought to use the router!