Skip to content

Commit 277f942

Browse files
committed
fix: Bob's Buddy Sentry events failing to serialize with enchantments
1 parent f017b43 commit 277f942

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
- Updated the list of Trinkets that cause Tavern Tier 7 to appear.
44
- Removed the distracting Bob's Buddy animation when hovering the leaderboard.
55
- Fixed certain Battlegrounds overlay settings not taking effect immediately.
6+
- Fixed an issue with the instrumentation we use to fix incorrect combat odds.
67

78
## **Release v1.55.8 - 2026-08-14**
89
**Battlegrounds**:

Hearthstone Deck Tracker/Utility/Analytics/Sentry.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
using Hearthstone_Deck_Tracker.Utility.Extensions;
1616
using Hearthstone_Deck_Tracker.Utility.Logging;
1717
using Hearthstone_Deck_Tracker.Utility.RemoteData;
18+
using Newtonsoft.Json;
19+
using Newtonsoft.Json.Linq;
1820
using SharpRaven;
1921
using SharpRaven.Data;
2022

@@ -198,7 +200,7 @@ private static void SendQueuedBobsBuddyEvents(string? shortId, string path, Func
198200
var e = BobsBuddyEvents.Dequeue();
199201
((BobsBuddyData)e.Extra).ShortId = shortId;
200202

201-
var eventId = Client.Capture(recode(e));
203+
var eventId = Client.Capture(WithSerializableExtra(recode(e)));
202204
if(eventId != null)
203205
sent++;
204206
else
@@ -224,6 +226,20 @@ private static SentryEvent RecodeIfBothSidesEmpty(SentryEvent e)
224226
private static SentryEvent RecodeAsStateCompleteFalse(SentryEvent e) =>
225227
Recode(e, $"BobsBuddy {BobsBuddyUtils.VersionString}: Incorrect Terminal Case: StateCompleteFalse");
226228

229+
private static SentryEvent WithSerializableExtra(SentryEvent e)
230+
{
231+
if(e.Extra == null)
232+
return e;
233+
// BobsBuddy entities contain reference cycles (Enchantment.AttachedTo), which make SharpRaven's serialization throw
234+
var serializer = JsonSerializer.Create(new JsonSerializerSettings
235+
{
236+
ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
237+
Error = (_, args) => args.ErrorContext.Handled = true,
238+
});
239+
e.Extra = JObject.FromObject(e.Extra, serializer);
240+
return e;
241+
}
242+
227243
private static SentryEvent Recode(SentryEvent e, string message) =>
228244
new SentryEvent(new SentryMessage(message))
229245
{

0 commit comments

Comments
 (0)