Observer/Newsletter/ChangeContactSubscription.php
private function addSubscriberToAutomation($email, $subscriber, $websiteId)
    {
        $storeId = $subscriber->getStoreId();
        $store = $this->storeManager->getStore($storeId);
        $programId = $this->helper->getWebsiteConfig(
            'connector_automation/visitor_automation/subscriber_automation',
            $websiteId
        );

        //not mapped or subscriber is not new then ignore
        if (! $programId || ! $this->isSubscriberNew) {
            return;
        }

        //save subscriber to the queue
        $automation = $this->automationFactory->create()
            ->setEmail($email)
            ->setAutomationType(
                \Dotdigitalgroup\Email\Model\Sync\Automation::AUTOMATION_TYPE_NEW_SUBSCRIBER
            )
            ->setEnrolmentStatus(
                \Dotdigitalgroup\Email\Model\Sync\Automation::AUTOMATION_STATUS_PENDING
            )
            ->setTypeId($subscriber->getId())
            ->setWebsiteId($websiteId)
            ->setStoreName($store->getName())
            ->setProgramId($programId);
        $this->automationResource->save($automation);
    }
private function addSubscriberToAutomation($email, $subscriber, $websiteId)
    {
        $storeId = $subscriber->getStoreId();
        $store = $this->storeManager->getStore($storeId);
        $programId = $this->helper->getWebsiteConfig(
            'connector_automation/visitor_automation/subscriber_automation',
            $websiteId
        );

        //not mapped or subscriber is not new then ignore
        if (! $programId || ! $this->isSubscriberNew) {
            return;
        }

        //save subscriber to the queue
        $automation = $this->automationFactory->create()
            ->setEmail($email)
            ->setAutomationType(
                \Dotdigitalgroup\Email\Model\Sync\Automation::AUTOMATION_TYPE_NEW_SUBSCRIBER
            )
            ->setEnrolmentStatus(
                \Dotdigitalgroup\Email\Model\Sync\Automation::AUTOMATION_STATUS_PENDING
            )
            ->setTypeId($subscriber->getId())
            ->setWebsiteId($websiteId)
            ->setStoreName($store->getName())
            ->setProgramId($programId);
        $this->automationResource->save($automation);
    }
private function addSubscriberToAutomation ( $ email , $ subscriber , $ websiteId ) { $ storeId = $ subscriber -> getStoreId ( ) ; $ store = $ this -> storeManager -> getStore ( $ storeId ) ; $ programId = $ this -> helper -> getWebsiteConfig ( 'connector_automation/visitor_automation/subscriber_automation' , $ websiteId ) ; //not mapped or subscriber is not new then ignore if ( ! $ programId || ! $ this -> isSubscriberNew ) { return ; } //save subscriber to the queue $ automation = $ this -> automationFactory -> create ( ) -> setEmail ( $ email ) -> setAutomationType ( \ Dotdigitalgroup \ Email \ Model \ Sync \ Automation :: AUTOMATION_TYPE_NEW_SUBSCRIBER ) -> setEnrolmentStatus ( \ Dotdigitalgroup \ Email \ Model \ Sync \ Automation :: AUTOMATION_STATUS_PENDING ) -> setTypeId ( $ subscriber -> getId ( ) ) -> setWebsiteId ( $ websiteId ) -> setStoreName ( $ store -> getName ( ) ) -> setProgramId ( $ programId ) ; $ this -> automationResource -> save ( $ automation ) ; }
Register subscriber to automation.

@param string $email
@param \Magento\Newsletter\Model\Subscriber $subscriber
@param string|int|null $websiteId

@return void
Register subscriber to automation .