code: public function doAutoRunEnhancements(LeadEvent $event)
      {
          $lead = $event->getLead();
          if ($lead && (null !== $lead->getDateIdentified() || !$lead->isAnonymous())) {
              // Ensure we do not duplicate this work within the same session.
              $leadKey = strtolower(
                  implode(
                      '|',
                      [
                          $lead->getFirstname(),
                          ($lead->getLastActive() ? $lead->getLastActive()->format('c') : ''),
                          $lead->getEmail(),
                          $lead->getPhone(),
                          $lead->getMobile(),
                      ]
                  )
              );
              if (strlen($leadKey) > 3) {
                  if (isset($this->leadsEnhanced[$leadKey])) {
                      return;
                  } else {
                      $this->leadsEnhanced[$leadKey] = true;
                  }
              }
  
              /** @var \MauticPlugin\MauticEnhancerBundle\Integration\AbstractEnhancerIntegration */
              $integrations = $this->enhancerHelper->getEnhancerIntegrations();
              foreach ($integrations as $integration) {
                  $settings = $integration->getIntegrationSettings();
                  if ($settings->getIsPublished()) {
                      $features = $settings->getFeatureSettings();
                      if (isset($features['autorun_enabled']) && $features['autorun_enabled']) {
                          try {
                              $integration->doEnhancement($lead);
                          } catch (\Exception $exception) {
                              $e = new ApiErrorException(
                                  'There was an issue using enhancer: '.$integration->getName(),
                                  0,
                                  $exception
                              );
                              if (!empty($lead)) {
                                  $e->setContact($lead);
                              }
                              throw $e;
                          }
                      }
                  }
              }
              $this->logger->info('doAutoRunEnhancements complete');
          }
      }
docs: Runs enhancements before the Lead is persisted.
  
  @param LeadEvent $event
  
  @throws ApiErrorException