Skip to content

Capture URL from where the question is asked in Duo Chat

What does this MR do and why?

This MR captures the URL from where the question was asked in Duo Chat, so that in the future, we can get statistics on whether the question was asked from the same URL as the previous question or not.

Follow-up work from issue https://gitlab.com/gitlab-org/gitlab/-/issues/430975.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

This MR is so simple and backend-only that I don't think a screenshot would be helpful, but feel free to request one if needed.

How to set up and validate locally

  1. Add some Duo Chat messages from different pages, for example the homepage and the todo list
  2. Open the rails console with rails c
  3. Find the user that you were logged into when creating those messages.
user = User.find_by(email: <USER EMAIL>)
  1. Observe that the messages are saved with the referrer URL set to the same URL you were on when you initially sent them. (Does not work for old messages from before this change.)
 messages = Gitlab::Llm::ChatStorage.new(user).messages

messages.select{|m| m.role == "user"}.map{|m| [m.referer_url, m.content]}

Related to #435290 (closed)

Edited by Lesley Razzaghian

Merge request reports