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

Aperta Adatta ai principianti
#4,855 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
72/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
php, wordpress
Ambito
analytics, backend

Direzione di ricerca

Inizia da src/rest-api/stats/class-endpoint-posts.php, in particolare da Endpoint_Posts::fetch_campaign_data() intorno alle righe 510–513, e confronta la gestione delle metriche con le richieste Post List Stats e Smart Linking menzionate nella issue. Riproduci la richiesta senza sort ed esamina la risposta della campagna. Il lavoro è completo quando l'endpoint evita gli avvisi relativi a chiavi non definite e restituisce le metriche della campagna fornite dall'API.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
PHP
Stelle
67
Fork
38
Merge medio
1g 5h
PR unite (30g)
79

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Parsely/wp-parsely

Tutte le issue di Parsely/wp-parsely

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.