campaignContext->consume(); if ($campaignCode === null) { return; } $customer = $observer->getEvent()->getCustomer(); $customerId = (int)($customer?->getId() ?? 0); $email = (string)($customer?->getEmail() ?? ''); if ($customerId <= 0 || trim($email) === '') { return; } try { $this->registrationRecorder->record( $campaignCode, $customerId, $email, (int)$customer->getWebsiteId(), (int)$customer->getStoreId() ); } catch (\Throwable $exception) { // Campaign tracking must not turn a successful account creation into an error page. $this->logger->error('Unable to record AI Mascot campaign registration.', [ 'campaign_code' => $campaignCode, 'customer_id' => $customerId, 'exception' => $exception, ]); } } }