55 clickhouseEventRepositoryV2 ,
66} from "./clickhouseEventRepositoryInstance.server" ;
77import { IEventRepository , TraceEventOptions } from "./eventRepository.types" ;
8- import { $replica , prisma } from "~/db.server" ;
8+ import { prisma } from "~/db.server" ;
99import { logger } from "~/services/logger.server" ;
1010import { FEATURE_FLAG , flags } from "../featureFlags.server" ;
1111import { getTaskEventStore } from "../taskEventStore.server" ;
@@ -24,9 +24,17 @@ export function resolveEventRepositoryForStore(store: string | undefined): IEven
2424 return eventRepository ;
2525}
2626
27+ export const EVENT_STORE_TYPES = {
28+ POSTGRES : "postgres" ,
29+ CLICKHOUSE : "clickhouse" ,
30+ CLICKHOUSE_V2 : "clickhouse_v2" ,
31+ } as const ;
32+
33+ export type EventStoreType = typeof EVENT_STORE_TYPES [ keyof typeof EVENT_STORE_TYPES ] ;
34+
2735export async function getConfiguredEventRepository (
2836 organizationId : string
29- ) : Promise < { repository : IEventRepository ; store : string } > {
37+ ) : Promise < { repository : IEventRepository ; store : EventStoreType } > {
3038 const organization = await prisma . organization . findFirst ( {
3139 select : {
3240 id : true ,
@@ -49,15 +57,15 @@ export async function getConfiguredEventRepository(
4957 ( organization . featureFlags as Record < string , unknown > | null ) ?? undefined
5058 ) ;
5159
52- if ( taskEventStore === "clickhouse_v2" ) {
53- return { repository : clickhouseEventRepositoryV2 , store : "clickhouse_v2" } ;
60+ if ( taskEventStore === EVENT_STORE_TYPES . CLICKHOUSE_V2 ) {
61+ return { repository : clickhouseEventRepositoryV2 , store : EVENT_STORE_TYPES . CLICKHOUSE_V2 } ;
5462 }
5563
56- if ( taskEventStore === "clickhouse" ) {
57- return { repository : clickhouseEventRepository , store : "clickhouse" } ;
64+ if ( taskEventStore === EVENT_STORE_TYPES . CLICKHOUSE ) {
65+ return { repository : clickhouseEventRepository , store : EVENT_STORE_TYPES . CLICKHOUSE } ;
5866 }
5967
60- return { repository : eventRepository , store : "postgres" } ;
68+ return { repository : eventRepository , store : EVENT_STORE_TYPES . POSTGRES } ;
6169}
6270
6371export async function getEventRepository (
0 commit comments