Create new configurator endpoint for custom event schemas
After the custom_event_schemas tables are created for new and existing projects as part of #9 (closed) and #10 (closed), respectively, an endpoint to save custom events should be added.
Endpoint requirements
The endpoint should accept a JSON payload which contains:
- The project ID(s) which these custom events should be stored against (so we can get the correct project DB).
- Any array of custom events which contains:
- The custom events' definition:
- Custom event name
- Previous custom event name (if name is changed)
- Custom event title (optional)
- Custom event description (optional)
- Custom event props
- Prop key
- Prop type (options:
string,number,boolean,time) - Prop title (optional)
- Prop description (optional)
- The state of the custom event:
- created
- updated
- deleted
- If the custom event was updated, what the old custom event name was.
- The custom events' definition:
- The endpoint should then apply the correct
INSERT,ALTER,DELETESQL functions based upon the state of the funnel.
Proposed input body
{
"project_ids": ["gitlab_project_1", "gitlab_project_2"],
"custom_events": [
{
"name": "Custom event 1",
"title": "Overridden custom event title",
"description": "Custom event description",
"props": [
{
"key": "action",
"type": "string",
"title": "Overridden custom event property title",
"description": "Custom event property description"
}
],
"state": "created"
},
{
"name": "Custom event 2",
"previous_name": "Custom event second",
"props": [
{
"key": "action",
"type": "string",
"title": "Overridden custom event property title",
"description": "Custom event property description"
},
{
"key": "label",
"type": "string"
}
],
"state": "updated"
},
{
"name": "Custom event 3",
"state": "deleted"
}
]
}
This is based upon the assumption that the set-up would be the same as the current funnels system: https://gitlab.com/gitlab-org/analytics-section/analytics-configurator/-/issues/30+.
Implementation plan
In analytics-manager
- Add a new authorised route
/custom-events-schemas, In this endpoint- Validate presence of
nameandpropsfields. - Loop over
project_idsin the request, and for each project handle the custom event by- Creating a new record if the
stateis created - Deleting old record and creating a new one if the state is
updated - Deleting a record if the state is
deleted
- Creating a new record if the
- Validate presence of
Edited by Halil Coban