Skip to content

Commit 4098fa7

Browse files
authored
fix: rename groupProperties to groups for capture methods (#139)
1 parent 8013ccc commit 4098fa7

File tree

10 files changed

+40
-39
lines changed

10 files changed

+40
-39
lines changed

CHANGELOG.md

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

33
- chore: change host to new address ([#137](https://github.com/PostHog/posthog-android/pull/137))
4+
- fix: rename groupProperties to groups for capture methods ([#139](https://github.com/PostHog/posthog-android/pull/139))
45

56
## 3.3.0 - 2024-05-24
67

posthog-android/lint-baseline.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
<issue
55
id="GradleDependency"
6-
message="A newer version of androidx.lifecycle:lifecycle-process than 2.6.2 is available: 2.8.0"
6+
message="A newer version of androidx.lifecycle:lifecycle-process than 2.6.2 is available: 2.8.1"
77
errorLine1=" implementation(&quot;androidx.lifecycle:lifecycle-process:${PosthogBuildConfig.Dependencies.LIFECYCLE}&quot;)"
88
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
99
<location
@@ -14,7 +14,7 @@
1414

1515
<issue
1616
id="GradleDependency"
17-
message="A newer version of androidx.lifecycle:lifecycle-common-java8 than 2.6.2 is available: 2.8.0"
17+
message="A newer version of androidx.lifecycle:lifecycle-common-java8 than 2.6.2 is available: 2.8.1"
1818
errorLine1=" implementation(&quot;androidx.lifecycle:lifecycle-common-java8:${PosthogBuildConfig.Dependencies.LIFECYCLE}&quot;)"
1919
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
2020
<location

posthog-android/src/test/java/com/posthog/android/PostHogFake.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public class PostHogFake : PostHogInterface {
2222
properties: Map<String, Any>?,
2323
userProperties: Map<String, Any>?,
2424
userPropertiesSetOnce: Map<String, Any>?,
25-
groupProperties: Map<String, Any>?,
25+
groups: Map<String, String>?,
2626
) {
2727
this.event = event
2828
this.properties = properties

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ public class PostHog private constructor(
228228
properties: Map<String, Any>?,
229229
userProperties: Map<String, Any>?,
230230
userPropertiesSetOnce: Map<String, Any>?,
231-
groupProperties: Map<String, Any>?,
231+
groups: Map<String, String>?,
232232
appendSharedProps: Boolean = true,
233233
appendGroups: Boolean = true,
234234
): Map<String, Any> {
@@ -294,7 +294,7 @@ public class PostHog private constructor(
294294

295295
if (appendGroups) {
296296
// merge groups
297-
mergeGroups(groupProperties)?.let {
297+
mergeGroups(groups)?.let {
298298
props["\$groups"] = it
299299
}
300300
}
@@ -310,18 +310,18 @@ public class PostHog private constructor(
310310
return props
311311
}
312312

313-
private fun mergeGroups(groupProperties: Map<String, Any>?): Map<String, Any>? {
313+
private fun mergeGroups(givenGroups: Map<String, String>?): Map<String, String>? {
314314
val preferences = getPreferences()
315315

316316
@Suppress("UNCHECKED_CAST")
317-
val groups = preferences.getValue(GROUPS) as? Map<String, Any>
318-
val newGroups = mutableMapOf<String, Any>()
317+
val groups = preferences.getValue(GROUPS) as? Map<String, String>
318+
val newGroups = mutableMapOf<String, String>()
319319

320320
groups?.let {
321321
newGroups.putAll(it)
322322
}
323323

324-
groupProperties?.let {
324+
givenGroups?.let {
325325
newGroups.putAll(it)
326326
}
327327

@@ -334,7 +334,7 @@ public class PostHog private constructor(
334334
properties: Map<String, Any>?,
335335
userProperties: Map<String, Any>?,
336336
userPropertiesSetOnce: Map<String, Any>?,
337-
groupProperties: Map<String, Any>?,
337+
groups: Map<String, String>?,
338338
) {
339339
try {
340340
if (!isEnabled()) {
@@ -368,7 +368,7 @@ public class PostHog private constructor(
368368
properties = properties,
369369
userProperties = userProperties,
370370
userPropertiesSetOnce = userPropertiesSetOnce,
371-
groupProperties = groupProperties,
371+
groups = groups,
372372
// only append shared props if not a snapshot event
373373
appendSharedProps = !snapshotEvent,
374374
// only append groups if not a group identify event
@@ -527,8 +527,8 @@ public class PostHog private constructor(
527527

528528
synchronized(groupsLock) {
529529
@Suppress("UNCHECKED_CAST")
530-
val groups = preferences.getValue(GROUPS) as? Map<String, Any>
531-
val newGroups = mutableMapOf<String, Any>()
530+
val groups = preferences.getValue(GROUPS) as? Map<String, String>
531+
val newGroups = mutableMapOf<String, String>()
532532

533533
groups?.let {
534534
val currentKey = it[type]
@@ -561,7 +561,7 @@ public class PostHog private constructor(
561561

562562
private fun loadFeatureFlagsRequest(onFeatureFlags: PostHogOnFeatureFlags?) {
563563
@Suppress("UNCHECKED_CAST")
564-
val groups = getPreferences().getValue(GROUPS) as? Map<String, Any>
564+
val groups = getPreferences().getValue(GROUPS) as? Map<String, String>
565565

566566
val distinctId = this.distinctId
567567
val anonymousId = this.anonymousId
@@ -783,15 +783,15 @@ public class PostHog private constructor(
783783
properties: Map<String, Any>?,
784784
userProperties: Map<String, Any>?,
785785
userPropertiesSetOnce: Map<String, Any>?,
786-
groupProperties: Map<String, Any>?,
786+
groups: Map<String, String>?,
787787
) {
788788
shared.capture(
789789
event,
790790
distinctId = distinctId,
791791
properties = properties,
792792
userProperties = userProperties,
793793
userPropertiesSetOnce = userPropertiesSetOnce,
794-
groupProperties = groupProperties,
794+
groups = groups,
795795
)
796796
}
797797

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ public interface PostHogInterface {
2121
* @param properties the custom properties
2222
* @param userProperties the user properties, set as a "$set" property, Docs https://posthog.com/docs/product-analytics/user-properties
2323
* @param userPropertiesSetOnce the user properties to set only once, set as a "$set_once" property, Docs https://posthog.com/docs/product-analytics/user-properties
24-
* @param groupProperties the group properties, set as a "$groups" property, Docs https://posthog.com/docs/product-analytics/group-analytics
24+
* @param groups the groups, set as a "$groups" property, Docs https://posthog.com/docs/product-analytics/group-analytics
2525
*/
2626
public fun capture(
2727
event: String,
2828
distinctId: String? = null,
2929
properties: Map<String, Any>? = null,
3030
userProperties: Map<String, Any>? = null,
3131
userPropertiesSetOnce: Map<String, Any>? = null,
32-
groupProperties: Map<String, Any>? = null,
32+
groups: Map<String, String>? = null,
3333
)
3434

3535
/**

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ internal class PostHogApi(
9999
fun decide(
100100
distinctId: String,
101101
anonymousId: String?,
102-
groups: Map<String, Any>?,
102+
groups: Map<String, String>?,
103103
): PostHogDecideResponse? {
104104
val decideRequest = PostHogDecideRequest(config.apiKey, distinctId, anonymousId = anonymousId, groups)
105105

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ internal class PostHogDecideRequest(
77
apiKey: String,
88
distinctId: String,
99
anonymousId: String?,
10-
groups: Map<String, Any>?,
10+
groups: Map<String, String>?,
1111
// add person_properties, group_properties
1212
) : HashMap<String, Any>() {
1313
init {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ internal class PostHogFeatureFlags(
3131
fun loadFeatureFlags(
3232
distinctId: String,
3333
anonymousId: String?,
34-
groups: Map<String, Any>?,
34+
groups: Map<String, String>?,
3535
onFeatureFlags: PostHogOnFeatureFlags?,
3636
) {
3737
executor.executeSafely {

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

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ internal class PostHogTest {
338338
props,
339339
userProperties = userProps,
340340
userPropertiesSetOnce = userPropsOnce,
341-
groupProperties = groupProps,
341+
groups = groups,
342342
)
343343

344344
queueExecutor.shutdownAndAwaitTermination()
@@ -363,7 +363,7 @@ internal class PostHogTest {
363363
props,
364364
userProperties = userProps,
365365
userPropertiesSetOnce = userPropsOnce,
366-
groupProperties = groupProps,
366+
groups = groups,
367367
)
368368

369369
queueExecutor.awaitExecution()
@@ -376,7 +376,7 @@ internal class PostHogTest {
376376
props,
377377
userProperties = userProps,
378378
userPropertiesSetOnce = userPropsOnce,
379-
groupProperties = groupProps,
379+
groups = groups,
380380
)
381381

382382
queueExecutor.shutdownAndAwaitTermination()
@@ -399,7 +399,7 @@ internal class PostHogTest {
399399
props,
400400
userProperties = userProps,
401401
userPropertiesSetOnce = userPropsOnce,
402-
groupProperties = groupProps,
402+
groups = groups,
403403
)
404404

405405
queueExecutor.shutdownAndAwaitTermination()
@@ -421,7 +421,7 @@ internal class PostHogTest {
421421
assertEquals("value", theEvent.properties!!["prop"] as String)
422422
assertEquals(userProps, theEvent.properties!!["\$set"])
423423
assertEquals(userPropsOnce, theEvent.properties!!["\$set_once"])
424-
assertEquals(groupProps, theEvent.properties!!["\$groups"])
424+
assertEquals(groups, theEvent.properties!!["\$groups"])
425425

426426
sut.close()
427427
}
@@ -438,7 +438,7 @@ internal class PostHogTest {
438438
properties = props,
439439
userProperties = userProps,
440440
userPropertiesSetOnce = userPropsOnce,
441-
groupProperties = groupProps,
441+
groups = groups,
442442
)
443443

444444
queueExecutor.shutdownAndAwaitTermination()
@@ -570,7 +570,7 @@ internal class PostHogTest {
570570

571571
sut.group("theType", "theKey", groupProps)
572572

573-
sut.capture("test", groupProperties = mutableMapOf("theType3" to "theKey3"))
573+
sut.capture("test", groups = mutableMapOf("theType3" to "theKey3"))
574574

575575
queueExecutor.shutdownAndAwaitTermination()
576576

@@ -605,7 +605,7 @@ internal class PostHogTest {
605605
props,
606606
userProperties = userProps,
607607
userPropertiesSetOnce = userPropsOnce,
608-
groupProperties = groupProps,
608+
groups = groups,
609609
)
610610

611611
queueExecutor.shutdownAndAwaitTermination()
@@ -637,7 +637,7 @@ internal class PostHogTest {
637637
props,
638638
userProperties = userProps,
639639
userPropertiesSetOnce = userPropsOnce,
640-
groupProperties = groupProps,
640+
groups = groups,
641641
)
642642

643643
queueExecutor.shutdownAndAwaitTermination()
@@ -671,7 +671,7 @@ internal class PostHogTest {
671671
props,
672672
userProperties = userProps,
673673
userPropertiesSetOnce = userPropsOnce,
674-
groupProperties = groupProps,
674+
groups = groups,
675675
)
676676

677677
queueExecutor.shutdownAndAwaitTermination()
@@ -701,7 +701,7 @@ internal class PostHogTest {
701701
props,
702702
userProperties = userProps,
703703
userPropertiesSetOnce = userPropsOnce,
704-
groupProperties = groupProps,
704+
groups = groups,
705705
)
706706

707707
queueExecutor.shutdownAndAwaitTermination()
@@ -723,7 +723,7 @@ internal class PostHogTest {
723723
assertEquals("value", theEvent.properties!!["prop"] as String)
724724
assertEquals(userProps, theEvent.properties!!["\$set"])
725725
assertEquals(userPropsOnce, theEvent.properties!!["\$set_once"])
726-
assertEquals(groupProps, theEvent.properties!!["\$groups"])
726+
assertEquals(groups, theEvent.properties!!["\$groups"])
727727

728728
sut.close()
729729
}
@@ -743,7 +743,7 @@ internal class PostHogTest {
743743
props,
744744
userProperties = userProps,
745745
userPropertiesSetOnce = userPropsOnce,
746-
groupProperties = groupProps,
746+
groups = groups,
747747
)
748748

749749
queueExecutor.shutdownAndAwaitTermination()
@@ -765,7 +765,7 @@ internal class PostHogTest {
765765
properties = props,
766766
userProperties = userProps,
767767
userPropertiesSetOnce = userPropsOnce,
768-
groupProperties = groupProps,
768+
groups = groups,
769769
)
770770

771771
queueExecutor.shutdownAndAwaitTermination()
@@ -913,7 +913,7 @@ internal class PostHogTest {
913913
props,
914914
userProperties = userProps,
915915
userPropertiesSetOnce = userPropsOnce,
916-
groupProperties = groupProps,
916+
groups = groups,
917917
)
918918

919919
queueExecutor.shutdownAndAwaitTermination()
@@ -946,7 +946,7 @@ internal class PostHogTest {
946946
props,
947947
userProperties = userProps,
948948
userPropertiesSetOnce = userPropsOnce,
949-
groupProperties = groupProps,
949+
groups = groups,
950950
)
951951

952952
queueExecutor.awaitExecution()
@@ -968,7 +968,7 @@ internal class PostHogTest {
968968
props,
969969
userProperties = userProps,
970970
userPropertiesSetOnce = userPropsOnce,
971-
groupProperties = groupProps,
971+
groups = groups,
972972
)
973973

974974
queueExecutor.shutdownAndAwaitTermination()

posthog/src/test/java/com/posthog/Utils.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public val date: Date = ISO8601Utils.parse("2023-09-20T11:58:49.000Z", ParsePosi
4848
public const val EVENT: String = "event"
4949
public const val DISTINCT_ID: String = "distinctId"
5050
public const val ANON_ID: String = "anonId"
51-
public val groups: Map<String, Any> = mapOf("group1" to "theValue")
51+
public val groups: Map<String, String> = mapOf("group1" to "theValue")
5252
public val userProps: Map<String, Any> = mapOf("user1" to "theValue")
5353
public val userPropsOnce: Map<String, Any> = mapOf("logged" to true)
5454
public val groupProps: Map<String, Any> = mapOf("premium" to true)

0 commit comments

Comments
 (0)