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:
2026-06-02 06:23:24 +00:00
parent 7dfaba6e3d
commit fbddd2458e
+17 -4
View File
@@ -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;
}
});
}