objectiv-analytics
objectiv-analytics copied to clipboard
Tracker Initialization: allow to re-initialize
Currently Trackers are immutable, exception made for a few properties like the active flag.
Nonetheless, sometimes it's necessary to reconfigure a Tracker instance with more complicated changes, like a new set of plugins, or a different Transport.
We have built a PoC for this in the https://github.com/objectiv/objectiv-analytics/pull/1164 PR, and we need to formalize these changes in a more coherent set of changes:
- Plugins and Transport should not rely on constructors to initialize, instead we should have a dedicated lifecycle method
- Plugins already have initialize, so we have to check if all of them are using that exclusively
- TransportInterface needs an initialize method, then we have to move constructor logic in there
- Both Plugins and Transports should be stateless, so we may re-initialize them safely
- Trackers should not perform initialization in their constructor, instead there should be a method for it
- As for Plugins and Transports, the Tracker should manage its state so it can be safely re-initialized with a new config