trackWithProperties method

  1. @override
Future<void> trackWithProperties({
  1. required String eventName,
  2. String? userId,
  3. String? partnerAnonymousId,
  4. required Map<String, dynamic> properties,
  5. dynamic onCompletion(
    1. SprigSurveyState
    )?,
  6. dynamic onResultCompletion(
    1. SprigSurveyResult
    )?,
})
override

Implementation

@override
Future<void> trackWithProperties({
  required String eventName,
  String? userId,
  String? partnerAnonymousId,
  required Map<String, dynamic> properties,
  Function(SprigSurveyState)? onCompletion,
  Function(SprigSurveyResult)? onResultCompletion,
}) async {
  try {
    final Map result = await methodChannel
        .invokeMethod('trackWithProperties', {
          'eventName': eventName,
          'userId': userId,
          'partnerAnonymousId': partnerAnonymousId,
          'properties': properties,
        });
    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 with properties: $e");
  }
}