public override SummaryData GetStackSummaryData(Stack stack) { if (!stack.SignatureInfo.ContainsKeyWithValue("Type", Event.KnownTypes.Session, Event.KnownTypes.SessionEnd, Event.KnownTypes.SessionHeartbeat)) return null; return new SummaryData { TemplateKey = "stack-session-summary", Data = new Dictionary<string, object>() }; }
public static Stack GenerateStack(bool generateId = false, string id = null, string organizationId = null, string projectId = null, string type = null, string title = null, DateTime? dateFixed = null, DateTime? utcFirstOccurrence = null, DateTime? utcLastOccurrence = null, int totalOccurrences = 0, bool isRegressed = false, bool isHidden = false, string signatureHash = null) { var stack = new Stack { Id = id.IsNullOrEmpty() ? generateId ? ObjectId.GenerateNewId().ToString() : null : id, OrganizationId = organizationId.IsNullOrEmpty() ? TestConstants.OrganizationId : organizationId, ProjectId = projectId.IsNullOrEmpty() ? TestConstants.ProjectIds.Random() : projectId, Title = title ?? RandomData.GetTitleWords(), Type = type ?? Stack.KnownTypes.Error, DateFixed = dateFixed, FirstOccurrence = utcFirstOccurrence ?? DateTime.MinValue, LastOccurrence = utcLastOccurrence ?? DateTime.MinValue, TotalOccurrences = totalOccurrences, IsRegressed = isRegressed, IsHidden = isHidden, SignatureHash = signatureHash ?? RandomData.GetAlphaNumericString(10, 10), SignatureInfo = new SettingsDictionary() }; for (int i = 0; i < RandomData.GetInt(0, 5); i++) { string tag = RandomData.GetWord(); while (stack.Tags.Contains(tag)) tag = RandomData.GetWord(); stack.Tags.Add(tag); } return stack; }
public override SummaryData GetStackSummaryData(Stack stack) { if (stack.SignatureInfo == null || !stack.SignatureInfo.ContainsKey("ExceptionType")) return null; dynamic data = new ExpandoObject(); data.Title = stack.Title; string value; if (stack.SignatureInfo.TryGetValue("ExceptionType", out value) && !String.IsNullOrEmpty(value)) { data.Type = value.Split(new[] { '.' }, StringSplitOptions.RemoveEmptyEntries).Last(); data.TypeFullName = value; } if (stack.SignatureInfo.TryGetValue("Method", out value) && !String.IsNullOrEmpty(value)) { string method = value.Split(new[] { '.' }, StringSplitOptions.RemoveEmptyEntries).Last(); int index = method.IndexOf('('); data.Method = index > 0 ? method.Substring(0, index) : method; data.MethodFullName = value; } if (stack.SignatureInfo.TryGetValue("Message", out value) && !String.IsNullOrEmpty(value)) data.Message = value; if (stack.SignatureInfo.TryGetValue("Path", out value) && !String.IsNullOrEmpty(value)) data.Path = value; return new SummaryData { TemplateKey = "stack-error-summary", Data = data }; }
public override SummaryData GetStackSummaryData(Stack stack) { if (stack.SignatureInfo == null || !stack.SignatureInfo.ContainsKey("ExceptionType")) return null; var data = new Dictionary<string, object> { { "Title", stack.Title } }; string value; if (stack.SignatureInfo.TryGetValue("ExceptionType", out value) && !String.IsNullOrEmpty(value)) { data.Add("Type", value.Split(new[] { '.' }, StringSplitOptions.RemoveEmptyEntries).Last()); data.Add("TypeFullName", value); } if (stack.SignatureInfo.TryGetValue("Method", out value) && !String.IsNullOrEmpty(value)) { string method = value.Split(new[] { '.' }, StringSplitOptions.RemoveEmptyEntries).Last(); int index = method.IndexOf('('); data.Add("Method", index > 0 ? method.Substring(0, index) : method); data.Add("MethodFullName", value); } if (stack.SignatureInfo.TryGetValue("Message", out value) && !String.IsNullOrEmpty(value)) data.Add("Message", value); if (stack.SignatureInfo.TryGetValue("Path", out value) && !String.IsNullOrEmpty(value)) data.Add("Path", value); return new SummaryData { TemplateKey = "stack-error-summary", Data = data }; }
public override SummaryData GetStackSummaryData(Stack stack) { if (!stack.SignatureInfo.ContainsKeyWithValue("Type", Event.KnownTypes.NotFound)) return null; return new SummaryData { TemplateKey = "stack-notfound-summary", Data = new Dictionary<string, object>() }; }
public SummaryData GetStackSummaryData(Stack stack) { var data = new Dictionary<string, object> { { "Type", stack.Type } }; string value; if (stack.SignatureInfo.TryGetValue("Source", out value)) data.Add("Source", value); return new SummaryData { TemplateKey = "stack-summary", Data = data }; }
public SummaryData GetStackSummaryData(Stack stack) { dynamic data = new ExpandoObject(); data.Type = stack.Type; string value; if (stack.SignatureInfo.TryGetValue("Source", out value)) { data.Source = value; } return new SummaryData { TemplateKey = "stack-summary", Data = data }; }
public WebHookDataContext(Version version, Stack stack, Organization organization = null, Project project = null, bool isNew = false, bool isRegression = false) { if (version == null) throw new ArgumentException("Version cannot be null.", "version"); if (stack == null) throw new ArgumentException("Stack cannot be null.", "stack"); Version = version; Organization = organization; Project = project; Stack = stack; IsNew = isNew; IsRegression = isRegression; }
public WebHookDataContext(Version version, PersistentEvent ev, Organization organization = null, Project project = null, Stack stack = null, bool isNew = false, bool isRegression = false) { if (version == null) throw new ArgumentException("Version cannot be null.", "version"); if (ev == null) throw new ArgumentException("Event cannot be null.", "ev"); Version = version; Organization = organization; Project = project; Stack = stack; Event = ev; IsNew = isNew; IsRegression = isRegression; }
public override SummaryData GetStackSummaryData(Stack stack) { if (stack.SignatureInfo == null || !stack.SignatureInfo.ContainsKey("StackTrace")) return null; var data = new Dictionary<string, object> { { "Title", stack.Title } }; string value; if (stack.SignatureInfo.TryGetValue("ExceptionType", out value)) { data.Add("Type", value.Split(new[] { '.' }, StringSplitOptions.RemoveEmptyEntries).Last()); data.Add("TypeFullName", value); } if (stack.SignatureInfo.TryGetValue("Path", out value)) data.Add("Path", value); return new SummaryData { TemplateKey = "stack-simple-summary", Data = data }; }
public override SummaryData GetStackSummaryData(Stack stack) { if (stack.SignatureInfo == null || !stack.SignatureInfo.ContainsKey("StackTrace")) return null; dynamic data = new ExpandoObject(); data.Title = stack.Title; string value; if (stack.SignatureInfo.TryGetValue("ExceptionType", out value)) { data.Type = value.Split(new[] { '.' }, StringSplitOptions.RemoveEmptyEntries).Last(); data.TypeFullName = value; } if (stack.SignatureInfo.TryGetValue("Path", out value)) data.Path = value; return new SummaryData { TemplateKey = "stack-simple-summary", Data = data }; }
public override SummaryData GetStackSummaryData(Stack stack) { if (!stack.SignatureInfo.ContainsKeyWithValue("Type", Event.KnownTypes.Log)) return null; return new SummaryData { TemplateKey = "stack-log-summary", Data = new Dictionary<string, object> { { "Title", stack.Title } } }; }
public override async Task ProcessBatchAsync(ICollection<EventContext> contexts) { var stacks = new Dictionary<string, Tuple<bool, Stack>>(); foreach (var ctx in contexts) { if (String.IsNullOrEmpty(ctx.Event.StackId)) { // only add default signature info if no other signature info has been added if (ctx.StackSignatureData.Count == 0) { ctx.StackSignatureData.AddItemIfNotEmpty("Type", ctx.Event.Type); ctx.StackSignatureData.AddItemIfNotEmpty("Source", ctx.Event.Source); } string signatureHash = ctx.StackSignatureData.Values.ToSHA1(); ctx.SignatureHash = signatureHash; Tuple<bool, Stack> value; if (stacks.TryGetValue(signatureHash, out value)) { ctx.Stack = value.Item2; } else { ctx.Stack = await _stackRepository.GetStackBySignatureHashAsync(ctx.Event.ProjectId, signatureHash).AnyContext(); if (ctx.Stack != null) stacks.Add(signatureHash, Tuple.Create(false, ctx.Stack)); } if (ctx.Stack == null) { _logger.Trace("Creating new event stack."); ctx.IsNew = true; string title = _formattingPluginManager.GetStackTitle(ctx.Event); var stack = new Stack { OrganizationId = ctx.Event.OrganizationId, ProjectId = ctx.Event.ProjectId, SignatureInfo = new SettingsDictionary(ctx.StackSignatureData), SignatureHash = signatureHash, Title = title?.Truncate(1000), Tags = ctx.Event.Tags ?? new TagSet(), Type = ctx.Event.Type, TotalOccurrences = 1, FirstOccurrence = ctx.Event.Date.UtcDateTime, LastOccurrence = ctx.Event.Date.UtcDateTime, IsHidden = ctx.Event.IsHidden }; ctx.Stack = stack; stacks.Add(signatureHash, Tuple.Create(true, ctx.Stack)); } } else { ctx.Stack = await _stackRepository.GetByIdAsync(ctx.Event.StackId, true).AnyContext(); if (ctx.Stack == null || ctx.Stack.ProjectId != ctx.Event.ProjectId) { ctx.SetError("Invalid StackId."); continue; } ctx.SignatureHash = ctx.Stack.SignatureHash; if (!stacks.ContainsKey(ctx.Stack.SignatureHash)) stacks.Add(ctx.Stack.SignatureHash, Tuple.Create(false, ctx.Stack)); else stacks[ctx.Stack.SignatureHash] = Tuple.Create(false, ctx.Stack); } if (!ctx.IsNew && ctx.Event.Tags != null && ctx.Event.Tags.Count > 0) { if (ctx.Stack.Tags == null) ctx.Stack.Tags = new TagSet(); List<string> newTags = ctx.Event.Tags.Where(t => !ctx.Stack.Tags.Contains(t)).ToList(); if (newTags.Count > 0) { ctx.Stack.Tags.AddRange(newTags); // make sure the stack gets saved if (!stacks.ContainsKey(ctx.Stack.SignatureHash)) stacks.Add(ctx.Stack.SignatureHash, Tuple.Create(true, ctx.Stack)); else stacks[ctx.Stack.SignatureHash] = Tuple.Create(true, stacks[ctx.Stack.SignatureHash].Item2); } } ctx.Event.IsFirstOccurrence = ctx.IsNew; // sync the fixed and hidden flags to the error occurrence ctx.Event.IsFixed = ctx.Stack.DateFixed.HasValue; ctx.Event.IsHidden = ctx.Stack.IsHidden; } var stacksToAdd = stacks.Where(kvp => kvp.Value.Item1 && String.IsNullOrEmpty(kvp.Value.Item2.Id)).Select(kvp => kvp.Value.Item2).ToList(); if (stacksToAdd.Count > 0) { await _stackRepository.AddAsync(stacksToAdd, true, sendNotification: stacksToAdd.Count == 1).AnyContext(); if (stacksToAdd.Count > 1) await _publisher.PublishAsync(new ExtendedEntityChanged { ChangeType = ChangeType.Added, Type = typeof(Stack).Name, OrganizationId = contexts.First().Organization.Id, ProjectId = contexts.First().Project.Id }).AnyContext(); } var stacksToSave = stacks.Where(kvp => kvp.Value.Item1 && !String.IsNullOrEmpty(kvp.Value.Item2.Id)).Select(kvp => kvp.Value.Item2).ToList(); if (stacksToSave.Count > 0) await _stackRepository.SaveAsync(stacksToSave, true, sendNotification: false).AnyContext(); // notification will get sent later in the update stats step // Set stack ids after they have been saved and created contexts.ForEach(ctx => { ctx.Event.StackId = ctx.Stack?.Id; }); }
public override SummaryData GetStackSummaryData(Stack stack) { if (!stack.SignatureInfo.ContainsKeyWithValue("Type", Event.KnownTypes.Session, Event.KnownTypes.SessionEnd)) return null; return new SummaryData { TemplateKey = "stack-session-summary", Data = new { Title = stack.Title } }; }
public override SummaryData GetStackSummaryData(Stack stack) { if (!stack.SignatureInfo.ContainsKeyWithValue("Type", Event.KnownTypes.Log)) return null; var data = new Dictionary<string, object>(); string source = stack.SignatureInfo?.GetString("Source"); if (!String.IsNullOrWhiteSpace(source) && String.Equals(source, stack.Title)) { var parts = source.Split(new[] { '.' }, StringSplitOptions.RemoveEmptyEntries); if (parts.Length > 1 && !String.Equals(source, parts.Last()) && parts.All(p => p.IsValidIdentifier())) { data.Add("Source", source); data.Add("SourceShortName", parts.Last()); } } return new SummaryData { TemplateKey = "stack-log-summary", Data = data }; }
public virtual SummaryData GetStackSummaryData(Stack stack) { return null; }