예제 #1
0
        /// <summary>
        /// Send a report to Backtrace API
        /// </summary>
        /// <param name="report">Report to send</param>
        /// <param name="sendCallback">Send report callback</param>
        public void Send(BacktraceReport report, Action <BacktraceResult> sendCallback = null)
        {
            if (Enabled == false)
            {
                Debug.LogWarning("Please enable BacktraceClient first - Please validate Backtrace client initializaiton in Unity IDE.");
                return;
            }
            //check rate limiting
            bool limitHit = _reportLimitWatcher.WatchReport(report);

            if (!limitHit)
            {
                if (_onClientReportLimitReached != null)
                {
                    _onClientReportLimitReached.Invoke(report);
                }

                if (sendCallback != null)
                {
                    sendCallback.Invoke(BacktraceResult.OnLimitReached(report));
                }

                _reportLimitWatcher.DisplayReportLimitHitMessage();
                return;
            }
            SendReport(report, sendCallback);
        }
        /// <summary>
        /// Sending a diagnostic report data to server API.
        /// </summary>
        /// <param name="data">Diagnostic data</param>
        /// <returns>Server response</returns>
        public IEnumerator Send(BacktraceData data, Action <BacktraceResult> callback = null)
        {
            //check rate limiting
            bool watcherValidation = reportLimitWatcher.WatchReport(data.Report);

            if (!watcherValidation)
            {
                yield return(BacktraceResult.OnLimitReached(data.Report));
            }
            if (data == null)
            {
                yield return(new BacktraceResult()
                {
                    Status = Types.BacktraceResultStatus.LimitReached
                });
            }
            string json = data.ToJson();

            if (string.IsNullOrEmpty(json))
            {
                yield return(BacktraceResult.OnLimitReached(data.Report));
            }

            yield return(Send(json, data.Attachments, data.Report, callback));
        }
예제 #3
0
        public async Task <BacktraceResult> SendAsync(BacktraceData data)
        {
            //check rate limiting
            bool watcherValidation = reportLimitWatcher.WatchReport(data.Report);

            if (!watcherValidation)
            {
                return(BacktraceResult.OnLimitReached(data.Report));
            }
            // execute user custom request handler
            if (RequestHandler != null)
            {
                return(RequestHandler?.Invoke(_serverurl.ToString(), FormDataHelper.GetContentTypeWithBoundary(Guid.NewGuid()), data));
            }
            //get a json from diagnostic object
            var json = JsonConvert.SerializeObject(data, JsonSerializerSettings);

            return(await SendAsync(Guid.NewGuid(), json, data.Attachments, data.Report, data.Deduplication));
        }
예제 #4
0
        /// <summary>
        /// Sending a diagnostic report data to server API.
        /// </summary>
        /// <param name="data">Diagnostic data</param>
        /// <returns>Server response</returns>
        public BacktraceResult Send(BacktraceData data)
        {
#if !NET35
            return(Task.Run(() => SendAsync(data)).Result);
#else
            //check rate limiting
            bool watcherValidation = reportLimitWatcher.WatchReport(data.Report);
            if (!watcherValidation)
            {
                return(BacktraceResult.OnLimitReached(data.Report));
            }
            // execute user custom request handler
            if (RequestHandler != null)
            {
                return(RequestHandler?.Invoke(_serverurl.ToString(), FormDataHelper.GetContentTypeWithBoundary(Guid.NewGuid()), data));
            }
            //set submission data
            string json = JsonConvert.SerializeObject(data);
            return(Send(Guid.NewGuid(), json, data.Report?.AttachmentPaths ?? new List <string>(), data.Report, data.Deduplication));
        }