HI @dimitri.fedorov ,
Thanks for writing in! How are you calling the setOnce function? Is it with the HTTP API? What endpoint URL are you using and is it the latest? Or are you using an SDK?
- Is it intended behaviour for
setOnce
? - No, it should work as once you set it, that is it. - If yes, is there any way to write a property for the user only once? - setOnce should do that but if you can answer the above, I will look into it for you!
Kind Regards,
Denis
How are you calling the setOnce function? Is it with the HTTP API? What endpoint URL are you using and is it the latest? Or are you using an SDK?
Hey Denis, thanks for writing back so soon!
I am using latest com.amplitude:android-sdk:2.37.0
, invocation code looks like this:
getClient().identify(new Identify()
.setOnce("startDate", DATE_FORMAT.format(now)));
Hi @dimitri.fedorov ,
I just tried the identify on the Android SDK but it seemed to set it just fine and I cannot change it. If you wish, I can copy and paste my MainActivity.java example for you in a PM? Maybe you can use it in a separate project and see if it works there so we can then see if it’s a coding or SDK issue. Would that be alright?
@Denis Holmes Sure, feel free to do so.
I am using Ampli generated code together with Android SDK calls, because Ampli does not have setOnce
. Maybe that is cause of the issue?
Anyway, would be happy to check your example.
Update after digging the issue with @Denis Holmes (many thanks!).
Somewhere in documentation (can’t find it right away) it is said property set with `setOnce` can be set to another value with any other method, i.e. with `set` or `unset`, etc. Only subsequent `setOnce` calls will be ignored.
In my case workflow was:
- Start anonymous session, no user ID set
- Set the property with `setOnce`
- Sign in user, set user ID
- Sessions and their properties are merged
Actual update of the property happens not by `setOnce`, but by merging sessions in the last step.
It may be not obvious at the first glance, but in my case Amplitude behaves exactly as designed.
Maybe this behaviour will be changed in the future, maybe it won’t be changed but specified more prominently in the docs But as for now, please be advised.
Thank you for the summary @dimitri.fedorov ! I massively appreciate it!
@Jeremie Gluckman May I ask for you to mark Dimitri’s most recent reply as the answer? I don’t seem to have the function for some reason.
Sure thing @Denis Holmes! Converted this thread to a question, enabling the ability to mark a best answer
Ahhh I see! I’m a wee bit sleepy this week Thanks Jeremie!
No worries @Denis Holmes. Here to help!
Update: this behaviour is explicitly mentioned in the documentation:
When users are merged, the user could "lose" user property values that were never meant to be changed (e.g. 'Start Version' or initial UTM parameters) because the new user property values will overwrite the original user property values.