Skip to content

feat: SOV endpoints for LLMO | LLMO-3605#1994

Merged
calvarezg merged 5 commits intomainfrom
feat/LLM0-3605-SOV
Mar 20, 2026
Merged

feat: SOV endpoints for LLMO | LLMO-3605#1994
calvarezg merged 5 commits intomainfrom
feat/LLM0-3605-SOV

Conversation

@calvarezg
Copy link
Copy Markdown
Contributor

@calvarezg calvarezg commented Mar 19, 2026

Changes Made

Implements the Share of Voice API endpoint for brand presence, returning per-topic brand mention share, popularity, ranking, and competitor breakdowns.

  • Added createShareOfVoiceHandler in llmo-brand-presence.js that calls the rpc_share_of_voice Supabase RPC and shapes the results into ShareOfVoiceData[]
  • Added volumeToPopularity helper to map imputed volume sentinel values (-30/-20/-10) and legacy positive values to High/Medium/Low/N/A categories
  • Added aggregateShareOfVoice helper to group flat RPC rows by topic, compute per-entity share-of-voice percentages, rank competitors, and sort results by popularity then share of voice
  • Registered the handler in llmo-mysticat-controller.js and wired up two new routes in routes/index.js:
    • GET /org/:spaceCatId/brands/all/brand-presence/share-of-voice
    • GET /org/:spaceCatId/brands/:brandId/brand-presence/share-of-voice
  • Added brand:read capability requirements for both routes in required-capabilities.js
  • Added API documentation in docs/llmo-brandalf-apis/share-of-voice-api.md

Related Issues

Relates to LLMO-3605

Testing the PR changes

  1. Start the service locally and authenticate with a valid brand:read token.
  2. Call GET /org/<orgId>/brands/<brandId>/brand-presence/share-of-voice and confirm a 200 response with a shareOfVoiceData array.
  3. Verify each item contains topic, popularity (High/Medium/Low/N/A), shareOfVoice, ranking, brandMentions, totalMentions, topCompetitors, and allCompetitors.
  4. Call the brands/all variant and confirm it returns aggregated data across all brands for the org.
  5. Apply query parameters (startDate, endDate, siteId, categoryId, topic, region, origin) and verify they are forwarded to the RPC correctly.
  6. Supply an invalid siteId (one not belonging to the org) and confirm a 403 Forbidden response.
  7. Call without auth and confirm a 401 response.

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

- Implemented `createShareOfVoiceHandler` to handle Share of Voice requests.
- Added `volumeToPopularity` and `aggregateShareOfVoice` functions for processing data.
- Registered new routes for Share of Voice in `index.js` and updated required capabilities.
- Enhanced tests for Share of Voice functionality, including edge cases and data aggregation.
- Introduced comprehensive documentation for the Share of Voice API, detailing endpoints, parameters, and response structures.
- Included examples for both all brands and specific brand queries.
- Documented internal query logic and response processing for clarity on data aggregation and handling.
@calvarezg calvarezg marked this pull request as draft March 19, 2026 14:56
@calvarezg calvarezg self-assigned this Mar 19, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@calvarezg calvarezg changed the title Feat/llm0 3605 sov feat: SOV endpoints for LLMO | LLMO-3605 Mar 19, 2026
- Added `maxCompetitors` parameter to the Share of Voice API documentation, allowing users to specify the maximum number of competitors returned per topic.
- Updated the `createShareOfVoiceHandler` to handle the new parameter and default to 5 if not provided.
- Modified the `volumeToPopularity` function to return 'Low' for null or zero volume values instead of 'N/A'.
- Enhanced tests to verify the correct handling of the `maxCompetitors` parameter in RPC calls and updated expectations for popularity values.
@github-actions
Copy link
Copy Markdown

This PR will trigger a minor release when merged.

@calvarezg calvarezg marked this pull request as ready for review March 20, 2026 14:15
- Added comments to clarify the purpose of `TOP_COMPETITORS_DISPLAYED` and `DEFAULT_MAX_COMPETITORS` constants.
- Simplified logging in `createShareOfVoiceHandler` by removing redundant size calculations for RPC response and share of voice data.
- Enhanced readability and maintainability of the code by streamlining the logging process.
@calvarezg calvarezg merged commit d315ec4 into main Mar 20, 2026
20 checks passed
@calvarezg calvarezg deleted the feat/LLM0-3605-SOV branch March 20, 2026 14:35
solaris007 pushed a commit that referenced this pull request Mar 20, 2026
# [1.362.0](v1.361.1...v1.362.0) (2026-03-20)

### Features

* SOV endpoints for LLMO | LLMO-3605 ([#1994](#1994)) ([d315ec4](d315ec4))
@solaris007
Copy link
Copy Markdown
Member

🎉 This PR is included in version 1.362.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants