Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-10-20 11:43:02 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-10-20 11:43:02 +0300
commitd9ab72d6080f594d0b3cae15f14b3ef2c6c638cb (patch)
tree2341ef426af70ad1e289c38036737e04b0aa5007 /lib/gitlab/tracking
parentd6e514dd13db8947884cd58fe2a9c2a063400a9b (diff)
Add latest changes from gitlab-org/gitlab@14-4-stable-eev14.4.0-rc42
Diffstat (limited to 'lib/gitlab/tracking')
-rw-r--r--lib/gitlab/tracking/docs/helper.rb67
-rw-r--r--lib/gitlab/tracking/docs/renderer.rb32
-rw-r--r--lib/gitlab/tracking/docs/templates/default.md.haml35
-rw-r--r--lib/gitlab/tracking/standard_context.rb10
4 files changed, 8 insertions, 136 deletions
diff --git a/lib/gitlab/tracking/docs/helper.rb b/lib/gitlab/tracking/docs/helper.rb
deleted file mode 100644
index 4e03858b771..00000000000
--- a/lib/gitlab/tracking/docs/helper.rb
+++ /dev/null
@@ -1,67 +0,0 @@
-# frozen_string_literal: true
-
-module Gitlab
- module Tracking
- module Docs
- # Helper with functions to be used by HAML templates
- module Helper
- def auto_generated_comment
- <<-MARKDOWN.strip_heredoc
- ---
- stage: Growth
- group: Product Intelligence
- info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#designated-technical-writers
- ---
-
- <!---
- This documentation is auto generated by a script.
-
- Please do not edit this file directly, check generate_event_dictionary task on lib/tasks/gitlab/snowplow.rake.
- --->
-
- <!-- vale gitlab.Spelling = NO -->
- MARKDOWN
- end
-
- def render_description(object)
- return 'Missing description' unless object.description.present?
-
- object.description
- end
-
- def render_event_taxonomy(object)
- headers = %w[category action label property value]
- values = %i[category action label property_description value_description]
- values = values.map { |key| backtick(object.attributes[key]) }
- values = values.join(" | ")
-
- [
- "| #{headers.join(" | ")} |",
- "#{'|---' * headers.size}|",
- "| #{values} |"
- ].join("\n")
- end
-
- def md_link_to(anchor_text, url)
- "[#{anchor_text}](#{url})"
- end
-
- def render_owner(object)
- "Owner: #{backtick(object.product_group)}"
- end
-
- def render_tiers(object)
- "Tiers: #{object.tiers.map(&method(:backtick)).join(', ')}"
- end
-
- def render_yaml_definition_path(object)
- "YAML definition: #{backtick(object.yaml_path)}"
- end
-
- def backtick(string)
- "`#{string}`"
- end
- end
- end
- end
-end
diff --git a/lib/gitlab/tracking/docs/renderer.rb b/lib/gitlab/tracking/docs/renderer.rb
deleted file mode 100644
index 184b935c2ba..00000000000
--- a/lib/gitlab/tracking/docs/renderer.rb
+++ /dev/null
@@ -1,32 +0,0 @@
-# frozen_string_literal: true
-
-module Gitlab
- module Tracking
- module Docs
- class Renderer
- include Gitlab::Tracking::Docs::Helper
- DICTIONARY_PATH = Rails.root.join('doc', 'development', 'snowplow')
- TEMPLATE_PATH = Rails.root.join('lib', 'gitlab', 'tracking', 'docs', 'templates', 'default.md.haml')
-
- def initialize(event_definitions)
- @layout = Haml::Engine.new(File.read(TEMPLATE_PATH))
- @event_definitions = event_definitions.sort
- end
-
- def contents
- # Render and remove an extra trailing new line
- @contents ||= @layout.render(self, event_definitions: @event_definitions).sub!(/\n(?=\Z)/, '')
- end
-
- def write
- filename = DICTIONARY_PATH.join('dictionary.md').to_s
-
- FileUtils.mkdir_p(DICTIONARY_PATH)
- File.write(filename, contents)
-
- filename
- end
- end
- end
- end
-end
diff --git a/lib/gitlab/tracking/docs/templates/default.md.haml b/lib/gitlab/tracking/docs/templates/default.md.haml
deleted file mode 100644
index 568f56590fa..00000000000
--- a/lib/gitlab/tracking/docs/templates/default.md.haml
+++ /dev/null
@@ -1,35 +0,0 @@
-= auto_generated_comment
-
-:plain
- # Event Dictionary
-
- This file is autogenerated, please do not edit it directly.
-
- To generate these files from the GitLab repository, run:
-
- ```shell
- bundle exec rake gitlab:snowplow:generate_event_dictionary
- ```
-
- The Event Dictionary is based on the following event definition YAML files:
-
- - [`config/events`](https://gitlab.com/gitlab-org/gitlab/-/tree/f9a404301ca22d038e7b9a9eb08d9c1bbd6c4d84/config/events)
- - [`ee/config/events`](https://gitlab.com/gitlab-org/gitlab/-/tree/f9a404301ca22d038e7b9a9eb08d9c1bbd6c4d84/ee/config/events)
-
- ## Event definitions
-
-\
-- event_definitions.each do |_path, object|
-
- = "### `#{object.category} #{object.action}`"
- \
- = render_event_taxonomy(object)
- \
- = render_description(object)
- \
- = render_yaml_definition_path(object)
- \
- = render_owner(object)
- \
- = render_tiers(object)
- \
diff --git a/lib/gitlab/tracking/standard_context.rb b/lib/gitlab/tracking/standard_context.rb
index fe5669be014..df62e8bbbe6 100644
--- a/lib/gitlab/tracking/standard_context.rb
+++ b/lib/gitlab/tracking/standard_context.rb
@@ -3,13 +3,14 @@
module Gitlab
module Tracking
class StandardContext
- GITLAB_STANDARD_SCHEMA_URL = 'iglu:com.gitlab/gitlab_standard/jsonschema/1-0-5'
+ GITLAB_STANDARD_SCHEMA_URL = 'iglu:com.gitlab/gitlab_standard/jsonschema/1-0-7'
GITLAB_RAILS_SOURCE = 'gitlab-rails'
def initialize(namespace: nil, project: nil, user: nil, **extra)
@namespace = namespace
@plan = namespace&.actual_plan_name
@project = project
+ @user = user
@extra = extra
end
@@ -35,7 +36,7 @@ module Gitlab
private
- attr_accessor :namespace, :project, :extra, :plan
+ attr_accessor :namespace, :project, :extra, :plan, :user
def to_h
{
@@ -44,6 +45,7 @@ module Gitlab
plan: plan,
extra: extra
}.merge(project_and_namespace)
+ .merge(user_data)
end
def project_and_namespace
@@ -58,6 +60,10 @@ module Gitlab
def project_id
project.is_a?(Integer) ? project : project&.id
end
+
+ def user_data
+ ::Feature.enabled?(:add_actor_based_user_to_snowplow_tracking, user) ? { user_id: user&.id } : {}
+ end
end
end
end