hash user ids for buffer events
This commit is contained in:
parent
3930b36b4a
commit
d9047b64e7
3 changed files with 19 additions and 4 deletions
|
@ -15,7 +15,7 @@ import okhttp3.Response;
|
|||
|
||||
public class BufferEventTask extends AsyncTask<Void, Void, Void> {
|
||||
private static final String TAG = "LbryBufferEvent";
|
||||
private static final String ENDPOINT = "https://api.lbry.tv/api/v1/metric/ui";
|
||||
private static final String ENDPOINT = "https://collector-service.lbry.tv/api/v1/events/video";
|
||||
|
||||
private String streamUrl;
|
||||
private String userIdHash;
|
||||
|
@ -40,7 +40,7 @@ public class BufferEventTask extends AsyncTask<Void, Void, Void> {
|
|||
data.put("stream_duration", streamDuration);
|
||||
data.put("duration", bufferDuration);
|
||||
|
||||
requestBody.put("device", "mobile");
|
||||
requestBody.put("device", "android");
|
||||
requestBody.put("type", "buffering");
|
||||
requestBody.put("client", userIdHash);
|
||||
requestBody.put("data", data);
|
||||
|
|
|
@ -298,9 +298,9 @@ public class FileViewFragment extends BaseFragment implements
|
|||
long duration = MainActivity.appPlayer.getDuration();
|
||||
long position = MainActivity.appPlayer.getCurrentPosition();
|
||||
// TODO: Determine a hash for the userId
|
||||
String userIdHash = Lbryio.currentUser != null ? String.valueOf(Lbryio.currentUser.getId()) : "0";
|
||||
String userIdHash = Helper.SHA256(Lbryio.currentUser != null ? String.valueOf(Lbryio.currentUser.getId()) : "0");
|
||||
if (mediaSourceUrl.startsWith(CDN_PREFIX)) {
|
||||
BufferEventTask bufferEvent = new BufferEventTask(claim.getPermanentUrl(), duration, position, userIdHash);
|
||||
BufferEventTask bufferEvent = new BufferEventTask(claim.getPermanentUrl(), duration, position, 1, userIdHash);
|
||||
bufferEvent.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
|
||||
} else {
|
||||
// sdk stream buffer events should be handled differently
|
||||
|
|
|
@ -30,6 +30,8 @@ import androidx.recyclerview.widget.GridLayoutManager;
|
|||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.google.android.gms.common.util.Hex;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
@ -37,6 +39,9 @@ import org.json.JSONObject;
|
|||
import java.io.Closeable;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
|
@ -766,4 +771,14 @@ public final class Helper {
|
|||
}
|
||||
return id.toString();
|
||||
}
|
||||
|
||||
public static String SHA256(String value) {
|
||||
try {
|
||||
MessageDigest digest = MessageDigest.getInstance("SHA-256");
|
||||
byte[] hash = digest.digest(value.getBytes("UTF-8"));
|
||||
return Hex.bytesToStringLowercase(hash);
|
||||
} catch (NoSuchAlgorithmException | UnsupportedEncodingException ex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue