Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 27 additions & 11 deletions shell/agents/Microsoft.Azure.Agent/AzureAgent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,24 +121,40 @@ public void Initialize(AgentConfig config)

public IEnumerable<CommandBase> GetCommands() => [new ReplaceCommand(this)];
public bool CanAcceptFeedback(UserAction action) => Telemetry.Enabled;
public void OnUserAction(UserActionPayload actionPayload) {

public void OnUserAction(UserActionPayload actionPayload)
{
// Send telemetry about the user action.
bool isUserFeedback = false;
bool shareConversation = false;
string details = null;
UserAction action = actionPayload.Action;
string action = actionPayload.Action.ToString();

if (action is UserAction.Dislike)
switch (actionPayload)
{
var dislike = (DislikePayload) actionPayload;
isUserFeedback = true;
details = string.Format("{0} | {1}", dislike.ShortFeedback, dislike.LongFeedback);
case DislikePayload dislike:
isUserFeedback = true;
shareConversation = dislike.ShareConversation;
details = string.Format("{0} | {1}", dislike.ShortFeedback, dislike.LongFeedback);
break;

case LikePayload like:
isUserFeedback = true;
shareConversation = like.ShareConversation;
break;

default:
break;
}
else if (action is UserAction.Like)

if (isUserFeedback)
{
isUserFeedback = true;
Telemetry.Trace(AzTrace.Feedback(action, shareConversation, _copilotResponse, details));
}
else
{
Telemetry.Trace(AzTrace.UserAction(action, _copilotResponse, details));
}

Telemetry.Trace(AzTrace.UserAction(action.ToString(), _copilotResponse, details, isUserFeedback));
}

public async Task RefreshChatAsync(IShell shell, bool force)
Expand Down Expand Up @@ -412,7 +428,7 @@ private ResponseData ParseCLIHandlerResponse(IShell shell)
{
// The placeholder section is not in the format as we've instructed ...
Log.Error("Placeholder section not in expected format:\n{0}", text);
Telemetry.Trace(AzTrace.Exception(_copilotResponse, "Placeholder section not in expected format."));
Telemetry.Trace(AzTrace.Exception("Placeholder section not in expected format."));
}

ReplaceKnownPlaceholders(data);
Expand Down
1 change: 0 additions & 1 deletion shell/agents/Microsoft.Azure.Agent/ChatSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ internal class ChatSession : IDisposable
// TODO: production URL not yet working for some regions.
// private const string ACCESS_URL = "https://copilotweb.production.portalrp.azure.com/api/access?api-version=2024-09-01";
private const string ACCESS_URL = "https://copilotweb.canary.production.portalrp.azure.com/api/access?api-version=2024-09-01";

private const string DL_TOKEN_URL = "https://copilotweb.production.portalrp.azure.com/api/conversations/start?api-version=2024-11-15";
private const string CONVERSATION_URL = "https://directline.botframework.com/v3/directline/conversations";

Expand Down
34 changes: 26 additions & 8 deletions shell/agents/Microsoft.Azure.Agent/Telemetry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,18 +88,38 @@ internal static void Initialize()
internal static AzTrace UserAction(
string shellCommand,
CopilotResponse response,
object details,
bool isFeedback = false)
object details)
{
if (Telemetry.Enabled)
{
return new()
{
QueryId = response.ReplyToId,
EventType = "UserAction",
ShellCommand = shellCommand,
TopicName = response.TopicName,
ConversationId = response.ConversationId,
Details = details
};
}

// Don't create an object when telemetry is disabled.
return null;
}

internal static AzTrace Feedback(
string shellCommand,
bool shareConversation,
CopilotResponse response,
object details)
{
if (Telemetry.Enabled)
{
return new()
{
EventType = "Feedback",
ShellCommand = shellCommand,
EventType = isFeedback ? "Feedback" : "UserAction",
TopicName = response.TopicName,
QueryId = shareConversation ? response.ReplyToId : null,
ConversationId = shareConversation ? response.ConversationId : null,
Details = details
};
}
Expand All @@ -115,9 +135,7 @@ internal static AzTrace Chat(CopilotResponse response)
return new()
{
EventType = "Chat",
QueryId = response.ReplyToId,
TopicName = response.TopicName,
ConversationId = response.ConversationId
TopicName = response.TopicName
};
}

Expand Down