markSurveyDismissed method

void markSurveyDismissed({
  1. int? abandonedAtItem,
  2. int? answeredCount,
})

Clears the active survey after the user closes the result page. Fired when the user closes the survey without completing it. abandonedAtItem is the 1-based question they were on; answeredCount is how many they had answered.

Implementation

/// Fired when the user closes the survey without completing it.
/// [abandonedAtItem] is the 1-based question they were on; [answeredCount]
/// is how many they had answered.
void markSurveyDismissed({int? abandonedAtItem, int? answeredCount}) {
  final state = _surveyOrchestrator.state;
  if (state == null) return;
  _events.toBoth(
    const ExperienceDismissed(),
    SurveyDismissed(
      abandonedAtItem: abandonedAtItem,
      itemTotal: _surveyItemTotal(state.config),
      answeredCount: answeredCount,
      dwellMs: _dwellTracker.consumeDwellMs(state.payload.cepCampaignId),
    ),
    state.payload,
  );
  _clearQuestionViewedAt(state.token);
  _surveyOrchestrator.dismiss();
}