@@ -3,8 +3,19 @@ namespace Sentry;
33/// <summary>
44/// Models members common between types that represent event-like data.
55/// </summary>
6- public interface IEventLike : IHasBreadcrumbs , IHasTags , IHasExtra
6+ public interface IEventLike : IHasTags , IHasExtra
77{
8+ /// <summary>
9+ /// A trail of events which happened prior to an issue.
10+ /// </summary>
11+ /// <seealso href="https://docs.sentry.io/platforms/dotnet/enriching-events/breadcrumbs/"/>
12+ IReadOnlyCollection < Breadcrumb > Breadcrumbs { get ; }
13+
14+ /// <summary>
15+ /// Adds a breadcrumb.
16+ /// </summary>
17+ void AddBreadcrumb ( Breadcrumb breadcrumb ) ;
18+
819 /// <summary>
920 /// The release distribution of the application.
1021 /// </summary>
@@ -96,6 +107,102 @@ public interface IEventLike : IHasBreadcrumbs, IHasTags, IHasExtra
96107[ EditorBrowsable ( EditorBrowsableState . Never ) ]
97108public static class EventLikeExtensions
98109{
110+ #if ! NETFRAMEWORK
111+ /// <summary>
112+ /// Adds a breadcrumb to the object.
113+ /// </summary>
114+ /// <param name="eventLike">The object.</param>
115+ /// <param name="message">The message.</param>
116+ /// <param name="category">The category.</param>
117+ /// <param name="type">The type.</param>
118+ /// <param name="dataPair">The data key-value pair.</param>
119+ /// <param name="level">The level.</param>
120+ public static void AddBreadcrumb (
121+ this IEventLike eventLike ,
122+ string message ,
123+ string ? category ,
124+ string ? type ,
125+ ( string , string ) ? dataPair = null ,
126+ BreadcrumbLevel level = default )
127+ {
128+ Dictionary < string , string > ? data = null ;
129+
130+ if ( dataPair != null )
131+ {
132+ data = new Dictionary < string , string >
133+ {
134+ { dataPair . Value . Item1 , dataPair . Value . Item2 }
135+ } ;
136+ }
137+
138+ eventLike . AddBreadcrumb (
139+ null ,
140+ message ,
141+ category ,
142+ type ,
143+ data ,
144+ level ) ;
145+ }
146+ #endif
147+
148+ /// <summary>
149+ /// Adds a breadcrumb to the object.
150+ /// </summary>
151+ /// <param name="eventLike">The object.</param>
152+ /// <param name="message">The message.</param>
153+ /// <param name="category">The category.</param>
154+ /// <param name="type">The type.</param>
155+ /// <param name="data">The data.</param>
156+ /// <param name="level">The level.</param>
157+ public static void AddBreadcrumb (
158+ this IEventLike eventLike ,
159+ string message ,
160+ string ? category = null ,
161+ string ? type = null ,
162+ IReadOnlyDictionary < string , string > ? data = null ,
163+ BreadcrumbLevel level = default )
164+ {
165+ eventLike . AddBreadcrumb (
166+ null ,
167+ message ,
168+ category ,
169+ type ,
170+ data ,
171+ level ) ;
172+ }
173+
174+ /// <summary>
175+ /// Adds a breadcrumb to the object.
176+ /// </summary>
177+ /// <remarks>
178+ /// This overload is used for testing.
179+ /// </remarks>
180+ /// <param name="eventLike">The object.</param>
181+ /// <param name="timestamp">The timestamp</param>
182+ /// <param name="message">The message.</param>
183+ /// <param name="category">The category.</param>
184+ /// <param name="type">The type.</param>
185+ /// <param name="data">The data</param>
186+ /// <param name="level">The level.</param>
187+ [ EditorBrowsable ( EditorBrowsableState . Never ) ]
188+ public static void AddBreadcrumb (
189+ this IEventLike eventLike ,
190+ DateTimeOffset ? timestamp ,
191+ string message ,
192+ string ? category = null ,
193+ string ? type = null ,
194+ IReadOnlyDictionary < string , string > ? data = null ,
195+ BreadcrumbLevel level = default )
196+ {
197+ eventLike . AddBreadcrumb ( new Breadcrumb (
198+ timestamp ,
199+ message ,
200+ type ,
201+ data ,
202+ category ,
203+ level ) ) ;
204+ }
205+
99206 /// <summary>
100207 /// Whether a <see cref="User"/> has been set to the object with any of its fields non null.
101208 /// </summary>
0 commit comments