Files
supabase/apps
Jordi EnricandClaude Sonnet 4.6 607cce2bc1 feat: pass subscription plan to ConfigCat for tier-based feature flags (#46063)
## Summary

- Adds the organization's `plan` (e.g. `free`, `pro`, `team`,
`enterprise`) as a custom attribute in the ConfigCat `User` object
- Uses the existing `useSelectedOrganizationQuery` — already called
inside `FeatureFlagProviderWithOrgContext`, so no extra network request
(React Query deduplicates)
- Refactors `customAttributes` construction from a conditional
assignment to an incremental object build, making it easy to add more
attributes in the future

## Why

This unlocks tier-based percentage rollouts in the ConfigCat dashboard.
For example, to roll out a feature to 25% of Pro accounts:

1. Add a Targeting Rule: `IF plan = "pro"`
2. Set the THEN clause to Percentage Options: `25% ON / 75% OFF`

The split is deterministic per user email (or switch to `org_id` as the
percentage evaluation attribute for per-org cohesion).

## Test plan

- [ ] Log in as a user on a paid plan and verify `plan` appears as a
custom attribute in ConfigCat's evaluation logs / targeting debugger
- [ ] Log in as a free-tier user and confirm `plan = "free"` is sent
- [ ] Confirm unauthenticated / org-less sessions don't break (attribute
is omitted when `selectedOrganization?.plan?.id` is undefined)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Improvements**
* Enhanced feature flag configuration to account for organization and
subscription plan information, ensuring more accurate feature
availability based on user context.

<!-- review_stack_entry_start -->

[![Review Change
Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/supabase/supabase/pull/46063?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack)

<!-- review_stack_entry_end -->

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-19 17:13:04 +02:00
..