matomo - Matomo:在插件 API 中获取 actionDetails
问题描述
我正在尝试创建自定义报告。我希望它显示 CustomDimensions,我可以在 actionDetails 下的 ?module=API&method=Live.getLastVisitsDetails&idSite=1&period=day&date=today&format=JSON&token_auth= 中找到它。
我尝试按照本文中的说明创建报告: https ://developer.matomo.org/guides/custom-reports-extended
但是当我要求“actionDetails”而不是“browserName”时,我没有得到任何结果。
我的功能如下所示:
$data = \Piwik\API\Request::processRequest('Live.getLastVisitsDetails', array(
'idSite' => $idSite,
'period' => $period,
'date' => $date,
'segment' => $segment,
'numLastVisitorsToFetch' => 100,
'minTimestamp' => false,
'flat' => false,
'doNotFetchActions' => true
));
$data->applyQueuedFilters();
// we could create a new instance by using new DataTable(),
// but we would lose DataTable metadata, which can be useful.
$result = $data->getEmptyClone($keepFilters = false);
foreach ($data->getRows() as $visitRow) {
$actionDetails = $visitRow->getColumn('browserName');
// try and get the row in the result DataTable for the browser
$browserRow = $result->getRowFromLabel($actionDetails);
$test = $visitRow->getColumn('actionDetails');
var_dump($test);
// if there is no row for this browser, create it
if ($browserRow === false) {
$result->addRowFromSimpleArray(array(
'label' => $actionDetails,
'nb_visits' => 1
));
} else { // if there is a row, increment the counter
$counter = $browserRow->getColumn('nb_visits');
$browserRow->setColumn('nb_visits', $counter + 1);
}
}
return $result;
var_dump 返回 array(0) { } 虽然我可以在打开 ?module=API&method=Live.getLastVisitsDetails&idSite=1&period=day&date=today&format=JSON&token_auth= 链接时看到数据。
如何获取 actionDetails 数据?
解决方案
您'doNotFetchActions' => true
可能已将其设置为 false?这会从结果中删除操作。
推荐阅读
- python - 从 CVXPY 数组中提取数字
- python - AttributeError:“元组”对象没有属性“写入”错误
- c# - 另一个 DbContext 上的 ASP.NET DbSet 标识属性
- c# - 日期字段未填充在 Razor 页面中
- git - WebStorm 的默认变更列表需要很长时间才能更新
- python - Python最有效的数据结构来保存值并检查值是否存在
- flutter - 无法构建 AAR,找不到任务“assembleAarDebug”
- php - 如何延迟测试 Laravel 作业?
- reinforcement-learning - 具有稳定基线的自定义 Openai 健身房环境
- flutter - 在 ListView.builder 中显示信息时出现问题