private int LogEvent(string eventType, IDictionary <string, object> eventProperties, long timestamp, AnalyticsEventOptions options) { if (timestamp <= 0) { timestamp = CurrentTimeMillis(); } Dictionary <string, object> dictionary = new Dictionary <string, object>(); dictionary.Add("user_id", userId); dictionary.Add("device_id", deviceId); dictionary.Add("event_type", eventType); dictionary.Add("session_id", ((options & AnalyticsEventOptions.MarkOutOfSession) == AnalyticsEventOptions.None) ? sessionId : (-1)); dictionary.Add("insert_id", Hash(userId + deviceId + eventType + sessionId + timestamp)); dictionary.Add("time", timestamp); dictionary.Add("event_properties", eventProperties); dictionary.Add("user_properties", userProperties); dictionary.Add("app_version", _buildVersionString); dictionary.Add("platform", deviceInfo.GetPlatform()); dictionary.Add("os_name", deviceInfo.GetOsName()); dictionary.Add("os_version", deviceInfo.GetOsVersion()); dictionary.Add("device_model", deviceInfo.GetModel()); dictionary.Add("device_name", deviceInfo.GetDeviceName()); dictionary.Add("language", deviceInfo.GetLanguage()); dictionary.Add("ip", "$remote"); settings.Save("lastEventTime", timestamp); string evt = Json.Encode(dictionary); int result = dbHelper.AddEvent(evt); if (dbHelper.GetEventCount() >= 1000) { dbHelper.RemoveEvents(dbHelper.GetNthEventId(20)); } if (dbHelper.GetEventCount() >= 30) { UpdateServer(); } else { UpdateServerDelayed(30000); } return(result); }
public void LogEvent(string eventType, IDictionary <string, object> eventProperties, AnalyticsEventOptions options) { CheckedLogEvent(eventType, eventProperties, CurrentTimeMillis(), options); }
private void CheckedLogEvent(string eventType, IDictionary <string, object> eventProperties, long timestamp, AnalyticsEventOptions options) { if (!string.IsNullOrEmpty(eventType)) { logQueue.QueueTask(delegate { LogEvent(eventType, eventProperties, timestamp, options); }); } }
public static void Send(string eventType, Dictionary <string, object> eventProperties, AnalyticsEventOptions options) { CheckInstance(); AmplitudeWrapper.Instance.LogEvent(eventType, eventProperties, options); }