Skip to content
This repository has been archived by the owner on Mar 23, 2021. It is now read-only.

Commit

Permalink
android: add a consistent device ID in Amplitude
Browse files Browse the repository at this point in the history
  • Loading branch information
saghul authored and erikrozendaal committed Mar 31, 2020
1 parent 8349858 commit 037e476
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions android/sdk/src/main/java/org/jitsi/meet/sdk/AmplitudeModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@

package org.jitsi.meet.sdk;

import android.annotation.SuppressLint;
import android.provider.Settings;
import android.text.TextUtils;

import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
Expand Down Expand Up @@ -49,8 +53,16 @@ public AmplitudeModule(ReactApplicationContext reactContext) {
* @param apiKey The API_KEY of the Amplitude project.
*/
@ReactMethod
@SuppressLint("HardwareIds")
public void init(String instanceName, String apiKey) {
Amplitude.getInstance(instanceName).initialize(getCurrentActivity(), apiKey);

// Set the device ID to something consistent.
String android_id
= Settings.Secure.getString(getReactApplicationContext().getContentResolver(), Settings.Secure.ANDROID_ID);
if (!TextUtils.isEmpty(android_id)) {
Amplitude.getInstance(instanceName).setDeviceId(android_id);
}
}

/**
Expand Down

0 comments on commit 037e476

Please sign in to comment.