Skip to content
This repository was archived by the owner on Sep 17, 2024. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions modules/analytics/db/schema.prisma
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")

}

model Event {
id String @db.Uuid @default(uuid()) @unique
timestamp DateTime @db.Timestamptz
name String
metadata Json?

// in the init migration, we add the timescale extension and call create_hypertable().

@@index(fields: [name, timestamp(sort: Desc)], map: "event_name_time_idx")
@@map("event")
}
11 changes: 11 additions & 0 deletions modules/analytics/db/schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Query, schema, uniqueIndex, index } from "./schema.gen.ts";

export const events = schema.table("events", {
id: Query.uuid("id").primaryKey().defaultRandom(),
timestamp: Query.timestamp("timestamp"),
name: Query.text("name"),
metadata: Query.jsonb("metadata")
}, (table) => ({
eventId: uniqueIndex("event_id").on(table.id),
eventNameTime: index("event_name_time").on(table.name, Query.desc(table.timestamp))
}));
23 changes: 13 additions & 10 deletions modules/analytics/module.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
{
"name": "Analytics",
"description": "Track and visualize user behavior data. (Coming mid-2024)",
"icon": "chart-line",
"tags": [
"game"
],
"authors": [],
"status": "coming_soon",
"scripts": {},
"errors": {}
"status": "stable",
"name": "Analytics",
"description": "Track and visualize user behavior data",
"icon": "chart-line",
"tags": [],
"authors": [
"rivet-gg",
"ABCxFF"
],
"scripts": {
},
"errors": {},
"dependencies": {}
}