55use Illuminate \Database \Eloquent \Model ;
66use Illuminate \Events \Dispatcher ;
77use Illuminate \Http \Request ;
8+ use Illuminate \Routing \Events \RouteMatched ;
89use Illuminate \Support \Facades \App ;
910use Illuminate \Support \Facades \Auth ;
10- use Illuminate \Support \Facades \Request as CurrentRequest ;
1111
1212class LaravelMixpanelEventHandler
1313{
@@ -88,15 +88,16 @@ public function onUserLogout(Model $user = null)
8888 }
8989
9090 /**
91- * @param $route
91+ * @param RouteMatched $route
9292 */
93- public function onViewLoad ($ route )
93+ public function onViewLoad (RouteMatched $ routeMatched )
9494 {
9595 if (Auth::check ()) {
9696 $ this ->mixPanel ->identify (Auth::user ()->getKey ());
9797 $ this ->mixPanel ->people ->set (Auth::user ()->getKey (), [], $ this ->request ->ip ());
9898 }
9999
100+ $ route = $ routeMatched ->route ;
100101 $ routeAction = $ route ->getAction ();
101102 $ route = (is_array ($ routeAction ) && array_key_exists ('as ' , $ routeAction ) ? $ routeAction ['as ' ] : null );
102103 $ this ->mixPanel ->track ('Page View ' , ['Route ' => $ route ]);
@@ -107,9 +108,9 @@ public function onViewLoad($route)
107108 */
108109 public function subscribe (Dispatcher $ events )
109110 {
110- $ events ->listen ('auth.attempt ' , 'GeneaLabs\LaravelMixpanel\Listeners\LaravelMixpanelEventHandler@onUserLoginAttempt ' );
111- $ events ->listen ('auth.login ' , 'GeneaLabs\LaravelMixpanel\Listeners\LaravelMixpanelEventHandler@onUserLogin ' );
112- $ events ->listen ('auth.logout ' , 'GeneaLabs\LaravelMixpanel\Listeners\LaravelMixpanelEventHandler@onUserLogout ' );
113- $ events ->listen ('router.matched ' , 'GeneaLabs\LaravelMixpanel\Listeners\LaravelMixpanelEventHandler@onViewLoad ' );
111+ $ events ->listen ('Illuminate\Auth\Events\Attempting ' , 'GeneaLabs\LaravelMixpanel\Listeners\LaravelMixpanelEventHandler@onUserLoginAttempt ' );
112+ $ events ->listen ('Illuminate\Auth\Events\Login ' , 'GeneaLabs\LaravelMixpanel\Listeners\LaravelMixpanelEventHandler@onUserLogin ' );
113+ $ events ->listen ('Illuminate\Auth\Events\Logout ' , 'GeneaLabs\LaravelMixpanel\Listeners\LaravelMixpanelEventHandler@onUserLogout ' );
114+ $ events ->listen ('Illuminate\Routing\Events\RouteMatched ' , 'GeneaLabs\LaravelMixpanel\Listeners\LaravelMixpanelEventHandler@onViewLoad ' );
114115 }
115116}
0 commit comments