amplitude / Amplitude-Kotlin

Amplitude Kotlin SDK
MIT License
27 stars 10 forks source link

Using this SDK with Java – properties of multiple types? #102

Closed kennedyjosh closed 1 year ago

kennedyjosh commented 1 year ago

I have an event with two properties:

  1. result which is a boolean
  2. reason which is a String

In Kotlin, it seems you can have multiple key types in mutuableMap. However, my project is in Java, where you can't do such a thing (to my knowledge).

Is there a workaround to have both these properties associated with one event when using Java?

I've tried just passing result as a string, but the consequence of this is that "true" and "false" show up as different values from boolean True and False when looking at the data to create analyses. Additionally, since the result prop is supposed to be a Boolean, Amplitude flags the events as invalid when it receives the string version.

yuhao900914 commented 1 year ago

Hi @kennedyjosh, Based on my understanding, you are trying to track an event with event properties and each property has a different type. The type of event properties is hashMap. Please check the following example. Thanks.


        // track event with event properties
        amplitude.track("test event properties", new HashMap() {{
            put("reason", "test event property value");
            put("result", true);
        }});