Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Second call Identify.set() with existing key has no effect #217

Open
kirkaDev opened this issue Aug 13, 2024 · 2 comments
Open

Second call Identify.set() with existing key has no effect #217

kirkaDev opened this issue Aug 13, 2024 · 2 comments
Labels
question Further information is requested

Comments

@kirkaDev
Copy link

Hello.

When I run

    val identify = Identify()
    identify.set("propertyName1", "str1")
    amplitude.identify(identify)
    amplitude.track("someEvent1", mapOf<String, Any?>...))

    identify.set("propertyName2", "str2")
    amplitude.identify(identify)
    amplitude.track("someEvent2", mapOf<String, Any?>...)

    identify.set("propertyName1", "str3")
    amplitude.identify(identify)
    amplitude.track("someEvent3", mapOf<String, Any?>...)

As result, I saw in user properties:
propertyName1: "str1" with someEvent1
propertyName2: "str2" with someEvent2
propertyName1: "str1" with someEvent3

I expected:
propertyName1: "str1" with someEvent1
propertyName2: "str2" with someEvent2
propertyName1: "str3" with someEvent3

because I used method set(), not setOnce().

After investigating the situation a bit, I saw that the internal map of the Identify object does not change if I send a new value ("str3") for the same key ("propertyName1"), if I send a new key it works as I expected.

For what created separate method setOnce() if the method set() works the same way?

If I use new object of Identify() for every changes it works as I expected.

Thank you for attention.

@kirkaDev kirkaDev added the question Further information is requested label Aug 13, 2024
@izaaz
Copy link
Collaborator

izaaz commented Aug 21, 2024

Thanks for raising this question @kirkaDev. Yes, looking at the code, the same object does not liking adding the same property twice. I believe the general expectation was that we recycle identify objects after they are used. It's going to be hard to change this behaviour since that would make it a breaking change and we'd have to increase the major version of the SDK. We'll keep this in mind for future releases.

@kirkaDev
Copy link
Author

Thank you for answer, @izaaz.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants