Skip to content

Commit b383900

Browse files
committed
remove correlation ids in Chat and UserAction
1 parent 210b87b commit b383900

File tree

2 files changed

+37
-9
lines changed

2 files changed

+37
-9
lines changed

shell/agents/Microsoft.Azure.Agent/AzureAgent.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,21 +124,31 @@ public void Initialize(AgentConfig config)
124124
public void OnUserAction(UserActionPayload actionPayload) {
125125
// Send telemetry about the user action.
126126
bool isUserFeedback = false;
127+
bool allowIdsForCorrelation = false;
127128
string details = null;
128129
UserAction action = actionPayload.Action;
129130

130131
if (action is UserAction.Dislike)
131132
{
132-
var dislike = (DislikePayload) actionPayload;
133133
isUserFeedback = true;
134+
DislikePayload dislikePayload = (DislikePayload)actionPayload;
135+
allowIdsForCorrelation = dislikePayload.ShareConversation;
136+
var dislike = (DislikePayload) actionPayload;
134137
details = string.Format("{0} | {1}", dislike.ShortFeedback, dislike.LongFeedback);
135138
}
136139
else if (action is UserAction.Like)
137140
{
138141
isUserFeedback = true;
139142
}
140143

141-
Telemetry.Trace(AzTrace.UserAction(action.ToString(), _copilotResponse, details, isUserFeedback));
144+
if (isUserFeedback)
145+
{
146+
Telemetry.Trace(AzTrace.Feedback(action.ToString(), _copilotResponse, details, allowIdsForCorrelation));
147+
}
148+
else
149+
{
150+
Telemetry.Trace(AzTrace.UserAction(action.ToString(), _copilotResponse, details));
151+
}
142152
}
143153

144154
public async Task RefreshChatAsync(IShell shell, bool force)

shell/agents/Microsoft.Azure.Agent/Telemetry.cs

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,20 +76,40 @@ internal static void Initialize()
7676
internal object Details { get; set; }
7777

7878
internal static AzTrace UserAction(
79+
string shellCommand,
80+
CopilotResponse response,
81+
object details)
82+
{
83+
if (Telemetry.Enabled)
84+
{
85+
return new()
86+
{
87+
TopicName = response.TopicName,
88+
ShellCommand = shellCommand,
89+
EventType = "UserAction",
90+
Details = details
91+
};
92+
}
93+
94+
// Don't create an object when telemetry is disabled.
95+
return null;
96+
}
97+
98+
internal static AzTrace Feedback(
7999
string shellCommand,
80100
CopilotResponse response,
81101
object details,
82-
bool isFeedback = false)
102+
bool allowIdsForCorrelation)
83103
{
84104
if (Telemetry.Enabled)
85105
{
86106
return new()
87107
{
88-
QueryId = response.ReplyToId,
108+
QueryId = allowIdsForCorrelation ? response.ReplyToId : null,
89109
TopicName = response.TopicName,
90-
ConversationId = response.ConversationId,
110+
ConversationId = allowIdsForCorrelation ? response.ConversationId : null,
91111
ShellCommand = shellCommand,
92-
EventType = isFeedback ? "Feedback" : "UserAction",
112+
EventType = "Feedback",
93113
Details = details
94114
};
95115
}
@@ -105,9 +125,7 @@ internal static AzTrace Chat(CopilotResponse response)
105125
return new()
106126
{
107127
EventType = "Chat",
108-
QueryId = response.ReplyToId,
109-
TopicName = response.TopicName,
110-
ConversationId = response.ConversationId
128+
TopicName = response.TopicName
111129
};
112130
}
113131

0 commit comments

Comments
 (0)