Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
15 changes: 13 additions & 2 deletions shell/agents/Microsoft.Azure.Agent/AzureAgent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,21 +124,32 @@ public void Initialize(AgentConfig config)
public void OnUserAction(UserActionPayload actionPayload) {
// Send telemetry about the user action.
bool isUserFeedback = false;
bool allowIdsForCorrelation = false;
string details = null;
UserAction action = actionPayload.Action;

if (action is UserAction.Dislike)
{
var dislike = (DislikePayload) actionPayload;
isUserFeedback = true;
DislikePayload dislike = (DislikePayload)actionPayload;
allowIdsForCorrelation = dislike.ShareConversation;
details = string.Format("{0} | {1}", dislike.ShortFeedback, dislike.LongFeedback);
}
else if (action is UserAction.Like)
{
isUserFeedback = true;
LikePayload like = (LikePayload)actionPayload;
allowIdsForCorrelation = like.ShareConversation;
}

Telemetry.Trace(AzTrace.UserAction(action.ToString(), _copilotResponse, details, isUserFeedback));
if (isUserFeedback)
{
Telemetry.Trace(AzTrace.Feedback(action.ToString(), _copilotResponse, details, allowIdsForCorrelation));
}
else
{
Telemetry.Trace(AzTrace.UserAction(action.ToString(), _copilotResponse, details));
}
}

public async Task RefreshChatAsync(IShell shell, bool force)
Expand Down
40 changes: 29 additions & 11 deletions shell/agents/Microsoft.Azure.Agent/Telemetry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ internal static void Initialize()
{
InstallationId = null;

string azureConfigDir = Environment.GetEnvironmentVariable("AZURE_CONFIG_DIR")
?? Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".azure");
string azCLIProfilePath = Path.Combine(azureConfigDir, "azureProfile.json");
string azPSHProfilePath = Path.Combine(azureConfigDir, "AzureRmContextSettings.json");
string azureConfigDir = Environment.GetEnvironmentVariable("AZURE_CONFIG_DIR");
string userProfile = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
string azCLIProfilePath = azureConfigDir ?? Path.Combine(userProfile, ".azure", "azureProfile.json");
string azPSHProfilePath = azureConfigDir ?? Path.Combine(userProfile, ".Azure", "AzureRmContextSettings.json");

try
{
Expand Down Expand Up @@ -76,20 +76,40 @@ internal static void Initialize()
internal object Details { get; set; }

internal static AzTrace UserAction(
string shellCommand,
CopilotResponse response,
object details)
{
if (Telemetry.Enabled)
{
return new()
{
TopicName = response.TopicName,
ShellCommand = shellCommand,
EventType = "UserAction",
Details = details
};
}

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

internal static AzTrace Feedback(
string shellCommand,
CopilotResponse response,
object details,
bool isFeedback = false)
bool allowIdsForCorrelation)
{
if (Telemetry.Enabled)
{
return new()
{
QueryId = response.ReplyToId,
QueryId = allowIdsForCorrelation ? response.ReplyToId : null,
TopicName = response.TopicName,
ConversationId = response.ConversationId,
ConversationId = allowIdsForCorrelation ? response.ConversationId : null,
ShellCommand = shellCommand,
EventType = isFeedback ? "Feedback" : "UserAction",
EventType = "Feedback",
Details = details
};
}
Expand All @@ -105,9 +125,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