File tree Expand file tree Collapse file tree
apps/web/app/api/analytics/track Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -82,8 +82,6 @@ export async function POST(request: NextRequest) {
8282 sanitizeString ( request . nextUrl . hostname ) ||
8383 "" ;
8484
85- const tenantId = body . orgId || ( hostname ? `domain:${ hostname } ` : "public" ) ;
86-
8785 const pathname = body . pathname ?? `/s/${ body . videoId } ` ;
8886
8987 await runPromise (
@@ -101,19 +99,24 @@ export async function POST(request: NextRequest) {
10199 return currentUser . id ;
102100 } ,
103101 } ) ;
104- if ( userId ) {
105- const [ videoRecord ] = yield * Effect . tryPromise ( ( ) =>
106- db ( )
107- . select ( { ownerId : videos . ownerId } )
108- . from ( videos )
109- . where ( eq ( videos . id , Video . VideoId . make ( body . videoId ) ) )
110- . limit ( 1 ) ,
111- ) . pipe ( Effect . orElseSucceed ( ( ) => [ ] as { ownerId : string } [ ] ) ) ;
112- if ( videoRecord && userId === videoRecord . ownerId ) {
113- return ;
114- }
102+
103+ const [ videoRecord ] = yield * Effect . tryPromise ( ( ) =>
104+ db ( )
105+ . select ( { ownerId : videos . ownerId } )
106+ . from ( videos )
107+ . where ( eq ( videos . id , Video . VideoId . make ( body . videoId ) ) )
108+ . limit ( 1 ) ,
109+ ) . pipe ( Effect . orElseSucceed ( ( ) => [ ] as { ownerId : string } [ ] ) ) ;
110+
111+ if ( userId && videoRecord && userId === videoRecord . ownerId ) {
112+ return ;
115113 }
116114
115+ const tenantId =
116+ body . orgId ||
117+ videoRecord ?. ownerId ||
118+ ( hostname ? `domain:${ hostname } ` : "public" ) ;
119+
117120 const tinybird = yield * Tinybird ;
118121 yield * tinybird . appendEvents ( [
119122 {
You can’t perform that action at this time.
0 commit comments