diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-22 06:10:55 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-22 06:10:55 +0300 |
commit | e0b6b475f203ebbe63a903328369c1363a747498 (patch) | |
tree | db5dd8ef36a7a5c81c39d94a53dd4d3ad39151fc /app/services/import | |
parent | 981548e28502956e47ac43c978cc36908636c265 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/services/import')
-rw-r--r-- | app/services/import/base_service.rb | 25 | ||||
-rw-r--r-- | app/services/import/bitbucket_server_service.rb | 2 | ||||
-rw-r--r-- | app/services/import/github_service.rb | 1 |
3 files changed, 28 insertions, 0 deletions
diff --git a/app/services/import/base_service.rb b/app/services/import/base_service.rb index ab3e9c7abba..6b5adcbc39e 100644 --- a/app/services/import/base_service.rb +++ b/app/services/import/base_service.rb @@ -35,5 +35,30 @@ module Import def success(project) super().merge(project: project, status: :success) end + + def track_access_level(import_type) + Gitlab::Tracking.event( + self.class.name, + 'create', + label: 'import_access_level', + user: current_user, + extra: { user_role: user_role, import_type: import_type } + ) + end + + def user_role + if current_user.id == target_namespace.owner_id + 'Owner' + else + access_level = current_user&.group_members&.find_by(source_id: target_namespace.id)&.access_level + + case access_level + when nil + 'Not a member' + else + Gitlab::Access.human_access(access_level) + end + end + end end end diff --git a/app/services/import/bitbucket_server_service.rb b/app/services/import/bitbucket_server_service.rb index 20f6c987c92..f7f17f1e53e 100644 --- a/app/services/import/bitbucket_server_service.rb +++ b/app/services/import/bitbucket_server_service.rb @@ -19,6 +19,8 @@ module Import project = create_project(credentials) + track_access_level('bitbucket') + if project.persisted? success(project) elsif project.errors[:import_source_disabled].present? diff --git a/app/services/import/github_service.rb b/app/services/import/github_service.rb index a60963e28c7..2378a4b11b1 100644 --- a/app/services/import/github_service.rb +++ b/app/services/import/github_service.rb @@ -13,6 +13,7 @@ module Import return context_error if context_error project = create_project(access_params, provider) + track_access_level('github') if project.persisted? store_import_settings(project) |