mirror of
https://github.com/supabase/supabase.git
synced 2026-10-07 02:15:05 +03:00
Offshoot from https://github.com/supabase/supabase/pull/47743. [Linear issue](https://linear.app/supabase/issue/FE-3939/add-user-logs-filter-to-the-logs-page) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added a `user` filter to Unified Logs with a user picker (email or ID). * Added “View user logs” actions from the Users table to jump to Unified Logs. * **Bug Fixes** * Updated Unified Logs searching so default log-type restrictions no longer block user-attributed results. * **UI Updates** * Unified Logs filter bar and reset behavior now include clearing the user filter. * Improved empty-state messaging when the selected user filter isn’t supported. * Refreshed highlighted styling in command list items. * **Tests** * Expanded coverage for user filter configuration and query edge cases. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: kemal.earth <606977+kemaldotearth@users.noreply.github.com> Co-authored-by: kemal <hello@kemal.earth> Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
45 lines
1.3 KiB
TypeScript
45 lines
1.3 KiB
TypeScript
import { getPaginatedUsersSQL } from '@supabase/pg-meta'
|
|
|
|
import { authKeys } from '@/data/auth/keys'
|
|
import { getQueryClient } from '@/data/query-client'
|
|
import { executeSql } from '@/data/sql/execute-sql-mutation'
|
|
|
|
export interface JourneyUser {
|
|
id: string
|
|
email: string | null
|
|
createdAt: string | null
|
|
lastSignInAt: string | null
|
|
}
|
|
|
|
export async function searchAuthUsers(
|
|
projectRef: string,
|
|
connectionString: string | null,
|
|
keywords: string,
|
|
signal?: AbortSignal
|
|
): Promise<JourneyUser[]> {
|
|
const queryClient = getQueryClient()
|
|
const result = await queryClient.fetchQuery<
|
|
{ id: string; email: string | null; created_at: string; last_sign_in_at: string | null }[]
|
|
>({
|
|
// eslint-disable-next-line @tanstack/query/exhaustive-deps
|
|
queryKey: authKeys.usersSearch(projectRef, keywords),
|
|
queryFn: () => {
|
|
const sql = getPaginatedUsersSQL({
|
|
keywords,
|
|
limit: 20,
|
|
sort: 'id',
|
|
order: 'asc',
|
|
})
|
|
return executeSql<
|
|
{ id: string; email: string | null; created_at: string; last_sign_in_at: string | null }[]
|
|
>({ projectRef, connectionString, sql }, signal).then((res) => res.result)
|
|
},
|
|
})
|
|
return result.map((row) => ({
|
|
id: row.id,
|
|
email: row.email,
|
|
createdAt: row.created_at,
|
|
lastSignInAt: row.last_sign_in_at,
|
|
}))
|
|
}
|