lundi 23 novembre 2015

Can we detect replaceState in an Ember transition?

We use this recipe to track google analytics page views:

Which is

var Router = Ember.Router.extend({
  // customization goes here
});

Router.reopen({
  notifyGoogleAnalytics: function() {
    return ga('send', 'pageview', {
        'page': this.get('url'),
        'title': this.get('url')
      });
  }.on('didTransition')
});

export default Router;

We now have some replaceState functionality in our app, which triggers this code, and we don't want it to.

Is there something we can do to this code sample (or a totally different approach), to detect the transition is a replaceState (as opposed to pushState) so we can add logic to not send the page view?




Aucun commentaire:

Enregistrer un commentaire