Closed PattaFeuFeu closed 2 years ago
Hi @PattaFeuFeu ,
Thank you for report the issue here. I have tested the case and it seems like a backend service behavior. Our backend service transfer nested objects in user properties into flatened key. In the example user-property-foo.foo and user-property-foo.bar were two different user properties but user-property-foo was not a key of user properties here. The backend service may support nested object value in the future, but for now unset all keys in nested object seems to be the right way to unset the parent key.
The SDK allows us to set user properties with a map—via
JSONObject
—like so:This will result in the following user properties being set:
user-property-foo.foo
Value:bar
user-property-foo.bar
Value:baz
In essence, "sub"-properties are being set.
However, when unsetting user properties, no such function for handling
JSONObject
(and with it: Maps) exists.Identify().unset("user-property-foo")
does not unset the properties set using the aforementioned code.Available workaround: Unsetting each sub-property individually, like so:
Expected Behavior
A method to unset sub-properties should exist that allows unsetting properties set via
JSONObject
. And/or theunset
method ofIdentify
should be able to remove all sub-properties previously set viaJSONObject
.Current Behavior
When setting a user property with
JSONObject
payload, for example a map turned into aJSONObject
, sub-properties are set on Amplitude. Those cannot easily be unset via theunset
method ofIdentify
.Possible Solution
Option A: Add method that accepts multiple sub-properties to be removed
Option B: Change behaviour of
unset
to accept aJSONObject
(similar to A)Option C: Change behaviour of
unset
to, in the end, remove all sub-properties for a given property automatically.In the case of the example above: When unsetting
user-property-foo
,user-property-foo
as well asuser-property-foo.foo
anduser-property-foo.bar
would be unset.Steps to Reproduce
JSONObject
Environment