mirror of
https://github.com/supabase/supabase.git
synced 2026-10-09 03:15:06 +03:00
## Context Just extracting the fixes which I think are applicable from this [PR](https://github.com/supabase/supabase/pull/47695) Main files are - `apps/studio/hooks/analytics/useLogsQuery.tsx` - `packages/common/auth.tsx` - `packages/common/feature-flags.tsx` ## Changes involved - Adjust `useLogsQuery` to accept an object as prop, rather than 4 individual params - This one doesn't address any Sentry issues, but is just a improvement to the function's API imo, more readable - Adjust how user email is retrieved in `feature-flags` - Related Sentry issue [here](https://supabase.sentry.io/issues/7592718607/?project=5459134) - The error is a bit vague, but Claude's attempt to fix looks alright in general IMO - Minimally verified that feature flags are loading as expected still <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved log-related screens and queries for more reliable loading and filtering across the app. * Fixed profile and account data handling so identity details are retrieved more consistently. * Improved authentication handling to better recognize missing user data and keep the app stable. * Updated feature flag personalization to use more accurate account information. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
38 lines
1.3 KiB
TypeScript
38 lines
1.3 KiB
TypeScript
import type { UserIdentity } from '@supabase/supabase-js'
|
|
import { useQuery } from '@tanstack/react-query'
|
|
|
|
import { profileKeys } from './keys'
|
|
import { auth } from '@/lib/gotrue'
|
|
import { UseCustomQueryOptions } from '@/types'
|
|
|
|
export async function getProfileIdentities() {
|
|
// getUser() is used instead of getSession() here because the client is configured
|
|
// with a `userStorage` option, under which getSession() can return a session whose
|
|
// `user` is a placeholder that throws when any of its properties are read.
|
|
const { error, data } = await auth.getUser()
|
|
|
|
if (error) throw error
|
|
if (!data.user) throw new Error('User not found with getUser()')
|
|
|
|
const { identities = [], new_email, email_change_sent_at } = data.user
|
|
return { identities, new_email, email_change_sent_at }
|
|
}
|
|
|
|
type ProfileIdentitiesData = {
|
|
identities: (UserIdentity & { email?: string })[]
|
|
new_email?: string
|
|
email_change_sent_at?: string
|
|
}
|
|
type ProfileIdentitiesError = any
|
|
|
|
export const useProfileIdentitiesQuery = <TData = ProfileIdentitiesData>({
|
|
enabled = true,
|
|
...options
|
|
}: UseCustomQueryOptions<ProfileIdentitiesData, ProfileIdentitiesError, TData> = {}) => {
|
|
return useQuery<ProfileIdentitiesData, ProfileIdentitiesError, TData>({
|
|
queryKey: profileKeys.identities(),
|
|
queryFn: () => getProfileIdentities(),
|
|
...options,
|
|
})
|
|
}
|