Skip to content

Commit 8524223

Browse files
committed
Update code and remove ids from exception telemetry
1 parent dc5061d commit 8524223

File tree

3 files changed

+30
-26
lines changed

3 files changed

+30
-26
lines changed

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

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -121,34 +121,39 @@ public void Initialize(AgentConfig config)
121121

122122
public IEnumerable<CommandBase> GetCommands() => [new ReplaceCommand(this)];
123123
public bool CanAcceptFeedback(UserAction action) => Telemetry.Enabled;
124-
public void OnUserAction(UserActionPayload actionPayload) {
124+
125+
public void OnUserAction(UserActionPayload actionPayload)
126+
{
125127
// Send telemetry about the user action.
126128
bool isUserFeedback = false;
127-
bool allowIdsForCorrelation = false;
129+
bool shareConversation = false;
128130
string details = null;
129-
UserAction action = actionPayload.Action;
131+
string action = actionPayload.Action.ToString();
130132

131-
if (action is UserAction.Dislike)
132-
{
133-
isUserFeedback = true;
134-
DislikePayload dislike = (DislikePayload)actionPayload;
135-
allowIdsForCorrelation = dislike.ShareConversation;
136-
details = string.Format("{0} | {1}", dislike.ShortFeedback, dislike.LongFeedback);
137-
}
138-
else if (action is UserAction.Like)
133+
switch (actionPayload)
139134
{
140-
isUserFeedback = true;
141-
LikePayload like = (LikePayload)actionPayload;
142-
allowIdsForCorrelation = like.ShareConversation;
135+
case DislikePayload dislike:
136+
isUserFeedback = true;
137+
shareConversation = dislike.ShareConversation;
138+
details = string.Format("{0} | {1}", dislike.ShortFeedback, dislike.LongFeedback);
139+
break;
140+
141+
case LikePayload like:
142+
isUserFeedback = true;
143+
shareConversation = like.ShareConversation;
144+
break;
145+
146+
default:
147+
break;
143148
}
144149

145150
if (isUserFeedback)
146151
{
147-
Telemetry.Trace(AzTrace.Feedback(action.ToString(), _copilotResponse, details, allowIdsForCorrelation));
152+
Telemetry.Trace(AzTrace.Feedback(action, shareConversation, _copilotResponse, details));
148153
}
149154
else
150155
{
151-
Telemetry.Trace(AzTrace.UserAction(action.ToString(), _copilotResponse, details));
156+
Telemetry.Trace(AzTrace.UserAction(action, _copilotResponse, details));
152157
}
153158
}
154159

@@ -423,7 +428,7 @@ private ResponseData ParseCLIHandlerResponse(IShell shell)
423428
{
424429
// The placeholder section is not in the format as we've instructed ...
425430
Log.Error("Placeholder section not in expected format:\n{0}", text);
426-
Telemetry.Trace(AzTrace.Exception(_copilotResponse, "Placeholder section not in expected format."));
431+
Telemetry.Trace(AzTrace.Exception("Placeholder section not in expected format."));
427432
}
428433

429434
ReplaceKnownPlaceholders(data);

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ internal class ChatSession : IDisposable
1414
// TODO: production URL not yet working for some regions.
1515
// private const string ACCESS_URL = "https://copilotweb.production.portalrp.azure.com/api/access?api-version=2024-09-01";
1616
private const string ACCESS_URL = "https://copilotweb.canary.production.portalrp.azure.com/api/access?api-version=2024-09-01";
17-
1817
private const string DL_TOKEN_URL = "https://copilotweb.production.portalrp.azure.com/api/conversations/start?api-version=2024-11-15";
1918
private const string CONVERSATION_URL = "https://directline.botframework.com/v3/directline/conversations";
2019

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ internal static AzTrace UserAction(
9494
{
9595
return new()
9696
{
97-
TopicName = response.TopicName,
98-
ShellCommand = shellCommand,
9997
EventType = "UserAction",
98+
ShellCommand = shellCommand,
99+
TopicName = response.TopicName,
100100
Details = details
101101
};
102102
}
@@ -107,19 +107,19 @@ internal static AzTrace UserAction(
107107

108108
internal static AzTrace Feedback(
109109
string shellCommand,
110+
bool shareConversation,
110111
CopilotResponse response,
111-
object details,
112-
bool allowIdsForCorrelation)
112+
object details)
113113
{
114114
if (Telemetry.Enabled)
115115
{
116116
return new()
117117
{
118-
QueryId = allowIdsForCorrelation ? response.ReplyToId : null,
119-
TopicName = response.TopicName,
120-
ConversationId = allowIdsForCorrelation ? response.ConversationId : null,
121-
ShellCommand = shellCommand,
122118
EventType = "Feedback",
119+
ShellCommand = shellCommand,
120+
TopicName = response.TopicName,
121+
QueryId = shareConversation ? response.ReplyToId : null,
122+
ConversationId = shareConversation ? response.ConversationId : null,
123123
Details = details
124124
};
125125
}

0 commit comments

Comments
 (0)