diff options
Diffstat (limited to 'app/controllers/projects/google_cloud/base_controller.rb')
-rw-r--r-- | app/controllers/projects/google_cloud/base_controller.rb | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/app/controllers/projects/google_cloud/base_controller.rb b/app/controllers/projects/google_cloud/base_controller.rb index f4a773a62f6..f293ec752ab 100644 --- a/app/controllers/projects/google_cloud/base_controller.rb +++ b/app/controllers/projects/google_cloud/base_controller.rb @@ -10,18 +10,25 @@ class Projects::GoogleCloud::BaseController < Projects::ApplicationController private def admin_project_google_cloud! - access_denied! unless can?(current_user, :admin_project_google_cloud, project) + unless can?(current_user, :admin_project_google_cloud, project) + track_event('admin_project_google_cloud!', 'access_denied', 'invalid_user') + access_denied! + end end def google_oauth2_enabled! config = Gitlab::Auth::OAuth::Provider.config_for('google_oauth2') if config.app_id.blank? || config.app_secret.blank? + track_event('google_oauth2_enabled!', 'access_denied', { reason: 'google_oauth2_not_configured', config: config }) access_denied! 'This GitLab instance not configured for Google Oauth2.' end end def feature_flag_enabled! - access_denied! unless Feature.enabled?(:incubation_5mp_google_cloud, project) + unless Feature.enabled?(:incubation_5mp_google_cloud) + track_event('feature_flag_enabled!', 'access_denied', 'feature_flag_not_enabled') + access_denied! + end end def validate_gcp_token! @@ -53,9 +60,21 @@ class Projects::GoogleCloud::BaseController < Projects::ApplicationController session[GoogleApi::CloudPlatform::Client.session_key_for_expires_at] end - def handle_gcp_error(error, project) - Gitlab::ErrorTracking.track_exception(error, project_id: project.id) + def handle_gcp_error(action, error) + track_event(action, 'gcp_error', error) @js_data = { screen: 'gcp_error', error: error.to_s }.to_json render status: :unauthorized, template: 'projects/google_cloud/errors/gcp_error' end + + def track_event(action, label, property) + options = { label: label, project: project, user: current_user } + + if property.is_a?(String) + options[:property] = property + else + options[:extra] = property + end + + Gitlab::Tracking.event('Projects::GoogleCloud', action, **options) + end end |