private IEnumerable <BreadcrumbViewModel> GetItemBreadcrumbs(int id, BreadcrumbType fromType, BreadcrumbType type) { var item = _productData.GetProductById(id); var crumbs = new List <BreadcrumbViewModel>(); if (fromType == BreadcrumbType.Section) { crumbs.Add(new BreadcrumbViewModel() { BreadCrumbType = fromType, Id = item.Section.Id.ToString(), Name = item.Section.Name }); } else { crumbs.Add(new BreadcrumbViewModel() { BreadCrumbType = fromType, Id = item.Brand.Id.ToString(), Name = item.Brand.Name }); } crumbs.Add(new BreadcrumbViewModel() { BreadCrumbType = type, Id = item.Id.ToString(), Name = item.Name }); return(crumbs); }
public static void Breadcrumb(string message, BreadcrumbType type, IDictionary <string, string>?metadata = null) { if (!_initialized) { return; } _client.Breadcrumbs.Leave(message, type, metadata); }
public Breadcrumb(string name, BreadcrumbType type, IDictionary <string, string> metadata) { if (name == null) { name = UndefinedName; } if (name.Length > MaximumNameLength) { name = name.Substring(0, MaximumNameLength); } this.AddToPayload("name", name); this.AddToPayload("timestamp", DateTime.UtcNow); this.AddToPayload("metaData", metadata); string breadcrumbType; switch (type) { case BreadcrumbType.Navigation: breadcrumbType = "navigation"; break; case BreadcrumbType.Request: breadcrumbType = "request"; break; case BreadcrumbType.Process: breadcrumbType = "process"; break; case BreadcrumbType.Log: breadcrumbType = "log"; break; case BreadcrumbType.User: breadcrumbType = "user"; break; case BreadcrumbType.State: breadcrumbType = "state"; break; case BreadcrumbType.Error: breadcrumbType = "error"; break; case BreadcrumbType.Manual: default: breadcrumbType = "manual"; break; } this.AddToPayload("type", breadcrumbType); }
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { Breadcrumb breadcrumb = null; // Load JArray from stream . For better or worse, probably a bit of the latter, // Newtonsoft.Json deserializes a persisted timestamp string as a JTokenType.Date . JArray a = JArray.Load(reader); if (IsBreadcrumbJson(a)) { // Extract values from "JArray a" . string timestamp = JsonUtils.JsonDateToGMTDateString(a[(int)BreadcrumbIndex.Timestamp]); BreadcrumbType breadcrumbType = (BreadcrumbType)(long)((JValue)(a[(int)BreadcrumbIndex.Type])).Value; Object data = null; // Launch = 0, // 0 - session launched ; -- // Text, // 1 - user breadcrumb ; {text:,level:} // Network, // 2 - network breadcrumb ; [verb,url,...,statusCode,errorCode] // Event, // 3 - app event ; {event:} // Reachability, // 4 - network change ; {change:,type:,oldType:,newType:} // View, // 5 - uiview change / load ; {event:,viewName:} // Error, // 6 - handled exception ; {name:,reason:} // Crash, // 7 - crash ; {name:,reason:} if (breadcrumbType == BreadcrumbType.Launch) { // SPEC: "[Session launched] is special in that it will only have a timestamp // and breadcrumb type field". } else { JToken dataToken = a[(int)BreadcrumbIndex.Data]; switch (breadcrumbType) { case BreadcrumbType.Network: data = dataToken.ToObject(typeof(Endpoint)); break; default: // TODO: This might be good enough, but should double check again later. data = dataToken.ToObject(typeof(Dictionary <string, Object>)); break; } } // Call Breadcrumb constructor. breadcrumb = new Breadcrumb( timestamp, breadcrumbType, data ); } return(breadcrumb); }
public async Task <IViewComponentResult> InvokeAsync(BreadcrumbType type, int id, BreadcrumbType fromType) { if (!Enum.IsDefined(typeof(BreadcrumbType), type)) { throw new InvalidEnumArgumentException(nameof(type), (int)type, typeof(BreadcrumbType)); } if (!Enum.IsDefined(typeof(BreadcrumbType), fromType)) { throw new InvalidEnumArgumentException(nameof(fromType), (int)fromType, typeof(BreadcrumbType)); } switch (type) { case BreadcrumbType.Section: var section = _productData.GetSectionById(id); return(View(new List <BreadcrumbViewModel>() { new BreadcrumbViewModel() { BreadCrumbType = type, Id = id.ToString(), Name = section.Name } })); case BreadcrumbType.Brand: var brand = _productData.GetBrandById(id); return(View(new List <BreadcrumbViewModel>() { new BreadcrumbViewModel() { BreadCrumbType = type, Id = id.ToString(), Name = brand.Name } })); case BreadcrumbType.Item: var crumbs = GetItemBreadcrumbs(id, fromType, type); return(View(crumbs)); case BreadcrumbType.None: default: return(View(new List <BreadcrumbViewModel>())); } }
private void AddBreadcrumb(BreadcrumbType breadcrumbType, Object data) { try { lock (this) { current_session.Add(new Breadcrumb(breadcrumbType, data)); if (current_session.Count > maxCount) { // Remove the oldest breadcrumb after the "session_start". // Only userBreadcrumbs will contain a "session_start". current_session.RemoveAt((this == userBreadcrumbs) ? 1 : 0); } saved = false; }; } catch (Exception ie) { Crittercism.LogInternalException(ie); // explicit nop } }
public Breadcrumb(string name, BreadcrumbType type) : this(name, type, null) { }
public static void LeaveBreadcrumb(string message, BreadcrumbType type, IDictionary <string, string> metadata) => InternalClient.Breadcrumbs.Leave(message, type, metadata);
public Breadcrumb(BreadcrumbType type, string path, Exception exception = null) { this.BreadcrumbType = type; this.Path = path; this.Exception = exception; }
internal Breadcrumb(string timestamp, BreadcrumbType breadcrumbType, Object data) { this.timestamp = timestamp; this.breadcrumbType = breadcrumbType; this.data = data; }
internal Breadcrumb(BreadcrumbType breadcrumbType, Object data) : this(TimeUtils.GMTDateString(DateTime.UtcNow), breadcrumbType, data) { }
/// <summary> /// Add a breadcrumb to the collection with the specified type and metadata /// </summary> /// <param name="message"></param> /// <param name="type"></param> /// <param name="metadata"></param> public void Leave(string message, BreadcrumbType type, IDictionary <string, string> metadata) { Leave(new Breadcrumb(message, type, metadata)); }
public Breadcrumb(string category, BreadcrumbType type) : this(category) { Type = type; }
public void Constructor_BreadcrumbsRecord_WithCategories(BreadcrumbType type) { var breadcrumbsRecord = new Breadcrumb("foo", type); Assert.That(breadcrumbsRecord.Type, Is.EqualTo(type)); }