|
| 1 | +namespace Sentry.Maui; |
| 2 | + |
| 3 | +/// <summary> |
| 4 | +/// Argument to the OnBreadcrumbCreateCallback |
| 5 | +/// </summary> |
| 6 | +public sealed class BreadcrumbEvent |
| 7 | +{ |
| 8 | + /// <summary> |
| 9 | + /// The sender of the event, usually the control that triggered it. |
| 10 | + /// </summary> |
| 11 | + public object? Sender { get; } |
| 12 | + |
| 13 | + /// <summary> |
| 14 | + /// The event name (e.g. "Tapped", "Swiped", etc.) |
| 15 | + /// </summary> |
| 16 | + public string EventName { get; } |
| 17 | + |
| 18 | + /// <summary> |
| 19 | + /// Any extra data to be included in the breadcrumb. This would typically be event specific information (for example |
| 20 | + /// it could include the X, Y coordinates of a tap event). |
| 21 | + /// </summary> |
| 22 | + public IEnumerable<KeyValuePair<string, string>> ExtraData { get; } |
| 23 | + |
| 24 | + /// <summary> |
| 25 | + /// Creates a new BreadcrumbEvent |
| 26 | + /// </summary> |
| 27 | + public BreadcrumbEvent(object? sender, string eventName) |
| 28 | + : this(sender, eventName, Array.Empty<KeyValuePair<string, string>>()) |
| 29 | + { |
| 30 | + } |
| 31 | + |
| 32 | + /// <summary> |
| 33 | + /// Creates a new BreadcrumbEvent |
| 34 | + /// </summary> |
| 35 | + public BreadcrumbEvent( |
| 36 | + object? sender, |
| 37 | + string eventName, |
| 38 | + params IEnumerable<KeyValuePair<string, string>> extraData) |
| 39 | + { |
| 40 | + Sender = sender; |
| 41 | + EventName = eventName; |
| 42 | + ExtraData = extraData; |
| 43 | + } |
| 44 | + |
| 45 | + /// <summary> |
| 46 | + /// Creates a new BreadcrumbEvent |
| 47 | + /// </summary> |
| 48 | + public BreadcrumbEvent( |
| 49 | + object? sender, |
| 50 | + string eventName, |
| 51 | + params IEnumerable<(string key, string value)> extraData) : this(sender, eventName, extraData.Select( |
| 52 | + e => new KeyValuePair<string, string>(e.key, e.value))) |
| 53 | + { |
| 54 | + } |
| 55 | + |
| 56 | + /// <summary> |
| 57 | + /// This constructor remains for backward compatibility. |
| 58 | + /// </summary> |
| 59 | + /// <param name="sender"></param> |
| 60 | + /// <param name="eventName"></param> |
| 61 | + /// <param name="extraData"></param> |
| 62 | + [Obsolete("Use one of the other simpler constructors instead.")] |
| 63 | + public BreadcrumbEvent( |
| 64 | + object? sender, |
| 65 | + string eventName, |
| 66 | + IEnumerable<(string Key, string Value)>[] extraData) : this(sender, eventName, extraData.SelectMany( |
| 67 | + x => x.Select(pair => new KeyValuePair<string, string>(pair.Key, pair.Value))) |
| 68 | + ) |
| 69 | + { |
| 70 | + } |
| 71 | +} |
0 commit comments