Farfetch / blackout

Blackout is the codename for the Farfetch Platform Solutions (FPS) projects. Useful to build e-commerce applications using the FPS APIs and integrating business logic.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Remove (or refactor) `createInstance` method from analytics's `Integration` class

nelsonleite opened this issue · comments

Is your proposal related to a problem?

Currently, to create a new integration in the analytics package, it is necessary that the developer overrides the Integration class's static method createInstance beyond creating a constructor. At the time, this method was created to provide more flexibility for the Integration on the object it can return. For example, an integration could easily use the Decorator pattern to return a wrapper to the real instance that does additional logging or preprocessing of the event before it is received by the final instance that would process the event.

While this feature is a good thing to have, in practice that necessity never materialised and having to force all integrations to override this method for the integration to work, even if they only end up returning a naked instance of the same class, ends up creating unnecessary additional work for the developer.

Describe the solution you'd like

Either remove this method from the Integration API and have the analytics instantiate the Integration's subclass directly or provide a way to keep this feature without requiring to override this method if the developer just wants to return a simple instance of the class.

All integrations are now working without this method, relying on the extension of the generic class Integration (that has this method already). Closing the issue, thanks!