Skip to content

Commit cd5810c

Browse files
committed
fix: requests with just queryString could not be handled
1 parent f7b779b commit cd5810c

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "tinect/matomo",
3-
"version": "5.0.1",
3+
"version": "5.0.2",
44
"description": "Matomo plugin for shopware 6",
55
"type": "shopware-platform-plugin",
66
"license": "MIT",

src/MessageQueue/TrackHandler.php

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,19 @@ public function __invoke(TrackMessage $message): void
5151
// Bulk tracking payload: enrich each request; do NOT also put params on URL
5252
try {
5353
$parameter = $this->enrichRequests($parameter, $commonParameters);
54-
} catch (\JsonException $exception) {
55-
$this->logger->error('Error enriching request.', [
56-
'parameter' => $parameter,
57-
'commonParameters' => $commonParameters,
58-
'message' => $exception->getMessage(),
59-
]);
54+
} catch (\JsonException) {
55+
parse_str($parameter, $parsedQuery);
56+
if ($parsedQuery !== []) {
57+
$parameter = $parsedQuery;
58+
}
6059
}
6160

6261
$data = [
6362
'body' => $parameter,
6463
];
65-
} else {
64+
}
65+
66+
if (\is_array($parameter)) {
6667
$merged = array_merge($parameter, $commonParameters);
6768
// Remove empty-string values to avoid invalid parameters like _id=""
6869
$merged = array_filter($merged, static function ($v) {
@@ -74,6 +75,14 @@ public function __invoke(TrackMessage $message): void
7475
];
7576
}
7677

78+
if (!isset($data)) {
79+
$this->logger->error('Parameters for Matomo tracking could not be handled.', [
80+
'parameters' => $message->parameters,
81+
]);
82+
83+
throw new \RuntimeException('Parameters for Matomo tracking could not be handled.');
84+
}
85+
7786
$client = new Client();
7887

7988
// Build headers and set JSON content type when sending bulk payload

0 commit comments

Comments
 (0)