Create custom event schemas table for new projects
Problem to solve
Users would like to be able to create their own custom events, and view these on their analytics dashboards. The problem is that right now we don't provide an easy way to do that. We can support event names through manually created YAML schemas, but nothing advanced.
We have already implemented a similar system for funnels: https://gitlab.com/gitlab-org/analytics-section/analytics-configurator/-/issues/30+.
Proposed solution
We should create a new configurator endpoint which accepts custom event definitions submitted from .com (configurator is already .com-only access) and stores these definitions in the Clickhouse database. Cube will then retrieve these definitions from Clickhouse directly.
See the parent epic for the overarching plan.
This issue is only related to creating the clickhouse tables for new projects during project setup.
Table structure
The proposed table structure would look something like:
custom_event_schemas
| Field name | Field type | Required |
|---|---|---|
name |
String |
true |
title |
String |
false |
description |
String |
false |
props |
string |
true |
created_at |
DateTime64(3, 'GMT') |
true |
With the primary key of PRIMARY KEY name.
CREATE TABLE custom_event_schemas
(
name String,
title String,
description String,
props String # A JSON string,
created_at DateTime64(3, 'GMT')
)
ENGINE = MergeTree
PRIMARY KEY name;
Having the created_at and gives us information for debugging and auditing purposes. I've opted for using the updated_atname as the primary key, but we could also require the user to define an ID instead.
Implementation plan
In analytics-manager
- Add a new
sqlquery to createcustom_event_schemastable and call this query in theSetupProject