Skip to content

Commit af4601c

Browse files
authored
chore(flags): more quota limit logs (#230)
1 parent dc6b220 commit af4601c

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

CHANGELOG.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
## Next
22

3-
## 3.11.3 - 2025-02-25
3+
## 3.11.3 - 2025-02-26
44

5-
- feat: support quota limiting for feature flags ([#228](https://github.com/PostHog/posthog-android/pull/228))
5+
- 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))
66

77
## 3.11.2 - 2025-02-04
88

posthog/src/main/java/com/posthog/internal/PostHogFeatureFlags.kt

+21-4
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,30 @@ internal class PostHogFeatureFlags(
4646
val linkedFlag = sessionRecording["linkedFlag"]
4747
if (linkedFlag is String) {
4848
val value = featureFlags[linkedFlag]
49-
if (value is Boolean) {
50-
recordingActive = value
51-
}
49+
recordingActive =
50+
when (value) {
51+
is Boolean -> {
52+
value
53+
}
54+
is String -> {
55+
// if its a multi-variant flag linked to "any"
56+
true
57+
}
58+
else -> {
59+
// disable recording if the flag does not exist/quota limited
60+
false
61+
}
62+
}
5263
} else if (linkedFlag is Map<*, *>) {
5364
// Check for specific flag variant
5465
val flag = linkedFlag["flag"] as? String
5566
val variant = linkedFlag["variant"] as? String
5667
if (flag != null && variant != null) {
5768
val value = featureFlags[flag] as? String
5869
recordingActive = value == variant
70+
} else {
71+
// disable recording if the flag does not exist/quota limited
72+
recordingActive = false
5973
}
6074
}
6175
// check for multi flag variant (any)
@@ -90,7 +104,10 @@ internal class PostHogFeatureFlags(
90104
response?.let {
91105
synchronized(featureFlagsLock) {
92106
if (response.quotaLimited?.contains("feature_flags") == true) {
93-
config.logger.log("Feature flags are quota limited, clearing existing flags")
107+
config.logger.log(
108+
"""Feature flags are quota limited, clearing existing flags.
109+
Learn more about billing limits at https://posthog.com/docs/billing/limits-alerts""",
110+
)
94111
this.featureFlags = null
95112
this.featureFlagPayloads = null
96113
config.cachePreferences?.let { preferences ->

0 commit comments

Comments
 (0)