Event definitions: merge identifiers and additional properties
What does this MR do and why?
Implements dynamic extraction of additional properties from method parameters in
InternalEvents.track_event
Problem: Currently, developers must pass additional properties when tracking internal events which doesn't bring any value, its just internal tracking logic exposure.
Solution:
Introduces a mechanism that automatically extracts properties
from kwargs
based on the event definition's additional_properties
definition
Validation
- Enable the feature flag:
Feature.enable(:merge_additional_properties_for_snowplow)
- Test the extraction behavior:
Before - manual specification required
Gitlab::InternalEvents.track_event(
'user_created_project',
additional_properties: { label: 'enterprise', property: 'saas' },
user: user,
project: project
)
After - automatic extraction
Gitlab::InternalEvents.track_event(
'user_created_project',
user: user,
project: project,
label: 'enterprise', # Automatically extracted
property: 'saas' # Automatically extracted
)
- Run the specs:
bundle exec rspec spec/lib/gitlab/internal_events_spec.rb -e "dynamic additional_properties extraction"
Related to #544730 (closed)
Edited by Niko Belokolodov