Commit 3db76269 authored by Terri Chu's avatar Terri Chu

Merge branch 'ali/remove-promoted-issues' into 'master'

Deprecate promoted_issues metric

See merge request gitlab-org/gitlab!71604
parents 4f4e3f5f 7d5fb818
......@@ -20,8 +20,6 @@ class ProductAnalyticsEvent < ApplicationRecord
where('collector_tstamp BETWEEN ? AND ? ', today - duration + 1, today + 1)
}
scope :by_category_and_action, ->(category, action) { where(se_category: category, se_action: action) }
def self.count_by_graph(graph, days)
group(graph).timerange(days).count
end
......
......@@ -7,7 +7,7 @@ product_stage: growth
product_group: group::product intelligence
product_category: collection
value_type: number
status: active
status: deprecated
milestone: "14.3"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/70485
time_frame: 28d
......
......@@ -942,7 +942,6 @@ Aggregated metrics collected in `7d` and `28d` time frames are added into Servic
:packages => 155,
:personal_snippets => 2106,
:project_snippets => 407,
:promoted_issues => 719,
:aggregated_metrics => {
:example_metrics_union => 7,
:example_metrics_intersection => 2
......
......@@ -27,7 +27,6 @@ RSpec.describe 'Every metric definition' do
mock_ci
mock_monitoring
user_auth_by_provider
promoted_issues
groups_gitlab_slack_application_active
projects_gitlab_slack_application_active
instances_gitlab_slack_application_active
......
......@@ -203,19 +203,6 @@ module Gitlab
}
end
def snowplow_event_counts(time_period)
return {} unless report_snowplow_events?
{
promoted_issues: count(
self_monitoring_project
.product_analytics_events
.by_category_and_action('epics', 'promote')
.where(time_period)
)
}
end
def system_usage_data_monthly
{
counts_monthly: {
......@@ -228,10 +215,9 @@ module Gitlab
packages: count(::Packages::Package.where(monthly_time_range_db_params)),
personal_snippets: count(PersonalSnippet.where(monthly_time_range_db_params)),
project_snippets: count(ProjectSnippet.where(monthly_time_range_db_params)),
projects_with_alerts_created: distinct_count(::AlertManagement::Alert.where(monthly_time_range_db_params), :project_id)
}.merge(
snowplow_event_counts(monthly_time_range_db_params(column: :collector_tstamp))
).tap do |data|
projects_with_alerts_created: distinct_count(::AlertManagement::Alert.where(monthly_time_range_db_params), :project_id),
promoted_issues: DEPRECATED_VALUE
}.tap do |data|
data[:snippets] = add(data[:personal_snippets], data[:project_snippets])
end
}
......@@ -786,10 +772,6 @@ module Gitlab
}
end
def report_snowplow_events?
self_monitoring_project && Feature.enabled?(:product_analytics_tracking, type: :ops)
end
def distinct_count_service_desk_enabled_projects(time_period)
project_creator_id_start = minimum_id(User)
project_creator_id_finish = maximum_id(User)
......@@ -850,10 +832,6 @@ module Gitlab
count(::Issue.with_prometheus_alert_events, start: minimum_id(Issue), finish: maximum_id(Issue))
end
def self_monitoring_project
Gitlab::CurrentSettings.self_monitoring_project
end
def clear_memoized
CE_MEMOIZED_VALUES.each { |v| clear_memoization(v) }
end
......
......@@ -724,7 +724,7 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
expect(counts_monthly[:projects_with_alerts_created]).to eq(1)
expect(counts_monthly[:projects]).to eq(1)
expect(counts_monthly[:packages]).to eq(1)
expect(counts_monthly[:promoted_issues]).to eq(1)
expect(counts_monthly[:promoted_issues]).to eq(Gitlab::UsageData::DEPRECATED_VALUE)
end
end
......@@ -1419,48 +1419,4 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
end
end
end
describe '.snowplow_event_counts' do
let_it_be(:time_period) { { collector_tstamp: 8.days.ago..1.day.ago } }
context 'when self-monitoring project exists' do
let_it_be(:project) { create(:project) }
before do
stub_application_setting(self_monitoring_project: project)
end
context 'and product_analytics FF is enabled for it' do
before do
stub_feature_flags(product_analytics_tracking: true)
create(:product_analytics_event, project: project, se_category: 'epics', se_action: 'promote')
create(:product_analytics_event, project: project, se_category: 'epics', se_action: 'promote', collector_tstamp: 2.days.ago)
create(:product_analytics_event, project: project, se_category: 'epics', se_action: 'promote', collector_tstamp: 9.days.ago)
create(:product_analytics_event, project: project, se_category: 'foo', se_action: 'bar', collector_tstamp: 2.days.ago)
end
it 'returns promoted_issues for the time period' do
expect(described_class.snowplow_event_counts(time_period)[:promoted_issues]).to eq(1)
end
end
context 'and product_analytics FF is disabled' do
before do
stub_feature_flags(product_analytics_tracking: false)
end
it 'returns an empty hash' do
expect(described_class.snowplow_event_counts(time_period)).to eq({})
end
end
end
context 'when self-monitoring project does not exist' do
it 'returns an empty hash' do
expect(described_class.snowplow_event_counts(time_period)).to eq({})
end
end
end
end
......@@ -36,17 +36,6 @@ RSpec.describe ProductAnalyticsEvent, type: :model do
it { expect(described_class.count_by_graph('platform', 30.days)).to eq({ 'app' => 1, 'mobile' => 1, 'web' => 2 }) }
end
describe '.by_category_and_action' do
let_it_be(:event) { create(:product_analytics_event, se_category: 'catA', se_action: 'actA') }
before do
create(:product_analytics_event, se_category: 'catA', se_action: 'actB')
create(:product_analytics_event, se_category: 'catB', se_action: 'actA')
end
it { expect(described_class.by_category_and_action('catA', 'actA')).to match_array([event]) }
end
describe '.count_collector_tstamp_by_day' do
let_it_be(:time_now) { Time.zone.now }
let_it_be(:time_ago) { Time.zone.now - 5.days }
......
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