Skip to content

fix: Restrict opportunities to 3 for freemium plan in spacecat-api-service#2072

Merged
sandsinh merged 9 commits intomainfrom
SITES-41731
Apr 6, 2026
Merged

fix: Restrict opportunities to 3 for freemium plan in spacecat-api-service#2072
sandsinh merged 9 commits intomainfrom
SITES-41731

Conversation

@sandsinh
Copy link
Copy Markdown
Contributor

@sandsinh sandsinh commented Mar 30, 2026

Summary

Restricts opportunities returned by the API to only PLG-allowed types (broken-backlinks, cwv, alt-text) when the site has Summit PLG enabled (freemium plan). This ensures freemium users only see the 3 supported opportunity types rather than all available opportunities.

Changes

  • src/controllers/opportunities.js: Added filterForSummitPlg() helper that checks if Summit PLG is enabled for the site and filters opportunities to the allowed types. Applied to both getAllForSite and getByStatus endpoints.
  • test/controllers/opportunities.test.js: Added 6 test cases covering PLG filtering for both endpoints (enabled/disabled), and verifying request context is passed through.

Related Issues

Test plan

  • Opportunities are filtered to 3 allowed types when Summit PLG is enabled
  • All opportunities are returned when Summit PLG is not enabled
  • Filtering applies to both getAllForSite and getByStatus endpoints
  • Request context is correctly passed to getIsSummitPlgEnabled

Notes

  • package.json contains a dev deploy label change (latestsandsinh) — revert before merge.

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 30, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@github-actions
Copy link
Copy Markdown

This PR will trigger a patch release when merged.

sandsinh and others added 2 commits March 31, 2026 00:40
getAllForSite and getByStatus were not forwarding the request context
to getIsSummitPlgEnabled, so the x-client-type header check was
skipped and PLG filtering always applied for FREE_TRIAL sites.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Comment thread package.json Outdated
"deploy": "hedy -v --deploy --aws-deploy-bucket=spacecat-prod-deploy --pkgVersion=latest",
"deploy-stage": "hedy -v --deploy --aws-deploy-bucket=spacecat-stage-deploy --pkgVersion=latest",
"deploy-dev": "hedy -v --deploy --pkgVersion=latest$CI_BUILD_NUM -l latest --aws-deploy-bucket=spacecat-dev-deploy --cleanup-ci=24h",
"deploy-dev": "hedy -v --deploy --pkgVersion=latest$CI_BUILD_NUM -l sandsinh --aws-deploy-bucket=spacecat-dev-deploy --cleanup-ci=24h",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's make sure we revert this.

Copy link
Copy Markdown
Contributor

@tarunsinghdev tarunsinghdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@sandsinh sandsinh merged commit fb979dc into main Apr 6, 2026
20 checks passed
@sandsinh sandsinh deleted the SITES-41731 branch April 6, 2026 10:56
solaris007 pushed a commit that referenced this pull request Apr 6, 2026
## [1.415.3](v1.415.2...v1.415.3) (2026-04-06)

### Bug Fixes

* Restrict opportunities to 3 for freemium plan in spacecat-api-service ([#2072](#2072)) ([fb979dc](fb979dc))
@solaris007
Copy link
Copy Markdown
Member

🎉 This PR is included in version 1.415.3 🎉

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