track method
Future<void>
track({
- required String eventName,
- dynamic onCompletion()?,
- dynamic onResultCompletion()?,
override
Implementation
@override
Future<void> track({
required String eventName,
Function(SprigSurveyState)? onCompletion,
Function(SprigSurveyResult)? onResultCompletion,
}) async {
try {
final Map result = await methodChannel.invokeMethod('track', {
'eventName': eventName,
});
SprigSurveyState surveyState = _surveyStateFromInt(result["surveyState"]);
int surveyId = result["surveyId"] as int;
if (onCompletion != null) {
onCompletion(surveyState);
}
if (onResultCompletion != null) {
onResultCompletion(SprigSurveyResult(surveyState: surveyState, surveyId: surveyId));
}
} catch (e) {
debugPrint("Failed to track event: $e");
}
}