logCurrentScreen method

Future<void> logCurrentScreen(
  1. BuildContext buildContext,
  2. String name
)

send the screen view event to the server if a video is triggered, it will be returned depending on configuration

  • user will see video on first time this screen as been seen Or each time this screen is visited

Implementation

Future<void> logCurrentScreen(BuildContext buildContext, String name) async {
  if (!_sessionApi!.hasSession) {
    debugPrint('''
    Missing Session Error: You must have a session to call this method
    ''');
    return;
  }
  if (triggeredVideo != null) {
    return;
  }
  runZonedGuarded(
    () async {
      final screenTriggeredVideo = await _eventApi!.logCurrentScreen(
        _sessionApi!.session,
        name,
      );
      if (screenTriggeredVideo == null) {
        return;
      }
      triggeredVideo = screenTriggeredVideo;
      if (screenTriggeredVideo.isTalkType) {
        await _showVideo(
          context: buildContext,
          trigger: screenTriggeredVideo,
        );
      } else if (screenTriggeredVideo.isSurveyType) {
        await _showSurvey(
          context: buildContext,
          trigger: screenTriggeredVideo,
        );
      }
    },
    (error, stack) => debugPrint("[PAL] error showing video: $error"),
  );
}