mirror of
https://git.mirrors.martin98.com/https://github.com/mendableai/firecrawl
synced 2025-08-05 13:40:40 +08:00
Nick: fixed .sort coupons and sentry to withAuth
This commit is contained in:
parent
7561fd279f
commit
3072d4a333
@ -1,5 +1,6 @@
|
|||||||
import { AuthResponse } from "../../src/types";
|
import { AuthResponse } from "../../src/types";
|
||||||
import { Logger } from "./logger";
|
import { Logger } from "./logger";
|
||||||
|
import * as Sentry from "@sentry/node";
|
||||||
|
|
||||||
let warningCount = 0;
|
let warningCount = 0;
|
||||||
|
|
||||||
@ -18,6 +19,7 @@ export function withAuth<T extends AuthResponse, U extends any[]>(
|
|||||||
try {
|
try {
|
||||||
return await originalFunction(...args);
|
return await originalFunction(...args);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
Sentry.captureException(error);
|
||||||
Logger.error(`Error in withAuth function: ${error}`);
|
Logger.error(`Error in withAuth function: ${error}`);
|
||||||
return { success: false, error: error.message } as T;
|
return { success: false, error: error.message } as T;
|
||||||
}
|
}
|
||||||
|
@ -40,14 +40,15 @@ export async function supaBillTeam(team_id: string, credits: number) {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
let couponCredits = 0;
|
let couponCredits = 0;
|
||||||
|
let sortedCoupons = [];
|
||||||
|
|
||||||
if (coupons && coupons.length > 0) {
|
if (coupons && coupons.length > 0) {
|
||||||
couponCredits = coupons.reduce(
|
couponCredits = coupons.reduce(
|
||||||
(total, coupon) => total + coupon.credits,
|
(total, coupon) => total + coupon.credits,
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
|
sortedCoupons = [...coupons].sort((a, b) => b.credits - a.credits);
|
||||||
}
|
}
|
||||||
|
|
||||||
let sortedCoupons = coupons.sort((a, b) => b.credits - a.credits);
|
|
||||||
// using coupon credits:
|
// using coupon credits:
|
||||||
if (couponCredits > 0) {
|
if (couponCredits > 0) {
|
||||||
// if there is no subscription and they have enough coupon credits
|
// if there is no subscription and they have enough coupon credits
|
||||||
|
Loading…
x
Reference in New Issue
Block a user