class AbtIntegrationHelper {

  void updateRunningExperiments(FetchEligibleCampaignsResponse response) {
    ArrayList<AbtExperimentInfo> runningExperiments = new ArrayList<>();
    for (CampaignProto.ThickContent content : response.getMessagesList()) {
      if (!content.getIsTestCampaign()
          && content
              .getPayloadCase()
              .equals(CampaignProto.ThickContent.PayloadCase.EXPERIMENTAL_PAYLOAD)) {
        FirebaseAbt.ExperimentPayload payload =
            content.getExperimentalPayload().getExperimentPayload();
        runningExperiments.add(
            new AbtExperimentInfo(
                payload.getExperimentId(),
                payload.getVariantId(),
                payload.getTriggerEvent(),
                new Date(payload.getExperimentStartTimeMillis()),
                payload.getTriggerTimeoutMillis(),
                payload.getTimeToLiveMillis()));
      }
    }
    if (runningExperiments.isEmpty()) {
      return;
    }
    executor.execute(
        () -> {
          try {
            Logging.logd(
                "Updating running experiments with: " + runningExperiments.size() + " experiments");
            abTesting.validateRunningExperiments(runningExperiments);
          } catch (AbtException e) {
            Logging.loge(
                "Unable to register experiments with ABT, missing analytics?\n" + e.getMessage());
          }
        });
  }

  @Inject public  AbtIntegrationHelper(FirebaseABTesting abTesting);

}