feat: log captain assistant and copilot usage

This commit is contained in:
Shivam Mishra
2026-06-30 16:14:50 +05:30
parent e9789ca9c4
commit f2df41299c
2 changed files with 8 additions and 0 deletions
@@ -77,6 +77,10 @@ class Captain::Conversation::ResponseBuilderJob < ApplicationJob
create_messages
Rails.logger.info("[CAPTAIN][ResponseBuilderJob] Incrementing response usage for #{account.id}")
account.increment_response_usage
# Granular usage reporting. Only assistant + copilot responses are logged for now;
# the other increment_response_usage call sites (task services, audio transcription)
# map to usage_types that are intentionally not recorded yet.
Captain::Usage.log(account: account, assistant: @assistant, usage_type: :assistant_response)
end
end
end
@@ -29,6 +29,10 @@ class Captain::Copilot::ChatService < Llm::BaseAiService
"#{self.class.name} Assistant: #{@assistant.id}, Incrementing response usage for account #{@account.id}"
)
@account.increment_response_usage
# Granular usage reporting. Only assistant + copilot responses are logged for now;
# the other increment_response_usage call sites (task services, audio transcription)
# map to usage_types that are intentionally not recorded yet.
Captain::Usage.log(account: @account, assistant: @assistant, usage_type: :copilot_response)
response
end