Skip to content

Commit

Permalink
chore(flags): more quota limit logs (#230)
Browse files Browse the repository at this point in the history
  • Loading branch information
dmarticus authored Feb 26, 2025
1 parent dc6b220 commit af4601c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
## Next

## 3.11.3 - 2025-02-25
## 3.11.3 - 2025-02-26

- feat: support quota limiting for feature flags ([#228](https://github.com/PostHog/posthog-android/pull/228))
- feat: support quota limiting for feature flags ([#228](https://github.com/PostHog/posthog-android/pull/228) and [#230](https://github.com/PostHog/posthog-android/pull/230))

## 3.11.2 - 2025-02-04

Expand Down
25 changes: 21 additions & 4 deletions posthog/src/main/java/com/posthog/internal/PostHogFeatureFlags.kt
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,30 @@ internal class PostHogFeatureFlags(
val linkedFlag = sessionRecording["linkedFlag"]
if (linkedFlag is String) {
val value = featureFlags[linkedFlag]
if (value is Boolean) {
recordingActive = value
}
recordingActive =
when (value) {
is Boolean -> {
value
}
is String -> {
// if its a multi-variant flag linked to "any"
true
}
else -> {
// disable recording if the flag does not exist/quota limited
false
}
}
} else if (linkedFlag is Map<*, *>) {
// Check for specific flag variant
val flag = linkedFlag["flag"] as? String
val variant = linkedFlag["variant"] as? String
if (flag != null && variant != null) {
val value = featureFlags[flag] as? String
recordingActive = value == variant
} else {
// disable recording if the flag does not exist/quota limited
recordingActive = false
}
}
// check for multi flag variant (any)
Expand Down Expand Up @@ -90,7 +104,10 @@ internal class PostHogFeatureFlags(
response?.let {
synchronized(featureFlagsLock) {
if (response.quotaLimited?.contains("feature_flags") == true) {
config.logger.log("Feature flags are quota limited, clearing existing flags")
config.logger.log(
"""Feature flags are quota limited, clearing existing flags.
Learn more about billing limits at https://posthog.com/docs/billing/limits-alerts""",
)
this.featureFlags = null
this.featureFlagPayloads = null
config.cachePreferences?.let { preferences ->
Expand Down

0 comments on commit af4601c

Please sign in to comment.