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(feature-flags): support quota limiting for feature flags #228

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

dmarticus
Copy link

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.

Copy link
Member

@marandaneto marandaneto left a comment

Choose a reason for hiding this comment

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

lets figure out PostHog/posthog-js-lite#403 (comment) first before merging this

Comment on lines +96 to +99
config.cachePreferences?.let { preferences ->
preferences.remove(FEATURE_FLAGS)
preferences.remove(FEATURE_FLAGS_PAYLOAD)
}
Copy link
Member

Choose a reason for hiding this comment

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

what should happen if session replay uses a feature flag and now is quota limited, should it stop working as well? if so, I guess we can also do preferences.remove(SESSION_REPLAY) if session replay has a linkedFlag value.

Copy link
Author

Choose a reason for hiding this comment

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

Oh, yeah, I didn't think of that scenario – can you tell me more about how session replay with flags works? I'm fine removing it but I don't really understand how session replay and flags overlap in this context.

Copy link
Member

Choose a reason for hiding this comment

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

@Posthog/team-replay would know more but the implementation is straightforward.
https://github.com/PostHog/posthog-android/blob/41ac8e9dbf989348823052c8c0f14c9c0d1fa2fd/posthog/src/main/java/com/posthog/internal/PostHogFeatureFlags.kt#L39C17-L68
https://github.com/PostHog/posthog/blob/31427d51f6a4aa91b45b3f4c49ef019f22c503d3/posthog/api/decide.py#L489
if /decide returns a linkedFlag value, that means we have to evaluate this flag locally, so the current approach will break session replay even if you have recordings quota.
now the question is, if you have recordings quota, you don't have flags quota, but session replay configs is enabled behind a flag, should it work or not?

Copy link
Member

Choose a reason for hiding this comment

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

well, it should fail closed

generally speaking folk are setting a linked flag to reduce cost/volume. so failing open would be nasty

so, I have a linked flag, but I am past flag quota, decide/config continues to return the linked flag for replay, the SDK never shows it as received because i'm past quota, and replay never starts

Copy link
Member

Choose a reason for hiding this comment

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

then i think the UX is all around how we notify people about being past quota. feels way more important for flags than other products

Copy link
Member

Choose a reason for hiding this comment

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

the current approach will silently disable session replay since the linked flag won't exist, which will be one more edge case to debug missing recordings on SDKs.
is that the expectation?

ps: there's the quota limiting logging but it's not really specific about session replay, so folks won't get it right away, I think.

Copy link
Member

Choose a reason for hiding this comment

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

yep, at least failing closed :)

ideally we'd register a super property on events if replay or flags or etc are past their quota for debugging (obvs doesn't help if events are past quota)

but yep, the onward journey will be the thing

Copy link
Member

@marandaneto marandaneto left a comment

Choose a reason for hiding this comment

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

left a few comments otherwise all good

@marandaneto
Copy link
Member

@dmarticus this should be done for iOS as well right? is your team doing it? or do you need help from @ioannisj

@dmarticus
Copy link
Author

@dmarticus this should be done for iOS as well right? is your team doing it? or do you need help from @ioannisj

Yup, I did it here: PostHog/posthog-ios#308, tagged you and Ioannis for review :)

@dmarticus
Copy link
Author

@marandaneto addressed your feedback but my tests are failing and I can't make head or tails of the kotlin build error; any chance you could give me a hand getting it over the line?

@marandaneto
Copy link
Member

@marandaneto addressed your feedback but my tests are failing and I can't make head or tails of the kotlin build error; any chance you could give me a hand getting it over the line?

sure, here we go 2b66513 (#228)
there was a recursion with the wrong return@block

@marandaneto
Copy link
Member

@dmarticus should I merge and release this?

@@ -1,5 +1,9 @@
## Next

## 3.11.3 - 2025-02-24
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
## 3.11.3 - 2025-02-24
## 3.11.3 - 2025-02-25

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.

3 participants