Skip to content

Commit 5ad73d5

Browse files
committed
Added a helper method for setting an existing user identity
1 parent 97938e1 commit 5ad73d5

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

Source/Samples/SampleConsole/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ private static void SampleApiUsages() {
127127

128128
ExceptionlessClient.Default.SubmitFeatureUsage("MyFeature");
129129
ExceptionlessClient.Default.SubmitNotFound("/somepage");
130-
ExceptionlessClient.Default.SubmitSessionStart(Guid.NewGuid().ToString("N"));
130+
ExceptionlessClient.Default.SubmitSessionStart();
131131

132132
try {
133133
throw new ApplicationException("Test");
@@ -143,7 +143,7 @@ private static void WriteOptionsMenu() {
143143
ClearConsoleLines(0, OPTIONS_MENU_LINE_COUNT - 1);
144144
Console.WriteLine("1: Send 1");
145145
Console.WriteLine("2: Send 100");
146-
Console.WriteLine("3: Send continous");
146+
Console.WriteLine("3: Send continuous");
147147
Console.WriteLine("4: Process queue");
148148
Console.WriteLine("5: Process directory");
149149
Console.WriteLine("D: Change date range (" + _dateSpans[_dateSpanIndex].ToWords() + ")");

Source/Shared/Extensions/EventBuilderExtensions.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using Exceptionless.Models.Data;
23

34
namespace Exceptionless {
45
public static class EventBuilderExtensions {
@@ -23,6 +24,16 @@ public static EventBuilder SetUserIdentity(this EventBuilder builder, string ide
2324
return builder;
2425
}
2526

27+
/// <summary>
28+
/// Sets the user's identity (ie. email address, username, user id) that the event happened to.
29+
/// </summary>
30+
/// <param name="builder">The event builder object.</param>
31+
/// <param name="userInfo">The user's identity that the event happened to.</param>
32+
public static EventBuilder SetUserIdentity(this EventBuilder builder, UserInfo userInfo) {
33+
builder.Target.SetUserIdentity(userInfo);
34+
return builder;
35+
}
36+
2637
/// <summary>
2738
/// Sets the user's description of the event.
2839
/// </summary>

Source/Shared/Plugins/Default/100 _HeartbeatPlugin.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public void DelayNext() {
5555
}
5656

5757
private void SendHeartbeat(object state) {
58-
_client.SubmitSessionHeartbeat(User.Identity, User.Name);
58+
_client.CreateSessionHeartbeat().SetUserIdentity(User).Submit();
5959
}
6060

6161
public void Dispose() {

0 commit comments

Comments
 (0)