public override SlackMessage GetSlackEventNotification(PersistentEvent ev, Project project, bool isCritical, bool isNew, bool isRegression) { if (!ShouldHandle(ev)) { return(null); } var attachment = new SlackMessage.SlackAttachment(ev) { Fields = new List <SlackMessage.SlackAttachmentFields> { new SlackMessage.SlackAttachmentFields { Title = "Source", Value = ev.Source.Truncate(60) } } }; AddDefaultSlackFields(ev, attachment.Fields, false); string subject = $"[{project.Name}] Feature: *{GetSlackEventUrl(ev.Id, ev.Source).Truncate(120)}*"; return(new SlackMessage(subject) { Attachments = new List <SlackMessage.SlackAttachment> { attachment } }); }
public override SlackMessage GetSlackEventNotification(PersistentEvent ev, Project project, bool isCritical, bool isNew, bool isRegression) { string messageOrSource = !String.IsNullOrEmpty(ev.Message) ? ev.Message : ev.Source; if (String.IsNullOrEmpty(messageOrSource)) { return(null); } string notificationType = "Occurrence event"; if (isNew) { notificationType = "New event"; } else if (isRegression) { notificationType = "Regression event"; } if (isCritical) { notificationType = String.Concat("Critical ", notificationType.ToLowerInvariant()); } var attachment = new SlackMessage.SlackAttachment(ev); if (!String.IsNullOrEmpty(ev.Message)) { attachment.Fields.Add(new SlackMessage.SlackAttachmentFields { Title = "Message", Value = ev.Message.Truncate(60) }); } if (!String.IsNullOrEmpty(ev.Source)) { attachment.Fields.Add(new SlackMessage.SlackAttachmentFields { Title = "Source", Value = ev.Source.Truncate(60) }); } AddDefaultSlackFields(ev, attachment.Fields); string subject = $"[{project.Name}] A {notificationType}: *{GetSlackEventUrl(ev.Id, messageOrSource.Truncate(120))}*"; return(new SlackMessage(subject) { Attachments = new List <SlackMessage.SlackAttachment> { attachment } }); }
public override SlackMessage GetSlackEventNotification(PersistentEvent ev, Project project, bool isCritical, bool isNew, bool isRegression) { if (!ShouldHandle(ev)) { return(null); } string notificationType = "occurrence 404"; if (isNew) { notificationType = "new 404"; } else if (isRegression) { notificationType = "regression 404"; } if (isCritical) { notificationType = String.Concat("critical ", notificationType); } var requestInfo = ev.GetRequestInfo(); var attachment = new SlackMessage.SlackAttachment(ev) { Color = "#BB423F", Fields = new List <SlackMessage.SlackAttachmentFields> { new SlackMessage.SlackAttachmentFields { Title = "Url", Value = requestInfo != null?requestInfo.GetFullPath(true, true, true) : ev.Source.Truncate(60) } } }; AddDefaultSlackFields(ev, attachment.Fields, false); string subject = $"[{project.Name}] A {notificationType}: *{GetSlackEventUrl(ev.Id, ev.Source.Truncate(120))}*"; return(new SlackMessage(subject) { Attachments = new List <SlackMessage.SlackAttachment> { attachment } }); }
public override SlackMessage GetSlackEventNotification(PersistentEvent ev, Project project, bool isCritical, bool isNew, bool isRegression) { if (!ShouldHandle(ev)) { return(null); } string notificationType = "log message"; if (isNew) { notificationType = "new log source"; } else if (isRegression) { notificationType = "log regression"; } if (isCritical) { notificationType = String.Concat("critical ", notificationType); } string source = !String.IsNullOrEmpty(ev.Source) ? ev.Source : "(Global)"; var attachment = new SlackMessage.SlackAttachment(ev) { Fields = new List <SlackMessage.SlackAttachmentFields> { new SlackMessage.SlackAttachmentFields { Title = "Source", Value = source.Truncate(60) } } }; if (!String.IsNullOrEmpty(ev.Message)) { attachment.Fields.Add(new SlackMessage.SlackAttachmentFields { Title = "Message", Value = ev.Message.Truncate(60) }); } string level = ev.GetLevel(); if (!String.IsNullOrEmpty(level)) { switch (level.ToLower()) { case "trace": case "debug": attachment.Color = "#5cb85c"; break; case "info": attachment.Color = "#5bc0de"; break; case "warn": attachment.Color = "#f0ad4e"; break; case "error": case "fatal": attachment.Color = "#d9534f"; break; } attachment.Fields.Add(new SlackMessage.SlackAttachmentFields { Title = "Level", Value = level.Truncate(60) }); } var requestInfo = ev.GetRequestInfo(); if (requestInfo != null) { attachment.Fields.Add(new SlackMessage.SlackAttachmentFields { Title = "Url", Value = requestInfo.GetFullPath(true, true, true) }); } AddDefaultSlackFields(ev, attachment.Fields); string subject = $"[{project.Name}] A {notificationType}: *{GetSlackEventUrl(ev.Id, source.Truncate(120))}*"; return(new SlackMessage(subject) { Attachments = new List <SlackMessage.SlackAttachment> { attachment } }); }
public override SlackMessage GetSlackEventNotification(PersistentEvent ev, Project project, bool isCritical, bool isNew, bool isRegression) { if (!ShouldHandle(ev)) { return(null); } var error = ev.GetError(); var stackingTarget = error?.GetStackingTarget(); if (stackingTarget?.Error == null) { return(null); } string errorTypeName = null; if (!String.IsNullOrEmpty(stackingTarget.Error.Type)) { errorTypeName = stackingTarget.Error.Type.TypeName().Truncate(60); } string errorType = !String.IsNullOrEmpty(errorTypeName) ? errorTypeName : "error"; string notificationType = String.Concat(errorType, " occurrence"); if (isNew) { notificationType = String.Concat("new ", errorType); } else if (isRegression) { notificationType = String.Concat(errorType, " regression"); } if (isCritical) { notificationType = String.Concat("critical ", notificationType); } var attachment = new SlackMessage.SlackAttachment(ev) { Color = "#BB423F", Fields = new List <SlackMessage.SlackAttachmentFields> { new SlackMessage.SlackAttachmentFields { Title = "Message", Value = stackingTarget.Error.Message.Truncate(60) } } }; if (!String.IsNullOrEmpty(errorTypeName)) { attachment.Fields.Add(new SlackMessage.SlackAttachmentFields { Title = "Type", Value = errorTypeName }); } if (stackingTarget.Method != null) { attachment.Fields.Add(new SlackMessage.SlackAttachmentFields { Title = "Method", Value = stackingTarget.Method.Name.Truncate(60) }); } AddDefaultSlackFields(ev, attachment.Fields); string subject = $"[{project.Name}] A {notificationType}: *{GetSlackEventUrl(ev.Id, stackingTarget.Error.Message.Truncate(120))}*"; return(new SlackMessage(subject) { Attachments = new List <SlackMessage.SlackAttachment> { attachment } }); }
public override SlackMessage GetSlackEventNotification(PersistentEvent ev, Project project, bool isCritical, bool isNew, bool isRegression) { if (!ShouldHandle(ev)) { return(null); } var error = ev.GetSimpleError(); if (error == null) { return(null); } string errorTypeName = null; if (!String.IsNullOrEmpty(error.Type)) { errorTypeName = error.Type.TypeName().Truncate(60); } string errorType = !String.IsNullOrEmpty(errorTypeName) ? errorTypeName : "error"; string notificationType = String.Concat(errorType, " occurrence"); if (isNew) { notificationType = String.Concat("new ", errorType); } else if (isRegression) { notificationType = String.Concat(errorType, " regression"); } if (isCritical) { notificationType = String.Concat("critical ", notificationType); } var attachment = new SlackMessage.SlackAttachment(ev) { Color = "#BB423F", Fields = new List <SlackMessage.SlackAttachmentFields> { new SlackMessage.SlackAttachmentFields { Title = "Message", Value = error.Message.Truncate(60) } } }; if (!String.IsNullOrEmpty(errorTypeName)) { attachment.Fields.Add(new SlackMessage.SlackAttachmentFields { Title = "Type", Value = errorTypeName }); } var lines = error.StackTrace.SplitLines().ToList(); if (lines.Count > 0) { var frames = lines.Take(3).ToList(); if (lines.Count > 3) { frames.Add("..."); } attachment.Fields.Add(new SlackMessage.SlackAttachmentFields { Title = "Stack Trace", Value = $"```{String.Join("\n", frames)}```" }); } AddDefaultSlackFields(ev, attachment.Fields); string subject = $"[{project.Name}] A {notificationType}: *{GetSlackEventUrl(ev.Id, error.Message.Truncate(120))}*"; return(new SlackMessage(subject) { Attachments = new List <SlackMessage.SlackAttachment> { attachment } }); }