Skip to content

Commit

Permalink
Move context id retrieval to strip and send methods
Browse files Browse the repository at this point in the history
  • Loading branch information
MattByers committed Jul 19, 2024
1 parent 715275b commit 2c3b24e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Mindscape.Raygun4Net4/RaygunClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -440,13 +440,15 @@ private void StripAndSend(Exception exception, IList<string> tags, IDictionary u
{
var requestMessage = BuildRequestMessage();
IList<RaygunBreadcrumb> breadcrumbs = BuildBreadCrumbList();
var contextId = GetContextId();

foreach (var e in StripWrapperExceptions(exception))
{
Send(BuildMessage(e, tags, userCustomData, userInfo, currentTime, x =>
{
x.Details.Request = requestMessage;
x.Details.Breadcrumbs = breadcrumbs;
x.Details.ContextId = contextId;
}));
}
}
Expand All @@ -455,13 +457,15 @@ private void StripAndSendInBackground(Exception exception, IList<string> tags, I
{
var requestMessage = BuildRequestMessage();
IList<RaygunBreadcrumb> breadcrumbs = BuildBreadCrumbList();
var contextId = GetContextId();

foreach (var e in StripWrapperExceptions(exception))
{
SendInBackground(() => BuildMessage(e, tags, userCustomData, userInfo, currentTime, x =>
{
x.Details.Request = requestMessage;
x.Details.Breadcrumbs = breadcrumbs;
x.Details.ContextId = contextId;
}));
}
}
Expand Down Expand Up @@ -600,7 +604,6 @@ protected RaygunMessage BuildMessage(Exception exception, IList<string> tags, ID
.SetVersion(ApplicationVersion)
.SetTags(tags)
.SetUserCustomData(userCustomData)
.SetContextId(GetContextId())
.SetUser(userInfoMessage ?? UserInfo ?? (!string.IsNullOrEmpty(User) ? new RaygunIdentifierMessage(User) : null))
.Customise(customise)
.Build();
Expand Down Expand Up @@ -668,7 +671,7 @@ protected IEnumerable<Exception> StripWrapperExceptions(Exception exception)
}
}

private static string GetContextId()
private string GetContextId()
{
return HttpContext.Current?.Session?.SessionID;
}
Expand Down

0 comments on commit 2c3b24e

Please sign in to comment.