Skip to content

Commit

Permalink
Merge pull request #175 from matomo-org/PG-4087-fix-retain-case-logic
Browse files Browse the repository at this point in the history
Changes lower case logic to DB, #PG-4087, #174
  • Loading branch information
AltamashShaikh authored Jan 15, 2025
2 parents f6a2868 + 5c43380 commit 0c3df01
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
7 changes: 7 additions & 0 deletions MarketingCampaignsReporting.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public function registerEvents()
'Report.filterReports' => 'removeOriginalCampaignReport',
'Insights.addReportToOverview' => 'addReportToInsightsOverview',
'AssetManager.getStylesheetFiles' => 'getStylesheetFiles',
'Plugin.shouldLowerCampaignCase' => 'shouldLowerCampaignCase',
);
}

Expand Down Expand Up @@ -120,4 +121,10 @@ public function isTrackerPlugin()
{
return true;
}

public function shouldLowerCampaignCase($pluginName, &$shouldLowerCampaignCase)
{
$systemSettings = StaticContainer::get(SystemSettings::class);
$shouldLowerCampaignCase = !$systemSettings->doNotChangeCaseOfUtmParameters->getValue();
}
}
17 changes: 11 additions & 6 deletions RecordBuilders/CampaignReporting.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,16 @@ protected function aggregate(ArchiveProcessor $archiveProcessor): array
*/
protected function aggregateFromLogs(LogAggregator $logAggregator, array $records, $dimensions, $table, $aggregatorMethod): void
{
$systemSettings = StaticContainer::get(SystemSettings::class);
if (!$systemSettings->doNotChangeCaseOfUtmParameters->getValue()) {
$newDimensions = [];
foreach ($dimensions as $dimension) {
$lowerDimensionColumn = $table . '.' . $dimension;
$newDimensions[$dimension] = "LOWER($lowerDimensionColumn)";
}
$dimensions = $newDimensions;
}

$whereClause = $table . ".referer_type = " . Common::REFERRER_TYPE_CAMPAIGN;
$query = $aggregatorMethod === 'queryConversionsByDimension' && version_compare(Version::VERSION, '5.2.0-b6', '>=')
? $logAggregator->$aggregatorMethod($dimensions, $whereClause, [], [], false, false, true)
Expand Down Expand Up @@ -134,7 +144,6 @@ protected function aggregateFromLogs(LogAggregator $logAggregator, array $record

protected function getLabelFromRowDimensions(array $dimensionsAsLabel, array $row): string
{
$systemSettings = StaticContainer::get(SystemSettings::class);
$labels = [];
foreach ($dimensionsAsLabel as $dimensionLabelPart) {
if (
Expand All @@ -144,12 +153,8 @@ protected function getLabelFromRowDimensions(array $dimensionsAsLabel, array $ro
$labels[] = $row[$dimensionLabelPart];
}
}
$label = implode(Archiver::SEPARATOR_COMBINED_DIMENSIONS, $labels);
if ($label && !$systemSettings->doNotChangeCaseOfUtmParameters->getValue()) {
$label = Common::mb_strtolower($label);
}

return $label;
return implode(Archiver::SEPARATOR_COMBINED_DIMENSIONS, $labels);
}

protected function getRecordToDimensions(): array
Expand Down

0 comments on commit 0c3df01

Please sign in to comment.