Skip to content

Track Code Suggestions authentication

Michał Wielich requested to merge michold-track-cs into master

What does this MR do and why?

Related to https://gitlab.com/gitlab-org/gitlab/-/issues/412542

We want to track Code Suggestions authentication events for authenticated users.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

  1. Get a running Snowplow micro service
  2. Enable the Code Suggestions API for the instance & user. Substitute "root" with the username of the user that you will be using for tests:
Feature.enable(:ai_assist_api)
Feature.enable(:ai_assist_flag)
ApplicationSetting.last.update!(instance_level_code_suggestions_enabled: true)

u = User.find_by_username('root')
u.namespace.update(code_suggestions: true)
  1. Get a personal access token for the user
  2. Run these curl commands:
curl http://127.0.0.1:3000/api/v4/ml/ai-assist?private_token=YOUR_ACCESS_TOKEN
curl -X POST http://127.0.0.1:3000/api/v4/code_suggestions/tokens?private_token=YOUR_ACCESS_TOKEN
  1. Now, when checking http://localhost:9091/micro/good for Snowplow events, you should see two new events triggered with an authenticate action mentioned in their payload and appropriate category for each of the two tested API classes.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Michał Wielich

Merge request reports