Skip to content

Commit b20d243

Browse files
committed
Merge branch 'release/44.2.0'
2 parents f7bd27a + 2ee8581 commit b20d243

14 files changed

Lines changed: 87 additions & 15 deletions

File tree

Classes/Controller/LeadController.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,9 @@ public function companiesAction(FilterDto $filter, string $export = ''): Respons
200200
}
201201

202202
$limit = (int)($this->settings['tracking']['company']['connectionLimit'] ?? 0);
203-
$statistics = $this->leadfeederRepository->getStatus()[0] ?? ['hits' => 0, 'misses' => 0];
204-
$available = $limit - $statistics['hits'] - $statistics['misses'];
203+
$statistics = $this->leadfeederRepository->getStatus()[0]
204+
?? ['hits' => 0, 'misses' => 0, 'errors' => 0];
205+
$available = $limit - $statistics['hits'] - $statistics['misses'] - $statistics['errors'];
205206
if ($available < 0) {
206207
$available = 0;
207208
}

Classes/Domain/Model/Log.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class Log extends AbstractModel
4545
public const STATUS_UTM_TRACK = 300;
4646
public const STATUS_COMPANY_ENRICH_CONNECTION = 400;
4747
public const STATUS_COMPANY_ENRICH_SUCCESSFUL = 410;
48+
public const STATUS_COMPANY_ENRICH_FAILED = 420;
4849
public const STATUS_API_CREATEVISITOR = 500;
4950
public const STATUS_ERROR = 900;
5051

@@ -167,6 +168,18 @@ public function getSearch(): ?Search
167168
return $searchRepository->findByIdentifier($searchUid);
168169
}
169170

171+
/**
172+
* Readable reason of a failed connection to an interface - like "401 Unauthorized" or an exception message
173+
*/
174+
public function getFailureReason(): string
175+
{
176+
$reason = trim($this->getPropertyByKey('statusCode') . ' ' . $this->getPropertyByKey('reason'));
177+
if ($reason === '') {
178+
$reason = $this->getPropertyByKey('message');
179+
}
180+
return $reason;
181+
}
182+
170183
public function getEventName(): string
171184
{
172185
return $this->getPropertyByKey('eventName');

Classes/Domain/Repository/LogRepository.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,11 @@ public function findAmountOfSuccessfulCompanyEnrichLogsOfCurrentMonth(): int
157157
return $this->findAmountOfCompanyEnrichLogsOfCurrentMonthByStatus(Log::STATUS_COMPANY_ENRICH_SUCCESSFUL);
158158
}
159159

160+
public function findAmountOfFailedCompanyEnrichLogsOfCurrentMonth(): int
161+
{
162+
return $this->findAmountOfCompanyEnrichLogsOfCurrentMonthByStatus(Log::STATUS_COMPANY_ENRICH_FAILED);
163+
}
164+
160165
public function findAmountOfCompanyEnrichLogsOfCurrentHour(): int
161166
{
162167
$connection = DatabaseUtility::getConnectionForTable(Log::TABLE_NAME);
@@ -193,7 +198,7 @@ protected function interestingLogsLogicalAnd(QueryInterface $query): array
193198
);
194199
if ($configString === '') {
195200
// In some rare cases TypoScript is not available in backend module even if TS is included in root template
196-
$configString = '2,3,25,28,26,21,22,23,48,50,55,60,70,80,100';
201+
$configString = '2,3,25,28,26,21,22,23,48,50,55,60,70,80,100,420';
197202
}
198203
$status = GeneralUtility::trimExplode(',', $configString, true);
199204
return [

Classes/Domain/Repository/Remote/LeadfeederRepository.php

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,18 @@ public function getPropertiesForIpAddress(Visitor $visitor, string $ipAddress =
100100
$this->logService->logCompanyEnrichConnectionSuccess($visitor);
101101
$properties = $this->normalizeProperties($data);
102102
}
103+
} else {
104+
$this->logFailedConnection($visitor, [
105+
'statusCode' => $response->getStatusCode(),
106+
'reason' => $response->getReasonPhrase(),
107+
]);
103108
}
104-
} catch (Throwable) {
109+
} catch (Throwable $exception) {
110+
$this->logFailedConnection($visitor, [
111+
'exception' => $exception::class,
112+
'message' => $exception->getMessage(),
113+
'code' => $exception->getCode(),
114+
]);
105115
}
106116
}
107117
return $properties;
@@ -114,14 +124,16 @@ public function getPropertiesForIpAddress(Visitor $visitor, string $ipAddress =
114124
public function getStatus(): array
115125
{
116126
$hits = $this->logRepository->findAmountOfSuccessfulCompanyEnrichLogsOfCurrentMonth();
127+
$errors = $this->logRepository->findAmountOfFailedCompanyEnrichLogsOfCurrentMonth();
117128
$connections = $this->logRepository->findAmountOfCompanyEnrichLogsOfCurrentMonth();
118129
$now = new \DateTime();
119130
return [
120131
[
121132
'year' => (int)$now->format('Y'),
122133
'month' => (int)$now->format('n'),
123134
'hits' => $hits,
124-
'misses' => max(0, $connections - $hits),
135+
'misses' => max(0, $connections - $hits - $errors),
136+
'errors' => $errors,
125137
],
126138
];
127139
}
@@ -143,6 +155,14 @@ public function isConfigured(): bool
143155
return $this->getToken() !== '' && $this->getAccountId() !== '';
144156
}
145157

