Skip to content

Commit 8084c05

Browse files
Merged IHasBreadcrumbs into IEventLike (#2670)
1 parent 300f248 commit 8084c05

File tree

3 files changed

+109
-142
lines changed

3 files changed

+109
-142
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ without native/platform specific bindings and SDKs. See [this ticket for more de
1616

1717
API Changes:
1818

19+
- IHasBreadcrumbs was removed. Use IEventLike instead. ([#2670](https://github.com/getsentry/sentry-dotnet/pull/2670))
1920
- ISpanContext was removed. Use ITraceContext instead. ([#2668](https://github.com/getsentry/sentry-dotnet/pull/2668))
2021
- Removed IHasTransactionNameSource. Use ITransactionContext instead. ([#2654](https://github.com/getsentry/sentry-dotnet/pull/2654))
2122
- Adding `Distribution` to `IEventLike` ([#2660](https://github.com/getsentry/sentry-dotnet/pull/2660))

src/Sentry/IEventLike.cs

Lines changed: 108 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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)]
97108
public 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>

src/Sentry/IHasBreadcrumbs.cs

Lines changed: 0 additions & 141 deletions
This file was deleted.

0 commit comments

Comments
 (0)