The project demonstrates system design of a simple analytics manager for a mobile application.
The implementation is in Swift, demo uses SwiftUI and tested using Swift Testing framework.
- The system provides an analytic service.
- The service is accessible from any location in code.
- The service receives analytics data from the application, as event.
- The service provides an input end point to receive an event.
- The service can accept multiple events.
- Each event must have a name and time.
- Each event can have additional associated data.
- The service provides option to set user id, session id and other metadata regarding the state of the application.
- The system supports different types of analytic services.
- Each service can specify the type of events it accepts.
- System should be scalable.
- Adding/removing new analytic services should be easy.
- Adding/removing new types of events should be easy.
- System should be testable.
- An
AnalyticsEvent
is defined as an interface with desired properties. - The interface can be implemented by different types of events.
- A protocol
AnalyticsService
is defined that provides methods to set metadata and send events. - The protocol can be implemented by different types of analytic services.
- The protocol oriented approach enables scalability and testability.
- An
AnalyticsManager
class is defined that manages multiple analytic services at once. - The manager can add/remove services and send events to all services.
- This class is implemented as a singleton, so that it can be accessed from any location in code.