Track unique web ide edit action

parent 43e236b0
---
title: Track unique web ide edit action for usage ping
merge_request: 40246
author:
type: changed
...@@ -136,7 +136,10 @@ module API ...@@ -136,7 +136,10 @@ module API
if result[:status] == :success if result[:status] == :success
commit_detail = user_project.repository.commit(result[:result]) commit_detail = user_project.repository.commit(result[:result])
Gitlab::UsageDataCounters::WebIdeCounter.increment_commits_count if find_user_from_warden if find_user_from_warden
Gitlab::UsageDataCounters::WebIdeCounter.increment_commits_count
Gitlab::UsageDataCounters::EditorUniqueCounter.track_web_ide_edit_action(author: current_user)
end
present commit_detail, with: Entities::CommitDetail, stats: params[:stats] present commit_detail, with: Entities::CommitDetail, stats: params[:stats]
else else
......
...@@ -367,11 +367,32 @@ RSpec.describe API::Commits do ...@@ -367,11 +367,32 @@ RSpec.describe API::Commits do
end end
end end
it 'does not increment the usage counters using access token authentication' do context 'when using access token authentication' do
it 'does not increment the usage counters' do
expect(::Gitlab::UsageDataCounters::WebIdeCounter).not_to receive(:increment_commits_count) expect(::Gitlab::UsageDataCounters::WebIdeCounter).not_to receive(:increment_commits_count)
expect(::Gitlab::UsageDataCounters::EditorUniqueCounter).not_to receive(:track_web_ide_edit_action)
post api(url, user), params: valid_c_params post api(url, user), params: valid_c_params
end end
end
context 'when using warden' do
it 'increments usage counters', :clean_gitlab_redis_shared_state do
session_id = Rack::Session::SessionId.new('6919a6f1bb119dd7396fadc38fd18d0d')
session_hash = { 'warden.user.user.key' => [[user.id], user.encrypted_password[0, 29]] }
Gitlab::Redis::SharedState.with do |redis|
redis.set("session:gitlab:#{session_id.private_id}", Marshal.dump(session_hash))
end
cookies[Gitlab::Application.config.session_options[:key]] = session_id.public_id
expect(::Gitlab::UsageDataCounters::WebIdeCounter).to receive(:increment_commits_count)
expect(::Gitlab::UsageDataCounters::EditorUniqueCounter).to receive(:track_web_ide_edit_action)
post api(url), params: valid_c_params
end
end
context 'a new file in project repo' do context 'a new file in project repo' do
before do before do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment