Created
February 10, 2015 09:09
-
-
Save rdwallis/a4b2e264cea2bcdf4946 to your computer and use it in GitHub Desktop.
GWTP Navigation Tracker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package YOUR_PACKAGE_NAME | |
import javax.inject.Inject; | |
import com.arcbees.analytics.shared.Analytics; | |
import com.google.web.bindery.event.shared.EventBus; | |
import com.gwtplatform.mvp.client.proxy.NavigationEvent; | |
import com.gwtplatform.mvp.client.proxy.NavigationHandler; | |
import com.gwtplatform.mvp.shared.proxy.TokenFormatter; | |
public class NavigationTracker implements NavigationHandler { | |
private final Analytics analytics; | |
private final TokenFormatter tokenFormatter; | |
@Inject | |
NavigationTracker(TokenFormatter tokenFormatter, EventBus eventBus, Analytics analytics) { | |
this.analytics = analytics; | |
this.tokenFormatter = tokenFormatter; | |
eventBus.addHandler(NavigationEvent.getType(), this); | |
} | |
@Override | |
public void onNavigation(final NavigationEvent navigationEvent) { | |
analytics.sendPageView().documentPath(tokenFormatter.toPlaceToken(navigationEvent.getRequest())).go(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment