Revert "Nick: log su usage"

This reverts commit 6567ef81f6ca6dfd5a92eafb04f4eed8d37e0a6c.
This commit is contained in:
Nicolas 2025-05-05 18:19:15 -03:00
parent 6567ef81f6
commit 17728379df
2 changed files with 0 additions and 48 deletions

View File

@ -5,7 +5,6 @@ import "dotenv/config";
import { logger } from "../../lib/logger";
import { configDotenv } from "dotenv";
import { saveJobToGCS } from "../../lib/gcs-jobs";
import { logStealthUsage } from "./temp-stealth-log";
configDotenv();
function cleanOfNull<T>(x: T): T {
@ -111,10 +110,6 @@ export async function logJob(job: FirecrawlJob, force: boolean = false) {
indexJob(job);
}
if (job.scrapeOptions?.proxy === "stealth" && job.team_id) {
logStealthUsage(job.team_id);
}
if (process.env.GCS_BUCKET_NAME) {
await saveJobToGCS(job);
}

View File

@ -1,43 +0,0 @@
import { cacheRedis } from "../../lib/cache";
import { logger } from "../../lib/logger";
import { supabase_service } from "../supabase";
export async function logStealthUsage(team_id: string) {
try {
let useCache = true;
if (!cacheRedis) {
useCache = false;
}
// Check Redis first
const redisKey = `stealth_usage:${team_id}`;
const exists = useCache ? await cacheRedis?.get(redisKey) : false;
if (exists) {
return;
}
// Check DB if not in Redis
const { data } = await supabase_service
.from("stealth_usage")
.select("team_id")
.eq("team_id", team_id);
if (!data?.length) {
// Insert into DB
const { error } = await supabase_service.from("stealth_usage").insert([
{
team_id,
},
]);
if (error) {
logger.error("Failed to log stealth usage", { error, team_id });
return;
}
}
// Cache in Redis for future lookups
await cacheRedis?.set(redisKey, "1", "EX", 60 * 60 * 24 * 10); // Cache for 10 days
} catch (err) {
logger.error("Error logging stealth usage", { error: err, team_id });
}
}