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
Add redis.sadd("billed_teams", team_id) to clearACUCTeam for centralized tracking (#2602)
devin-ai-integration[bot]130baf5c4aab
diff --git a/apps/api/src/controllers/auth.ts b/apps/api/src/controllers/auth.tsindex a155ac3dd..0c30470d7 100644--- a/apps/api/src/controllers/auth.ts+++ b/apps/api/src/controllers/auth.ts@@ -14,6 +14,7 @@ import { logger } from "../lib/logger";import { redlock } from "../services/redlock";import { deleteKey, getValue } from "../services/redis";import { setValue } from "../services/redis";+import { getRedisConnection } from "../services/queue-service";import { validate } from "uuid";import * as Sentry from "@sentry/node";import { AuthCreditUsageChunk, AuthCreditUsageChunkFromTeam } from "./v1/types";@@ -206,7 +207,7 @@ export async function getACUC(if (retries === maxRetries) {throw new Error("Failed to retrieve authentication and credit usage data after 3 attempts: " +- JSON.stringify(error),+ JSON.stringify(error),);}@@ -239,8 +240,8 @@ export async function setCachedACUCTeam(| AuthCreditUsageChunkFromTeam| null| ((- acuc: AuthCreditUsageChunkFromTeam,- ) => AuthCreditUsageChunkFromTeam | null),+ acuc: AuthCreditUsageChunkFromTeam,+ ) => AuthCreditUsageChunkFromTeam | null),) {const cacheKeyACUC = `acuc_team_${team_id}_${is_extract ? "extract" : "scrape"}`;const redLockKey = `lock_${cacheKeyACUC}`;@@ -336,7 +337,7 @@ export async function getACUCTeam(if (retries === maxRetries) {throw new Error("Failed to retrieve authentication and credit usage data after 3 attempts: " +- JSON.stringify(error),+ JSON.stringify(error),);}@@ -384,6 +385,9 @@ export async function clearACUCTeam(team_id: string): Promise<void> {// Also clear the base cache keyawait deleteKey(`acuc_team_${team_id}`);++ // Add team to billed_teams set so tally gets updated too+ await getRedisConnection().sadd("billed_teams", team_id);}export async function authenticateUser(diff --git a/apps/api/src/services/billing/auto_charge.ts b/apps/api/src/services/billing/auto_charge.tsindex 0405347c9..a7d838cc2 100644--- a/apps/api/src/services/billing/auto_charge.ts+++ b/apps/api/src/services/billing/auto_charge.ts@@ -115,8 +115,8 @@ async function _autoChargeScale(chunk.price_associated_auto_recharge_price_id === undefined? "undefined": JSON.stringify(- chunk.price_associated_auto_recharge_price_id,- ),+ chunk.price_associated_auto_recharge_price_id,+ ),});return {success: false,@@ -269,13 +269,13 @@ async function _autoChargeScale(canceled_at: null,current_period_start: subscription.current_period_start? new Date(- subscription.current_period_start * 1000,- ).toISOString()+ subscription.current_period_start * 1000,+ ).toISOString(): null,current_period_end: subscription.current_period_end? new Date(- subscription.current_period_end * 1000,- ).toISOString()+ subscription.current_period_end * 1000,+ ).toISOString(): null,created: subscription.created? new Date(subscription.created * 1000).toISOString()