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

fix(batch-exports): Include properties in feature_enabled call #17860

Merged
merged 4 commits into from
Oct 9, 2023

Conversation

tomasfarias
Copy link
Contributor

Problem

The backend is returning a 403, even though the flag is enabled for a specific team. Maybe the call is missing properties used in other similar calls?

Changes

Adds arguments to feature_enabled call when creating high frequency batch exports.

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

How did you test this code?

@@ -170,11 +170,20 @@ def create(self, validated_data: dict) -> BatchExport:
destination_data = validated_data.pop("destination")
team_id = self.context["team_id"]

if validated_data["interval"] not in ("hour", "day", "week") and not posthoganalytics.feature_enabled(
"high-frequency-batch-exports",
Copy link
Collaborator

Choose a reason for hiding this comment

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

hey @tomasfarias you can try this locally to check if it works or not. (just create the same feature flag in your local env with the same match by and check if it works)

In this case, the feature flag is based on the project group, and not distinct IDs, which means you need to pass in the groups parameter with key project and value as the project ID.

So, you just need to add project instead of organization in this case, and the property 'id' in group_properties

Copy link
Collaborator

Choose a reason for hiding this comment

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

One potential gotcha, and reason not to use project and use organisations instead is that currently this will enable it for both, team 2 and 9291 in EU and US both, vs. just those teams in US.

Hence, using org IDs, which are unique across deployments works better usually.

Copy link
Contributor Author

@tomasfarias tomasfarias Oct 9, 2023

Choose a reason for hiding this comment

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

We can switch the flag to organizations. That means the code changes implemented here are enough, right? Thank you for your input!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've tested things out locally using this branch and flags based on organization and things work 👍 (Discovered a frontend bug while I was at it).

@tomasfarias tomasfarias marked this pull request as ready for review October 9, 2023 11:31
@tomasfarias tomasfarias requested a review from neilkakkar October 9, 2023 11:31
@tomasfarias tomasfarias merged commit b9a4840 into master Oct 9, 2023
74 checks passed
@tomasfarias tomasfarias deleted the fix/high-frequency-batch-exports-flag-check branch October 9, 2023 12:23
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