Closed jpgarcia closed 11 years ago
actually my app is not named app :) and it works as when you define the plugin in you're injecting the app as a parameter, but yes you're right this.app is much better.
To reproduce the issue:
Create two plugins:
(function($) {
Sammy = Sammy || {};
Sammy.PluginA = function(app) {
this.bind('event-context-after', function() {
console.log('PluginA path:' + this.path)
});
};
})(jQuery);
(function($) {
Sammy = Sammy || {};
Sammy.PluginB = function(app) {
this.bind('event-context-after', function() {
console.log('PluginB path:' + this.path)
});
};
})(jQuery);
Enable both in your app:
this.use('PluginA');
this.use('PluginB');
PluginA path:/#/home
PluginB path:event-context-after
I've just pushed the this.app update as you suggested.
Hey guys, I've also added a new one for KISSmetrics
thanks!
Ah, sorry about that. You are of course correct. Still this.app might be better, so thanks for that. Hm.. I am thinking, since you added another kind of tracking plugin, does it make more sense to create a separate repository for those and add a link in the README or a separate file in the plugins directory? I am not sure. It's nice to have everything in one place though. What do you think?
@jpgarcia any thoughts on this? :)
Hey endor! mmm I don't think so. I'd go for the option B (having a new file in plugins' folder and keep them in the same repo)
... Sorry about my delayed response! I must have forgotten to reply 4 months ago :)
I've just added a new plugin for tracking page views on Mixpanel, hope you find it useful.
Also performed some tweaks on the Google Analytics plugin as I realized that when binding two 'event-context-after' events (e.g.:Google Analytics + Mixpanel plugins) you receive the path value as 'event-context-after' instead of the actual path on the 2nd plugin declared. So I updated to code to get the path from app.last_location[1] rather than from this.path.
Please let me know if there is a better approach to get this path and using both plugins at the same time.