I am implementing an ITracker interface that looks something like:
public interface ITracker
{
void Track(ITrackerEvent trackerEvent);
}
I initially created an implementation of this interface wrapping Mixpanel.NET. I then created another one that wraps Application Insights. However, the Application Insights one requires Flush() to send the data to the server.
I don't want to pollute the ITracker interface with a Flush() method just because one of the implementations needs one. It would feel like a leaky abstraction.
However, I need to call this method at some point and don't want to do so every time Track is called.
Is is possible to call a method when the Tracker is garbage collected at the end of the session? Is this even a good approach?
I feel like I'm missing a trick here!
Aucun commentaire:
Enregistrer un commentaire