Skip to content

Commit c452235

Browse files
committed
Rename sendFeatureFlags -> appendFeatureFlags
1 parent 3b3a581 commit c452235

8 files changed

Lines changed: 42 additions & 42 deletions

File tree

posthog-server/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
## Next
22

33
- feat: Include `evaluated_at` properties in `$feature_flag_called` events ([#321](https://github.com/PostHog/posthog-android/pull/321))
4-
- feat: Add `sendFeatureFlags` optional boolean to `capture` ([#347](https://github.com/PostHog/posthog-android/pull/347))
4+
- feat: Add `appendFeatureFlags` optional boolean to `capture` ([#347](https://github.com/PostHog/posthog-android/pull/347))
55

66
## 2.0.1 - 2025-11-24
77

posthog-server/USAGE.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ postHog.capture(
177177

178178
### Enriching Events with Feature Flags
179179

180-
You can automatically enrich captured events with the user's current feature flag values by setting `sendFeatureFlags` to `true`. This adds `$feature/flag_name` properties for each flag and an `$active_feature_flags` array containing all enabled flags.
180+
You can automatically enrich captured events with the user's current feature flag values by setting `appendFeatureFlags` to `true`. This adds `$feature/flag_name` properties for each flag and an `$active_feature_flags` array containing all enabled flags.
181181

182182
This is useful for analyzing how feature flags correlate with user behavior without manually tracking flag states.
183183

@@ -188,7 +188,7 @@ postHog.capture(
188188
distinctId = "user123",
189189
event = "purchase_completed",
190190
properties = mapOf("amount" to 99.99),
191-
sendFeatureFlags = true
191+
appendFeatureFlags = true
192192
)
193193
```
194194

@@ -201,12 +201,12 @@ postHog.capture(
201201
PostHogCaptureOptions
202202
.builder()
203203
.property("amount", 99.99)
204-
.sendFeatureFlags(true)
204+
.appendFeatureFlags(true)
205205
.build()
206206
);
207207
```
208208

209-
When `sendFeatureFlags` is `true`, the SDK will fetch feature flags for the user (or use locally evaluated flags if local evaluation is enabled) and include them in the event properties.
209+
When `appendFeatureFlags` is `true`, the SDK will fetch feature flags for the user (or use locally evaluated flags if local evaluation is enabled) and include them in the event properties.
210210

211211
## Error Tracking
212212

posthog-server/api/posthog-server.api

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,31 +42,31 @@ public final class com/posthog/server/PostHogCaptureOptions {
4242
public static final field Companion Lcom/posthog/server/PostHogCaptureOptions$Companion;
4343
public synthetic fun <init> (Ljava/util/Map;Ljava/util/Map;Ljava/util/Map;Ljava/util/Map;Ljava/util/Date;ZLkotlin/jvm/internal/DefaultConstructorMarker;)V
4444
public static final fun builder ()Lcom/posthog/server/PostHogCaptureOptions$Builder;
45+
public final fun getAppendFeatureFlags ()Z
4546
public final fun getGroups ()Ljava/util/Map;
4647
public final fun getProperties ()Ljava/util/Map;
47-
public final fun getSendFeatureFlags ()Z
4848
public final fun getTimestamp ()Ljava/util/Date;
4949
public final fun getUserProperties ()Ljava/util/Map;
5050
public final fun getUserPropertiesSetOnce ()Ljava/util/Map;
5151
}
5252

5353
public final class com/posthog/server/PostHogCaptureOptions$Builder {
5454
public fun <init> ()V
55+
public final fun appendFeatureFlags (Z)Lcom/posthog/server/PostHogCaptureOptions$Builder;
5556
public final fun build ()Lcom/posthog/server/PostHogCaptureOptions;
57+
public final fun getAppendFeatureFlags ()Z
5658
public final fun getGroups ()Ljava/util/Map;
5759
public final fun getProperties ()Ljava/util/Map;
58-
public final fun getSendFeatureFlags ()Z
5960
public final fun getTimestamp ()Ljava/util/Date;
6061
public final fun getUserProperties ()Ljava/util/Map;
6162
public final fun getUserPropertiesSetOnce ()Ljava/util/Map;
6263
public final fun group (Ljava/lang/String;Ljava/lang/String;)Lcom/posthog/server/PostHogCaptureOptions$Builder;
6364
public final fun groups (Ljava/util/Map;)Lcom/posthog/server/PostHogCaptureOptions$Builder;
6465
public final fun properties (Ljava/util/Map;)Lcom/posthog/server/PostHogCaptureOptions$Builder;
6566
public final fun property (Ljava/lang/String;Ljava/lang/Object;)Lcom/posthog/server/PostHogCaptureOptions$Builder;
66-
public final fun sendFeatureFlags (Z)Lcom/posthog/server/PostHogCaptureOptions$Builder;
67+
public final fun setAppendFeatureFlags (Z)V
6768
public final fun setGroups (Ljava/util/Map;)V
6869
public final fun setProperties (Ljava/util/Map;)V
69-
public final fun setSendFeatureFlags (Z)V
7070
public final fun setTimestamp (Ljava/util/Date;)V
7171
public final fun setUserProperties (Ljava/util/Map;)V
7272
public final fun setUserPropertiesSetOnce (Ljava/util/Map;)V

posthog-server/src/main/java/com/posthog/server/PostHog.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ public class PostHog : PostHogStateless(), PostHogInterface {
4141
userPropertiesSetOnce: Map<String, Any>?,
4242
groups: Map<String, String>?,
4343
timestamp: java.util.Date?,
44-
sendFeatureFlags: Boolean,
44+
appendFeatureFlags: Boolean,
4545
) {
4646
val mergedProperties =
47-
if (sendFeatureFlags) {
47+
if (appendFeatureFlags) {
4848
mergeFeatureFlagProperties(
4949
distinctId = distinctId,
5050
groups = groups,

posthog-server/src/main/java/com/posthog/server/PostHogCaptureOptions.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ public class PostHogCaptureOptions private constructor(
1414
public val userPropertiesSetOnce: Map<String, Any>?,
1515
public val groups: Map<String, String>?,
1616
public val timestamp: Date? = null,
17-
public val sendFeatureFlags: Boolean = false,
17+
public val appendFeatureFlags: Boolean = false,
1818
) {
1919
public class Builder {
2020
public var properties: MutableMap<String, Any>? = null
2121
public var userProperties: MutableMap<String, Any>? = null
2222
public var userPropertiesSetOnce: MutableMap<String, Any>? = null
2323
public var groups: MutableMap<String, String>? = null
2424
public var timestamp: Date? = null
25-
public var sendFeatureFlags: Boolean = false
25+
public var appendFeatureFlags: Boolean = false
2626

2727
/**
2828
* Add a single custom property to the capture options
@@ -163,8 +163,8 @@ public class PostHogCaptureOptions private constructor(
163163
* `$active_feature_flags` array containing names of all truthy flags.
164164
* @see <a href="https://posthog.com/docs/feature-flags">Documentation: Feature Flags</a>
165165
*/
166-
public fun sendFeatureFlags(sendFeatureFlags: Boolean): Builder {
167-
this.sendFeatureFlags = sendFeatureFlags
166+
public fun appendFeatureFlags(appendFeatureFlags: Boolean): Builder {
167+
this.appendFeatureFlags = appendFeatureFlags
168168
return this
169169
}
170170

@@ -175,7 +175,7 @@ public class PostHogCaptureOptions private constructor(
175175
userPropertiesSetOnce,
176176
groups,
177177
timestamp,
178-
sendFeatureFlags,
178+
appendFeatureFlags,
179179
)
180180
}
181181

posthog-server/src/main/java/com/posthog/server/PostHogInterface.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public sealed interface PostHogInterface {
7676
* @param userPropertiesSetOnce the user properties to set only once, set as a "$set_once" property, Docs https://posthog.com/docs/product-analytics/user-properties
7777
* @param groups the groups, set as a "$groups" property, Docs https://posthog.com/docs/product-analytics/group-analytics
7878
* @param timestamp the timestamp for the event
79-
* @param sendFeatureFlags when true, enriches the event with feature flag properties
79+
* @param appendFeatureFlags when true, enriches the event with feature flag properties
8080
*/
8181
@JvmSynthetic
8282
public fun capture(
@@ -87,14 +87,14 @@ public sealed interface PostHogInterface {
8787
userPropertiesSetOnce: Map<String, Any>? = null,
8888
groups: Map<String, String>? = null,
8989
timestamp: Date? = null,
90-
sendFeatureFlags: Boolean = false,
90+
appendFeatureFlags: Boolean = false,
9191
)
9292

9393
/**
9494
* Captures events
9595
* @param distinctId the distinctId
9696
* @param event the event name
97-
* @param options the capture options containing properties, userProperties, userPropertiesSetOnce, groups, and sendFeatureFlags
97+
* @param options the capture options containing properties, userProperties, userPropertiesSetOnce, groups, and appendFeatureFlags
9898
*/
9999
public fun capture(
100100
distinctId: String,
@@ -109,7 +109,7 @@ public sealed interface PostHogInterface {
109109
options.userPropertiesSetOnce,
110110
options.groups,
111111
options.timestamp,
112-
options.sendFeatureFlags,
112+
options.appendFeatureFlags,
113113
)
114114
}
115115

posthog-server/src/test/java/com/posthog/server/PostHogCaptureOptionsTest.kt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -583,41 +583,41 @@ internal class PostHogCaptureOptionsTest {
583583
}
584584

585585
@Test
586-
fun `sendFeatureFlags defaults to false`() {
586+
fun `appendFeatureFlags defaults to false`() {
587587
val options = PostHogCaptureOptions.builder().build()
588588

589-
assertEquals(false, options.sendFeatureFlags)
589+
assertEquals(false, options.appendFeatureFlags)
590590
}
591591

592592
@Test
593-
fun `sendFeatureFlags can be set to true`() {
593+
fun `appendFeatureFlags can be set to true`() {
594594
val options =
595595
PostHogCaptureOptions.builder()
596-
.sendFeatureFlags(true)
596+
.appendFeatureFlags(true)
597597
.build()
598598

599-
assertEquals(true, options.sendFeatureFlags)
599+
assertEquals(true, options.appendFeatureFlags)
600600
}
601601

602602
@Test
603-
fun `sendFeatureFlags returns builder for chaining`() {
603+
fun `appendFeatureFlags returns builder for chaining`() {
604604
val builder = PostHogCaptureOptions.builder()
605-
val result = builder.sendFeatureFlags(true)
605+
val result = builder.appendFeatureFlags(true)
606606

607607
assertEquals(builder, result)
608608
}
609609

610610
@Test
611-
fun `sendFeatureFlags can be combined with other options`() {
611+
fun `appendFeatureFlags can be combined with other options`() {
612612
val options =
613613
PostHogCaptureOptions.builder()
614614
.property("key", "value")
615-
.sendFeatureFlags(true)
615+
.appendFeatureFlags(true)
616616
.timestamp(Date(1234567890L))
617617
.build()
618618

619619
assertEquals(mapOf("key" to "value"), options.properties)
620-
assertEquals(true, options.sendFeatureFlags)
620+
assertEquals(true, options.appendFeatureFlags)
621621
assertEquals(Date(1234567890L), options.timestamp)
622622
}
623623
}

posthog-server/src/test/java/com/posthog/server/PostHogTest.kt

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ internal class PostHogTest {
277277
}
278278

279279
@Test
280-
fun `capture with sendFeatureFlags false does not enrich properties`() {
280+
fun `capture with appendFeatureFlags false does not enrich properties`() {
281281
val mockServer = MockWebServer()
282282
mockServer.enqueue(MockResponse().setResponseCode(200))
283283
mockServer.start()
@@ -296,7 +296,7 @@ internal class PostHogTest {
296296
"test_event",
297297
PostHogCaptureOptions.builder()
298298
.property("custom", "value")
299-
.sendFeatureFlags(false)
299+
.appendFeatureFlags(false)
300300
.build(),
301301
)
302302

@@ -306,11 +306,11 @@ internal class PostHogTest {
306306
val props = request.parseBatch().firstEventProperties()
307307
assertFalse(
308308
props.keys.any { it.startsWith("\$feature/") },
309-
"Event should not contain \$feature/ properties when sendFeatureFlags is false",
309+
"Event should not contain \$feature/ properties when appendFeatureFlags is false",
310310
)
311311
assertFalse(
312312
props.containsKey("\$active_feature_flags"),
313-
"Event should not contain \$active_feature_flags when sendFeatureFlags is false",
313+
"Event should not contain \$active_feature_flags when appendFeatureFlags is false",
314314
)
315315
assertEquals("value", props["custom"])
316316

@@ -319,7 +319,7 @@ internal class PostHogTest {
319319
}
320320

321321
@Test
322-
fun `capture with sendFeatureFlags true enriches event with feature flag properties`() {
322+
fun `capture with appendFeatureFlags true enriches event with feature flag properties`() {
323323
val localEvalResponse = createLocalEvaluationResponse("test-flag")
324324
val mockServer = MockWebServer()
325325
mockServer.enqueue(jsonResponse(localEvalResponse))
@@ -341,7 +341,7 @@ internal class PostHogTest {
341341
"test_event",
342342
PostHogCaptureOptions.builder()
343343
.property("custom", "value")
344-
.sendFeatureFlags(true)
344+
.appendFeatureFlags(true)
345345
.build(),
346346
)
347347

@@ -366,7 +366,7 @@ internal class PostHogTest {
366366
}
367367

368368
@Test
369-
fun `capture with sendFeatureFlags uses local evaluation and does not call flags endpoint`() {
369+
fun `capture with appendFeatureFlags uses local evaluation and does not call flags endpoint`() {
370370
val localEvalResponse = createLocalEvaluationResponse("test-flag")
371371
val mockServer = MockWebServer()
372372
mockServer.enqueue(jsonResponse(localEvalResponse))
@@ -387,7 +387,7 @@ internal class PostHogTest {
387387
distinctId = "user123",
388388
event = "test_event",
389389
properties = mapOf("custom" to "value"),
390-
sendFeatureFlags = true,
390+
appendFeatureFlags = true,
391391
)
392392

393393
// Collect all requests
@@ -416,7 +416,7 @@ internal class PostHogTest {
416416
}
417417

418418
@Test
419-
fun `capture with sendFeatureFlags without local evaluation calls flags endpoint`() {
419+
fun `capture with appendFeatureFlags without local evaluation calls flags endpoint`() {
420420
val flagsResponse = createFlagsResponse("test-flag")
421421
val mockServer = MockWebServer()
422422
mockServer.enqueue(jsonResponse(flagsResponse))
@@ -436,7 +436,7 @@ internal class PostHogTest {
436436
distinctId = "user123",
437437
event = "test_event",
438438
properties = mapOf("custom" to "value"),
439-
sendFeatureFlags = true,
439+
appendFeatureFlags = true,
440440
)
441441

442442
val requests = mutableListOf<RecordedRequest>()
@@ -466,7 +466,7 @@ internal class PostHogTest {
466466
}
467467

468468
@Test
469-
fun `capture with sendFeatureFlags includes truthy flags in active_feature_flags and excludes falsy`() {
469+
fun `capture with appendFeatureFlags includes truthy flags in active_feature_flags and excludes falsy`() {
470470
val localEvalResponse =
471471
"""
472472
{
@@ -531,7 +531,7 @@ internal class PostHogTest {
531531
postHog.capture(
532532
distinctId = "user123",
533533
event = "test_event",
534-
sendFeatureFlags = true,
534+
appendFeatureFlags = true,
535535
)
536536

537537
// Skip /local_evaluation request

0 commit comments

Comments
 (0)