Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(flags): Set up initial backend for feature management #26628

Open
wants to merge 61 commits into
base: master
Choose a base branch
from

Conversation

havenbarnes
Copy link
Contributor

@havenbarnes havenbarnes commented Dec 4, 2024

Problem

Follow up to https://github.com/PostHog/posthog/pull/26363/files

Changes

Adds the following endpoints for feature management CRUD ops:

GET    /api/projects/{project_id}/features/         - List all features
POST   /api/projects/{project_id}/features/         - Create a feature
GET    /api/projects/{project_id}/features/{id}/    - Get specific feature
PUT    /api/projects/{project_id}/features/{id}/    - Full update
PATCH  /api/projects/{project_id}/features/{id}/    - Partial update

GET    /api/projects/{project_id}/features/{id}/primary_feature_flag/    - Get primary flag
GET    /api/projects/{project_id}/features/{id}/feature_flags/           - Get all flags
GET    /api/projects/{project_id}/features/{id}/experiments/             - Get experiments
GET    /api/projects/{project_id}/features/{id}/early_access_features/   - Get EAFs

👉 Stay up-to-date with PostHog coding conventions for a smoother review.

Does this work well for both Cloud and self-hosted?

Yes

How did you test this code?

Added API tests

havenbarnes and others added 30 commits November 22, 2024 13:26
Base automatically changed from feature-management-ui-setup to master December 6, 2024 19:39
@@ -30,6 +30,7 @@ class Stage(models.TextChoices):
stage = models.CharField(max_length=40, choices=Stage.choices)
documentation_url = models.URLField(max_length=800, blank=True)
created_at = models.DateTimeField(auto_now_add=True)
feature_management = models.ForeignKey("posthog.Feature", on_delete=models.SET_NULL, null=True)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

"Why feature_management vs just feature?"

The existing feature_flag foreign key on some of these models uses related names that would clash with feature:

related_name="features",
related_query_name="feature",

Copy link
Contributor

Choose a reason for hiding this comment

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

ah, that's a bit annoying, but I understand the choice.

@havenbarnes havenbarnes marked this pull request as ready for review December 9, 2024 19:59
@havenbarnes havenbarnes requested a review from dmarticus December 9, 2024 19:59
Copy link
Contributor

@dmarticus dmarticus left a comment

Choose a reason for hiding this comment

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

looks great! Seems like CI is a bit mad but I think the changes are sensible and the tests are good.

@@ -30,6 +30,7 @@ class Stage(models.TextChoices):
stage = models.CharField(max_length=40, choices=Stage.choices)
documentation_url = models.URLField(max_length=800, blank=True)
created_at = models.DateTimeField(auto_now_add=True)
feature_management = models.ForeignKey("posthog.Feature", on_delete=models.SET_NULL, null=True)
Copy link
Contributor

Choose a reason for hiding this comment

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

ah, that's a bit annoying, but I understand the choice.

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