amplitude / Amplitude-ReactNative

Official Amplitude React Native SDK
MIT License
82 stars 21 forks source link

How to set array of unique values? #137

Closed Deodes closed 2 years ago

Deodes commented 2 years ago

We have different platforms for our app and we want to provide user property across them. So we need an array of unique values, for this we're using:

const value = ... // value - 'a' | 'b' | 'c'
const identify = new Identify();
identify.append('Property', value); 

But when we check the analytics in Amplitude we see:

Property: ['a', 'a', 'c', 'b', 'a']

How we can set unique values to array in user property?

"@amplitude/react-native": "^2.5.0", "react-native": "0.68.1"

yuhao900914 commented 2 years ago

Hi @Deodes. You can use identify.postInsert instead. If there is any duplication, it will do no operation. Thanks.

Deodes commented 2 years ago

@yuhao900914 You sent the link to docs for browser, but we use legacy react-native SDK and there is no identify.postInsert method. We see it in new react-native SDK(Beta), but we afraid to use it because it's just Beta

yuhao900914 commented 2 years ago

Yea, currently react-native doesn't have that method. I will create a ticket and work on that soon. I will let you know after that has been done.

Deodes commented 2 years ago

@yuhao900914 Thank you very much, I really appreciate that you respond quickly and try to solve the problem as soon as possible!

yuhao900914 commented 2 years ago

Hi @Deodes, we just released the new version to add the preInsert and postInsert. @amplitude/react-native v2.14.0 Please have a try. Thanks.

Deodes commented 2 years ago

Hi @yuhao900914, thank you very much for such a quick solution, testing will begin soon!