158+
protected function logFailedConnection(Visitor $visitor, array $properties): void
159+
{
160+
try {
161+
$this->logService->logCompanyEnrichConnectionFailed($visitor, $properties);
162+
} catch (Throwable) {
163+
}
164+
}
165+
146166
protected function isCompanyHit(mixed $data): bool
147167
{
148168
return is_array($data)

Classes/Domain/Repository/VisitorRepository.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,10 @@ public function findAllByProperty(
144144
int $limit = 1000
145145
): QueryResultInterface {
146146
$query = $this->createQuery();
147-
$constraint = $query->equals(StringUtility::cleanString($propertyName), $propertyValue);
147+
$propertyName = StringUtility::cleanString($propertyName, false, '._-');
148+
$constraint = $query->equals($propertyName, $propertyValue);
148149
if ($exactMatch === false) {
149-
$constraint = $query->like(StringUtility::cleanString($propertyName), '%' . $propertyValue . '%');
150+
$constraint = $query->like($propertyName, '%' . $propertyValue . '%');
150151
}
151152
$query->matching($constraint);
152153
$query->setOrderings(ArrayUtility::cleanStringForArrayKeys($orderings));

Classes/Domain/Service/CompanyConfigurationService.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
class CompanyConfigurationService
1818
{
1919
private const TOKEN_LENGTH = 40;
20-
private const TOKEN_PATTERN = '~[0-9a-f]{' . self::TOKEN_LENGTH . '}~';
20+
private const TOKEN_PATTERN = '~^[0-9a-zA-Z]{' . self::TOKEN_LENGTH . '}\z~';
2121
public const TEMPLATE_TABLE = 'sys_template';
2222

2323
protected array $configuration = [
@@ -104,8 +104,7 @@ protected function isValidConfiguration(string $token, string $accountId): void
104104
*/
105105
protected function isCorrectSpelling(string $token): void
106106
{
107-
preg_match(self::TOKEN_PATTERN, $token, $result);
108-
if (strlen($token) !== self::TOKEN_LENGTH || ($result[0] ?? '') !== $token) {
107+
if (preg_match(self::TOKEN_PATTERN, $token) !== 1) {
109108
throw new ConfigurationException(
110109
LocalizationUtility::translateByKey('module.companiesDisabled.token.failureSpelling'),
111110
1687114799

Classes/Domain/Service/LogService.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,18 @@ public function logCompanyEnrichConnectionSuccess(Visitor $visitor): void
286286
$this->log(Log::STATUS_COMPANY_ENRICH_SUCCESSFUL, $visitor);
287287
}
288288

289+
/**
290+
* @param Visitor $visitor
291+
* @param array $properties reason of the failure - e.g. a http status code or an exception message
292+
* @return void
293+
* @throws IllegalObjectTypeException
294+
* @throws UnknownObjectException
295+
*/
296+
public function logCompanyEnrichConnectionFailed(Visitor $visitor, array $properties = []): void
297+
{
298+
$this->log(Log::STATUS_COMPANY_ENRICH_FAILED, $visitor, $properties);
299+
}
300+
289301
/**
290302
* @param Visitor $visitor
291303
* @param string $message exception message

Configuration/TypoScript/Lux/03_BackendViewConfiguration.typoscript

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ lib.lux.settings {
44
activity {
55
# Look at \In2code\Lux\Domain\Model\Log::STATUS_... for some status definitions
66
# Falback values are defined in LogRepository::interestingLogsLogicalAnd
7-
defineLogStatusForInterestingLogs = 2,3,25,28,26,21,22,23,48,50,55,60,70,80,100
7+
defineLogStatusForInterestingLogs = 2,3,25,28,26,21,22,23,48,50,55,60,70,80,100,420
88
}
99
}
1010
}

Documentation/Technical/Changelog/Index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
| Version | Date | State | TYPO3 | Description |
1111
|------------|------------|----------|-------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
12+
| 44.2.0 | 2026-09-02 | Task | `v13 + v14` | Allow deleting of visitors via command by chained properties, Show if leadfeeder requests are failing, update token pattern for leadfeeder API keys |
1213
| 44.1.1 | 2026-08-24 | Bugfix | `v13 + v14` | Allow extending of HEADER_ROBOTS for other extensions |
1314
| 44.1.0 | 2026-08-24 | Task | `v13 + v14` | Return status code 400 for invalid TypeNum requests with missing parameters to prevent unneeded logging, Render "X-Robots-Tag: noindex, nofollow" in all FE TypeNum answers. |
1415
| 44.0.0 !!! | 2026-08-20 | Task | `v13 + v14` | Default settings changed: LocalStorage instead of Fingerprinting (see breacking changes), Wiredminds integration replaces with successor Leadfeeder (see breaking changes) |

Resources/Private/Language/de.locallang_db.xlf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,6 +1015,10 @@
10151015
<source>IP misses</source>
10161016
<target state="translated">Unerkannte IP-Adressen</target>
10171017
</trans-unit>
1018+
<trans-unit id="module.analysis.statistics.wiredminds.statistics.errors">
1019+
<source>Failed connections</source>
1020+
<target state="translated">Fehlgeschlagene Verbindungen</target>
1021+
</trans-unit>
10181022
<trans-unit id="module.analysis.statistics.wiredminds.statistics.req_available">
10191023
<source>Queries remaining</source>
10201024
<target state="translated">Verbleibende Abfragen</target>
@@ -1163,6 +1167,10 @@
11631167
<source>Successfully converted company to lead via Leadfeeder</source>
11641168
<target state="translated">Firma erfolgreich ermittelt mittels Leadfeeder</target>
11651169
</trans-unit>
1170+
<trans-unit id="module.analysis.log.status.420">
1171+
<source>Leadfeeder connection failed</source>
1172+
<target state="translated">Leadfeeder Verbindung fehlgeschlagen</target>
1173+
</trans-unit>
11661174
<trans-unit id="module.analysis.log.status.500">
11671175
<source>Created new lead via API</source>
11681176
<target state="translated">Lead über API erstellt</target>

0 commit comments

Comments
 (0)