Skip to content

feat(feature-flags): support quota limiting for feature flags #403#56

Merged
haacked merged 5 commits intomainfrom
feat/quota-limited-flags
Feb 22, 2025
Merged

feat(feature-flags): support quota limiting for feature flags #403#56
haacked merged 5 commits intomainfrom
feat/quota-limited-flags

Conversation

@dmarticus
Copy link
Contributor

with PostHog/posthog#28564, we now start to respond different with the /decide and /local_evaluation APIs if users have gone over their quota limit. Now we need to change the SDKs to handle these new responses.

@dmarticus dmarticus requested a review from haacked as a code owner February 21, 2025 21:11
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

This PR adds support for handling quota limits in PostHog's .NET SDK, responding to changes in the /decide and /local_evaluation APIs when users exceed their quota limits.

  • Added QuotaLimited property to DecideApiResult in /src/PostHog/Api/DecideApiResult.cs to track which features are quota-limited
  • Implemented quota limit handling in /src/PostHog/PostHogClient.cs to return empty dictionaries for bulk flag requests when limits are hit
  • Added quota limit checks in DecideAsync() method to handle feature flag quota limitations
  • Added debug logging for quota exceeded scenarios with appropriate messages
  • Added comprehensive test coverage in /tests/UnitTests/Features/FeatureFlagsTests.cs for quota limit scenarios

3 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings | Greptile

@haacked
Copy link
Collaborator

haacked commented Feb 21, 2025

Thanks @dmarticus! I'll fix this up.

@dmarticus
Copy link
Contributor Author

@haacked thanks! I was working on it locally but my .NET LSP isn't playing nicely so it's been a pain. Thanks for helping, lmk if you have questions about the implementation!

@haacked
Copy link
Collaborator

haacked commented Feb 21, 2025

When attempting a local evaluation API call that is quota limited, I assume we don't want to fallback to /decide correct? If one is quota limited, do we assume the other is too? Or should we continue to fallback to /decide?

@haacked
Copy link
Collaborator

haacked commented Feb 21, 2025

@dmarticus I also noticed the log level for quota exceeded is Debug in this PR. I'm thinking this is something a consumer would want to notice. It should probably be Warning or Error. Right?

@dmarticus
Copy link
Contributor Author

When attempting a local evaluation API call that is quota limited, I assume we don't want to fallback to /decide correct? If one is quota limited, do we assume the other is too? Or should we continue to fallback to /decide?

Yup, we should short-circuit if we get a local eval call that's quota limited

@dmarticus
Copy link
Contributor Author

@dmarticus I also noticed the log level for quota exceeded is Debug in this PR. I'm thinking this is something a consumer would want to notice. It should probably be Warning or Error. Right?

Yeah, let's go with a warning log, that's what the other PRs do.

Copy link
Collaborator

@haacked haacked left a comment

Choose a reason for hiding this comment

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

Nice work!

@haacked haacked merged commit 59b3d0a into main Feb 22, 2025
4 checks passed
@haacked haacked deleted the feat/quota-limited-flags branch February 22, 2025 01: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