Skip to content

Commit ff5a940

Browse files
authored
Make orgId nullable (#113)
1 parent 45d7565 commit ff5a940

File tree

5 files changed

+10
-3
lines changed

5 files changed

+10
-3
lines changed

.github/workflows/CI.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,6 @@ jobs:
106106
run: pnpm install
107107
- name: Migrate production database
108108
run: npx drizzle-kit migrate
109-
working-directory: apps/db
109+
working-directory: packages/db
110110
env:
111111
DATABASE_URL: ${{ secrets.PRODUCTION_DATABASE_URL }}

apps/web/src/actions/analytics/events.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ type Table = 'events' | 'messages';
2121

2222
type AnalyticsEvent = {
2323
id: string;
24-
orgId: string;
24+
orgId: string | null;
2525
userId: string;
2626
timestamp: number;
2727
event: RooCodeTelemetryEvent;
@@ -36,6 +36,7 @@ export const captureEvent = async ({ event, ...rest }: AnalyticsEvent) => {
3636
table = 'messages';
3737
const { taskId, mode, message } = event.properties;
3838
const { ts, type, ask, say, text, reasoning, partial } = message;
39+
3940
value = {
4041
...rest,
4142
taskId,
@@ -48,6 +49,7 @@ export const captureEvent = async ({ event, ...rest }: AnalyticsEvent) => {
4849
reasoning,
4950
partial,
5051
};
52+
5153
break;
5254
}
5355
default: {
@@ -95,10 +97,12 @@ export const getUsage = async ({
9597
}
9698

9799
const userFilter = effectiveUserId ? 'AND userId = {userId: String}' : '';
100+
98101
const queryParams: Record<string, string | number> = {
99102
orgId: orgId!,
100103
timePeriod,
101104
};
105+
102106
if (effectiveUserId) {
103107
queryParams.userId = effectiveUserId;
104108
}

apps/web/src/actions/analytics/messages.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { analytics } from '@/lib/server';
1010

1111
const messageSchema = z.object({
1212
id: z.string(),
13-
orgId: z.string(),
13+
orgId: z.string().nullable(),
1414
userId: z.string(),
1515
taskId: z.string(),
1616
mode: z.string().nullable(),

packages/db/clickhouse/events.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,5 @@ CREATE TABLE default.events
3232
ENGINE = ReplicatedMergeTree('/clickhouse/tables/{uuid}/{shard}', '{replica}')
3333
ORDER BY (id, type, timestamp)
3434
SETTINGS index_granularity = 8192;
35+
36+
ALTER TABLE default.events MODIFY COLUMN `orgId` Nullable(String);

packages/db/clickhouse/messages.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ ORDER BY (id, timestamp)
1818
SETTINGS index_granularity = 8192;
1919

2020
ALTER TABLE default.messages ADD COLUMN mode Nullable(String);
21+
ALTER TABLE default.messages MODIFY COLUMN `orgId` Nullable(String);

0 commit comments

Comments
 (0)