Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. π₯
TypeScript aiai-agentsai-crawlerai-scrapingai-searchcrawlerdata-extractionhtml-to-markdownllmmarkdownscraperscrapingweb-crawlerweb-dataweb-data-extractionweb-scraperweb-scrapingweb-searchwebscraping
refactor(billing): de-thread ACUC sub_id from the billing-attribution path (#4013)
firecrawl-spring[bot]3d0cfac9a8d7
diff --git a/apps/api/src/controllers/v0/search.ts b/apps/api/src/controllers/v0/search.tsindex 5493aef29..19463249b 100644--- a/apps/api/src/controllers/v0/search.ts+++ b/apps/api/src/controllers/v0/search.ts@@ -33,7 +33,6 @@ async function searchHelper(jobId: string,req: Request,team_id: string,- subscription_id: string | null | undefined,crawlerOptions: any,pageOptions: PageOptions,searchOptions: SearchOptions,@@ -87,7 +86,6 @@ async function searchHelper(const searchCredits = Math.ceil(res.length / 10) * 2;billTeam(team_id,- subscription_id,searchCredits,api_key_id,{ endpoint: "search", jobId },@@ -267,7 +265,6 @@ export async function searchController(req: Request, res: Response) {jobId,req,team_id,- chunk?.sub_id,crawlerOptions,pageOptions,searchOptions,diff --git a/apps/api/src/controllers/v1/batch-scrape.ts b/apps/api/src/controllers/v1/batch-scrape.tsindex 599ca9f01..8e5d4750a 100644--- a/apps/api/src/controllers/v1/batch-scrape.ts+++ b/apps/api/src/controllers/v1/batch-scrape.ts@@ -173,7 +173,6 @@ export async function batchScrapeController(if (threatScanCredits > 0) {billTeam(req.auth.team_id,- req.acuc?.sub_id ?? undefined,threatScanCredits,req.acuc?.api_key_id ?? null,{ endpoint: "batch_scrape", jobId: id },diff --git a/apps/api/src/controllers/v1/crawl.ts b/apps/api/src/controllers/v1/crawl.tsindex 545943ddb..fd730e57f 100644--- a/apps/api/src/controllers/v1/crawl.ts+++ b/apps/api/src/controllers/v1/crawl.ts@@ -80,7 +80,6 @@ export async function crawlController(if (threatScanCredits > 0) {billTeam(req.auth.team_id,- req.acuc?.sub_id ?? undefined,threatScanCredits,req.acuc?.api_key_id ?? null,{ endpoint: "crawl" },diff --git a/apps/api/src/controllers/v1/extract.ts b/apps/api/src/controllers/v1/extract.tsindex b432706cc..c25beebee 100644--- a/apps/api/src/controllers/v1/extract.ts+++ b/apps/api/src/controllers/v1/extract.ts@@ -67,7 +67,6 @@ async function oldExtract(result = await performExtraction_F0(extractId, {request,teamId: req.auth.team_id,- subId: req.acuc?.sub_id ?? undefined,apiKeyId: req.acuc?.api_key_id ?? null,});@@ -171,7 +170,6 @@ export async function extractController(if (threatScanCredits > 0) {billTeam(req.auth.team_id,- req.acuc?.sub_id ?? undefined,threatScanCredits,req.acuc?.api_key_id ?? null,{ endpoint: "extract" },diff --git a/apps/api/src/controllers/v1/fireclaw.ts b/apps/api/src/controllers/v1/fireclaw.tsindex b7404fbaf..0f2bdbf3b 100644--- a/apps/api/src/controllers/v1/fireclaw.ts+++ b/apps/api/src/controllers/v1/fireclaw.ts@@ -66,7 +66,6 @@ export async function fireclawController(try {await billTeam(req.auth.team_id,- req.acuc?.sub_id ?? undefined,totalCredits,req.acuc?.api_key_id ?? null,{ endpoint: "fireclaw" },diff --git a/apps/api/src/controllers/v1/map.ts b/apps/api/src/controllers/v1/map.tsindex 35aefb53d..052d88f0b 100644--- a/apps/api/src/controllers/v1/map.ts+++ b/apps/api/src/controllers/v1/map.ts@@ -503,13 +503,10 @@ export async function mapController(// Bill the teamconst creditsToBill = 1 + threatScanCredits;- billTeam(- req.auth.team_id,- req.acuc?.sub_id,- creditsToBill,- req.acuc?.api_key_id ?? null,- { endpoint: "map", jobId: mapId },- ).catch(error => {+ billTeam(req.auth.team_id, creditsToBill, req.acuc?.api_key_id ?? null, {+ endpoint: "map",+ jobId: mapId,+ }).catch(error => {logger.error(`Failed to bill team ${req.auth.team_id} for ${creditsToBill} credit(s): ${error}`,);diff --git a/apps/api/src/controllers/v1/search.ts b/apps/api/src/controllers/v1/search.tsindex 80d4e1d19..58d13a271 100644--- a/apps/api/src/controllers/v1/search.ts+++ b/apps/api/src/controllers/v1/search.ts@@ -279,7 +279,6 @@ export async function searchController(if (!isSearchPreview) {billTeam(req.auth.team_id,- req.acuc?.sub_id ?? undefined,result.searchCredits,req.acuc?.api_key_id ?? null,{ endpoint: "search", jobId },diff --git a/apps/api/src/controllers/v2/agent.ts b/apps/api/src/controllers/v2/agent.tsindex 83f17c0a0..b8ff9ca88 100644--- a/apps/api/src/controllers/v2/agent.ts+++ b/apps/api/src/controllers/v2/agent.ts@@ -87,7 +87,6 @@ export async function agentController(if (threatScanCredits > 0) {billTeam(req.auth.team_id,- req.acuc?.sub_id ?? undefined,threatScanCredits,req.acuc?.api_key_id ?? null,{ endpoint: "agent", jobId: agentId },diff --git a/apps/api/src/controllers/v2/batch-scrape.ts b/apps/api/src/controllers/v2/batch-scrape.tsindex 687b2ded2..7228d6921 100644--- a/apps/api/src/controllers/v2/batch-scrape.ts+++ b/apps/api/src/controllers/v2/batch-scrape.ts@@ -201,7 +201,6 @@ export async function batchScrapeController() {billTeam(req.auth.team_id,- req.acuc?.sub_id ?? undefined,threatScanCredits,req.acuc?.api_key_id ?? null,billing,diff --git a/apps/api/src/controllers/v2/browser.ts b/apps/api/src/controllers/v2/browser.tsindex 0002a8d38..efa1404f0 100644--- a/apps/api/src/controllers/v2/browser.ts+++ b/apps/api/src/controllers/v2/browser.ts@@ -608,13 +608,10 @@ export async function browserDeleteController(});});- billTeam(- req.auth.team_id,- req.acuc?.sub_id ?? undefined,- creditsBilled,- req.acuc?.api_key_id ?? null,- { endpoint: usedPrompt ? "interact" : "browser", jobId: session.id },- ).catch(error => {+ billTeam(req.auth.team_id, creditsBilled, req.acuc?.api_key_id ?? null, {+ endpoint: usedPrompt ? "interact" : "browser",+ jobId: session.id,+ }).catch(error => {logger.error("Failed to bill team for browser session", {error,creditsBilled,@@ -754,7 +751,6 @@ export async function browserWebhookDestroyedController(billTeam(session.team_id,- undefined, // subscription_id β billTeam will look it upcreditsBilled,null, // api_key_id not available in webhook context{ endpoint: usedPrompt ? "interact" : "browser", jobId: session.id },diff --git a/apps/api/src/controllers/v2/crawl.ts b/apps/api/src/controllers/v2/crawl.tsindex 27f1b3c75..5fc1761ce 100644--- a/apps/api/src/controllers/v2/crawl.ts+++ b/apps/api/src/controllers/v2/crawl.ts@@ -84,7 +84,6 @@ export async function crawlController(if (threatScanCredits > 0) {billTeam(req.auth.team_id,- req.acuc?.sub_id ?? undefined,threatScanCredits,req.acuc?.api_key_id ?? null,{ endpoint: "crawl" },diff --git a/apps/api/src/controllers/v2/extract.ts b/apps/api/src/controllers/v2/extract.tsindex b1d536adc..3564cc7ec 100644--- a/apps/api/src/controllers/v2/extract.ts+++ b/apps/api/src/controllers/v2/extract.ts@@ -112,7 +112,6 @@ export async function extractController(if (threatScanCredits > 0) {billTeam(req.auth.team_id,- req.acuc?.sub_id ?? undefined,threatScanCredits,req.acuc?.api_key_id ?? null,{ endpoint: "extract", jobId: extractId },diff --git a/apps/api/src/controllers/v2/map.ts b/apps/api/src/controllers/v2/map.tsindex 7cbbe1761..b85681fb2 100644--- a/apps/api/src/controllers/v2/map.ts+++ b/apps/api/src/controllers/v2/map.ts@@ -100,13 +100,10 @@ export async function mapController(if (avgrabResults !== null) {const creditsCost = avgrabResults.length;- billTeam(- req.auth.team_id,- req.acuc?.sub_id ?? undefined,- creditsCost,- req.acuc?.api_key_id ?? null,- { endpoint: "map", jobId: mapId },- ).catch(error => {+ billTeam(req.auth.team_id, creditsCost, req.acuc?.api_key_id ?? null, {+ endpoint: "map",+ jobId: mapId,+ }).catch(error => {logger.error(`Failed to bill team ${req.auth.team_id} for ${creditsCost} credits: ${error}`,);@@ -228,13 +225,10 @@ export async function mapController(// Bill the teamconst creditsToBill = 1 + threatScanCredits;- billTeam(- req.auth.team_id,- req.acuc?.sub_id ?? undefined,- creditsToBill,- req.acuc?.api_key_id ?? null,- { endpoint: "map", jobId: mapId },- ).catch(error => {+ billTeam(req.auth.team_id, creditsToBill, req.acuc?.api_key_id ?? null, {+ endpoint: "map",+ jobId: mapId,+ }).catch(error => {logger.error("Failed to bill team for map credits", {teamId: req.auth.team_id,creditsToBill,diff --git a/apps/api/src/controllers/v2/research-proxy.ts b/apps/api/src/controllers/v2/research-proxy.tsindex 3eeeb7fe8..ca7a905ee 100644--- a/apps/api/src/controllers/v2/research-proxy.ts+++ b/apps/api/src/controllers/v2/research-proxy.ts@@ -320,7 +320,6 @@ function createResearchController(if (credits > 0) {billTeam(authedReq.auth.team_id,- authedReq.acuc?.sub_id ?? undefined,credits,authedReq.acuc?.api_key_id ?? null,{diff --git a/apps/api/src/controllers/v2/scrape-browser.ts b/apps/api/src/controllers/v2/scrape-browser.tsindex 867cc6c55..b702b5fbf 100644--- a/apps/api/src/controllers/v2/scrape-browser.ts+++ b/apps/api/src/controllers/v2/scrape-browser.ts@@ -474,13 +474,10 @@ export async function scrapeStopInteractiveBrowserController(});});- billTeam(- req.auth.team_id,- req.acuc?.sub_id ?? undefined,- creditsBilled,- req.acuc?.api_key_id ?? null,- { endpoint: "interact", jobId: session.id },- ).catch(error => {+ billTeam(req.auth.team_id, creditsBilled, req.acuc?.api_key_id ?? null, {+ endpoint: "interact",+ jobId: session.id,+ }).catch(error => {logger.error("Failed to bill team for interact session", {error,creditsBilled,diff --git a/apps/api/src/controllers/v2/search.ts b/apps/api/src/controllers/v2/search.tsindex b4ae9968e..a89d74e72 100644--- a/apps/api/src/controllers/v2/search.ts+++ b/apps/api/src/controllers/v2/search.ts@@ -238,14 +238,15 @@ export async function searchController(if (!isSearchPreview && shouldBill) {billTeam(req.auth.team_id,- req.acuc?.sub_id ?? undefined,result.searchCredits,req.acuc?.api_key_id ?? null,billing,).catch(error =>- logger.error(- `Failed to bill team ${req.acuc?.sub_id} for ${result.searchCredits} credits: ${error}`,- ),+ logger.error("Failed to bill team for search credits", {+ teamId: req.auth.team_id,+ searchCredits: result.searchCredits,+ error,+ }),);}diff --git a/apps/api/src/lib/deep-research/deep-research-service.ts b/apps/api/src/lib/deep-research/deep-research-service.tsindex 3c9ddadda..e42981f66 100644--- a/apps/api/src/lib/deep-research/deep-research-service.ts+++ b/apps/api/src/lib/deep-research/deep-research-service.ts@@ -25,7 +25,7 @@ export interface DeepResearchServiceOptions {export async function performDeepResearch(options: DeepResearchServiceOptions) {const costTracking = new CostTracking();- const { researchId, teamId, timeLimit, subId, maxUrls, apiKeyId } = options;+ const { researchId, teamId, timeLimit, maxUrls, apiKeyId } = options;const startTime = Date.now();let currentTopic = options.query;let urlsAnalyzed = 0;@@ -427,7 +427,6 @@ export async function performDeepResearch(options: DeepResearchServiceOptions) {// Bill team for usage based on URLs analyzedbillTeam(teamId,- subId,credits_billed,apiKeyId,{ endpoint: "deep_research", jobId: researchId },diff --git a/apps/api/src/lib/extract/extraction-service.ts b/apps/api/src/lib/extract/extraction-service.tsindex 79261ede3..b081704b1 100644--- a/apps/api/src/lib/extract/extraction-service.ts+++ b/apps/api/src/lib/extract/extraction-service.ts@@ -150,7 +150,6 @@ async function performExtraction(await billTeam(teamId,- subId,creditsToBill,apiKeyId,{ endpoint: "extract", jobId: extractId },@@ -666,7 +665,6 @@ async function performExtraction(});await billTeam(teamId,- subId,creditsToBill,apiKeyId,{ endpoint: "extract", jobId: extractId },@@ -778,7 +776,6 @@ async function performExtraction(});await billTeam(teamId,- subId,creditsToBill,apiKeyId,{ endpoint: "extract", jobId: extractId },@@ -806,7 +803,6 @@ async function performExtraction(const creditsToBill = Math.ceil(tokens_billed / 15);await billTeam(teamId,- subId,creditsToBill,apiKeyId,{ endpoint: "extract", jobId: extractId },@@ -998,7 +994,6 @@ async function performExtraction(// Bill team for usageawait billTeam(teamId,- subId,creditsToBill,apiKeyId,{ endpoint: "extract" },@@ -1066,7 +1061,6 @@ async function performExtraction(const creditsToBill = Math.ceil(tokens_billed / 15);await billTeam(teamId,- subId,creditsToBill,apiKeyId,{ endpoint: "extract" },diff --git a/apps/api/src/lib/extract/fire-0/extraction-service-f0.ts b/apps/api/src/lib/extract/fire-0/extraction-service-f0.tsindex aeb3224a1..3613903ff 100644--- a/apps/api/src/lib/extract/fire-0/extraction-service-f0.ts+++ b/apps/api/src/lib/extract/fire-0/extraction-service-f0.ts@@ -44,7 +44,6 @@ import { resolveThreatProtection } from "../../threat-protection/request";interface ExtractServiceOptions {request: ExtractRequest;teamId: string;- subId?: string;cacheMode?: "load" | "save" | "direct";cacheKey?: string;apiKeyId: number | null;@@ -78,7 +77,7 @@ export async function performExtraction_F0(extractId: string,options: ExtractServiceOptions,): Promise<ExtractResult> {- const { request, teamId, subId, apiKeyId } = options;+ const { request, teamId, apiKeyId } = options;const createdAt = options.createdAt? new Date(options.createdAt): new Date();@@ -869,7 +868,6 @@ export async function performExtraction_F0(// Bill team for usagebillTeam(teamId,- subId,creditsToBill,apiKeyId,{ endpoint: "extract", jobId: extractId },diff --git a/apps/api/src/lib/generate-llmstxt/generate-llmstxt-service.ts b/apps/api/src/lib/generate-llmstxt/generate-llmstxt-service.tsindex fc3ca92b7..46c61de90 100644--- a/apps/api/src/lib/generate-llmstxt/generate-llmstxt-service.ts+++ b/apps/api/src/lib/generate-llmstxt/generate-llmstxt-service.ts@@ -72,7 +72,6 @@ export async function performGenerateLlmsTxt(maxUrls = 100,showFullText,cache = true,- subId,apiKeyId,} = options;const startTime = Date.now();@@ -267,7 +266,13 @@ export async function performGenerateLlmsTxt(});// Bill team for usage- billTeam(teamId, subId, urls.length, apiKeyId, { endpoint: "llms_txt", jobId: generationId }, logger).catch(error => {+ billTeam(+ teamId,+ urls.length,+ apiKeyId,+ { endpoint: "llms_txt", jobId: generationId },+ logger,+ ).catch(error => {logger.error(`Failed to bill team ${teamId} for ${urls.length} urls`, {teamId,count: urls.length,diff --git a/apps/api/src/services/billing/__tests__/batch_billing.test.ts b/apps/api/src/services/billing/__tests__/batch_billing.test.tsindex d687f27d7..d207476f3 100644--- a/apps/api/src/services/billing/__tests__/batch_billing.test.ts+++ b/apps/api/src/services/billing/__tests__/batch_billing.test.ts@@ -121,7 +121,6 @@ import { processBillingBatch } from "../batch_billing";function makeOp(overrides: Record<string, unknown> = {}) {return JSON.stringify({team_id: "team-1",- subscription_id: "sub-1",credits: 10,billing: { endpoint: "extract" },is_extract: false,@@ -177,7 +176,6 @@ describe("processBillingBatch", () => {source: "processBillingBatch",endpoint: "extract",apiKeyId: 123,- subscriptionId: "sub-1",},featureId: "CREDITS",});@@ -197,7 +195,6 @@ describe("processBillingBatch", () => {source: "processBillingBatch",endpoint: "extract",apiKeyId: 123,- subscriptionId: "sub-1",},featureId: "CREDITS",});@@ -208,12 +205,10 @@ describe("processBillingBatch", () => {queue = [makeOp({team_id: "team-1",- subscription_id: "sub-1",autumnTrackInRequest: true,}),makeOp({team_id: "team-2",- subscription_id: "sub-2",autumnTrackInRequest: true,}),];@@ -231,7 +226,6 @@ describe("processBillingBatch", () => {source: "processBillingBatch",endpoint: "extract",apiKeyId: 123,- subscriptionId: "sub-1",},featureId: "CREDITS",});diff --git a/apps/api/src/services/billing/__tests__/credit_billing.test.ts b/apps/api/src/services/billing/__tests__/credit_billing.test.tsindex 0f5a34d50..8ba3ca9ab 100644--- a/apps/api/src/services/billing/__tests__/credit_billing.test.ts+++ b/apps/api/src/services/billing/__tests__/credit_billing.test.ts@@ -56,14 +56,13 @@ beforeEach(() => {describe("billTeam", () => {it("marks billing as already tracked when request tracking succeeds", async () => {- await billTeam("team-1", "sub-1", 3, 123, {+ await billTeam("team-1", 3, 123, {endpoint: "search",jobId: "job-1",});expect(queueBillingOperation).toHaveBeenCalledWith(["team-1",- "sub-1",3,123,{ endpoint: "search", jobId: "job-1" },@@ -86,7 +85,7 @@ describe("billTeam", () => {it("refunds Autumn when queueing fails after request tracking", async () => {queueBillingOperation.mockResolvedValueOnce({ success: false });- await billTeam("team-1", "sub-1", 3, 123, {+ await billTeam("team-1", 3, 123, {endpoint: "search",jobId: "job-1",});@@ -107,14 +106,13 @@ describe("billTeam", () => {it("leaves batch tracking enabled when request tracking is off", async () => {trackCredits.mockResolvedValueOnce(false);- await billTeam("team-1", "sub-1", 3, 123, {+ await billTeam("team-1", 3, 123, {endpoint: "search",jobId: "job-1",});expect(queueBillingOperation).toHaveBeenCalledWith(["team-1",- "sub-1",3,123,{ endpoint: "search", jobId: "job-1" },diff --git a/apps/api/src/services/billing/batch_billing.ts b/apps/api/src/services/billing/batch_billing.tsindex 7fb087d9b..d6a4f75df 100644--- a/apps/api/src/services/billing/batch_billing.ts+++ b/apps/api/src/services/billing/batch_billing.ts@@ -24,7 +24,6 @@ const LOCK_TIMEOUT = 30000; // 30 seconds lock timeout// Define interfaces for billing operationsinterface BillingOperation {team_id: string;- subscription_id: string | null;credits: number;billing?: BillingMetadata;endpoint?: BillingEndpoint;@@ -37,7 +36,6 @@ interface BillingOperation {// Grouped billing operations for batch processinginterface GroupedBillingOperation {team_id: string;- subscription_id: string | null;total_credits: number;billing: BillingMetadata;is_extract: boolean;@@ -79,7 +77,6 @@ async function refundRequestTrackedCredits(group: GroupedBillingOperation) {source: "processBillingBatch",...toAutumnBillingProperties(group.billing),apiKeyId: group.api_key_id,- subscriptionId: group.subscription_id,},featureId: featureIdForBillingEndpoint(group.billing.endpoint),});@@ -130,7 +127,7 @@ export async function processBillingBatch() {`π¦ Processing batch of ${operations.length} billing operations`,);- // Group operations by team_id and subscription_id+ // Group operations by team_id, endpoint, is_extract, and api_key_idconst groupedOperations = new Map<string, GroupedBillingOperation>();for (const op of operations) {@@ -139,12 +136,11 @@ export async function processBillingBatch() {op.billing ?? (op.endpoint ? { endpoint: op.endpoint } : undefined),isExtract: op.is_extract,});- const key = `${op.team_id}:${op.subscription_id ?? "null"}:${billing.endpoint}:${op.is_extract}:${op.api_key_id}`;+ const key = `${op.team_id}:${billing.endpoint}:${op.is_extract}:${op.api_key_id}`;if (!groupedOperations.has(key)) {groupedOperations.set(key, {team_id: op.team_id,- subscription_id: op.subscription_id,total_credits: 0,billing,is_extract: op.is_extract,@@ -164,7 +160,6 @@ export async function processBillingBatch() {`π Billing team ${group.team_id} for ${group.total_credits} credits`,{team_id: group.team_id,- subscription_id: group.subscription_id,total_credits: group.total_credits,billing: group.billing,operation_count: group.operations.length,@@ -185,7 +180,6 @@ export async function processBillingBatch() {message: "No DB, bypassed.",})(group.team_id,- group.subscription_id,group.total_credits,group.api_key_id,logger,@@ -263,7 +257,6 @@ export function startBillingBatchProcessing() {*/export async function queueBillingOperation(team_id: string,- subscription_id: string | null | undefined,credits: number,api_key_id: number | null,billing: BillingMetadata,@@ -278,7 +271,6 @@ export async function queueBillingOperation(logger.info(`Queueing billing operation for team ${team_id}`, {team_id,- subscription_id,credits,billing,is_extract,@@ -287,7 +279,6 @@ export async function queueBillingOperation(try {const operation: BillingOperation = {team_id,- subscription_id: subscription_id ?? null,credits,billing,is_extract,@@ -335,7 +326,6 @@ export async function queueBillingOperation(// Modified version of the billing function for batch operationsasync function supaBillTeam(team_id: string,- subscription_id: string | null | undefined,credits: number,api_key_id: number | null,__logger?: any,@@ -345,7 +335,6 @@ async function supaBillTeam(module: "credit_billing",method: "supaBillTeam",teamId: team_id,- subscriptionId: subscription_id,credits,});@@ -360,7 +349,7 @@ async function supaBillTeam(try {data = await billTeam7({team_id,- subscription_id: subscription_id ?? null,+ subscription_id: null,credits,api_key_id: api_key_id ?? null,is_extract,diff --git a/apps/api/src/services/billing/credit_billing.ts b/apps/api/src/services/billing/credit_billing.tsindex ec97a48bf..a08d527d4 100644--- a/apps/api/src/services/billing/credit_billing.ts+++ b/apps/api/src/services/billing/credit_billing.ts@@ -7,12 +7,8 @@ import {import { toAutumnBillingProperties, type BillingMetadata } from "./types";import type { Logger } from "winston";-/**- * If you do not know the subscription_id in the current context, pass subscription_id as undefined.- */export async function billTeam(team_id: string,- subscription_id: string | null | undefined,credits: number,api_key_id: number | null,billing: BillingMetadata,@@ -21,7 +17,6 @@ export async function billTeam(return withAuth(async (team_id: string,- subscription_id: string | null | undefined,credits: number,api_key_id: number | null,billing: BillingMetadata,@@ -42,7 +37,6 @@ export async function billTeam(const result = await queueBillingOperation(team_id,- subscription_id,credits,api_key_id,billing,@@ -62,5 +56,5 @@ export async function billTeam(return result;},{ success: true, message: "No DB, bypassed." },- )(team_id, subscription_id, credits, api_key_id, billing, logger);+ )(team_id, credits, api_key_id, billing, logger);}diff --git a/apps/api/src/services/extract-worker.ts b/apps/api/src/services/extract-worker.tsindex b2cdd1346..cb798e1c0 100644--- a/apps/api/src/services/extract-worker.ts+++ b/apps/api/src/services/extract-worker.ts@@ -59,7 +59,6 @@ const processExtractJob = async (result = await performExtraction_F0(data.extractId, {request: data.request,teamId: data.teamId,- subId: data.subId ?? undefined,apiKeyId: data.apiKeyId ?? null,});diff --git a/apps/api/src/services/indexing/index-worker.ts b/apps/api/src/services/indexing/index-worker.tsindex 3f85f3500..9656c9421 100644--- a/apps/api/src/services/indexing/index-worker.ts+++ b/apps/api/src/services/indexing/index-worker.ts@@ -82,7 +82,6 @@ const processBillingJobInternal = async (token: string, job: Job) => {// This is an individual billing operation that should be queued for batch processingconst {team_id,- subscription_id,credits,billing,endpoint,@@ -100,7 +99,6 @@ const processBillingJobInternal = async (token: string, job: Job) => {// Add to the REDIS batch queueawait queueBillingOperation(team_id,- subscription_id,credits,api_key_id ?? null,resolveBillingMetadata({diff --git a/apps/api/src/services/monitoring/runner.ts b/apps/api/src/services/monitoring/runner.tsindex 47b38d5d3..3b5849909 100644--- a/apps/api/src/services/monitoring/runner.ts+++ b/apps/api/src/services/monitoring/runner.ts@@ -364,7 +364,6 @@ async function billMonitorCheck(params: {"bill_team",{team_id: params.monitor.team_id,- subscription_id: undefined,credits: params.actualCredits,billing: { endpoint: "monitor", jobId: params.check.id },is_extract: false,diff --git a/apps/api/src/services/worker/scrape-worker.ts b/apps/api/src/services/worker/scrape-worker.tsindex a4d4bebc6..cac3b23f6 100644--- a/apps/api/src/services/worker/scrape-worker.ts+++ b/apps/api/src/services/worker/scrape-worker.ts@@ -185,7 +185,6 @@ async function billScrapeJob("bill_team",{team_id: job.data.team_id,- subscription_id: undefined,credits: creditsToBeBilled,billing,is_extract: false,@@ -250,18 +249,14 @@ function billThreatBlockedDiscoveries(blocked.map(x => x.decision),);if (threatScanCredits <= 0) return;- billTeam(- args.teamId,- undefined,- threatScanCredits,- args.apiKeyId,- args.billing,- ).catch(error => {- logger.error(- `Failed to bill team ${args.teamId} for ${threatScanCredits} threat scan credit(s)`,- { error },- );- });+ billTeam(args.teamId, threatScanCredits, args.apiKeyId, args.billing).catch(+ error => {+ logger.error(+ `Failed to bill team ${args.teamId} for ${threatScanCredits} threat scan credit(s)`,+ { error },+ );+ },+ );}async function processJob(job: NuQJob<ScrapeJobSingleUrls>) {