public static bool isUniqueMessage(string message, Dictionary <string, object> thisData = null) { if (!filterMessages) { return(true); } var client = new RestClient("https://api.rollbar.com/api/1"); var request = new RestRequest("/items/", Method.GET); request.AddParameter("access_token", rollbarReadToken); var clientResponse = client.Execute <Dictionary <string, object> >(request); Dictionary <string, object> response = clientResponse.Data; object val; response.TryGetValue("err", out val); // Check for errors before we proceed if ((long)val == 0) { response.TryGetValue("result", out val); Dictionary <string, object> result = (Dictionary <string, object>)val; result.TryGetValue("items", out val); SimpleJson.JsonArray jsonArray = (SimpleJson.JsonArray)val; object[] items = jsonArray.ToArray(); foreach (object Item in items) { Dictionary <string, object> item = (Dictionary <string, object>)Item; string itemMessage = JsonParsing.getString(item, "title"); string itemStatus = JsonParsing.getString(item, "status"); string itemResolvedVersion = JsonParsing.getString(item, "resolved_in_version"); long itemId = JsonParsing.getLong(item, "id"); bool uniqueData = isUniqueData(itemId, thisData); if (itemMessage == message) { // Filter messages & data so that we send only reports which are unique if (itemStatus == "active" && !uniqueData) { return(false); // Note that if an item reoccurs after being marked as "resolved" it is automatically reactivated. } else if (itemResolvedVersion != null) { if (Versioning.Compare(itemResolvedVersion, Constants.EDDI_VERSION) > 0) { return(false); // This has been marked as resolved in a more current client version. } } } } } return(true); }
public static bool isUniqueData(long itemId, Dictionary <string, object> thisData = null) { if (thisData is null) { return(true); } var client = new RestClient("https://api.rollbar.com/api/1"); var request = new RestRequest("/item/" + itemId + "/instances/", Method.GET); request.AddParameter("access_token", rollbarReadToken); var clientResponse = client.Execute <Dictionary <string, object> >(request); Dictionary <string, object> response = clientResponse.Data; object val; response.TryGetValue("err", out val); // Check for errors before we proceed if ((long)val == 0) { response.TryGetValue("result", out val); Dictionary <string, object> result = (Dictionary <string, object>)val; result.TryGetValue("instances", out val); SimpleJson.JsonArray jsonArray = (SimpleJson.JsonArray)val; object[] instances = jsonArray.ToArray(); foreach (object Instance in instances) { Dictionary <string, object> instance = (Dictionary <string, object>)Instance; instance.TryGetValue("data", out val); Dictionary <string, object> instanceData = (Dictionary <string, object>)val; instanceData.TryGetValue("custom", out val); Dictionary <string, object> customData = (Dictionary <string, object>)val; if (customData != null) { if (customData.Keys.Count == thisData.Keys.Count && customData.Keys.All(k => thisData.ContainsKey(k) && Equals(thisData[k], customData[k]))) { return(false); } } } } return(true); }