This commit is contained in:
gdlbo
2024-03-25 16:36:55 +03:00
parent 43d859d240
commit 024a7bc356
3 changed files with 17 additions and 21 deletions
@@ -14,6 +14,7 @@ import com.vk.statistic.Statistic;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import ru.vtosters.hooks.other.Preferences;
import ru.vtosters.lite.music.Metrics;
import java.util.Locale;
@@ -313,39 +314,29 @@ public class VideoTracker {
bundle.putLong("ts", System.currentTimeMillis());
StatisticsBridge1.a().a(str, bundle);
if (Preferences.getBoolValue("sendVideoMetrics", true)) {
try {
sendMetrics(str);
} catch (JSONException e) {
throw new RuntimeException(e);
}
}
}
public void sendMetrics(String event) throws JSONException {
JSONArray arr = new JSONArray();
JSONObject jsonObject = new JSONObject();
jsonObject.put("e", event);
jsonObject.put("video_id", this.a.a + "_" + this.a.b);
jsonObject.put("position", this.f15642f);
jsonObject.put("ts", System.currentTimeMillis());
jsonObject.put("source", this.f15639c);
jsonObject.put("ref", this.f15639c);
jsonObject.put("event", "player_close");
jsonObject.put("stall_duration", "0");
jsonObject.put("bandwidth", "0");
jsonObject.put("stall_count", "0");
if (!TextUtils.isEmpty(this.a.l0)) {
jsonObject.put("track_code", this.a.l0);
}
if (!TextUtils.isEmpty(this.f15640d)) {
jsonObject.put("context", this.f15640d);
}
jsonObject.put("video_id", this.a.a + "_" + this.a.b);
jsonObject.put("position", "start");
jsonObject.put("position_sec", 0);
jsonObject.put("cur_quality", "auto");
arr.put(jsonObject);
Log.d("VideoTracker", event);
Log.d("VideoTracker", arr.toString());
Metrics.trackEvents(arr.toString());
@@ -178,7 +178,7 @@ public class MusicFragment extends TrackedMaterialPreferenceToolbarFragment {
getPreferenceScreen(),
"sendMusicMetrics",
"Отправлять статистику",
"Статистика прослушиваний необходима для работы рекомендаций и истории прослушивания музыки\n\nЕсли вас не интересуют рекомендации - смело отключайте данную функцию",
"Статистика прослушиваний необходима для работы рекомендаций и истории прослушивания музыки",
null,
true,
(preference, o) -> {
+5
View File
@@ -31,6 +31,11 @@
android:key="__dbg_disable_video_feed"
android:summary="@string/interfacevideorecsum"
android:title="@string/interfacevideorec"/>
<com.vtosters.lite.ui.MaterialSwitchPreference
android:defaultValue="true"
android:key="sendVideoMetrics"
android:summary="Статистика прослушиваний необходима для работы рекомендаций и истории видео"
android:title="Отправлять статистику"/>
<Preference
android:key="clearvideohistory"
android:summary="@string/clearvideohistory_summ"