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
Remove AUTUMN_REQUEST_TRACK_EXPERIMENT gating (#3849)
firecrawl-spring[bot]af3db24e0bf2
diff --git a/apps/api/src/config.ts b/apps/api/src/config.tsindex 88105b218..45dac64a6 100644--- a/apps/api/src/config.ts+++ b/apps/api/src/config.ts@@ -73,8 +73,6 @@ const configSchema = z.object({LLAMAPARSE_API_KEY: z.string().optional(),STRIPE_SECRET_KEY: z.string().optional(),AUTUMN_SECRET_KEY: z.string().optional(),- AUTUMN_REQUEST_TRACK_EXPERIMENT: z.string().optional(),- AUTUMN_REQUEST_TRACK_EXPERIMENT_PERCENT: z.coerce.number().default(100),RESEND_API_KEY: z.string().optional(),PREVIEW_TOKEN: z.string().optional(),SEARCH_PREVIEW_TOKEN: z.string().optional(),diff --git a/apps/api/src/services/autumn/__tests__/autumn.service.test.ts b/apps/api/src/services/autumn/__tests__/autumn.service.test.tsindex 9162f3811..a3b6a24d1 100644--- a/apps/api/src/services/autumn/__tests__/autumn.service.test.ts+++ b/apps/api/src/services/autumn/__tests__/autumn.service.test.ts@@ -92,10 +92,7 @@ vi.mock("../../../db/connection", () => ({}));vi.mock("../../../config", () => ({- config: {- AUTUMN_REQUEST_TRACK_EXPERIMENT: undefined,- AUTUMN_REQUEST_TRACK_EXPERIMENT_PERCENT: 100,- },+ config: {},}));// Import AFTER mocks are wired up.@@ -104,10 +101,7 @@ import {BoundedMap,BoundedSet,featureIdForBillingEndpoint,- isAutumnRequestTrackEnabled,- orgBucket,} from "../autumn.service";-import { config } from "../../../config";// ---------------------------------------------------------------------------// Helpers@@ -129,8 +123,6 @@ beforeEach(() => {vi.clearAllMocks();state.autumnClientRef = mockAutumnClient;state.supabaseStubData = { data: { org_id: "org-1" }, error: null };- config.AUTUMN_REQUEST_TRACK_EXPERIMENT = undefined;- config.AUTUMN_REQUEST_TRACK_EXPERIMENT_PERCENT = 100;mockCheck.mockResolvedValue({allowed: true,customerId: "org-1",@@ -607,43 +599,3 @@ describe("featureIdForBillingEndpoint", () => {expect(featureIdForBillingEndpoint(undefined)).toBe("CREDITS");});});--// ----------------------------------------------------------------------------// experiment gating-// -----------------------------------------------------------------------------describe("orgBucket", () => {- it("is deterministic β same orgId always returns the same bucket", () => {- const id = "a1b2c3d4-e5f6-7890-abcd-ef1234567890";- expect(orgBucket(id)).toBe(orgBucket(id));- });-- it("returns a value in [0, 100)", () => {- const ids = [- "00000000-0000-0000-0000-000000000000",- "ffffffff-ffff-ffff-ffff-ffffffffffff",- "a1b2c3d4-e5f6-7890-abcd-ef1234567890",- ];- for (const id of ids) {- const b = orgBucket(id);- expect(b).toBeGreaterThanOrEqual(0);- expect(b).toBeLessThan(100);- }- });-- it("strips dashes and uses first 8 hex chars", () => {- // "a1b2c3d4" β parseInt("a1b2c3d4", 16) = 2712847316 β 2712847316 % 100 = 16- expect(orgBucket("a1b2c3d4-0000-0000-0000-000000000000")).toBe(16);- });-});--describe("isAutumnRequestTrackEnabled", () => {- it("returns false when request tracking flag is not 'true'", () => {- expect(isAutumnRequestTrackEnabled()).toBe(false);- });-- it("returns true when request tracking is enabled", () => {- config.AUTUMN_REQUEST_TRACK_EXPERIMENT = "true";- expect(isAutumnRequestTrackEnabled()).toBe(true);- });-});diff --git a/apps/api/src/services/autumn/autumn.service.ts b/apps/api/src/services/autumn/autumn.service.tsindex 54d1e51a0..f757f0462 100644--- a/apps/api/src/services/autumn/autumn.service.ts+++ b/apps/api/src/services/autumn/autumn.service.ts@@ -1,5 +1,4 @@import { randomUUID } from "crypto";-import { config } from "../../config";import { logger } from "../../lib/logger";import { eq } from "drizzle-orm";import { dbRr } from "../../db/connection";@@ -35,26 +34,6 @@ export function featureIdForBillingEndpoint(endpoint?: string): string {return endpoint === "search" ? SEARCH_CREDITS_FEATURE_ID : CREDITS_FEATURE_ID;}-/**- * Deterministic bucket for an org UUID.- *- * Takes the first 8 hex digits of the id (after stripping dashes) and maps- * them to an integer in [0, 100). The same orgId always lands in the same- * bucket so the experiment decision is stable across requests.- */-export function orgBucket(orgId: string): number {- const hex = orgId.replace(/-/g, "").slice(0, 8);- return parseInt(hex, 16) % 100;-}--export function isAutumnRequestTrackEnabled(orgId?: string): boolean {- if (config.AUTUMN_REQUEST_TRACK_EXPERIMENT !== "true") return false;- if (!orgId || config.AUTUMN_REQUEST_TRACK_EXPERIMENT_PERCENT >= 100) {- return true;- }- return orgBucket(orgId) < config.AUTUMN_REQUEST_TRACK_EXPERIMENT_PERCENT;-}-const AUTUMN_DEFAULT_PLAN_ID = "free";/*** Size-bounded Map with FIFO eviction. When the map is at capacity the oldest@@ -498,28 +477,17 @@ export class AutumnService {/*** Records a credit usage event directly in Autumn. Returns true on success.- *- * For request-scoped tracking the AUTUMN_REQUEST_TRACK_EXPERIMENT gate is- * evaluated using a stable bucket derived from the org UUID so the same- * org always gets the same answer for a given percent value.*/async trackCredits({teamId,value,properties,- requestScoped = false,featureId = CREDITS_FEATURE_ID,}: TrackCreditsParams): Promise<boolean> {- if (requestScoped && !isAutumnRequestTrackEnabled()) return false;if (!autumnClient) return false;if (this.isPreviewTeam(teamId)) return false;try {- if (requestScoped) {- const orgId = await this.resolveOrgId(teamId);- if (!isAutumnRequestTrackEnabled(orgId)) return false;- }-const customerId = await this.ensureTrackingContext(teamId);return await this.track({customerId,@@ -534,7 +502,6 @@ export class AutumnService {{teamId,value,- requestScoped,error,},);diff --git a/apps/api/src/services/autumn/types.ts b/apps/api/src/services/autumn/types.tsindex bd7c8e78a..e1d4c272f 100644--- a/apps/api/src/services/autumn/types.ts+++ b/apps/api/src/services/autumn/types.ts@@ -70,7 +70,6 @@ export type TrackCreditsParams = {teamId: string;value: number;properties?: Record<string, unknown>;- requestScoped?: boolean;featureId?: string;};diff --git a/apps/api/src/services/billing/__tests__/credit_billing.test.ts b/apps/api/src/services/billing/__tests__/credit_billing.test.tsindex 20ebb484b..0f5a34d50 100644--- a/apps/api/src/services/billing/__tests__/credit_billing.test.ts+++ b/apps/api/src/services/billing/__tests__/credit_billing.test.ts@@ -79,7 +79,7 @@ describe("billTeam", () => {jobId: "job-1",apiKeyId: 123,},- requestScoped: true,+ featureId: "SEARCH_CREDITS",});});@@ -100,6 +100,7 @@ describe("billTeam", () => {jobId: "job-1",apiKeyId: 123,},+ featureId: "SEARCH_CREDITS",});});diff --git a/apps/api/src/services/billing/credit_billing.ts b/apps/api/src/services/billing/credit_billing.tsindex 56391f67a..8c5414406 100644--- a/apps/api/src/services/billing/credit_billing.ts+++ b/apps/api/src/services/billing/credit_billing.ts@@ -39,7 +39,6 @@ export async function billTeam(teamId: team_id,value: credits,properties: autumnProperties,- requestScoped: true,featureId,});diff --git a/apps/api/src/services/worker/scrape-worker.ts b/apps/api/src/services/worker/scrape-worker.tsindex 3f8e9c4e0..5b5ff8b62 100644--- a/apps/api/src/services/worker/scrape-worker.ts+++ b/apps/api/src/services/worker/scrape-worker.ts@@ -154,7 +154,6 @@ async function billScrapeJob(teamId: job.data.team_id,value: creditsToBeBilled,properties: autumnProperties,- requestScoped: true,featureId,});const billingJobId = uuidv7();