From 129551887a11eaa18d8bc2c7ffdc5f85a74a6deb Mon Sep 17 00:00:00 2001
From: Manoel Aranda Neto <marandaneto@gmail.com>
Date: Mon, 3 Jun 2024 17:49:29 +0200
Subject: [PATCH 1/5] fix: rename groupProperties to groups for capture methods

---
 CHANGELOG.md                                       |  1 +
 .../test/java/com/posthog/android/PostHogFake.kt   |  2 +-
 posthog/src/main/java/com/posthog/PostHog.kt       | 14 +++++++-------
 .../src/main/java/com/posthog/PostHogInterface.kt  |  4 ++--
 .../main/java/com/posthog/internal/PostHogApi.kt   |  2 +-
 .../com/posthog/internal/PostHogDecideRequest.kt   |  2 +-
 .../com/posthog/internal/PostHogFeatureFlags.kt    |  2 +-
 posthog/src/test/java/com/posthog/Utils.kt         |  2 +-
 8 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index ac47c886..f47fc6c5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,7 @@
 ## Next
 
 - chore: change host to new address ([#137](https://github.com/PostHog/posthog-android/pull/137))
+- fix: rename groupProperties to groups for capture methods ([#137](https://github.com/PostHog/posthog-android/pull/137))
 
 ## 3.3.0 - 2024-05-24
 
diff --git a/posthog-android/src/test/java/com/posthog/android/PostHogFake.kt b/posthog-android/src/test/java/com/posthog/android/PostHogFake.kt
index d3ce847e..d5c466c9 100644
--- a/posthog-android/src/test/java/com/posthog/android/PostHogFake.kt
+++ b/posthog-android/src/test/java/com/posthog/android/PostHogFake.kt
@@ -22,7 +22,7 @@ public class PostHogFake : PostHogInterface {
         properties: Map<String, Any>?,
         userProperties: Map<String, Any>?,
         userPropertiesSetOnce: Map<String, Any>?,
-        groupProperties: Map<String, Any>?,
+        groups: Map<String, String>?,
     ) {
         this.event = event
         this.properties = properties
diff --git a/posthog/src/main/java/com/posthog/PostHog.kt b/posthog/src/main/java/com/posthog/PostHog.kt
index b201a69a..783f4abc 100644
--- a/posthog/src/main/java/com/posthog/PostHog.kt
+++ b/posthog/src/main/java/com/posthog/PostHog.kt
@@ -228,7 +228,7 @@ public class PostHog private constructor(
         properties: Map<String, Any>?,
         userProperties: Map<String, Any>?,
         userPropertiesSetOnce: Map<String, Any>?,
-        groupProperties: Map<String, Any>?,
+        groups: Map<String, String>?,
         appendSharedProps: Boolean = true,
         appendGroups: Boolean = true,
     ): Map<String, Any> {
@@ -294,7 +294,7 @@ public class PostHog private constructor(
 
         if (appendGroups) {
             // merge groups
-            mergeGroups(groupProperties)?.let {
+            mergeGroups(groups)?.let {
                 props["\$groups"] = it
             }
         }
@@ -334,7 +334,7 @@ public class PostHog private constructor(
         properties: Map<String, Any>?,
         userProperties: Map<String, Any>?,
         userPropertiesSetOnce: Map<String, Any>?,
-        groupProperties: Map<String, Any>?,
+        groups: Map<String, String>?,
     ) {
         try {
             if (!isEnabled()) {
@@ -368,7 +368,7 @@ public class PostHog private constructor(
                     properties = properties,
                     userProperties = userProperties,
                     userPropertiesSetOnce = userPropertiesSetOnce,
-                    groupProperties = groupProperties,
+                    groups = groups,
                     // only append shared props if not a snapshot event
                     appendSharedProps = !snapshotEvent,
                     // only append groups if not a group identify event
@@ -561,7 +561,7 @@ public class PostHog private constructor(
 
     private fun loadFeatureFlagsRequest(onFeatureFlags: PostHogOnFeatureFlags?) {
         @Suppress("UNCHECKED_CAST")
-        val groups = getPreferences().getValue(GROUPS) as? Map<String, Any>
+        val groups = getPreferences().getValue(GROUPS) as? Map<String, String>
 
         val distinctId = this.distinctId
         val anonymousId = this.anonymousId
@@ -783,7 +783,7 @@ public class PostHog private constructor(
             properties: Map<String, Any>?,
             userProperties: Map<String, Any>?,
             userPropertiesSetOnce: Map<String, Any>?,
-            groupProperties: Map<String, Any>?,
+            groups: Map<String, String>?,
         ) {
             shared.capture(
                 event,
@@ -791,7 +791,7 @@ public class PostHog private constructor(
                 properties = properties,
                 userProperties = userProperties,
                 userPropertiesSetOnce = userPropertiesSetOnce,
-                groupProperties = groupProperties,
+                groups = groups,
             )
         }
 
diff --git a/posthog/src/main/java/com/posthog/PostHogInterface.kt b/posthog/src/main/java/com/posthog/PostHogInterface.kt
index a6699734..be526d82 100644
--- a/posthog/src/main/java/com/posthog/PostHogInterface.kt
+++ b/posthog/src/main/java/com/posthog/PostHogInterface.kt
@@ -21,7 +21,7 @@ public interface PostHogInterface {
      * @param properties the custom properties
      * @param userProperties the user properties, set as a "$set" property, Docs https://posthog.com/docs/product-analytics/user-properties
      * @param userPropertiesSetOnce the user properties to set only once, set as a "$set_once" property, Docs https://posthog.com/docs/product-analytics/user-properties
-     * @param groupProperties the group properties, set as a "$groups" property, Docs https://posthog.com/docs/product-analytics/group-analytics
+     * @param groups the group properties, set as a "$groups" property, Docs https://posthog.com/docs/product-analytics/group-analytics
      */
     public fun capture(
         event: String,
@@ -29,7 +29,7 @@ public interface PostHogInterface {
         properties: Map<String, Any>? = null,
         userProperties: Map<String, Any>? = null,
         userPropertiesSetOnce: Map<String, Any>? = null,
-        groupProperties: Map<String, Any>? = null,
+        groups: Map<String, String>? = null,
     )
 
     /**
diff --git a/posthog/src/main/java/com/posthog/internal/PostHogApi.kt b/posthog/src/main/java/com/posthog/internal/PostHogApi.kt
index 0e3e8eca..075b2532 100644
--- a/posthog/src/main/java/com/posthog/internal/PostHogApi.kt
+++ b/posthog/src/main/java/com/posthog/internal/PostHogApi.kt
@@ -99,7 +99,7 @@ internal class PostHogApi(
     fun decide(
         distinctId: String,
         anonymousId: String?,
-        groups: Map<String, Any>?,
+        groups: Map<String, String>?,
     ): PostHogDecideResponse? {
         val decideRequest = PostHogDecideRequest(config.apiKey, distinctId, anonymousId = anonymousId, groups)
 
diff --git a/posthog/src/main/java/com/posthog/internal/PostHogDecideRequest.kt b/posthog/src/main/java/com/posthog/internal/PostHogDecideRequest.kt
index 4a672c5e..b18733bb 100644
--- a/posthog/src/main/java/com/posthog/internal/PostHogDecideRequest.kt
+++ b/posthog/src/main/java/com/posthog/internal/PostHogDecideRequest.kt
@@ -7,7 +7,7 @@ internal class PostHogDecideRequest(
     apiKey: String,
     distinctId: String,
     anonymousId: String?,
-    groups: Map<String, Any>?,
+    groups: Map<String, String>?,
     // add person_properties, group_properties
 ) : HashMap<String, Any>() {
     init {
diff --git a/posthog/src/main/java/com/posthog/internal/PostHogFeatureFlags.kt b/posthog/src/main/java/com/posthog/internal/PostHogFeatureFlags.kt
index 13897e4a..0691cdab 100644
--- a/posthog/src/main/java/com/posthog/internal/PostHogFeatureFlags.kt
+++ b/posthog/src/main/java/com/posthog/internal/PostHogFeatureFlags.kt
@@ -31,7 +31,7 @@ internal class PostHogFeatureFlags(
     fun loadFeatureFlags(
         distinctId: String,
         anonymousId: String?,
-        groups: Map<String, Any>?,
+        groups: Map<String, String>?,
         onFeatureFlags: PostHogOnFeatureFlags?,
     ) {
         executor.executeSafely {
diff --git a/posthog/src/test/java/com/posthog/Utils.kt b/posthog/src/test/java/com/posthog/Utils.kt
index 658b6bf2..eb0b9092 100644
--- a/posthog/src/test/java/com/posthog/Utils.kt
+++ b/posthog/src/test/java/com/posthog/Utils.kt
@@ -48,7 +48,7 @@ public val date: Date = ISO8601Utils.parse("2023-09-20T11:58:49.000Z", ParsePosi
 public const val EVENT: String = "event"
 public const val DISTINCT_ID: String = "distinctId"
 public const val ANON_ID: String = "anonId"
-public val groups: Map<String, Any> = mapOf("group1" to "theValue")
+public val groups: Map<String, String> = mapOf("group1" to "theValue")
 public val userProps: Map<String, Any> = mapOf("user1" to "theValue")
 public val userPropsOnce: Map<String, Any> = mapOf("logged" to true)
 public val groupProps: Map<String, Any> = mapOf("premium" to true)

From 1b6063a4e7c61606ed784a7afce8db0ee1611108 Mon Sep 17 00:00:00 2001
From: Manoel Aranda Neto <marandaneto@gmail.com>
Date: Mon, 3 Jun 2024 17:50:06 +0200
Subject: [PATCH 2/5] fix

---
 CHANGELOG.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index f47fc6c5..cc03845e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,7 +1,7 @@
 ## Next
 
 - chore: change host to new address ([#137](https://github.com/PostHog/posthog-android/pull/137))
-- fix: rename groupProperties to groups for capture methods ([#137](https://github.com/PostHog/posthog-android/pull/137))
+- fix: rename groupProperties to groups for capture methods ([#139](https://github.com/PostHog/posthog-android/pull/139))
 
 ## 3.3.0 - 2024-05-24
 

From 9a574e0ad27f70e4b9ec0903004f2d6432efa84d Mon Sep 17 00:00:00 2001
From: Manoel Aranda Neto <marandaneto@gmail.com>
Date: Mon, 3 Jun 2024 17:58:51 +0200
Subject: [PATCH 3/5] fix tests

---
 .../src/test/java/com/posthog/PostHogTest.kt  | 34 +++++++++----------
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/posthog/src/test/java/com/posthog/PostHogTest.kt b/posthog/src/test/java/com/posthog/PostHogTest.kt
index 5099928b..361fdab9 100644
--- a/posthog/src/test/java/com/posthog/PostHogTest.kt
+++ b/posthog/src/test/java/com/posthog/PostHogTest.kt
@@ -338,7 +338,7 @@ internal class PostHogTest {
             props,
             userProperties = userProps,
             userPropertiesSetOnce = userPropsOnce,
-            groupProperties = groupProps,
+            groups = groups,
         )
 
         queueExecutor.shutdownAndAwaitTermination()
@@ -363,7 +363,7 @@ internal class PostHogTest {
             props,
             userProperties = userProps,
             userPropertiesSetOnce = userPropsOnce,
-            groupProperties = groupProps,
+            groups = groups,
         )
 
         queueExecutor.awaitExecution()
@@ -376,7 +376,7 @@ internal class PostHogTest {
             props,
             userProperties = userProps,
             userPropertiesSetOnce = userPropsOnce,
-            groupProperties = groupProps,
+            groups = groups,
         )
 
         queueExecutor.shutdownAndAwaitTermination()
@@ -399,7 +399,7 @@ internal class PostHogTest {
             props,
             userProperties = userProps,
             userPropertiesSetOnce = userPropsOnce,
-            groupProperties = groupProps,
+            groups = groups,
         )
 
         queueExecutor.shutdownAndAwaitTermination()
@@ -421,7 +421,7 @@ internal class PostHogTest {
         assertEquals("value", theEvent.properties!!["prop"] as String)
         assertEquals(userProps, theEvent.properties!!["\$set"])
         assertEquals(userPropsOnce, theEvent.properties!!["\$set_once"])
-        assertEquals(groupProps, theEvent.properties!!["\$groups"])
+        assertEquals(groups, theEvent.properties!!["\$groups"])
 
         sut.close()
     }
@@ -438,7 +438,7 @@ internal class PostHogTest {
             properties = props,
             userProperties = userProps,
             userPropertiesSetOnce = userPropsOnce,
-            groupProperties = groupProps,
+            groups = groups,
         )
 
         queueExecutor.shutdownAndAwaitTermination()
@@ -570,7 +570,7 @@ internal class PostHogTest {
 
         sut.group("theType", "theKey", groupProps)
 
-        sut.capture("test", groupProperties = mutableMapOf("theType3" to "theKey3"))
+        sut.capture("test", groups = mutableMapOf("theType3" to "theKey3"))
 
         queueExecutor.shutdownAndAwaitTermination()
 
@@ -605,7 +605,7 @@ internal class PostHogTest {
             props,
             userProperties = userProps,
             userPropertiesSetOnce = userPropsOnce,
-            groupProperties = groupProps,
+            groups = groups,
         )
 
         queueExecutor.shutdownAndAwaitTermination()
@@ -637,7 +637,7 @@ internal class PostHogTest {
             props,
             userProperties = userProps,
             userPropertiesSetOnce = userPropsOnce,
-            groupProperties = groupProps,
+            groups = groups,
         )
 
         queueExecutor.shutdownAndAwaitTermination()
@@ -671,7 +671,7 @@ internal class PostHogTest {
             props,
             userProperties = userProps,
             userPropertiesSetOnce = userPropsOnce,
-            groupProperties = groupProps,
+            groups = groups,
         )
 
         queueExecutor.shutdownAndAwaitTermination()
@@ -701,7 +701,7 @@ internal class PostHogTest {
             props,
             userProperties = userProps,
             userPropertiesSetOnce = userPropsOnce,
-            groupProperties = groupProps,
+            groups = groups,
         )
 
         queueExecutor.shutdownAndAwaitTermination()
@@ -723,7 +723,7 @@ internal class PostHogTest {
         assertEquals("value", theEvent.properties!!["prop"] as String)
         assertEquals(userProps, theEvent.properties!!["\$set"])
         assertEquals(userPropsOnce, theEvent.properties!!["\$set_once"])
-        assertEquals(groupProps, theEvent.properties!!["\$groups"])
+        assertEquals(groups, theEvent.properties!!["\$groups"])
 
         sut.close()
     }
@@ -743,7 +743,7 @@ internal class PostHogTest {
             props,
             userProperties = userProps,
             userPropertiesSetOnce = userPropsOnce,
-            groupProperties = groupProps,
+            groups = groups,
         )
 
         queueExecutor.shutdownAndAwaitTermination()
@@ -765,7 +765,7 @@ internal class PostHogTest {
             properties = props,
             userProperties = userProps,
             userPropertiesSetOnce = userPropsOnce,
-            groupProperties = groupProps,
+            groups = groups,
         )
 
         queueExecutor.shutdownAndAwaitTermination()
@@ -913,7 +913,7 @@ internal class PostHogTest {
             props,
             userProperties = userProps,
             userPropertiesSetOnce = userPropsOnce,
-            groupProperties = groupProps,
+            groups = groups,
         )
 
         queueExecutor.shutdownAndAwaitTermination()
@@ -946,7 +946,7 @@ internal class PostHogTest {
             props,
             userProperties = userProps,
             userPropertiesSetOnce = userPropsOnce,
-            groupProperties = groupProps,
+            groups = groups,
         )
 
         queueExecutor.awaitExecution()
@@ -968,7 +968,7 @@ internal class PostHogTest {
             props,
             userProperties = userProps,
             userPropertiesSetOnce = userPropsOnce,
-            groupProperties = groupProps,
+            groups = groups,
         )
 
         queueExecutor.shutdownAndAwaitTermination()

From e0575e755d3925a6ab02e5468ab6b9165f4f1e23 Mon Sep 17 00:00:00 2001
From: Manoel Aranda Neto <marandaneto@gmail.com>
Date: Mon, 3 Jun 2024 18:03:12 +0200
Subject: [PATCH 4/5] fixes

---
 posthog/src/main/java/com/posthog/PostHog.kt         | 12 ++++++------
 .../src/main/java/com/posthog/PostHogInterface.kt    |  2 +-
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/posthog/src/main/java/com/posthog/PostHog.kt b/posthog/src/main/java/com/posthog/PostHog.kt
index 783f4abc..ec5b1092 100644
--- a/posthog/src/main/java/com/posthog/PostHog.kt
+++ b/posthog/src/main/java/com/posthog/PostHog.kt
@@ -310,18 +310,18 @@ public class PostHog private constructor(
         return props
     }
 
-    private fun mergeGroups(groupProperties: Map<String, Any>?): Map<String, Any>? {
+    private fun mergeGroups(givenGroups: Map<String, String>?): Map<String, String>? {
         val preferences = getPreferences()
 
         @Suppress("UNCHECKED_CAST")
-        val groups = preferences.getValue(GROUPS) as? Map<String, Any>
-        val newGroups = mutableMapOf<String, Any>()
+        val groups = preferences.getValue(GROUPS) as? Map<String, String>
+        val newGroups = mutableMapOf<String, String>()
 
         groups?.let {
             newGroups.putAll(it)
         }
 
-        groupProperties?.let {
+        givenGroups?.let {
             newGroups.putAll(it)
         }
 
@@ -527,8 +527,8 @@ public class PostHog private constructor(
 
         synchronized(groupsLock) {
             @Suppress("UNCHECKED_CAST")
-            val groups = preferences.getValue(GROUPS) as? Map<String, Any>
-            val newGroups = mutableMapOf<String, Any>()
+            val groups = preferences.getValue(GROUPS) as? Map<String, String>
+            val newGroups = mutableMapOf<String, String>()
 
             groups?.let {
                 val currentKey = it[type]
diff --git a/posthog/src/main/java/com/posthog/PostHogInterface.kt b/posthog/src/main/java/com/posthog/PostHogInterface.kt
index be526d82..a6a49363 100644
--- a/posthog/src/main/java/com/posthog/PostHogInterface.kt
+++ b/posthog/src/main/java/com/posthog/PostHogInterface.kt
@@ -21,7 +21,7 @@ public interface PostHogInterface {
      * @param properties the custom properties
      * @param userProperties the user properties, set as a "$set" property, Docs https://posthog.com/docs/product-analytics/user-properties
      * @param userPropertiesSetOnce the user properties to set only once, set as a "$set_once" property, Docs https://posthog.com/docs/product-analytics/user-properties
-     * @param groups the group properties, set as a "$groups" property, Docs https://posthog.com/docs/product-analytics/group-analytics
+     * @param groups the groups, set as a "$groups" property, Docs https://posthog.com/docs/product-analytics/group-analytics
      */
     public fun capture(
         event: String,

From fdac761677e0d16b1a1a37e7441a71c6ceb97bfb Mon Sep 17 00:00:00 2001
From: Manoel Aranda Neto <marandaneto@gmail.com>
Date: Tue, 4 Jun 2024 08:47:17 +0200
Subject: [PATCH 5/5] lint

---
 posthog-android/lint-baseline.xml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/posthog-android/lint-baseline.xml b/posthog-android/lint-baseline.xml
index ae5728cb..19d12a0c 100644
--- a/posthog-android/lint-baseline.xml
+++ b/posthog-android/lint-baseline.xml
@@ -3,7 +3,7 @@
 
     <issue
         id="GradleDependency"
-        message="A newer version of androidx.lifecycle:lifecycle-process than 2.6.2 is available: 2.8.0"
+        message="A newer version of androidx.lifecycle:lifecycle-process than 2.6.2 is available: 2.8.1"
         errorLine1="    implementation(&quot;androidx.lifecycle:lifecycle-process:${PosthogBuildConfig.Dependencies.LIFECYCLE}&quot;)"
         errorLine2="                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
         <location
@@ -14,7 +14,7 @@
 
     <issue
         id="GradleDependency"
-        message="A newer version of androidx.lifecycle:lifecycle-common-java8 than 2.6.2 is available: 2.8.0"
+        message="A newer version of androidx.lifecycle:lifecycle-common-java8 than 2.6.2 is available: 2.8.1"
         errorLine1="    implementation(&quot;androidx.lifecycle:lifecycle-common-java8:${PosthogBuildConfig.Dependencies.LIFECYCLE}&quot;)"
         errorLine2="                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
         <location