Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable raw data access for sites with visitor logs/profiles disabled #22933

Open
wants to merge 38 commits into
base: 5.x-dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
0cc801c
Add logic for determining if a site has Visitor Logs disabled
nathangavin Jan 12, 2025
aa2f1d6
Filter Site data for sites with visitor log disabled
nathangavin Jan 14, 2025
6849440
PHP formatting
nathangavin Jan 14, 2025
319ac71
Add explanatory comment for columns chosen in query
nathangavin Jan 15, 2025
13e891e
Merge branch '5.x-dev' into dev-16739
nathangavin Jan 15, 2025
db6bc65
Replace array() with [] in some places
nathangavin Jan 15, 2025
8995e67
Add descriptive comments to explain new code
nathangavin Jan 15, 2025
70919af
PHP formatting
nathangavin Jan 15, 2025
c022b7c
Properly redact PII data from SQL query while maintaining data structure
nathangavin Jan 15, 2025
7cb3cc0
Update report fields to conditionally render based on source data
nathangavin Jan 15, 2025
ba0cbb6
Build vue files
innocraft-automation Jan 15, 2025
6d116c8
Merge branch '5.x-dev' into dev-16739
nathangavin Jan 16, 2025
85ddbd9
Replace old solution with filtering at API function level
nathangavin Jan 16, 2025
bd71f73
Merge branch 'dev-16739' of github.com:matomo-org/matomo into dev-16739
nathangavin Jan 16, 2025
f56fccb
Remove unnecessary vue changes
nathangavin Jan 16, 2025
93cbcbb
Build vue files
innocraft-automation Jan 16, 2025
9a18737
Reset generated vue files
nathangavin Jan 16, 2025
1cd08a5
Resolve merge conflicts
nathangavin Jan 16, 2025
822b687
Reset some files edited by vue automation
nathangavin Jan 16, 2025
4477581
Merge branch '5.x-dev' into dev-16739
nathangavin Jan 17, 2025
eede563
Makes code for filtering GDPR data more explanatory
nathangavin Jan 17, 2025
e4fb08e
Merge branch 'dev-16739' of github.com:matomo-org/matomo into dev-16739
nathangavin Jan 17, 2025
c073fdb
Build vue files
innocraft-automation Jan 17, 2025
df02a6d
Merge branch '5.x-dev' into dev-16739
nathangavin Jan 19, 2025
44b8cd3
Clean up files and address PHPCS
nathangavin Jan 19, 2025
687a3d2
Build vue files
innocraft-automation Jan 19, 2025
7eae4d8
Add System test to test new API behaviour
nathangavin Jan 20, 2025
bc67556
Merge branch 'dev-16739' of github.com:matomo-org/matomo into dev-16739
nathangavin Jan 20, 2025
ce59cd3
Reset files modified by GH actions
nathangavin Jan 20, 2025
cd23103
Set function to private
nathangavin Jan 20, 2025
b7ceb25
Merge branch '5.x-dev' into dev-16739
nathangavin Jan 20, 2025
2013042
Update segment logic to permit userId segment
nathangavin Jan 20, 2025
10718af
Update setting retrieval to a cleaner approach
nathangavin Jan 20, 2025
594949c
Set Visitor log setting better in test fixture
nathangavin Jan 20, 2025
942efc8
Fix broken fixture by actually saving site settings
nathangavin Jan 20, 2025
bbc37eb
PHPCS fixes
nathangavin Jan 20, 2025
dd010fd
Update column logic to include actual API name
nathangavin Jan 21, 2025
b512927
Merge branch '5.x-dev' into dev-16739
nathangavin Jan 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions plugins/PrivacyManager/API.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Piwik\Container\StaticContainer;
use Piwik\Piwik;
use Piwik\Config as PiwikConfig;
use Piwik\Plugin\SettingsProvider;
use Piwik\Plugins\PrivacyManager\Model\DataSubjects;
use Piwik\Plugins\PrivacyManager\Dao\LogDataAnonymizer;
use Piwik\Plugins\PrivacyManager\Model\LogDataAnonymizations;
Expand Down Expand Up @@ -122,12 +123,52 @@ public function findDataSubjects($idSite, $segment)
'countryFlag',
];

$GDPRColumnsToKeep = [
'lastActionDateTime',
'idVisit',
'idSite',
'siteName',
];

$settings = new SettingsProvider(\Piwik\Plugin\Manager::getInstance());

/*
* for each site, determine if visitor logs or visitor profiles have
* been disabled.
*/
sgiehl marked this conversation as resolved.
Show resolved Hide resolved
$siteIds = Site::getIdSitesFromIdSitesString($idSite);
$siteIdsWithVisitorLogsDisabled = [];
if (!is_array($siteIds)) {
sgiehl marked this conversation as resolved.
Show resolved Hide resolved
$siteIds = [intval($siteIds)];
}
foreach ($siteIds as $id) {
sgiehl marked this conversation as resolved.
Show resolved Hide resolved
$measurableSettings = $settings->getAllMeasurableSettings($id, null);
sgiehl marked this conversation as resolved.
Show resolved Hide resolved
$isVisitorLogDisabled = $measurableSettings["Live"]->getSetting('disable_visitor_log')->getValue();
$isVisitorProfileDisabled = $measurableSettings["Live"]->getSetting('disable_visitor_profile')->getValue();

if ($isVisitorLogDisabled || $isVisitorProfileDisabled) {
$siteIdsWithVisitorLogsDisabled[] = $id;
sgiehl marked this conversation as resolved.
Show resolved Hide resolved
}
}

foreach ($result->getColumns() as $column) {
if (!in_array($column, $columnsToKeep)) {
$result->deleteColumn($column);
}
}

if (count($siteIdsWithVisitorLogsDisabled) > 0) {
foreach ($result->getRowsWithoutSummaryRow() as $row) {
if (in_array($row->getColumn('idSite'), $siteIdsWithVisitorLogsDisabled)) {
foreach (array_keys($row->getColumns()) as $column) {
if (!in_array($column, $GDPRColumnsToKeep)) {
$row->deleteColumn($column);
}
}
}
}
}
sgiehl marked this conversation as resolved.
Show resolved Hide resolved

// Note: Datatable PostProcessor is disabled for this method in PrivacyManager::shouldDisablePostProcessing
return $result;
}
Expand Down
1 change: 1 addition & 0 deletions plugins/PrivacyManager/vue/src/ManageGdpr/ManageGdpr.vue
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@
class="visitorLogTooltip"
title="View visitor profile"
@click="showProfile(dataSubject.visitorId, dataSubject.idSite)"
v-show="dataSubject.visitorId"
>
<img src="plugins/Live/images/visitorProfileLaunch.png" style="margin-right:3.5px"/>
<span>{{ translate('Live_ViewVisitorProfile') }}</span>
Expand Down
Loading