杏彩体育 v1.0.1版本的 MD5 值为:f363e7619122f7bd90c8b2a2d9a7cb53
以下内容为反编译后的 AnalyticsMessages.java 源代码,内容仅作参考
package com.mixpanel.android.mpmetrics;
import android.content.Context;
import android.os.Build;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Looper;
import android.os.Message;
import android.util.DisplayMetrics;
import com.alibaba.android.arouter.utils.Consts;
import com.bumptech.glide.load.Key;
import com.mixpanel.android.mpmetrics.MPDbAdapter;
import com.mixpanel.android.util.Base64Coder;
import com.mixpanel.android.util.HttpService;
import com.mixpanel.android.util.LegacyVersionUtils;
import com.mixpanel.android.util.MPLog;
import com.mixpanel.android.util.RemoteService;
import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.SocketTimeoutException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import org.json.JSONException;
import org.json.JSONObject;
public class AnalyticsMessages {
private static final int CLEAR_ANONYMOUS_UPDATES = 7;
private static final int EMPTY_QUEUES = 6;
private static final int ENQUEUE_EVENTS = 1;
private static final int ENQUEUE_GROUP = 3;
private static final int ENQUEUE_PEOPLE = 0;
private static final int FLUSH_QUEUE = 2;
private static final int KILL_WORKER = 5;
private static final String LOGTAG = "MixpanelAPI.Messages";
private static final int PUSH_ANONYMOUS_PEOPLE_RECORDS = 4;
private static final int REMOVE_RESIDUAL_IMAGE_FILES = 9;
private static final int REWRITE_EVENT_PROPERTIES = 8;
private static final Map<Context, AnalyticsMessages> sInstances = new HashMap();
protected final MPConfig mConfig;
protected final Context mContext;
private final Worker mWorker = createWorker();
AnalyticsMessages(Context context, MPConfig mPConfig) {
this.mContext = context;
this.mConfig = mPConfig;
getPoster().checkIsMixpanelBlocked();
}
protected Worker createWorker() {
return new Worker();
}
public static AnalyticsMessages getInstance(Context context, MPConfig mPConfig) {
AnalyticsMessages analyticsMessages;
Map<Context, AnalyticsMessages> map = sInstances;
synchronized (map) {
Context applicationContext = context.getApplicationContext();
if (!map.containsKey(applicationContext)) {
analyticsMessages = new AnalyticsMessages(applicationContext, mPConfig);
map.put(applicationContext, analyticsMessages);
} else {
analyticsMessages = map.get(applicationContext);
}
}
return analyticsMessages;
}
public void eventsMessage(EventDescription eventDescription) {
Message obtain = Message.obtain();
obtain.what = 1;
obtain.obj = eventDescription;
this.mWorker.runMessage(obtain);
}
public void peopleMessage(PeopleDescription peopleDescription) {
Message obtain = Message.obtain();
obtain.what = 0;
obtain.obj = peopleDescription;
this.mWorker.runMessage(obtain);
}
public void groupMessage(GroupDescription groupDescription) {
Message obtain = Message.obtain();
obtain.what = 3;
obtain.obj = groupDescription;
this.mWorker.runMessage(obtain);
}
public void pushAnonymousPeopleMessage(PushAnonymousPeopleDescription pushAnonymousPeopleDescription) {
Message obtain = Message.obtain();
obtain.what = 4;
obtain.obj = pushAnonymousPeopleDescription;
this.mWorker.runMessage(obtain);
}
public void clearAnonymousUpdatesMessage(MixpanelDescription mixpanelDescription) {
Message obtain = Message.obtain();
obtain.what = 7;
obtain.obj = mixpanelDescription;
this.mWorker.runMessage(obtain);
}
public void postToServer(MixpanelDescription mixpanelDescription) {
Message obtain = Message.obtain();
obtain.what = 2;
obtain.obj = mixpanelDescription.getToken();
obtain.arg1 = 0;
this.mWorker.runMessage(obtain);
}
public void emptyTrackingQueues(MixpanelDescription mixpanelDescription) {
Message obtain = Message.obtain();
obtain.what = 6;
obtain.obj = mixpanelDescription;
this.mWorker.runMessage(obtain);
}
public void updateEventProperties(UpdateEventsPropertiesDescription updateEventsPropertiesDescription) {
Message obtain = Message.obtain();
obtain.what = 8;
obtain.obj = updateEventsPropertiesDescription;
this.mWorker.runMessage(obtain);
}
public void removeResidualImageFiles(File file) {
Message obtain = Message.obtain();
obtain.what = 9;
obtain.obj = file;
this.mWorker.runMessage(obtain);
}
public void hardKill() {
Message obtain = Message.obtain();
obtain.what = 5;
this.mWorker.runMessage(obtain);
}
boolean isDead() {
return this.mWorker.isDead();
}
protected MPDbAdapter makeDbAdapter(Context context) {
return MPDbAdapter.getInstance(context, this.mConfig);
}
protected RemoteService getPoster() {
return new HttpService();
}
public static class EventDescription extends MixpanelMessageDescription {
private final String mEventName;
private final boolean mIsAutomatic;
private final JSONObject mSessionMetadata;
public EventDescription(String str, JSONObject jSONObject, String str2) {
this(str, jSONObject, str2, false, new JSONObject());
}
public EventDescription(String str, JSONObject jSONObject, String str2, boolean z, JSONObject jSONObject2) {
super(str2, jSONObject);
this.mEventName = str;
this.mIsAutomatic = z;
this.mSessionMetadata = jSONObject2;
}
public String getEventName() {
return this.mEventName;
}
public JSONObject getProperties() {
return getMessage();
}
public JSONObject getSessionMetadata() {
return this.mSessionMetadata;
}
public boolean isAutomatic() {
return this.mIsAutomatic;
}
}
static class PeopleDescription extends MixpanelMessageDescription {
public PeopleDescription(JSONObject jSONObject, String str) {
super(str, jSONObject);
}
public String toString() {
return getMessage().toString();
}
public boolean isAnonymous() {
return !getMessage().has("$distinct_id");
}
}
static class GroupDescription extends MixpanelMessageDescription {
public GroupDescription(JSONObject jSONObject, String str) {
super(str, jSONObject);
}
public String toString() {
return getMessage().toString();
}
}
static class PushAnonymousPeopleDescription extends MixpanelDescription {
private final String mDistinctId;
public PushAnonymousPeopleDescription(String str, String str2) {
super(str2);
this.mDistinctId = str;
}
public String toString() {
return this.mDistinctId;
}
public String getDistinctId() {
return this.mDistinctId;
}
}
public static class MixpanelMessageDescription extends MixpanelDescription {
private final JSONObject mMessage;
public MixpanelMessageDescription(String str, JSONObject jSONObject) {
super(str);
if (jSONObject != null && jSONObject.length() > 0) {
Iterator<String> keys = jSONObject.keys();
while (keys.hasNext()) {
String next = keys.next();
try {
jSONObject.get(next).toString();
} catch (AssertionError e) {
jSONObject.remove(next);
MPLog.e(AnalyticsMessages.LOGTAG, "Removing people profile property from update (see https://github.com/mixpanel/mixpanel-android/issues/567)", e);
} catch (JSONException unused) {
}
}
}
this.mMessage = jSONObject;
}
public JSONObject getMessage() {
return this.mMessage;
}
}
static class UpdateEventsPropertiesDescription extends MixpanelDescription {
private final Map<String, String> mProps;
public UpdateEventsPropertiesDescription(String str, Map<String, String> map) {
super(str);
this.mProps = map;
}
public Map<String, String> getProperties() {
return this.mProps;
}
}
public static class MixpanelDescription {
private final String mToken;
public MixpanelDescription(String str) {
this.mToken = str;
}
public String getToken() {
return this.mToken;
}
}
public void logAboutMessageToMixpanel(String str) {
MPLog.v(LOGTAG, str + " (Thread " + Thread.currentThread().getId() + ")");
}
public void logAboutMessageToMixpanel(String str, Throwable th) {
MPLog.v(LOGTAG, str + " (Thread " + Thread.currentThread().getId() + ")", th);
}
public class Worker {
private SystemInformation mSystemInformation;
private final Object mHandlerLock = new Object();
private long mFlushCount = 0;
private long mAveFlushFrequency = 0;
private long mLastFlushTime = -1;
private Handler mHandler = restartWorkerThread();
public Worker() {
}
public boolean isDead() {
boolean z;
synchronized (this.mHandlerLock) {
z = this.mHandler == null;
}
return z;
}
public void runMessage(Message message) {
synchronized (this.mHandlerLock) {
Handler handler = this.mHandler;
if (handler == null) {
AnalyticsMessages analyticsMessages = AnalyticsMessages.this;
analyticsMessages.logAboutMessageToMixpanel("Dead mixpanel worker dropping a message: " + message.what);
} else {
handler.sendMessage(message);
}
}
}
protected Handler restartWorkerThread() {
HandlerThread handlerThread = new HandlerThread("com.mixpanel.android.AnalyticsWorker", 10);
handlerThread.start();
return new AnalyticsMessageHandler(handlerThread.getLooper());
}
public class AnalyticsMessageHandler extends Handler {
private MPDbAdapter mDbAdapter;
private int mFailedRetries;
private final long mFlushInterval;
private long mTrackEngageRetryAfter;
public AnalyticsMessageHandler(Looper looper) {
super(looper);
this.mDbAdapter = null;
Worker.this.mSystemInformation = SystemInformation.getInstance(AnalyticsMessages.this.mContext);
this.mFlushInterval = AnalyticsMessages.this.mConfig.getFlushInterval();
}
@Override
public void handleMessage(Message message) {
String token;
int pushAnonymousUpdatesToPeopleDb;
JSONObject prepareEventObject;
if (this.mDbAdapter == null) {
MPDbAdapter makeDbAdapter = AnalyticsMessages.this.makeDbAdapter(AnalyticsMessages.this.mContext);
this.mDbAdapter = makeDbAdapter;
makeDbAdapter.cleanupEvents(System.currentTimeMillis() - AnalyticsMessages.this.mConfig.getDataExpiration(), MPDbAdapter.Table.EVENTS);
this.mDbAdapter.cleanupEvents(System.currentTimeMillis() - AnalyticsMessages.this.mConfig.getDataExpiration(), MPDbAdapter.Table.PEOPLE);
}
try {
if (message.what == 0) {
PeopleDescription peopleDescription = (PeopleDescription) message.obj;
MPDbAdapter.Table table = peopleDescription.isAnonymous() ? MPDbAdapter.Table.ANONYMOUS_PEOPLE : MPDbAdapter.Table.PEOPLE;
AnalyticsMessages.this.logAboutMessageToMixpanel("Queuing people record for sending later");
AnalyticsMessages.this.logAboutMessageToMixpanel(" " + peopleDescription.toString());
token = peopleDescription.getToken();
pushAnonymousUpdatesToPeopleDb = this.mDbAdapter.addJSON(peopleDescription.getMessage(), token, table);
if (peopleDescription.isAnonymous()) {
pushAnonymousUpdatesToPeopleDb = 0;
}
} else if (message.what == 3) {
GroupDescription groupDescription = (GroupDescription) message.obj;
AnalyticsMessages.this.logAboutMessageToMixpanel("Queuing group record for sending later");
AnalyticsMessages.this.logAboutMessageToMixpanel(" " + groupDescription.toString());
token = groupDescription.getToken();
pushAnonymousUpdatesToPeopleDb = this.mDbAdapter.addJSON(groupDescription.getMessage(), token, MPDbAdapter.Table.GROUPS);
} else if (message.what == 1) {
EventDescription eventDescription = (EventDescription) message.obj;
try {
prepareEventObject = prepareEventObject(eventDescription);
AnalyticsMessages.this.logAboutMessageToMixpanel("Queuing event for sending later");
AnalyticsMessages.this.logAboutMessageToMixpanel(" " + prepareEventObject.toString());
token = eventDescription.getToken();
} catch (JSONException e) {
e = e;
token = null;
}
try {
pushAnonymousUpdatesToPeopleDb = this.mDbAdapter.addJSON(prepareEventObject, token, MPDbAdapter.Table.EVENTS);
} catch (JSONException e2) {
e = e2;
MPLog.e(AnalyticsMessages.LOGTAG, "Exception tracking event " + eventDescription.getEventName(), e);
pushAnonymousUpdatesToPeopleDb = -3;
if (pushAnonymousUpdatesToPeopleDb < AnalyticsMessages.this.mConfig.getBulkUploadLimit()) {
}
AnalyticsMessages.this.logAboutMessageToMixpanel("Flushing queue due to bulk upload limit (" + pushAnonymousUpdatesToPeopleDb + ") for project " + token);
Worker.this.updateFlushFrequency();
sendAllData(this.mDbAdapter, token);
}
} else if (message.what == 4) {
PushAnonymousPeopleDescription pushAnonymousPeopleDescription = (PushAnonymousPeopleDescription) message.obj;
String distinctId = pushAnonymousPeopleDescription.getDistinctId();
token = pushAnonymousPeopleDescription.getToken();
pushAnonymousUpdatesToPeopleDb = this.mDbAdapter.pushAnonymousUpdatesToPeopleDb(token, distinctId);
} else {
if (message.what == 7) {
token = ((MixpanelDescription) message.obj).getToken();
this.mDbAdapter.cleanupAllEvents(MPDbAdapter.Table.ANONYMOUS_PEOPLE, token);
} else {
if (message.what == 8) {
UpdateEventsPropertiesDescription updateEventsPropertiesDescription = (UpdateEventsPropertiesDescription) message.obj;
MPLog.d(AnalyticsMessages.LOGTAG, this.mDbAdapter.rewriteEventDataWithProperties(updateEventsPropertiesDescription.getProperties(), updateEventsPropertiesDescription.getToken()) + " stored events were updated with new properties.");
} else if (message.what == 2) {
AnalyticsMessages.this.logAboutMessageToMixpanel("Flushing queue due to scheduled or forced flush");
Worker.this.updateFlushFrequency();
token = (String) message.obj;
sendAllData(this.mDbAdapter, token);
} else if (message.what == 6) {
token = ((MixpanelDescription) message.obj).getToken();
this.mDbAdapter.cleanupAllEvents(MPDbAdapter.Table.EVENTS, token);
this.mDbAdapter.cleanupAllEvents(MPDbAdapter.Table.PEOPLE, token);
this.mDbAdapter.cleanupAllEvents(MPDbAdapter.Table.GROUPS, token);
this.mDbAdapter.cleanupAllEvents(MPDbAdapter.Table.ANONYMOUS_PEOPLE, token);
} else if (message.what == 5) {
MPLog.w(AnalyticsMessages.LOGTAG, "Worker received a hard kill. Dumping all events and force-killing. Thread id " + Thread.currentThread().getId());
synchronized (Worker.this.mHandlerLock) {
this.mDbAdapter.deleteDB();
Worker.this.mHandler = null;
Looper.myLooper().quit();
}
} else if (message.what == 9) {
LegacyVersionUtils.removeLegacyResidualImageFiles((File) message.obj);
} else {
MPLog.e(AnalyticsMessages.LOGTAG, "Unexpected message received by Mixpanel worker: " + message);
}
token = null;
}
pushAnonymousUpdatesToPeopleDb = -3;
}
if ((pushAnonymousUpdatesToPeopleDb < AnalyticsMessages.this.mConfig.getBulkUploadLimit() || pushAnonymousUpdatesToPeopleDb == -2) && this.mFailedRetries <= 0 && token != null) {
AnalyticsMessages.this.logAboutMessageToMixpanel("Flushing queue due to bulk upload limit (" + pushAnonymousUpdatesToPeopleDb + ") for project " + token);
Worker.this.updateFlushFrequency();
sendAllData(this.mDbAdapter, token);
} else if (pushAnonymousUpdatesToPeopleDb <= 0 || hasMessages(2, token)) {
} else {
AnalyticsMessages.this.logAboutMessageToMixpanel("Queue depth " + pushAnonymousUpdatesToPeopleDb + " - Adding flush in " + this.mFlushInterval);
if (this.mFlushInterval >= 0) {
Message obtain = Message.obtain();
obtain.what = 2;
obtain.obj = token;
obtain.arg1 = 1;
sendMessageDelayed(obtain, this.mFlushInterval);
}
}
} catch (RuntimeException e3) {
MPLog.e(AnalyticsMessages.LOGTAG, "Worker threw an unhandled exception", e3);
synchronized (Worker.this.mHandlerLock) {
Worker.this.mHandler = null;
try {
Looper.myLooper().quit();
MPLog.e(AnalyticsMessages.LOGTAG, "Mixpanel will not process any more analytics messages", e3);
} catch (Exception e4) {
MPLog.e(AnalyticsMessages.LOGTAG, "Could not halt looper", e4);
}
}
}
}
protected long getTrackEngageRetryAfter() {
return this.mTrackEngageRetryAfter;
}
private void sendAllData(MPDbAdapter mPDbAdapter, String str) {
if (!AnalyticsMessages.this.getPoster().isOnline(AnalyticsMessages.this.mContext, AnalyticsMessages.this.mConfig.getOfflineMode())) {
AnalyticsMessages.this.logAboutMessageToMixpanel("Not flushing data to Mixpanel because the device is not connected to the internet.");
return;
}
sendData(mPDbAdapter, str, MPDbAdapter.Table.EVENTS, AnalyticsMessages.this.mConfig.getEventsEndpoint());
sendData(mPDbAdapter, str, MPDbAdapter.Table.PEOPLE, AnalyticsMessages.this.mConfig.getPeopleEndpoint());
sendData(mPDbAdapter, str, MPDbAdapter.Table.GROUPS, AnalyticsMessages.this.mConfig.getGroupsEndpoint());
}
private void sendData(MPDbAdapter mPDbAdapter, String str, MPDbAdapter.Table table, String str2) {
RemoteService poster = AnalyticsMessages.this.getPoster();
String[] generateDataString = mPDbAdapter.generateDataString(table, str);
int i = 0;
Integer num = 0;
if (generateDataString != null) {
num = Integer.valueOf(generateDataString[2]);
}
while (generateDataString != null && num.intValue() > 0) {
String str3 = generateDataString[i];
String str4 = generateDataString[1];
String encodeString = Base64Coder.encodeString(str4);
HashMap hashMap = new HashMap();
hashMap.put(MPDbAdapter.KEY_DATA, encodeString);
if (MPConfig.DEBUG) {
hashMap.put("verbose", "1");
}
try {
try {
byte[] performRequest = poster.performRequest(str2, hashMap, AnalyticsMessages.this.mConfig.getSSLSocketFactory());
if (performRequest == null) {
try {
AnalyticsMessages.this.logAboutMessageToMixpanel("Response was null, unexpected failure posting to " + str2 + Consts.DOT);
} catch (OutOfMemoryError e) {
e = e;
MPLog.e(AnalyticsMessages.LOGTAG, "Out of memory when posting to " + str2 + Consts.DOT, e);
if (i == 0) {
}
} catch (MalformedURLException e2) {
e = e2;
MPLog.e(AnalyticsMessages.LOGTAG, "Cannot interpret " + str2 + " as a URL.", e);
if (i == 0) {
}
}
} else {
try {
String str5 = new String(performRequest, Key.STRING_CHARSET_NAME);
if (this.mFailedRetries > 0) {
this.mFailedRetries = i;
removeMessages(2, str);
}
AnalyticsMessages.this.logAboutMessageToMixpanel("Successfully posted to " + str2 + ": \n" + str4);
AnalyticsMessages analyticsMessages = AnalyticsMessages.this;
StringBuilder sb = new StringBuilder();
sb.append("Response was ");
sb.append(str5);
analyticsMessages.logAboutMessageToMixpanel(sb.toString());
i = 1;
} catch (UnsupportedEncodingException e3) {
throw new RuntimeException("UTF not supported on this platform?", e3);
break;
}
}
} catch (OutOfMemoryError e4) {
e = e4;
i = 1;
} catch (MalformedURLException e5) {
e = e5;
i = 1;
}
} catch (RemoteService.ServiceUnavailableException e6) {
AnalyticsMessages.this.logAboutMessageToMixpanel("Cannot post message to " + str2 + Consts.DOT, e6);
this.mTrackEngageRetryAfter = (long) (e6.getRetryAfter() * 1000);
i = 0;
if (i == 0) {
}
} catch (SocketTimeoutException e7) {
AnalyticsMessages.this.logAboutMessageToMixpanel("Cannot post message to " + str2 + Consts.DOT, e7);
i = 0;
if (i == 0) {
}
} catch (IOException e8) {
AnalyticsMessages.this.logAboutMessageToMixpanel("Cannot post message to " + str2 + Consts.DOT, e8);
i = 0;
if (i == 0) {
}
}
if (i == 0) {
AnalyticsMessages.this.logAboutMessageToMixpanel("Not retrying this batch of events, deleting them from DB.");
mPDbAdapter.cleanupEvents(str3, table, str);
generateDataString = mPDbAdapter.generateDataString(table, str);
if (generateDataString != null) {
num = Integer.valueOf(generateDataString[2]);
}
i = 0;
} else {
removeMessages(2, str);
long max = Math.max(((long) Math.pow(2.0d, this.mFailedRetries)) * 60000, this.mTrackEngageRetryAfter);
this.mTrackEngageRetryAfter = max;
this.mTrackEngageRetryAfter = Math.min(max, 600000L);
Message obtain = Message.obtain();
obtain.what = 2;
obtain.obj = str;
sendMessageDelayed(obtain, this.mTrackEngageRetryAfter);
this.mFailedRetries++;
AnalyticsMessages.this.logAboutMessageToMixpanel("Retrying this batch of events in " + this.mTrackEngageRetryAfter + " ms");
return;
}
}
}
private JSONObject getDefaultEventProperties() throws JSONException {
JSONObject jSONObject = new JSONObject();
jSONObject.put("mp_lib", "android");
jSONObject.put("$lib_version", "7.4.1");
jSONObject.put("$os", "Android");
jSONObject.put("$os_version", Build.VERSION.RELEASE == null ? "UNKNOWN" : Build.VERSION.RELEASE);
jSONObject.put("$manufacturer", Build.MANUFACTURER == null ? "UNKNOWN" : Build.MANUFACTURER);
jSONObject.put("$brand", Build.BRAND == null ? "UNKNOWN" : Build.BRAND);
jSONObject.put("$model", Build.MODEL != null ? Build.MODEL : "UNKNOWN");
DisplayMetrics displayMetrics = Worker.this.mSystemInformation.getDisplayMetrics();
jSONObject.put("$screen_dpi", displayMetrics.densityDpi);
jSONObject.put("$screen_height", displayMetrics.heightPixels);
jSONObject.put("$screen_width", displayMetrics.widthPixels);
String appVersionName = Worker.this.mSystemInformation.getAppVersionName();
if (appVersionName != null) {
jSONObject.put("$app_version", appVersionName);
jSONObject.put("$app_version_string", appVersionName);
}
Integer appVersionCode = Worker.this.mSystemInformation.getAppVersionCode();
if (appVersionCode != null) {
String valueOf = String.valueOf(appVersionCode);
jSONObject.put("$app_release", valueOf);
jSONObject.put("$app_build_number", valueOf);
}
Boolean valueOf2 = Boolean.valueOf(Worker.this.mSystemInformation.hasNFC());
if (valueOf2 != null) {
jSONObject.put("$has_nfc", valueOf2.booleanValue());
}
Boolean valueOf3 = Boolean.valueOf(Worker.this.mSystemInformation.hasTelephony());
if (valueOf3 != null) {
jSONObject.put("$has_telephone", valueOf3.booleanValue());
}
String currentNetworkOperator = Worker.this.mSystemInformation.getCurrentNetworkOperator();
if (currentNetworkOperator != null && !currentNetworkOperator.trim().isEmpty()) {
jSONObject.put("$carrier", currentNetworkOperator);
}
Boolean isWifiConnected = Worker.this.mSystemInformation.isWifiConnected();
if (isWifiConnected != null) {
jSONObject.put("$wifi", isWifiConnected.booleanValue());
}
Boolean isBluetoothEnabled = Worker.this.mSystemInformation.isBluetoothEnabled();
if (isBluetoothEnabled != null) {
jSONObject.put("$bluetooth_enabled", isBluetoothEnabled);
}
String bluetoothVersion = Worker.this.mSystemInformation.getBluetoothVersion();
if (bluetoothVersion != null) {
jSONObject.put("$bluetooth_version", bluetoothVersion);
}
return jSONObject;
}
private JSONObject prepareEventObject(EventDescription eventDescription) throws JSONException {
JSONObject jSONObject = new JSONObject();
JSONObject properties = eventDescription.getProperties();
JSONObject defaultEventProperties = getDefaultEventProperties();
defaultEventProperties.put(MPDbAdapter.KEY_TOKEN, eventDescription.getToken());
if (properties != null) {
Iterator<String> keys = properties.keys();
while (keys.hasNext()) {
String next = keys.next();
defaultEventProperties.put(next, properties.get(next));
}
}
jSONObject.put("event", eventDescription.getEventName());
jSONObject.put("properties", defaultEventProperties);
jSONObject.put("$mp_metadata", eventDescription.getSessionMetadata());
return jSONObject;
}
}
public void updateFlushFrequency() {
long currentTimeMillis = System.currentTimeMillis();
long j = this.mFlushCount;
long j2 = 1 + j;
long j3 = this.mLastFlushTime;
if (j3 > 0) {
long j4 = ((currentTimeMillis - j3) + (this.mAveFlushFrequency * j)) / j2;
this.mAveFlushFrequency = j4;
AnalyticsMessages analyticsMessages = AnalyticsMessages.this;
analyticsMessages.logAboutMessageToMixpanel("Average send frequency approximately " + (j4 / 1000) + " seconds.");
}
this.mLastFlushTime = currentTimeMillis;
this.mFlushCount = j2;
}
}
public long getTrackEngageRetryAfter() {
return ((Worker.AnalyticsMessageHandler) this.mWorker.mHandler).getTrackEngageRetryAfter();
}
}