android: add a consistent deviceId for Amplitude from SharedPreferences
This commit is contained in:
parent
cef98f457f
commit
b1d1599a1c
|
@ -17,6 +17,8 @@
|
||||||
package org.jitsi.meet.sdk;
|
package org.jitsi.meet.sdk;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
|
@ -40,6 +42,8 @@ class AmplitudeModule
|
||||||
extends ReactContextBaseJavaModule {
|
extends ReactContextBaseJavaModule {
|
||||||
|
|
||||||
public static final String NAME = "Amplitude";
|
public static final String NAME = "Amplitude";
|
||||||
|
public static final String JITSI_PREFERENCES = "jitsi-preferences";
|
||||||
|
public static final String AMPLITUDE_DEVICE_ID_KEY = "amplitudeDeviceId";
|
||||||
|
|
||||||
public AmplitudeModule(ReactApplicationContext reactContext) {
|
public AmplitudeModule(ReactApplicationContext reactContext) {
|
||||||
super(reactContext);
|
super(reactContext);
|
||||||
|
@ -58,8 +62,8 @@ class AmplitudeModule
|
||||||
Amplitude.getInstance(instanceName).initialize(getCurrentActivity(), apiKey);
|
Amplitude.getInstance(instanceName).initialize(getCurrentActivity(), apiKey);
|
||||||
|
|
||||||
// Set the device ID to something consistent.
|
// Set the device ID to something consistent.
|
||||||
String android_id
|
SharedPreferences sharedPreferences = getReactApplicationContext().getSharedPreferences(JITSI_PREFERENCES, Context.MODE_PRIVATE);
|
||||||
= Settings.Secure.getString(getReactApplicationContext().getContentResolver(), Settings.Secure.ANDROID_ID);
|
String android_id = sharedPreferences.getString(AMPLITUDE_DEVICE_ID_KEY, "");
|
||||||
if (!TextUtils.isEmpty(android_id)) {
|
if (!TextUtils.isEmpty(android_id)) {
|
||||||
Amplitude.getInstance(instanceName).setDeviceId(android_id);
|
Amplitude.getInstance(instanceName).setDeviceId(android_id);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue