26 lines
674 B
JavaScript
26 lines
674 B
JavaScript
|
|
export const useErrorLogging = (resourceType) => {
|
|
const supabase = useSupabaseClient()
|
|
const toast = useToast()
|
|
const profileStore = useProfileStore()
|
|
|
|
const logError = async (error) => {
|
|
let errorData = {
|
|
message: error,
|
|
tenant: profileStore.currentTenant,
|
|
profile: profileStore.activeProfile.id
|
|
}
|
|
|
|
const {data:supabaseData,error:supabaseError} = await supabase.from("errors").insert(errorData).select().single()
|
|
|
|
if(supabaseError) {
|
|
console.error(supabaseError)
|
|
} else if(supabaseData) {
|
|
return supabaseData.id
|
|
}
|
|
|
|
}
|
|
|
|
return { logError}
|
|
}
|