Tracking namespace that empowered a user to use a feature
Problem
For every analytics event that happens we're trying to track the namespace/project of where the event happens, for example a merge request is merged within a certain namespace. This works since most features are enabled or disabled on a namespace basis. This means the namespace is a property of the event. A single user can trigger events in many different namespaces. The information is collected in our Standard Context
Starting with Code-Suggestions / Duo Pro this no longer holds true, since having code-suggestions enabled allows you to use it everywhere. So for analytics purposes we want to know which namespaces the user belongs to which allow him to use code-suggestions, e.g. to analyze adoption of code suggestions for a specific customer. It's possible that multiple namespaces award a user with that capability.
In case of this issue for Code Suggestions (https://gitlab.com/gitlab-org/modelops/applied-ml/code-suggestions/ai-assist/-/issues/340), we attached the information as <code data-sourcepos="6:170-6:194">gitlab_saas_namespace_ids</code>, but this is a context specific to Code Suggestions, but we also want to collect this information in other cases such as Duo Chat (see https://gitlab.com/gitlab-org/gitlab/-/issues/452316) so we need a scalable solution.
Desired Outcome
Have a solution to capture the information of which namespaces allowed the user to use this feature for all events it's relevant for, not only code suggestions.
Proposed Solution
Add the field feature_enabled_by_namespace_ids
to Gitlab Standard Context to track, which namespaces enable the customer to use a feature in addition to the already existing namespace_id
field which tracks where the feature is being used. The fields should be made available as a property to pass in for an internal event like namespace
or project
are being passed in currently.
Example case
- User has access to namespaces
A
,B
andC
- User is has Duo Chat enabled for themselves through namespaces
A
andC
(e.g. because they are a contractor for the companies behind those two namespaces) - User is using Duo Chat in namespace
A
, standard context values are then:namespace_id: 'A'
feature_enabled_by_namespace_ids: ['A', 'C']
- User is using Duo Chat in namespace
B
, standard context values are then:namespace_id: 'B'
feature_enabled_by_namespace_ids: ['A', 'C']
Implementation steps
- Suggested standard context addition:
"feature_enabled_by_namespace_ids": {
"description": "List of namespaces that allow the user to use the tracked feature ",
"type": ["array", "null"],
"items": {
"type": "integer",
"minimum": 0,
"maximum": 2147483647
}
}
- Make sure the pseudonymization lambda does not pseudonymize this field and let's it through
- Add the field to the internal events tracking call and make it available just like passing in
namespace
orproject