private void LogReport(ErrorReport report, object exception)
        {
            string message;

            if (!string.IsNullOrEmpty(report.StackTrace))
            {
                message = report.StackTrace;
                AppCenterLog.Verbose(AppConstants.AppCenterLogTag, message);
            }
            else
            {
                AppCenterLog.Verbose(AppConstants.AppCenterLogTag, "No system exception was found");
            }

            if (report.AndroidDetails != null)
            {
                AppCenterLog.Verbose(AppConstants.AppCenterLogTag, report.AndroidDetails.ThreadName);
            }
            else if (report.iOSDetails != null)
            {
                AppCenterLog.Verbose(AppConstants.AppCenterLogTag, report.iOSDetails.ExceptionName);
            }

            if (exception != null)
            {
                AppCenterLog.Verbose(AppConstants.AppCenterLogTag, "There is an exception associated with the failure");
            }
        }
Exemple #2
0
        /// <exception cref="IngestionException"/>
        public async Task ExecuteCallAsync(IServiceCall call)
        {
            if (call.CancellationToken.IsCancellationRequested)
            {
                return;
            }
            var baseUrl = string.IsNullOrEmpty(_baseLogUrl) ? DefaultBaseUrl : _baseLogUrl;

            AppCenterLog.Verbose(AppCenterLog.LogTag, $"Calling {baseUrl + ApiVersion}...");

            // Create request headers.
            var requestHeaders = CreateHeaders(call.AppSecret, call.InstallId);

            AppCenterLog.Verbose(AppCenterLog.LogTag, "Headers: " +
                                 $"{AppSecret}={GetRedactedAppSecret(call.AppSecret)}, " +
                                 $"{InstallId}={call.InstallId}");

            // Create request content.
            var requestContent = CreateLogsContent(call.Logs);

            AppCenterLog.Verbose(AppCenterLog.LogTag, requestContent);

            // Send request.
            await _httpNetwork.SendAsync(baseUrl + ApiVersion, "POST", requestHeaders, requestContent, call.CancellationToken).ConfigureAwait(false);
        }
        /// <exception cref="IngestionException"/>
        public async Task <string> SendAsync(string uri, string method, IDictionary <string, string> headers, string jsonContent, CancellationToken cancellationToken)
        {
            using (var request = CreateRequest(uri, method, headers, jsonContent))
                using (var response = await SendRequestAsync(request, cancellationToken).ConfigureAwait(false))
                {
                    if (response == null)
                    {
                        throw new IngestionException("Null response received");
                    }
                    var    responseContent = "(null)";
                    string contentType     = null;
                    if (response.Content != null)
                    {
                        responseContent = await response.Content.ReadAsStringAsync().ConfigureAwait(false);

                        if (response.Content.Headers.TryGetValues("Content-Type", out var contentTypeHeaders))
                        {
                            contentType = contentTypeHeaders.FirstOrDefault();
                        }
                    }
                    string logPayload;
                    if (contentType == null || contentType.StartsWith("text/") || contentType.StartsWith("application/"))
                    {
                        logPayload = responseContent;
                    }
                    else
                    {
                        logPayload = "<binary>";
                    }
                    var logMessage = $"HTTP response status={(int)response.StatusCode} ({response.StatusCode}) payload={logPayload}";
                    AppCenterLog.Verbose(AppCenterLog.LogTag, logMessage);
                    if (response.StatusCode != HttpStatusCode.OK)
                    {
                        throw new HttpIngestionException(logMessage)
                              {
                                  Method          = request.Method.ToString(),
                                  RequestUri      = request.RequestUri,
                                  StatusCode      = (int)response.StatusCode,
                                  RequestContent  = jsonContent,
                                  ResponseContent = responseContent
                              };
                    }
                    return(responseContent);
                }
        }
        /// <exception cref="IngestionException"/>
        private async Task <string> CallAsync(string appSecret, Guid installId, IList <Log> logs, CancellationToken token)
        {
            token.ThrowIfCancellationRequested();
            var baseUrl = string.IsNullOrEmpty(_baseLogUrl) ? DefaultBaseUrl : _baseLogUrl;

            AppCenterLog.Verbose(AppCenterLog.LogTag, $"Calling {baseUrl + ApiVersion}...");

            // Create request headers.
            var requestHeaders = CreateHeaders(appSecret, installId);

            AppCenterLog.Verbose(AppCenterLog.LogTag, "Headers: " +
                                 $"{AppSecret}={GetRedactedAppSecret(appSecret)}, " +
                                 $"{InstallId}={installId}");

            // Create request content.
            var requestContent = CreateLogsContent(logs);

            AppCenterLog.Verbose(AppCenterLog.LogTag, requestContent);

            // Send request.
            return(await _httpNetwork.SendAsync(baseUrl + ApiVersion, "POST", requestHeaders, requestContent, token).ConfigureAwait(false));
        }
Exemple #5
0
        public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
        {
            // Override point for customization after application launch.
            // If not required for your application you can safely delete this method

            AppCenter.LogLevel = LogLevel.Verbose;
            AppCenter.SetLogUrl("https://in-integration.dev.avalanch.es");
            Distribute.SetInstallUrl("http://install.appcenter-int.trafficmanager.net");
            Distribute.SetApiUrl("https://appcenter-int.trafficmanager.net/api/v0.1");
            Distribute.DontCheckForUpdatesInDebug();
            AppCenter.Start("b889c4f2-9ac2-4e2e-ae16-dae54f2c5899", typeof(Analytics), typeof(Crashes), typeof(Distribute));
            try
            {
                ThrowAnException();
            }
            catch (Exception e)
            {
                AppCenterLog.Verbose("THETAG", "THEMESSAGE", e);
            }

            Analytics.SetEnabledAsync(true);
            System.Diagnostics.Debug.WriteLine("ANALYTICS: " + Analytics.IsEnabledAsync().Result);
            return(true);
        }
        public Task <string> SendAsync(string uri, string method, IDictionary <string, string> headers, string jsonContent,
                                       CancellationToken cancellationToken)
        {
            var tcs = new TaskCompletionSource <string>();

            UnityCoroutineHelper.StartCoroutine(() => SendAsync(uri, method, headers, jsonContent, request =>
            {
                if (cancellationToken.IsCancellationRequested)
                {
                    tcs.SetCanceled();
                    return;
                }
                if (request.isNetworkError)
                {
                    tcs.SetException(new NetworkIngestionException());
                }
                else if (request.isHttpError)
                {
                    tcs.SetException(new HttpIngestionException($"Operation returned an invalid status code '{request.responseCode}'")
                    {
                        Method          = request.method,
                        RequestUri      = new Uri(request.url),
                        StatusCode      = (int)request.responseCode,
                        RequestContent  = jsonContent,
                        ResponseContent = request.downloadHandler.text
                    });
                }
                else
                {
                    var responseContent = request.downloadHandler.text;
                    AppCenterLog.Verbose(AppCenterLog.LogTag, $"HTTP response status={(int)request.responseCode} payload={responseContent}");
                    tcs.SetResult(responseContent);
                }
            }));
            return(tcs.Task);
        }
Exemple #7
0
        public void Verbose(string tag, string message, Exception ex = null)
        {
            var collectedMessage = CollectExceptionDetails(message, ex);

            AppCenterLog.Verbose(tag, collectedMessage, ex);
        }