Commit 83d20964 authored by Sean McGivern's avatar Sean McGivern

Merge branch 'remove-tracking-controller-concern' into 'master'

Remove Snowplow controller concern

See merge request gitlab-org/gitlab!55816
parents c2688ebe 22e82122
...@@ -16,7 +16,6 @@ class ApplicationController < ActionController::Base ...@@ -16,7 +16,6 @@ class ApplicationController < ActionController::Base
include SessionlessAuthentication include SessionlessAuthentication
include SessionsHelper include SessionsHelper
include ConfirmEmailWarning include ConfirmEmailWarning
include Gitlab::Tracking::ControllerConcern
include Gitlab::Experimentation::ControllerConcern include Gitlab::Experimentation::ControllerConcern
include InitializesCurrentUserMode include InitializesCurrentUserMode
include Impersonation include Impersonation
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
class Groups::EmailCampaignsController < Groups::ApplicationController class Groups::EmailCampaignsController < Groups::ApplicationController
include InProductMarketingHelper include InProductMarketingHelper
include Gitlab::Tracking::ControllerConcern
EMAIL_CAMPAIGNS_SCHEMA_URL = 'iglu:com.gitlab/email_campaigns/jsonschema/1-0-0' EMAIL_CAMPAIGNS_SCHEMA_URL = 'iglu:com.gitlab/email_campaigns/jsonschema/1-0-0'
...@@ -25,7 +24,7 @@ class Groups::EmailCampaignsController < Groups::ApplicationController ...@@ -25,7 +24,7 @@ class Groups::EmailCampaignsController < Groups::ApplicationController
subject_line: subject_line(@track, @series) subject_line: subject_line(@track, @series)
} }
track_self_describing_event(EMAIL_CAMPAIGNS_SCHEMA_URL, data: data) ::Gitlab::Tracking.self_describing_event(EMAIL_CAMPAIGNS_SCHEMA_URL, data: data)
end end
def redirect_link def redirect_link
......
...@@ -50,6 +50,7 @@ module PackagesHelper ...@@ -50,6 +50,7 @@ module PackagesHelper
def track_package_event(event_name, scope, **args) def track_package_event(event_name, scope, **args)
::Packages::CreateEventService.new(nil, current_user, event_name: event_name, scope: scope).execute ::Packages::CreateEventService.new(nil, current_user, event_name: event_name, scope: scope).execute
track_event(event_name, **args) category = args.delete(:category) || self.class.name
::Gitlab::Tracking.event(category, event_name.to_s, **args)
end end
end end
...@@ -11,7 +11,7 @@ module GroupInviteMembers ...@@ -11,7 +11,7 @@ module GroupInviteMembers
result = Members::CreateService.new(current_user, invite_params).execute(group) result = Members::CreateService.new(current_user, invite_params).execute(group)
track_event('invite_members', label: 'new_group_form') if result[:status] == :success ::Gitlab::Tracking.event(self.class.name, 'invite_members', label: 'new_group_form') if result[:status] == :success
end end
def emails_param def emails_param
......
...@@ -11,7 +11,7 @@ class Groups::Analytics::CoverageReportsController < Groups::Analytics::Applicat ...@@ -11,7 +11,7 @@ class Groups::Analytics::CoverageReportsController < Groups::Analytics::Applicat
def index def index
respond_to do |format| respond_to do |format|
format.csv do format.csv do
track_event(:download_code_coverage_csv, **download_tracker_params) ::Gitlab::Tracking.event(self.class.name, 'download_code_coverage_csv', **download_tracker_params)
send_data(render_csv(report_results), type: 'text/csv; charset=utf-8') send_data(render_csv(report_results), type: 'text/csv; charset=utf-8')
end end
end end
......
...@@ -12,7 +12,7 @@ class Groups::Analytics::RepositoryAnalyticsController < Groups::Analytics::Appl ...@@ -12,7 +12,7 @@ class Groups::Analytics::RepositoryAnalyticsController < Groups::Analytics::Appl
end end
def show def show
track_event(**pageview_tracker_params) Gitlab::Tracking.event(self.class.name, 'show', **pageview_tracker_params)
end end
private private
......
# frozen_string_literal: true # frozen_string_literal: true
class SurveyResponsesController < ApplicationController class SurveyResponsesController < ApplicationController
include Gitlab::Tracking::ControllerConcern
SURVEY_RESPONSE_SCHEMA_URL = 'iglu:com.gitlab/survey_response/jsonschema/1-0-0' SURVEY_RESPONSE_SCHEMA_URL = 'iglu:com.gitlab/survey_response/jsonschema/1-0-0'
skip_before_action :authenticate_user! skip_before_action :authenticate_user!
...@@ -28,7 +26,7 @@ class SurveyResponsesController < ApplicationController ...@@ -28,7 +26,7 @@ class SurveyResponsesController < ApplicationController
response: params[:response] response: params[:response]
}.compact }.compact
track_self_describing_event(SURVEY_RESPONSE_SCHEMA_URL, data: data) ::Gitlab::Tracking.self_describing_event(SURVEY_RESPONSE_SCHEMA_URL, data: data)
end end
def to_number(param) def to_number(param)
......
...@@ -21,7 +21,7 @@ RSpec.describe SurveyResponsesController do ...@@ -21,7 +21,7 @@ RSpec.describe SurveyResponsesController do
end end
it 'tracks a survey_response event' do it 'tracks a survey_response event' do
expect(controller).to receive(:track_self_describing_event).with( expect(Gitlab::Tracking).to receive(:self_describing_event).with(
SurveyResponsesController::SURVEY_RESPONSE_SCHEMA_URL, SurveyResponsesController::SURVEY_RESPONSE_SCHEMA_URL,
data: { survey_id: 1, response: 'bar' } data: { survey_id: 1, response: 'bar' }
) )
...@@ -32,7 +32,7 @@ RSpec.describe SurveyResponsesController do ...@@ -32,7 +32,7 @@ RSpec.describe SurveyResponsesController do
context 'not on GitLab.com' do context 'not on GitLab.com' do
it 'does not track a survey_response event' do it 'does not track a survey_response event' do
expect(controller).not_to receive(:track_self_describing_event) expect(Gitlab::Tracking).not_to receive(:self_describing_event)
subject subject
end end
......
...@@ -4,21 +4,6 @@ module Gitlab ...@@ -4,21 +4,6 @@ module Gitlab
module Tracking module Tracking
SNOWPLOW_NAMESPACE = 'gl' SNOWPLOW_NAMESPACE = 'gl'
module ControllerConcern
extend ActiveSupport::Concern
protected
def track_event(action = action_name, **args)
category = args.delete(:category) || self.class.name
Gitlab::Tracking.event(category, action.to_s, **args)
end
def track_self_describing_event(schema_url, data:, **args)
Gitlab::Tracking.self_describing_event(schema_url, data: data, **args)
end
end
class << self class << self
def enabled? def enabled?
Gitlab::CurrentSettings.snowplow_enabled? Gitlab::CurrentSettings.snowplow_enabled?
......
...@@ -56,8 +56,6 @@ RSpec.describe ApplicationController do ...@@ -56,8 +56,6 @@ RSpec.describe ApplicationController do
end end
end end
it_behaves_like 'a Trackable Controller'
describe '#add_gon_variables' do describe '#add_gon_variables' do
before do before do
Gon.clear Gon.clear
......
...@@ -42,7 +42,7 @@ RSpec.describe Projects::Registry::TagsController do ...@@ -42,7 +42,7 @@ RSpec.describe Projects::Registry::TagsController do
it 'tracks the event', :snowplow do it 'tracks the event', :snowplow do
get_tags get_tags
expect_snowplow_event(category: anything, action: 'list_tags') expect_snowplow_event(category: 'Projects::Registry::TagsController', action: 'list_tags')
end end
end end
...@@ -107,11 +107,12 @@ RSpec.describe Projects::Registry::TagsController do ...@@ -107,11 +107,12 @@ RSpec.describe Projects::Registry::TagsController do
destroy_tag('test.') destroy_tag('test.')
end end
it 'tracks the event' do it 'tracks the event', :snowplow do
expect_delete_tags(%w[test.]) expect_delete_tags(%w[test.])
expect(controller).to receive(:track_event).with(:delete_tag)
destroy_tag('test.') destroy_tag('test.')
expect_snowplow_event(category: 'Projects::Registry::TagsController', action: 'delete_tag')
end end
end end
end end
......
# frozen_string_literal: true
RSpec.shared_examples 'a Trackable Controller' do
describe '#track_event', :snowplow do
before do
sign_in user
end
context 'with no params' do
controller(described_class) do
def index
track_event
head :ok
end
end
it 'tracks the action name', :snowplow do
get :index
expect_snowplow_event(category: 'AnonymousController', action: 'index')
end
end
context 'with params' do
controller(described_class) do
def index
track_event('some_event', category: 'SomeCategory', label: 'errorlabel')
head :ok
end
end
it 'tracks with the specified param' do
get :index
expect_snowplow_event(category: 'SomeCategory', action: 'some_event', label: 'errorlabel')
end
end
end
end
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