Skip to content

feat: referral traffic endpoints follow up | LLMO-4261#2301

Open
calvarezg wants to merge 17 commits intomainfrom
feat-LLMO-4261-referral-follow-up
Open

feat: referral traffic endpoints follow up | LLMO-4261#2301
calvarezg wants to merge 17 commits intomainfrom
feat-LLMO-4261-referral-follow-up

Conversation

@calvarezg
Copy link
Copy Markdown
Contributor

Description

Extend referral traffic API with device breakdown and additional metrics

Adds a new /by-device endpoint and extends several existing referral traffic
endpoints with additional metrics to achieve parity with the legacy non-PG dashboard.

New endpoint:

  • GET /sites/:siteId/referral-traffic/by-device — pageviews and bounce rate grouped
    by device type across all four sources (optel, cdn, ga4, adobe_analytics)

Extended endpoints:

  • /trend — adds bounceRate, consentRate (optel), entries, revenue, avgSessionDuration,
    pagesPerVisit, orders, conversionRate per weekly bucket
  • /by-platform — adds visits, avgTimeOnSite, revenue (adobe_analytics; null elsewhere)
  • /by-url — adds entries, exits, avgTimeOnSite, revenue (adobe_analytics; null elsewhere);
    page intent now resolved via the page_intents lookup table using path-based matching
  • /by-page-intent — rewritten to join page_intents on url_path, removing dependency
    on the stale page_intent column in traffic tables

Sort support: entries, exits, avg_time_on_site, revenue added to allowed sort columns
for /by-url.

Tests updated to cover new fields and the new /by-device route.

Please ensure your pull request adheres to the following guidelines:

  • make sure to link the related issues in this description. Or if there's no issue created, make sure you
    describe here the problem you're solving.
  • when merging / squashing, make sure the fixed issue references are visible in the commits, for easy compilation of release notes

If the PR is changing the API specification:

  • make sure you add a "Not implemented yet" note the endpoint description, if the implementation is not ready
    yet. Ideally, return a 501 status code with a message explaining the feature is not implemented yet.
  • make sure you add at least one example of the request and response.

If the PR is changing the API implementation or an entity exposed through the API:

  • make sure you update the API specification and the examples to reflect the changes.

If the PR is introducing a new audit type:

  • make sure you update the API specification with the type, schema of the audit result and an example

Related Issues

LLMO-4261

Updated the maximum page size limit from 500 to 1000 in the referral traffic controller and corresponding test to accommodate larger data requests.
- Introduced a mapping for referral traffic sources to their respective database tables.
- Updated the `withReferralTrafficAuth` function to handle site access validation without storing the context.
- Modified the `createReferralTrafficWeeksHandler` to query the correct table based on the provided source.
- Added validation to return a 400 error for unsupported sources in the business impact endpoint.
- Updated tests to verify new source handling and default behavior.
…etrics

- Introduced a new endpoint `GET /sites/:siteId/referral-traffic/by-device` to fetch referral traffic data categorized by device type.
- Updated existing referral traffic handlers to include additional metrics such as entries, exits, average time on site, and revenue for better insights.
- Enhanced test cases to validate the new endpoint and updated metrics in the response structure.
…r optional fields

- Added new test cases to validate the mapping of optional numeric fields in the referral traffic handlers, ensuring accurate data representation for various metrics including entries, exits, and revenue.
- Updated existing tests to cover scenarios where non-null values are provided, improving overall test coverage and reliability.
@github-actions
Copy link
Copy Markdown

This PR will trigger a minor release when merged.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 30, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants