Commit c187f58f authored by Vasilii Iakliushin's avatar Vasilii Iakliushin

Add usage ping counter for Static Site Editor views

Contributes to https://gitlab.com/gitlab-org/gitlab/-/issues/233994
parent 28fb4a1d
......@@ -27,6 +27,8 @@ class Projects::StaticSiteEditorController < Projects::ApplicationController
).execute
if service_response.success?
Gitlab::UsageDataCounters::StaticSiteEditorCounter.increment_views_count
@data = serialize_necessary_payload_values_to_json(service_response.payload)
else
# TODO: For now, if the service returns any error, the user is redirected
......
---
title: Add usage ping to count Static Site Editor views
merge_request: 44573
author:
type: added
......@@ -266,7 +266,8 @@ module Gitlab
Gitlab::UsageDataCounters::SourceCodeCounter,
Gitlab::UsageDataCounters::MergeRequestCounter,
Gitlab::UsageDataCounters::DesignsCounter,
Gitlab::UsageDataCounters::KubernetesAgentCounter
Gitlab::UsageDataCounters::KubernetesAgentCounter,
Gitlab::UsageDataCounters::StaticSiteEditorCounter
]
end
......
# frozen_string_literal: true
module Gitlab
module UsageDataCounters
class StaticSiteEditorCounter < BaseCounter
KNOWN_EVENTS = %w[views].freeze
PREFIX = 'static_site_editor'
class << self
def increment_views_count
count(:views)
end
end
end
end
end
......@@ -54,11 +54,16 @@ RSpec.describe Projects::StaticSiteEditorController do
context "as developer" do
before do
allow(Gitlab::UsageDataCounters::StaticSiteEditorCounter).to receive(:increment_views_count)
project.add_role(user, 'developer')
sign_in(user)
get :show, params: default_params
end
it 'increases the views counter' do
expect(Gitlab::UsageDataCounters::StaticSiteEditorCounter).to have_received(:increment_views_count)
end
it 'renders the edit page' do
expect(response).to render_template(:show)
end
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Gitlab::UsageDataCounters::StaticSiteEditorCounter do
it_behaves_like 'a redis usage counter', 'StaticSiteEditor', :views
it_behaves_like 'a redis usage counter with totals', :static_site_editor,
views: 3
end
......@@ -618,6 +618,7 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
subject { described_class.usage_counters }
it { is_expected.to include(:kubernetes_agent_gitops_sync) }
it { is_expected.to include(:static_site_editor_views) }
end
describe '.usage_data_counters' 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