piwik/piwik — pull request #336 by sslavic (2014-06-30 14:23:10+00:00)
Title: [piwik-js] Added support for registering plugins in Tracker public API

So far adding plugins was only accessible through Piwik public API, Piwik.addPlugin.
Problem with this was that it was not possible to register plugins before any event has been handled, since Piwik singleton initialization (and any plugin registration) happens after _paq is processed and this is too late - any registered plugin will not be included in processing events fired by evaluation of _paq array items.

This patch enables registering Tracker plugins on Tracker itself, so addPlugin can be part of _paq instructions.
It is not enforced when addPlugin instructions will be processed (e.g. addPlugin is not part of alwaysFirst), for flexibility - e.g. one can have trackPageView evaluated without plugin, then addPlugin for all the next steps, or one can have addPlugin pushed first to _paq, and then trackPageView, if plugin should be applied for trackPageView as well.