@djmetzle opened this Issue on January 10th 2023

Similar issue to: https://github.com/matomo-org/matomo/issues/20189

Expected Behavior

Tracking requests are processed without errors.

Current Behavior

Type Errors occur in the `AdvertisingConversionExport` plugin when tracking hits include array for GET parameters: ``` Uncaught exception in /var/www/html/plugins/AdvertisingConversionExport/Tracker/RequestProcessor.php line 96: parse_url(): Argument #1 ($url) must be of type string, array given #0 /var/www/html/plugins/AdvertisingConversionExport/Tracker/RequestProcessor.php(96): parse_url(Array, 6) #1 /var/www/html/plugins/AdvertisingConversionExport/Tracker/RequestProcessor.php(41): Piwik\Plugins\AdvertisingConversionExport\Tracker\RequestProcessor->getClickIdAndProviderFromRequest(Object(Piwik\Tracker\Request)) #2 /var/www/html/core/Tracker/Visit.php(154): Piwik\Plugins\AdvertisingConversionExport\Tracker\RequestProcessor->manipulateRequest(Object(Piwik\Tracker\Request)) #3 /var/www/html/core/Tracker.php(172): Piwik\Tracker\Visit->handle() #4 /var/www/html/plugins/QueuedTracking/Queue/Processor/Handler.php(46): Piwik\Tracker->trackRequest(Object(Piwik\Tracker\Request)) #5 /var/www/html/plugins/QueuedTracking/Queue/Processor.php(194): Piwik\Plugins\QueuedTracking\Queue\Processor\Handler->process(Object(Piwik\Tracker), Object(Piwik\Tracker\RequestSet)) #6 /var/www/html/plugins/QueuedTracking/Queue/Processor.php(143): Piwik\Plugins\QueuedTracking\Queue\Processor->processRequestSets(Object(Piwik\Tracker), Array) #7 /var/www/html/plugins/QueuedTracking/Commands/Process.php(86): Piwik\Plugins\QueuedTracking\Queue\Processor->process() #8 /var/www/html/vendor/symfony/console/Symfony/Component/Console/Command/Command.php(257): Piwik\Plugins\QueuedTracking\Commands\Process->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #9 /var/www/html/vendor/symfony/console/Symfony/Component/Console/Application.php(874): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #10 /var/www/html/vendor/symfony/console/Symfony/Component/Console/Application.php(195): Symfony\Component\Console\Application->doRunCommand(Object(Piwik\Plug ins\QueuedTracking\Commands\Process), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #11 [internal function]: Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #12 /var/www/html/core/Console.php(135): call_user_func(Array, Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #13 /var/www/html/core/Access.php(670): Piwik\Console->Piwik\{closure}() #14 /var/www/html/core/Console.php(136): Piwik\Access::doAsSuperUser(Object(Closure)) #15 /var/www/html/core/Console.php(87): Piwik\Console->doRunImpl(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #16 /var/www/html/vendor/symfony/console/Symfony/Component/Console/Application.php(126): Piwik\Console->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #17 /var/www/html/console(32): Symfony\Component\Console\Application->run() #18 {main} ```

Possible Solution

We are working with this patch to AdvertisingConversionExport/Tracker/RequestProcessor.php:

--- RequestProcessor.php
+++ Patched.php
@@ -93,7 +93,8 @@

         $rawParams = $request->getRawParams();

-        parse_str(parse_url($rawParams['url'] ?? '', PHP_URL_QUERY) ?? '', $params);
+        $rawUrl = is_string($rawParams['url']) ? $rawParams['url'] : ''; 
+        parse_str(parse_url($rawUrl, PHP_URL_QUERY) ?? '', $params);

         foreach ($providers as $provider) {
             if (empty($provider::CLICK_ID_REQUEST_PARAM)) {

This is a premium plugin, so it is not easy to get a diff, nor to create an issue on the plugin repo.

Steps to Reproduce (for Bugs)

Tracking hits include utm_campaign[]=.... form get parameters that decode into arrays, not simple strings.

Context

These are "bad" tracking hits, in the sense that utm_campaign[]=... are not technically correct, but we should not be failing hard on processing these hits. Specifically, these errors stall out processing while using the QueuedTracking plugin, and stall all processing of the queue, similar to https://github.com/matomo-org/plugin-QueuedTracking/issues/192

Your Environment

  • Matomo Version: 4.12.3
  • PHP Version: 8.0.26
  • Server Operating System: Docker (alpine) (running on Fedora)
  • Additionally installed plugins:
    • CustomReports
    • MarketingCampaignsReporting
    • CustomAlerts
    • LogViewer
    • InvalidateReports
    • TasksTimetable
    • QueuedTracking
    • AbTesting
    • MediaAnalytics
    • FormAnalytics
    • Funnels
    • RollUpReporting
    • SearchEngineKeywordsPerformance
    • MultiChannelConversionAttribution
    • HeatmapSessionRecording
    • SEOWebVitals
    • UsersFlow
    • ActivityLog
    • WhiteLabel
    • Cohorts
    • AdvertisingConversionExport
    • LoginSaml
    • WooCommerceAnalytics
    • CustomVariables
    • GoogleAnalyticsImporter
@MatomoForumNotifications commented on January 10th 2023

This issue has been mentioned on Matomo forums. There might be relevant details there:

https://forum.matomo.org/t/mediaanalytics-error-message/48642/5

@sgiehl commented on January 11th 2023 Member

@AltamashShaikh could you have a look at this one pls.

@AltamashShaikh commented on January 11th 2023 Contributor

@sgiehl I will have a look

@AltamashShaikh commented on January 11th 2023 Contributor

@djmetzle For issue w.r.t premium features please contact [support@matomo.org](mailto:support@matomo.org) which will help you get an answer quickly.

Anyways I tried replicating the issue by creating the URL something like this
http://localhost.demo.com/?yclid=test&utm_campaign[]=1&utm_campaign[]=2 and I can see this works though

Screenshot from 2023-01-11 15-58-58

Do you have a example URL where we can reproduce this ?

@djmetzle commented on January 12th 2023

Hey @AltamashShaikh, sorry to leave you hanging!

I've posted a detailed comment about our situation here:
https://github.com/matomo-org/matomo/issues/20189#issuecomment-1379690414

These recent troubles all seem related to type errors caused by a (potential?) bug in UrlHelper, and recent changes to DeviceDetector?
I've been sweeping the forums and the issues on the main matomo repo, and these errors seem (to me at least) similar and related.

@AltamashShaikh commented on January 12th 2023 Contributor

@djmetzle Cannot find a sample URL in the above comment, it would be good to share the sample URL causing such issue, so that we can debug and fix it.

Just FYI, I tried hitting the same URL by enabling QueuedTracking plugin and tried to process the queue later to replicate the issue and it worked as expected

Powered by GitHub Issue Mirror