48 lines
1.4 KiB
Go
48 lines
1.4 KiB
Go
// Package model defines domain types passed between layers.
|
|
package model
|
|
|
|
import "time"
|
|
|
|
// EventTable enumerates the four ClickHouse event tables written by
|
|
// cdp-ingestion. Used to whitelist `events` queries so we never interpolate
|
|
// an untrusted table name into a template.
|
|
type EventTable string
|
|
|
|
const (
|
|
EventTableTrack EventTable = "events_track"
|
|
EventTableIdentify EventTable = "events_identify"
|
|
EventTablePage EventTable = "events_page"
|
|
EventTableGroup EventTable = "events_group"
|
|
)
|
|
|
|
func (t EventTable) Valid() bool {
|
|
switch t {
|
|
case EventTableTrack, EventTableIdentify, EventTablePage, EventTableGroup:
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
// EventQuery is the parsed filter passed to repo.QueryEvents.
|
|
type EventQuery struct {
|
|
WorkspaceID string
|
|
Table EventTable
|
|
From time.Time
|
|
To time.Time
|
|
UserID string // optional
|
|
AnonymousID string // optional
|
|
EventName string // optional, only meaningful when Table == events_track
|
|
Limit int
|
|
Offset int
|
|
}
|
|
|
|
// QueryResult is a generic columns+rows envelope returned by Query API endpoints.
|
|
type QueryResult struct {
|
|
Columns []string `json:"columns"`
|
|
Rows [][]any `json:"rows"`
|
|
RowCount int `json:"row_count"`
|
|
DurationMS int64 `json:"duration_ms"`
|
|
CacheHit bool `json:"cache_hit"`
|
|
Meta map[string]any `json:"meta,omitempty"`
|
|
}
|