Campaign metrics read visitors and avg_engaged, which sort=views responses omit
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
Research direction
Start in src/rest-api/stats/class-endpoint-posts.php, especially Endpoint_Posts::fetch_campaign_data() around lines 510–513, and compare its metric handling with the Post List Stats and Smart Linking requests mentioned in the issue. Reproduce the request without sort and inspect the campaign response. Done means the endpoint avoids undefined-key warnings and returns the campaign metrics the API provides.
Written by the indexing model from the issue text.
Description
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
- Request
GET /wp-parsely/v2/stats/posts?campaign_id=wp-parsely&campaign_medium=smart-link&period_start=30dwithoutsort, as the Engagement Boost dashboard does. - 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.
- Dominant language
- PHP
- Stars
- 67
- Forks
- 38
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 79
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Parsely/wp-parsely
-
Bug Feature: Engagement Boost wp-parsely
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Parsely/wp-parsely#4856 ·
Maintainers usually reply within 1 day
-
Bug Feature: Engagement Boost wp-parsely
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Parsely/wp-parsely#4854 ·
Maintainers usually reply within 1 day
-
wp-parsely
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Parsely/wp-parsely#4753 ·
Maintainers usually reply within 1 day
-
Bug wp-parsely
Difficulty 4/5 3-5 days Newbie friendliness 58/100
Parsely/wp-parsely#4663 ·
Maintainers usually reply within 1 day
-
Documentation wp-parsely
Difficulty 3/5 1-2 days Newbie friendliness 74/100
Parsely/wp-parsely#4559 ·
Maintainers usually reply within 1 day
All issues in Parsely/wp-parsely
Similar issues
-
15.0
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
opnsense/plugins#5976 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
open-telemetry/opentelemetry-php-distro#176 ·
Maintainers usually reply within 2 days
-
No Code Attached Yet
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
joomla/joomla-cms#48941 ·
Maintainers usually reply within 1 day
-
needs-triage Platform(Default)
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day