Add custom context to package Snowplow tracking
requested to merge 371801-fix-existing-snowplow-events-adapted-from-redis-metrics-to-conform-to-a-new-standard-general-2 into master
What does this MR do and why?
Add custom context to Snowplow event according to the new schema
Screenshots or screen recordings
How to set up and validate locally
[1] pry(main)> scope = 'npm_package'
=> "npm_package"
[2] pry(main)> event_name = "i_package_#{scope}_user"
=> "i_package_npm_package_user"
[3] pry(main)> category = 'sample_cat'
=> "sample_cat"
[4] pry(main)> action = 'push'
=> "push"
[6] pry(main)> project = Project.first
=> #<Project id:1 gitlab-org/gitlab-test>>
[7] pry(main)> namespace = project.namespace
=> #<Group id:22 @gitlab-org>
[8] pry(main)> args = {namespace: namespace}
=> {:namespace=>#<Group id:22 @gitlab-org>}
[9] pry(main)> ::Gitlab::Tracking.event(
category,
action.to_s,
label: 'redis_hll_counters.user_packages.user_packages_total_unique_counts_monthly',
context: [Gitlab::Tracking::ServicePingContext.new(data_source: :redis_hll, event: event_name).to_context],
POST http://localhost:9091/micro/good
Content-Type: application/json
{
"contexts": [
"iglu:com.gitlab/gitlab_service_ping/jsonschema/1-0-0"
], "limit": 1
}
Verify the response contains
...
"schema": "iglu:com.gitlab/gitlab_service_ping/jsonschema/1-0-0",
"data": {
"data_source": "redis_hll",
"event_name": "i_package_npm_package_user"
}
}
]
},
"se_category": "sample_cat",
"se_action": "push",
"se_label": "redis_hll_counters.user_packages.user_packages_total_unique_counts_monthly",
...
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #371801 (closed)
Edited by Niko Belokolodov