jiti-meet/react/features/analytics/handlers/amplitude/fixDeviceID.native.ts

24 lines
664 B
TypeScript
Raw Normal View History

import DefaultPreference from 'react-native-default-preference';
import DeviceInfo from 'react-native-device-info';
2020-01-30 16:57:41 +00:00
/**
* Custom logic for setting the correct device id.
*
* @param {AmplitudeClient} amplitude - The amplitude instance.
* @returns {void}
*/
2022-09-06 12:51:50 +00:00
export async function fixDeviceID(amplitude: any) {
await DefaultPreference.setName('jitsi-preferences');
const current = await DefaultPreference.get('amplitudeDeviceId');
if (current) {
amplitude.setDeviceId(current);
} else {
const uid = DeviceInfo.getUniqueId();
2020-01-30 16:57:41 +00:00
amplitude.setDeviceId(uid);
DefaultPreference.set('amplitudeDeviceId', uid);
}
2020-01-30 16:57:41 +00:00
}