-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
ref(core): Improve event mechanism
for supabase integration
#17286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ import { setHttpStatus, SPAN_STATUS_ERROR, SPAN_STATUS_OK, startSpan } from '../ | |
import type { IntegrationFn } from '../types-hoist/integration'; | ||
import { debug } from '../utils/debug-logger'; | ||
import { isPlainObject } from '../utils/is'; | ||
import { addExceptionMechanism } from '../utils/misc'; | ||
|
||
const AUTH_OPERATIONS_TO_INSTRUMENT = [ | ||
'reauthenticate', | ||
|
@@ -236,6 +237,7 @@ function instrumentAuthOperation(operation: AuthOperationFn, isAdmin = false): A | |
captureException(res.error, { | ||
mechanism: { | ||
handled: false, | ||
type: 'auto.db.supabase.auth', | ||
}, | ||
}); | ||
} else { | ||
|
@@ -252,6 +254,7 @@ function instrumentAuthOperation(operation: AuthOperationFn, isAdmin = false): A | |
captureException(err, { | ||
mechanism: { | ||
handled: false, | ||
type: 'auto.db.supabase.auth', | ||
}, | ||
}); | ||
|
||
|
@@ -408,18 +411,27 @@ function instrumentPostgRESTFilterBuilder(PostgRESTFilterBuilder: PostgRESTFilte | |
err.details = res.error.details; | ||
} | ||
|
||
const supabaseContext: Record<string, unknown> = {}; | ||
const supabaseContext: Record<string, any> = {}; | ||
if (queryItems.length) { | ||
supabaseContext.query = queryItems; | ||
} | ||
if (Object.keys(body).length) { | ||
supabaseContext.body = body; | ||
} | ||
|
||
captureException(err, { | ||
contexts: { | ||
supabase: supabaseContext, | ||
}, | ||
captureException(err, scope => { | ||
scope.addEventProcessor(e => { | ||
addExceptionMechanism(e, { | ||
handled: false, | ||
type: 'auto.db.supabase.postgres', | ||
}); | ||
|
||
return e; | ||
}); | ||
|
||
scope.setContext('supabase', supabaseContext); | ||
|
||
return scope; | ||
Lms24 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}); | ||
} | ||
|
||
|
@@ -448,6 +460,7 @@ function instrumentPostgRESTFilterBuilder(PostgRESTFilterBuilder: PostgRESTFilte | |
return res; | ||
}, | ||
(err: Error) => { | ||
// TODO: shouldn't we capture this error? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @onurtemizkan not sure if this is me missing something or if we should call There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, looks like this comes from the original implementation we ported: I don't see a reason why we should not capture this, though. |
||
if (span) { | ||
setHttpStatus(span, 500); | ||
span.end(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these types are one level more specific than the trace origin on the spans (
auto.db.supabase
). I think this is fine.