/// <summary> /// Reports all recorded view events to the server /// </summary> /// <returns></returns> internal async Task <CountlyResponse> ReportAllRecordedViewEventsAsync(bool addToRequestQueue = true) { if (_viewEventRepo.Models.Count == 0) { return(new CountlyResponse { IsSuccess = false, ErrorMessage = "No events to send" }); } //Send all at once var requestParams = new Dictionary <string, object> { { "events", JsonConvert.SerializeObject(_viewEventRepo.Models, Formatting.Indented, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }) } }; //Even if res = false all events should be removed because responses are stored locally. _viewEventRepo.Clear(); var res = await _requestCountlyHelper.GetResponseAsync(requestParams, addToRequestQueue); return(res); }
/// <summary> /// Private method that sends crash details to the server. Set param "nonfatal" to true for Custom Logged errors /// </summary> /// <param name="message"></param> /// <param name="stackTrace"></param> /// <param name="type"></param> /// <param name="segments"></param> /// <param name="nonfatal"></param> /// <returns></returns> public async Task <CountlyResponse> SendCrashReportAsync(string message, string stackTrace, LogType type, IDictionary <string, object> segments = null, bool nonfatal = true) { //if (ConsentModel.CheckConsent(FeaturesEnum.Crashes.ToString())) //{ var model = CountlyExceptionDetailModel.ExceptionDetailModel; model.Error = stackTrace; model.Name = message; model.Nonfatal = nonfatal; model.Custom = segments as Dictionary <string, object>; model.Logs = string.Join("\n", _crashBreadcrumbs); #if UNITY_IOS model.Manufacture = UnityEngine.iOS.Device.generation.ToString(); #endif #if UNITY_ANDROID model.Manufacture = SystemInfo.deviceModel; #endif var requestParams = new Dictionary <string, object> { { "crash", JsonConvert.SerializeObject(model, Formatting.Indented, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }) } }; return(await _requestCountlyHelper.GetResponseAsync(requestParams)); //} }
/// <summary> /// Changes DeviceId. /// Continues with the current session. /// Merges data for old and new Device Id. /// </summary> /// <param name="deviceId"></param> public async Task <CountlyResponse> ChangeDeviceIdAndMergeSessionDataAsync(string deviceId) { //Ignore call if new and old device id are same if (DeviceId == deviceId) { return new CountlyResponse { IsSuccess = true } } ; //Keep old device id var oldDeviceId = DeviceId; //Update device id UpdateDeviceId(deviceId); //Merge user data for old and new device var requestParams = new Dictionary <string, object> { { "old_device_id", oldDeviceId } }; await _requestCountlyHelper.GetResponseAsync(requestParams); return(new CountlyResponse { IsSuccess = true }); }
/// <summary> /// Uploads all user details /// </summary> /// <returns></returns> public async Task <CountlyResponse> SetUserDetailsAsync(CountlyUserDetailsModel userDetailsModel) { if (!_countlyUtils.IsPictureValid(userDetailsModel.PictureUrl)) { throw new Exception("Accepted picture formats are .png, .gif and .jpeg"); } var requestParams = new Dictionary <string, object> { { "user_details", JsonConvert.SerializeObject(userDetailsModel, Formatting.Indented, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }) }, }; return(await _requestCountlyHelper.GetResponseAsync(requestParams)); }
public async Task <CountlyResponse> ExecuteBeginSessionAsync() { FirstLaunchAppHelper.Process(); _lastSessionRequestTime = DateTime.Now; //Session initiated IsSessionInitiated = true; _eventNumberInSameSessionHelper.RemoveAllEvents(); //if (ConsentModel.CheckConsent(FeaturesEnum.Sessions.ToString())) //{ var requestParams = new Dictionary <string, object> { { "begin_session", 1 }, { "ignore_cooldown", _configModel.IgnoreSessionCooldown } }; requestParams.Add("metrics", JsonConvert.SerializeObject(CountlyMetricModel.Metrics, Formatting.Indented, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore })); requestParams.Add("ip_address", _optionalParametersCountlyService.IPAddress); var response = await _requestCountlyHelper.GetResponseAsync(requestParams); //Extend session only after session has begun // if (response.IsSuccess) // { //Start session timer if (!_configModel.EnableManualSessionHandling) { InitSessionTimer(); _sessionTimer.Start(); } // } //} return(response); }