class DisplayCallbacksImpl implements FirebaseInAppMessagingDisplayCallbacks {

  @Override
  public Task<Void> impressionDetected() {

    // In the future, when more logAction events are supported, it might be worth
    // extracting this logic into a manager similar to InAppMessageStreamManager
    String MESSAGE_IMPRESSION = "message impression to metrics logger";

    if (shouldLog() && !wasImpressed) {
      Logging.logd("Attempting to record: " + MESSAGE_IMPRESSION);

      Completable logImpressionToMetricsLogger =
          Completable.fromAction(() -> metricsLoggerClient.logImpression(inAppMessage));

      Completable logImpressionCompletable =
          logToImpressionStore()
              .andThen(logImpressionToMetricsLogger)
              .andThen(updateWasImpressed());

      return maybeToTask(logImpressionCompletable.toMaybe(), schedulers.io());
    }
    logActionNotTaken(MESSAGE_IMPRESSION);
    return new TaskCompletionSource<Void>().getTask();
  }

  @VisibleForTesting  DisplayCallbacksImpl(
      ImpressionStorageClient impressionStorageClient,
      Clock clock,
      Schedulers schedulers,
      RateLimiterClient rateLimiterClient,
      CampaignCacheClient campaignCacheClient,
      RateLimit appForegroundRateLimit,
      MetricsLoggerClient metricsLoggerClient,
      DataCollectionHelper dataCollectionHelper,
      InAppMessage inAppMessage,
      String triggeringEvent);

}