-
Notifications
You must be signed in to change notification settings - Fork 46
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(feature-flags): support quota limiting for feature flags #403
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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 quota limiting support for feature flags in the PostHog JS Lite library, handling scenarios where users exceed their API usage limits.
- Added
quotaLimited
property toPostHogDecideResponse
type inposthog-core/src/types.ts
to track which features are quota-limited - Implemented handling of 402 status codes in
posthog-node/src/feature-flags.ts
to clear all local flags when quota is exceeded - Added test coverage in
posthog-core/test/posthog.featureflags.spec.ts
to verify feature flags returnundefined
whenquotaLimited
includes 'feature_flags' - Modified
apiImplementation
inposthog-node/test/test-utils.ts
to support simulating quota limit responses withlocalFlagsStatus
parameter
6 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile
Size Change: +992 B (+0.76%) Total Size: 132 kB
ℹ️ View Unchanged
|
…-js-lite into feat/quota-limited-flags
@@ -1225,7 +1249,7 @@ export abstract class PostHogCore extends PostHogCoreStateless { | |||
return this._decideResponsePromise | |||
} | |||
|
|||
private setKnownFeatureFlags(featureFlags: PostHogDecideResponse['featureFlags']): void { | |||
private setKnownFeatureFlags(featureFlags: PostHogDecideResponse['featureFlags'] | null): void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since this and setKnownFeatureFlagPayloads
accept null
now, we can change the other places from:
this.setKnownFeatureFlags({})
this.setKnownFeatureFlagPayloads({})
to null values as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
left a comment but otherwise LGTM
before merging, lets figure this out PostHog/posthog-android#228 (comment) |
with this PR, 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.