Skip to content
代码片段 群组 项目
提交 954218ca 编辑于 作者: Michał Wielich's avatar Michał Wielich 提交者: Sincheol (David) Kim
浏览文件

Track code suggestions authentication

Track code suggestions authentication
上级 707cfcff
No related branches found
No related tags found
无相关合并请求
---
description: An event triggered when a user is authorized to use Code Suggestions
category: API::Ml::AiAssist
action: authenticate
label_description: code_suggestions
property_description:
value_description:
extra_properties:
identifiers:
- user
product_section: dev
product_stage: modelops
product_group: ai_assisted
milestone: "16.1"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/122774
distributions:
- ee
tiers:
- free
- premium
- ultimate
......@@ -42,6 +42,13 @@ def access_code_suggestions_when_proxied_to_saas?
end
post do
with_proxy_ai_request do
Gitlab::Tracking.event(
'API::CodeSuggestions',
:authenticate,
user: current_user,
label: 'code_suggestions'
)
token = Gitlab::CodeSuggestions::AccessToken.new(current_user)
present token, with: Entities::CodeSuggestionsAccessToken
end
......
......@@ -22,6 +22,13 @@ class AiAssist < ::API::Base
success EE::API::Entities::Ml::AiAssist
end
get 'ai-assist' do
Gitlab::Tracking.event(
'API::Ml::AiAssist',
:authenticate,
user: current_user,
label: 'code_suggestions'
)
response = {
user_is_allowed: true,
third_party_ai_features_enabled: current_user.third_party_ai_features_enabled?
......
......@@ -13,6 +13,21 @@
expect(json_response).to include(**body)
end
it "records Snowplow events" do
post_api
if case_name == 'successful'
expect_snowplow_event(
category: described_class.name,
action: :authenticate,
user: current_user,
label: 'code_suggestions'
)
else
expect_no_snowplow_event
end
end
end
shared_examples 'a successful response' do
......
......@@ -15,15 +15,32 @@
end
shared_examples 'a response' do |result, body = nil|
it "returns #{result} response", :aggregate_failures do
before do
allowed_group
end
it "returns #{result} response", :aggregate_failures do
get_api
expect(response).to have_gitlab_http_status(result)
expect(json_response).to eq(body) if body
end
it "records Snowplow events" do
get_api
if result == :ok
expect_snowplow_event(
category: described_class.name,
action: :authenticate,
user: current_user,
label: 'code_suggestions'
)
else
expect_no_snowplow_event
end
end
end
describe 'GET /ml/ai-assist user_is_allowed' do
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册