Skip to content
This repository has been archived by the owner on Sep 17, 2024. It is now read-only.

Commit

Permalink
Setup analytics module and schema
Browse files Browse the repository at this point in the history
  • Loading branch information
ABCxFF committed Aug 25, 2024
1 parent 4381160 commit ffc78c5
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 10 deletions.
16 changes: 16 additions & 0 deletions modules/analytics/db/migrations/20240813023547_init/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
-- Add timescale
CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;

-- CreateTable
CREATE TABLE "event" (
"id" UUID NOT NULL,
"timestamp" TIMESTAMPTZ NOT NULL,
"name" TEXT NOT NULL,
"metadata" JSONB
);

-- CreateIndex
CREATE UNIQUE INDEX "event_id_key" ON "event"("id");

-- CreateIndex
CREATE INDEX "event_name_time_idx" ON "event"("name", "timestamp" DESC);
3 changes: 3 additions & 0 deletions modules/analytics/db/migrations/migration_lock.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Please do not edit this file manually
# It should be added in your version-control system (i.e. Git)
provider = "postgresql"
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")
}
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": {}
}

0 comments on commit ffc78c5

Please sign in to comment.