Campaign metrics read visitors and avg_engaged, which sort=views responses omit

Abierto Apto para principiantes
#4,855 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
72/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
php, wordpress

Línea de trabajo

Empieza en src/rest-api/stats/class-endpoint-posts.php, en particular en Endpoint_Posts::fetch_campaign_data() alrededor de las líneas 510–513, y compara cómo se procesan las métricas con las solicitudes de Post List Stats y Smart Linking mencionadas en la incidencia. Reproduce la solicitud sin sort e inspecciona la respuesta de la campaña. El trabajo estará hecho cuando el endpoint evite las advertencias por claves no definidas y devuelva las métricas de campaña que proporciona la API.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Bug Feature: Engagement Boost wp-parsely

Describe the bug

Endpoint_Posts::fetch_campaign_data() copies four metrics from the campaign response without checking that they exist (src/rest-api/stats/class-endpoint-posts.php:510–:513). The Parse.ly API returns different metrics depending on sort: with sort=views, metrics holds only views and recirculation_rate, while visitors and avg_engaged need sort=avg_engaged. The plugin already works around this elsewhere, as Post List Stats and Smart Linking request sort=avg_engaged for that reason.

The Engagement Boost dashboard sends no sort, so the endpoint falls back to views for both the main and the campaign request. Reading visitors and avg_engaged then raises a warning for each post with campaign data, and the response never includes campaign.visitors or campaign.avgEngaged.

To Reproduce

  1. Request GET /wp-parsely/v2/stats/posts?campaign_id=wp-parsely&campaign_medium=smart-link&period_start=30d without sort, as the Engagement Boost dashboard does.
  2. Check the PHP error log.

PHP raises Undefined array key "visitors" at class-endpoint-posts.php:511 and Undefined array key "avg_engaged" at :513 for each post with campaign data. Each campaign object holds only views and recirculationRate.

Expected behavior

No warnings, and a campaign object that holds the metrics the API returned.

Environment

wp-parsely 3.26.1 and current develop, PHP 8.3. Confirmed against the live Parse.ly API: a sort=views request with these campaign parameters returns only views and recirculation_rate.

Additional context

The dashboard only reads campaign.views, so the visible effect today is the log noise. Possible fixes: copy only the metrics present, and request sort=avg_engaged for the campaign data if visitors and avg_engaged are needed.

Related: #4854, which affects the same block.

Lenguaje dominante
PHP
Estrellas
67
Forks
38
Merge medio
1 d 5 h
PR fusionados (30 d)
79

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de Parsely/wp-parsely

Todos los issues de Parsely/wp-parsely

Issues similares

Más issues de PHP

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.