Analytics
The LikeMinds SDK offers a comprehensive set of predefined user events that can be tracked within your chat application.
For a complete list of events being tracked, please refer to the Analytics Events documentation.
Prerequisites
Before integrating the LikeMinds SDK, ensure that you have the following prerequisites:
- A Flutter project that is properly set up and running.
- The LikeMinds Flutter Chat SDK installed and initialized in your project.
Callback
To effectively receive and manage analytics events, you need to implement the analytics listener function. This function will be triggered whenever an analytics event occurs, allowing you to define custom handling logic as needed. Below is an example of how to implement this listener:
void _analyticListener(LMChatAnalyticsEventFired state) {
debugPrint(
"Analytics Event Caught: ${state.eventName} : ${state.eventProperties.toString()}",
);
// Implement your custom logic here to process the analytics events,
// such as forwarding them to your analytics service.
// For instance:
// YourAnalyticsService.logEvent(state.eventName, state.eventProperties);
}
The LMChatAnalyticsEventFired
state is emitted whenever an analytics event is triggered within the SDK.
String eventName
: The name of the triggered event.Map<String, dynamic> eventProperties
: A collection of properties associated with the specific event.
Example Implementation
When initializing the LikeMinds Chat SDK, you must pass the dynamic Function(LMChatAnalyticsEventFired)? analyticsListener
parameter to the initialize()
function. This allows the SDK to utilize your custom listener for handling analytics events. Here’s how to set it up:
await LMChatCore.instance.initialize(
analyticsListener: _analyticListener
);