feat(vtex): add Sales Performance analytics tools (cards, trend, table) - #542
Merged
Conversation
Adds three read-only tools wrapping the admin "Performance de vendas" (Sales Performance) dashboard endpoints under /api/analytics/consumption/, reusing the existing VtexId-session analytics helper: - VTEX_GET_SALES_PERFORMANCE_SUMMARY -> sp-cards (KPI summary) - VTEX_GET_SALES_PERFORMANCE_TREND -> sp-graphic (single-metric time series) - VTEX_GET_SALES_PERFORMANCE_TABLE -> sp-item-detail-table (breakdown ranked by a dimension) Payloads reverse-engineered live from the dashboard: 20 valid metric values, 17 groupByDim dimensions, sortType (percentage|variation), sortOrientation and pagination. See .context/sales-performance-api-spec.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds three read-only MCP tools that wrap the VTEX admin "Performance de vendas" (Sales Performance) dashboard, under
/api/analytics/consumption/:VTEX_GET_SALES_PERFORMANCE_SUMMARYsp-cardsVTEX_GET_SALES_PERFORMANCE_TRENDsp-graphicVTEX_GET_SALES_PERFORMANCE_TABLEsp-item-detail-tablesp-item-detail-tableis the endpoint originally requested. The other two round out the same dashboard and reuse the same helpers.How
Follows the existing
custom/home-analytics.tspattern and reusesfetchAnalyticsConsumption/resolveAnalyticsDateRange(VtexId session-token auth, literal query strings so ISO colons aren't encoded). Registered inserver/tools/index.ts.Payload possibilities (reverse-engineered live from the dashboard)
metric1..metric5):capturedRevenue,approvedRevenue,invoicedRevenue,canceledRevenue,captured/approved/invoiced/canceledOrders,…Items,…AverageTicket,itemsPerOrder,packagesPerOrder,averageSellingPrice,averageShippingPrice.groupByDimdimensions:productName(default),category,brand,marketplaceName,deliveryMethod,shippingOption,destinationCity,destinationState,sellerName,paymentMethod,ownershipProduct,campaign,coupon,tradePolicy,promotion,utmCampaign,utmSource.sortType:percentage|variation(the UI "Representativa" toggle is client-side only, not an API value).sortOrientation:DESC|ASC; plusitemsPerPage/startIndexpagination.Full spec captured in
.context/sales-performance-api-spec.md(gitignored).Test
bun test server/tools/custom/sales-performance.test.ts→ 4 pass (URL-shape assertions, incl. no%3Aencoding).bun test server/tools/custom/→ 35 pass.bun run check→ no new type errors from these files (pre-existing errors are inside the@decocms/runtimedependency).🤖 Generated with Claude Code
Summary by cubic
Adds three read-only VTEX analytics tools that expose the admin Sales Performance dashboard (KPI cards, single-metric trend, ranked breakdown table). This enables programmatic access via the existing analytics session flow without changing existing tools.
fetchAnalyticsConsumption,resolveAnalyticsDateRange, and the shared URL builder; timestamps stay literal (no encoded colons). Auth uses VtexId session from App Key/Token.hour|day|week|month; table supportssortType(percentage|variation),sortOrientation, and pagination.vtex/server/tools/index.ts. Tests assert URL shape and metric mapping (bun testpasses).Written for commit 7194419. Summary will update on new commits.