Open jorgeuos opened 5 months ago
@jorgeuos Custom Dimensions are site specific, so maybe it fails as the segment isn't available globally. We need to investigate that. As a workaround: Did you try running the invalidation with --sites=1, to limit it to the site where it is available?
I've quickly reproduced that locally. It is indeed a problem around the segment not being available globally, but only site specific. We could rework the command to automatically skip sites where a segment is not available and print an info in that case.
The suggested workaround from above works as expected, so this might not need to be highest priority.
The workaround looks promising!
I'll continue to update some sites and if I hit any roadblocks, I'll update here.
I'm not sure, but I'm guessing that there's a bug with how custom dimensions are used in segments. I believe that in the segment, it's looking for the custom dimension by the id, but when the custom dimension log table is created, it's looking for the index.
Because I just ran:
./console core:invalidate-report-data --dates=2024-02-01,2024-05-28 --sites=30 --segment=15
./console core:archive --force-idsegments=15 --force-idsites=30
And all of a sudden, another custom dimension is being used in the segment.
Could this be the issue?
File: matomo/plugins/CustomDimensions/Dao/LogTable.php
public static function buildCustomDimensionColumnName($indexOrDimension)
{
if (is_array($indexOrDimension) && isset($indexOrDimension['index'])) { // <-- indexOrDimension
$indexOrDimension = $indexOrDimension['index'];
}
$indexOrDimension = (int) $indexOrDimension;
if ($indexOrDimension >= 1) {
return 'custom_dimension_' . (int) $indexOrDimension;
}
}
File: matomo/plugins/CustomDimensions/DataTable/Filter/AddSegmentMetadata.php
/**
* @param DataTable $table
*/
public function filter($table)
{
$dimension = CustomDimensionsRequestProcessor::buildCustomDimensionTrackingApiName($this->idDimension);
foreach ($table->getRows() as $row) {
$label = $row->getColumn('label');
if ($label !== false) {
if ($label === Archiver::LABEL_CUSTOM_VALUE_NOT_DEFINED) {
$label = '';
}
$row->setMetadata('segment', $dimension . '==' . urlencode($label));
}
$subTable = $row->getSubtable();
if ($subTable) {
$subTable->filter('Piwik\Plugins\CustomDimensions\DataTable\Filter\AddSubtableSegmentMetadata', array($this->idDimension, $label));
}
}
}
What happened?
I have created a Segment, looks like this:
And I want to invalidate past dates to run the archiver on these segments:
And if I use the Segment definition:
And if I invalidate without a segment definition or id and then rerun the core:archive, I just see rows like:
But I can see that there is data in that custom_dimension:
Why is this happening? I have tried with multiple segments and custom dimensions. I have tried with numerical values and strings. I have tried with building the segment in the UI and with API calls: Operator Behavior Example == Equals &segment=dimension1==quepapoloco != Not equals &segment=dimension1!= (E.g. Not empty) =@ Contains &segment=dimension1=@quepapo =^ Starts with &segment=dimension1=^quepapo
I have tried with custom dimensions in both visits scope and action scope. I don't know why it's not working but the error refers to this line:
And if I follow that
getAvailableSegments()
function, I can see that it's calling aPiwikCache::getTransientCache();
function, so I thought it might be an issue with that. I've tried clearing the cache too:But nothing changes
Config relevant to the segments:
Any thoughts on why this is happening or is it not possible to use custom_dimension_x with segments?
What should happen?
I wan't to add a custom dimensions for a visits, so that a session can be tracked and filtered with from the Segment editor.
How can this be reproduced?
Add a Custom dimension with visit scope, populate the custom_dimension_x column for the matching rows, invalidate past dates, run core archiving.
Matomo version
5.0.2-5.0.3
PHP version
8.2.19
Server operating system
Alpine Linux 3.19
What browsers are you seeing the problem on?
Chrome
Computer operating system
MacOS
Relevant log output
Validations