| <?php |
|
|
| |
| |
| |
| |
| |
| |
|
|
| declare(strict_types=1); |
|
|
| namespace Piwik\Plugins\BotTracking\Reports; |
|
|
| use Piwik\DataTable; |
| use Piwik\Piwik; |
| use Piwik\Plugin\Report; |
| use Piwik\Plugin\ViewDataTable; |
| use Piwik\Plugins\BotTracking\Columns\Metrics\AvgResponseSize; |
| use Piwik\Plugins\BotTracking\Columns\Metrics\AvgServerTime; |
| use Piwik\Plugins\BotTracking\Columns\Metrics\PageNotFound404Requests; |
| use Piwik\Plugins\BotTracking\Columns\Metrics\Requests; |
| use Piwik\Plugins\BotTracking\Columns\Metrics\ServerError5xxRequests; |
| use Piwik\Plugins\BotTracking\Metrics; |
| use Piwik\Report\ReportWidgetFactory; |
| use Piwik\Widget\WidgetsList; |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| abstract class AbstractAIChatbotContentUrlReport extends Report |
| { |
| protected function init(): void |
| { |
| parent::init(); |
|
|
| $this->categoryId = 'General_AIAssistants'; |
| $this->subcategoryId = 'BotTracking_AIChatbotsContentRequests'; |
| $this->metrics = [new Requests(), new ServerError5xxRequests(), new PageNotFound404Requests()]; |
| $this->processedMetrics = [new AvgServerTime(), new AvgResponseSize()]; |
| $this->defaultSortColumn = Metrics::COLUMN_REQUESTS; |
| } |
|
|
| public function configureView(ViewDataTable $view): void |
| { |
| parent::configureView($view); |
|
|
| $view->config->setDefaultColumnsToDisplay( |
| ['label', Metrics::COLUMN_REQUESTS, Metrics::COLUMN_AVG_SERVER_TIME, Metrics::COLUMN_AVG_RESPONSE_SIZE], |
| false, |
| false |
| ); |
|
|
| |
| $view->config->show_table_all_columns = false; |
|
|
| |
| |
| $view->config->show_insights = false; |
| $view->config->show_bar_chart = false; |
| $view->config->show_pie_chart = false; |
| $view->config->show_tag_cloud = false; |
|
|
| |
| $view->config->filters[] = function (DataTable $table) { |
| foreach ($table->getRows() as $row) { |
| if ($row->isSummaryRow()) { |
| continue; |
| } |
| $label = $row->getColumn('label'); |
| if (is_string($label) && $label !== '') { |
| $row->setMetadata('url', 'https://' . $label); |
| } |
| } |
| }; |
|
|
| SegmentNotSupportedMessageHelper::addSegmentNotSupportedMessage($view); |
| } |
|
|
| public function configureWidgets(WidgetsList $widgetsList, ReportWidgetFactory $factory): void |
| { |
| $widgetsList->addWidgetConfig($factory->createWidget()->setIsWide()); |
| } |
|
|
| |
| |
| |
| |
| |
| abstract protected function getRequestsDocumentationKey(): string; |
|
|
| |
| |
| |
| public function getMetricsDocumentation(): array |
| { |
| $docs = parent::getMetricsDocumentation(); |
|
|
| |
| $docs[Metrics::COLUMN_REQUESTS] = Piwik::translate($this->getRequestsDocumentationKey()); |
|
|
| return $docs; |
| } |
| } |
|
|