Skip to content

Commit

Permalink
Merge branch '5.x-dev' into PG-3720-allow-force-index
Browse files Browse the repository at this point in the history
  • Loading branch information
snake14 authored Oct 18, 2024
2 parents ea75dd6 + 1626319 commit 0443e66
Show file tree
Hide file tree
Showing 40 changed files with 215 additions and 66 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/phpcs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: PHPCS check

on: pull_request

permissions:
actions: read
checks: read
contents: read
deployments: none
issues: read
packages: none
pull-requests: read
repository-projects: none
security-events: none
statuses: read

jobs:
phpcs:
name: PHPCS
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
lfs: false
persist-credentials: false
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
tools: cs2pr
- name: Install dependencies
run:
composer init --name=matomo/marketingcampaignsreporting --quiet;
composer --no-plugins config allow-plugins.dealerdirect/phpcodesniffer-composer-installer true -n;
composer config repositories.matomo-coding-standards vcs https://github.com/matomo-org/matomo-coding-standards -n;
composer require matomo-org/matomo-coding-standards:dev-master;
composer install --dev --prefer-dist --no-progress --no-suggest
- name: Check PHP code styles
id: phpcs
run: ./vendor/bin/phpcs --report-full --standard=phpcs.xml --report-checkstyle=./phpcs-report.xml
- name: Show PHPCS results in PR
if: ${{ always() && steps.phpcs.outcome == 'failure' }}
run: cs2pr ./phpcs-report.xml --prepend-filename
13 changes: 7 additions & 6 deletions API.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Matomo - free/libre analytics platform
*
Expand Down Expand Up @@ -156,7 +157,7 @@ private function isTableEmpty(DataTable\DataTableInterface $dataTable)
{
if ($dataTable instanceof DataTable) {
return $dataTable->getRowsCount() == 0;
} else if ($dataTable instanceof DataTable\Map) {
} elseif ($dataTable instanceof DataTable\Map) {
foreach ($dataTable->getDataTables() as $label => $childTable) {
if ($this->isTableEmpty($childTable)) {
return true;
Expand All @@ -168,17 +169,18 @@ private function isTableEmpty(DataTable\DataTableInterface $dataTable)
}
}

private function mergeDataTableMaps(DataTable\DataTableInterface $dataTable,
DataTable\DataTableInterface $referrersDataTable)
{
private function mergeDataTableMaps(
DataTable\DataTableInterface $dataTable,
DataTable\DataTableInterface $referrersDataTable
) {
if ($dataTable instanceof DataTable) {
if ($this->isTableEmpty($dataTable)) {
$referrersDataTable->setAllTableMetadata($dataTable->getAllTableMetadata());
return $referrersDataTable;
} else {
return $dataTable;
}
} else if ($dataTable instanceof DataTable\Map) {
} elseif ($dataTable instanceof DataTable\Map) {
foreach ($dataTable->getDataTables() as $label => $childTable) {
$newTable = $this->mergeDataTableMaps($childTable, $referrersDataTable->getTable($label));
$dataTable->addTable($newTable, $label);
Expand All @@ -188,5 +190,4 @@ private function mergeDataTableMaps(DataTable\DataTableInterface $dataTable,
throw new \Exception("Sanity check: unknown datatable type '" . get_class($dataTable) . "'.");
}
}

}
21 changes: 11 additions & 10 deletions Archiver.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Matomo - free/libre analytics platform
*
Expand All @@ -13,15 +14,15 @@

class Archiver extends \Piwik\Plugin\Archiver
{
const CAMPAIGN_ID_RECORD_NAME = 'MarketingCampaignsReporting_Id';
const CAMPAIGN_NAME_RECORD_NAME = 'MarketingCampaignsReporting_Name';
const CAMPAIGN_KEYWORD_RECORD_NAME = 'MarketingCampaignsReporting_Keyword';
const CAMPAIGN_SOURCE_RECORD_NAME = 'MarketingCampaignsReporting_Source';
const CAMPAIGN_MEDIUM_RECORD_NAME = 'MarketingCampaignsReporting_Medium';
const CAMPAIGN_CONTENT_RECORD_NAME = 'MarketingCampaignsReporting_Content';
const CAMPAIGN_GROUP_RECORD_NAME = 'MarketingCampaignsReporting_Group';
const CAMPAIGN_PLACEMENT_RECORD_NAME = 'MarketingCampaignsReporting_Placement';
const HIERARCHICAL_SOURCE_MEDIUM_RECORD_NAME = 'MarketingCampaignsReporting_SourceMedium_Name';
public const CAMPAIGN_ID_RECORD_NAME = 'MarketingCampaignsReporting_Id';
public const CAMPAIGN_NAME_RECORD_NAME = 'MarketingCampaignsReporting_Name';
public const CAMPAIGN_KEYWORD_RECORD_NAME = 'MarketingCampaignsReporting_Keyword';
public const CAMPAIGN_SOURCE_RECORD_NAME = 'MarketingCampaignsReporting_Source';
public const CAMPAIGN_MEDIUM_RECORD_NAME = 'MarketingCampaignsReporting_Medium';
public const CAMPAIGN_CONTENT_RECORD_NAME = 'MarketingCampaignsReporting_Content';
public const CAMPAIGN_GROUP_RECORD_NAME = 'MarketingCampaignsReporting_Group';
public const CAMPAIGN_PLACEMENT_RECORD_NAME = 'MarketingCampaignsReporting_Placement';
public const HIERARCHICAL_SOURCE_MEDIUM_RECORD_NAME = 'MarketingCampaignsReporting_SourceMedium_Name';

const SEPARATOR_COMBINED_DIMENSIONS = " - ";
public const SEPARATOR_COMBINED_DIMENSIONS = " - ";
}
4 changes: 3 additions & 1 deletion Campaign/CampaignDetector.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Matomo - free/libre analytics platform
*
Expand Down Expand Up @@ -29,7 +30,8 @@ public function detectCampaignFromRequest(Request $request, $campaignParameters)
$landingUrl = PageUrl::cleanupUrl($landingUrl);
$landingUrlParsed = parse_url($landingUrl);

if (!isset($landingUrlParsed['query'])
if (
!isset($landingUrlParsed['query'])
&& !isset($landingUrlParsed['fragment'])
) {
return false;
Expand Down
1 change: 1 addition & 0 deletions Campaign/CampaignDetectorInterface.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Matomo - free/libre analytics platform
*
Expand Down
2 changes: 1 addition & 1 deletion Columns/Base.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Matomo - free/libre analytics platform
*
Expand Down Expand Up @@ -52,7 +53,6 @@ public function onNewVisit(Request $request, Visitor $visitor, $action)
// If for some reason a campaign was detected in Core Tracker
// but not here, copy that campaign to the Advanced Campaign
if ($visitProperties['referer_type'] == Common::REFERRER_TYPE_CAMPAIGN) {

$campaignDimensions = array(
(new CampaignName())->getColumnName() => $visitProperties['referer_name']
);
Expand Down
1 change: 1 addition & 0 deletions Columns/CampaignContent.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Matomo - free/libre analytics platform
*
Expand Down
1 change: 1 addition & 0 deletions Columns/CampaignGroup.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Matomo - free/libre analytics platform
*
Expand Down
1 change: 1 addition & 0 deletions Columns/CampaignId.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Matomo - free/libre analytics platform
*
Expand Down
1 change: 1 addition & 0 deletions Columns/CampaignKeyword.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Matomo - free/libre analytics platform
*
Expand Down
1 change: 1 addition & 0 deletions Columns/CampaignMedium.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Matomo - free/libre analytics platform
*
Expand Down
4 changes: 3 additions & 1 deletion Columns/CampaignName.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Matomo - free/libre analytics platform
*
Expand Down Expand Up @@ -53,7 +54,8 @@ public function shouldForceNewVisit(Request $request, Visitor $visitor, Action $
// we force a new visit if the referrer is a campaign and it's different than the currently recorded referrer.
// if the current referrer is 'direct entry', however, we assume the referrer information was sent in a later request, and
// we just update the existing referrer information instead of creating a visit.
if (!empty($campaignDimensions)
if (
!empty($campaignDimensions)
&& $this->isCampaignInformationNew($visitor, $campaignDimensions)
) {
Common::printDebug("Existing visit detected, but creating new visit because campaign information is different than last action.");
Expand Down
1 change: 1 addition & 0 deletions Columns/CampaignPlacement.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Matomo - free/libre analytics platform
*
Expand Down
1 change: 1 addition & 0 deletions Columns/CampaignSource.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Matomo - free/libre analytics platform
*
Expand Down
1 change: 1 addition & 0 deletions Columns/CampaignSourceMedium.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Matomo - free/libre analytics platform
*
Expand Down
1 change: 1 addition & 0 deletions Columns/CombinedKeywordContent.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Matomo - free/libre analytics platform
*
Expand Down
1 change: 1 addition & 0 deletions MarketingCampaignsReporting.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Matomo - free/libre analytics platform
*
Expand Down
6 changes: 4 additions & 2 deletions RecordBuilders/CampaignReporting.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Matomo - free/libre analytics platform
*
Expand Down Expand Up @@ -104,7 +105,7 @@ protected function aggregateFromLogs(LogAggregator $logAggregator, array $record
Metrics::INDEX_BOUNCE_COUNT => $row[Metrics::INDEX_BOUNCE_COUNT],
Metrics::INDEX_NB_VISITS_CONVERTED => $row[Metrics::INDEX_NB_VISITS_CONVERTED],
];
} else if ($aggregatorMethod == 'queryConversionsByDimension') {
} elseif ($aggregatorMethod == 'queryConversionsByDimension') {
$idGoal = (int) $row['idgoal'];
$columns = [
Metrics::INDEX_GOALS => [
Expand Down Expand Up @@ -133,7 +134,8 @@ protected function getLabelFromRowDimensions(array $dimensionsAsLabel, array $ro
{
$labels = [];
foreach ($dimensionsAsLabel as $dimensionLabelPart) {
if (isset($row[$dimensionLabelPart])
if (
isset($row[$dimensionLabelPart])
&& $row[$dimensionLabelPart] != ''
) {
$labels[] = $row[$dimensionLabelPart];
Expand Down
1 change: 1 addition & 0 deletions Reports/Base.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Matomo - free/libre analytics platform
*
Expand Down
1 change: 1 addition & 0 deletions Reports/GetContent.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Matomo - free/libre analytics platform
*
Expand Down
1 change: 1 addition & 0 deletions Reports/GetGroup.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Matomo - free/libre analytics platform
*
Expand Down
1 change: 1 addition & 0 deletions Reports/GetId.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Matomo - free/libre analytics platform
*
Expand Down
1 change: 1 addition & 0 deletions Reports/GetKeyword.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Matomo - free/libre analytics platform
*
Expand Down
1 change: 1 addition & 0 deletions Reports/GetKeywordContentFromNameId.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Matomo - free/libre analytics platform
*
Expand Down
1 change: 1 addition & 0 deletions Reports/GetMedium.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Matomo - free/libre analytics platform
*
Expand Down
1 change: 1 addition & 0 deletions Reports/GetName.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Matomo - free/libre analytics platform
*
Expand Down
1 change: 1 addition & 0 deletions Reports/GetNameFromSourceMediumId.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Matomo - free/libre analytics platform
*
Expand Down
1 change: 1 addition & 0 deletions Reports/GetPlacement.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Matomo - free/libre analytics platform
*
Expand Down
1 change: 1 addition & 0 deletions Reports/GetSource.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Matomo - free/libre analytics platform
*
Expand Down
1 change: 1 addition & 0 deletions Reports/GetSourceMedium.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Matomo - free/libre analytics platform
*
Expand Down
7 changes: 5 additions & 2 deletions Tracker/RequestProcessor.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Matomo - free/libre analytics platform
*
Expand Down Expand Up @@ -32,9 +33,11 @@ public function onNewVisit(Tracker\Visit\VisitProperties $visitProperties, Track
$campaignGroup = $visitProperties->getProperty((new CampaignGroup())->getColumnName());
$campaignPlacement = $visitProperties->getProperty((new CampaignPlacement())->getColumnName());

if (!empty($campaignContent) || !empty($campaignId) || !empty($campaignKeyword) ||
if (
!empty($campaignContent) || !empty($campaignId) || !empty($campaignKeyword) ||
!empty($campaignMedium) || !empty($campaignName) || !empty($campaignSource) ||
!empty($campaignGroup) || !empty($campaignPlacement)) {
!empty($campaignGroup) || !empty($campaignPlacement)
) {
$visitProperties->setProperty('referer_type', Common::REFERRER_TYPE_CAMPAIGN);
}

Expand Down
1 change: 1 addition & 0 deletions VisitorDetails.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Matomo - free/libre analytics platform
*
Expand Down
22 changes: 16 additions & 6 deletions lang/cs.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
{
"MarketingCampaignsReporting": {
"CombinedSourceMedium": "Zdroj - médium",
"CampaignId": "Id kampaně",
"CampaignIds": "Identifikace kampaně",
"CombinedKeywordContent": "Klíčové slovo - obsah",
"Names": "Jména kampaní",
"CombinedSourceMedium": "Zdroj - médium",
"CombinedSourcesMediums": "Zdroj kampaně - médium",
"Content": "Obsah kampaně",
"Contents": "Obsah kampaně",
"Group": "Skupina kampaně",
"Groups": "Skupiny kampaně",
"Keyword": "Klíčové slovo kampaně",
"Keywords": "Klíčová slova kampaně",
"Sources": "Zdroje kampaní",
"Medium": "Médium kampaně",
"Mediums": "Média kampaně",
"Contents": "Obsah kampaně",
"CombinedSourcesMediums": "Zdroj kampaně - médium"
"Name": "Název kampaně",
"Names": "Jména kampaní",
"Placement": "Umístění kampaně",
"Placements": "Umístění kampaní",
"Source": "Zdroj kampaně",
"Sources": "Zdroje kampaní"
}
}
}
Loading

0 comments on commit 0443e66

Please sign in to comment.