/// <summary> /// Posts a RaygunMessage to the Raygun api endpoint. /// </summary> /// <param name="raygunMessage">The RaygunMessage to send. This needs its OccurredOn property /// set to a valid DateTime and as much of the Details property as is available.</param> public void Send(RaygunMessage raygunMessage) { if (ValidateApiKey()) { bool canSend = OnSendingMessage(raygunMessage); if (canSend) { string message = null; try { message = SimpleJson.SerializeObject(raygunMessage); } catch (Exception ex) { RaygunClient.Log(string.Format("Error serializing raygun message: {0}", ex.Message)); } if (message != null) { SendMessage(message); } } } }
private bool ValidateApiKey() { if (string.IsNullOrEmpty(_apiKey)) { RaygunClient.Log("ApiKey has not been provided, exception will not be logged"); return(false); } return(true); }
private void SendMessage(string message) { try { byte[] data = StringToAscii(message); Dictionary <string, string> headers = new Dictionary <string, string>(); headers["X-ApiKey"] = _apiKey; new WWW(new Uri("https://api.raygun.io/entries").AbsoluteUri, data, headers); } catch (Exception ex) { RaygunClient.Log(string.Format("Error Logging Exception to Raygun.io {0}", ex.Message)); } }
private void SendMessage(string message) { try { var request = UnityEngine.Networking.UnityWebRequest.Post("https://api.raygun.com/entries", message); var customUploadHandler = new UnityEngine.Networking.UploadHandlerRaw(System.Text.Encoding.UTF8.GetBytes(message)); customUploadHandler.contentType = "application/json"; request.uploadHandler = customUploadHandler; request.SetRequestHeader("X-ApiKey", _apiKey); request.SendWebRequest(); } catch (Exception ex) { RaygunClient.Log(string.Format("Error Logging Exception to Raygun {0}", ex.Message)); } }