Skip to content
代码片段 群组 项目
未验证 提交 c60053e1 编辑于 作者: Olivier Gonzalez's avatar Olivier Gonzalez 提交者: GitLab
浏览文件

Improve internal event tracking documentation

Explicit how addtional_properties should be used.
上级 6bb52325
No related branches found
No related tags found
无相关合并请求
...@@ -78,8 +78,26 @@ track_internal_event( ...@@ -78,8 +78,26 @@ track_internal_event(
Additional properties can be passed when tracking events. They can be used to save additional data related to given event. Additional properties can be passed when tracking events. They can be used to save additional data related to given event.
Tracking classes have built-in properties with keys `label` (string), `property` (string) and `value`(numeric). It's recommended Tracking classes already have three built-in properties:
to use these properties first.
- `label` (string)
- `property` (string)
- `value`(numeric)
The arbitrary naming and typing of the these three properties is due to constraints from the data extraction process.
It's recommended to use these properties first, even if their name does not match with the data you want to track.
This recommendation is particularly important if you want to leverage these attributes as
[metric filters](metric_definition_guide.md#filters). You can further describe what is the actual data being tracked
by using the `description` property in the YAML definition of the event. For an example, see
[`create_ci_internal_pipeline.yml`](https://gitlab.com/gitlab-org/gitlab/-/blob/537ea367dab731e886e6040d8399c430fdb67ab7/config/events/create_ci_internal_pipeline.yml):
```ruby
additional_properties:
label:
description: The source of the pipeline, e.g. a push, a schedule or similar.
property:
description: The source of the config, e.g. the repository, auto_devops or similar.
```
Additional properties are passed by including the `additional_properties` hash in the `#track_event` call: Additional properties are passed by including the `additional_properties` hash in the `#track_event` call:
...@@ -88,8 +106,8 @@ track_internal_event( ...@@ -88,8 +106,8 @@ track_internal_event(
"create_ci_build", "create_ci_build",
user: user, user: user,
additional_properties: { additional_properties: {
label: 'scheduled', label: source, # The label is tracking the source of the pipeline
value: 20 property: config_source # The property is tracking the source of the configuration
} }
) )
``` ```
...@@ -100,10 +118,9 @@ If you need to pass more than three additional properties, you can use the `addi ...@@ -100,10 +118,9 @@ If you need to pass more than three additional properties, you can use the `addi
track_internal_event( track_internal_event(
"code_suggestion_accepted", "code_suggestion_accepted",
user: user, user: user,
additional_properties: { label: editor_name,
label: 'vsc', property: suggestion_type,
property: 'automatic', value: suggestion_shown_duration
value: 200,
lang: 'ruby', lang: 'ruby',
custom_key: 'custom_value' custom_key: 'custom_value'
} }
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册