fix: remove incompatible startTransaction API call in sentry.ts
The Sentry Next.js SDK doesn't expose startTransaction at the module level in the same way. Replaced with Sentry.withScope wrapper for transaction tracing which is compatible with the installed SDK version.
This commit is contained in:
+17
-4
@@ -69,7 +69,20 @@ export const setUserContext = (userId: string, brandId?: string) => {
|
||||
});
|
||||
};
|
||||
|
||||
// Export for transaction tracing
|
||||
export const startTransaction = (name: string, op: string = "custom") => {
|
||||
return Sentry.startTransaction({ name, op });
|
||||
};
|
||||
// Export for transaction tracing - simplified wrapper
|
||||
export async function withTransaction<T>(
|
||||
name: string,
|
||||
op: string,
|
||||
fn: () => Promise<T>
|
||||
): Promise<T> {
|
||||
return Sentry.withScope(async (scope) => {
|
||||
scope.setTransactionName(name);
|
||||
try {
|
||||
const result = await fn();
|
||||
return result;
|
||||
} catch (error) {
|
||||
Sentry.captureException(error);
|
||||
throw error;
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user