public async Task StoreExceptionAsync(RavenPayload payload) { if (payload == null) return; try { StorageFolder folder = await GetRavenFolderAsync(); StorageFile file = await folder.CreateFileAsync(payload.EventID, CreationCollisionOption.ReplaceExisting); await FileIO.WriteTextAsync(file, JsonConvert.SerializeObject(payload)); } catch (FileNotFoundException) { } }
public override bool Equals(object obj) { RavenPayload payload = obj as RavenPayload; return(payload != null && payload.EventID == EventID); }
internal async Task StorePayloadAsync(RavenPayload payload) { await _storage.StoreExceptionAsync(payload); }
internal async Task<string> SendPayloadAsync(RavenPayload payload) { try { string jsonString = JsonConvert.SerializeObject(payload); StringContent content = new StringContent(jsonString, Encoding.UTF8, "application/json"); System.Diagnostics.Debug.WriteLine("[SENTRY] Sending exception to: " + Dsn.SentryUri); System.Diagnostics.Debug.WriteLine("[SENTRY] Payload: " + jsonString); var response = await _httpClient.PostAsync(Dsn.SentryUri, content); response.EnsureSuccessStatusCode(); // Extract the ID and delete the stored exception so it doesn't get sent again. // This will just return if no exception is stored with this ID. JObject responseJson = JObject.Parse(await response.Content.ReadAsStringAsync()); string resultId = (string)responseJson["id"]; await _storage.DeleteStoredExceptionAsync(resultId); return resultId; } catch (Exception ex) { HandleInternalException(ex); // Store this payload if there's an error sending the exception // e.g. server offline or client has no internet connection await StorePayloadAsync(payload); } return null; }
private async Task<RavenPayload> GetBasePayloadAsync(RavenLogLevel level, IDictionary<string, string> tags, IDictionary<string, object> extra) { RavenPayload payload = new RavenPayload() { EventID = Guid.NewGuid().ToString("n"), Project = Dsn.ProjectID, Level = level, Timestamp = DateTime.UtcNow, Platform = _platform.PlatformTag, Logger = String.IsNullOrEmpty(Logger) ? "root" : Logger, User = _user, Tags = await SetDefaultTagsAsync(tags), Extra = SetDefaultExtra(extra) }; return payload; }