Skip to content

refactor(billing): remove request-scoped Autumn tracking (AUTUMN_REQUEST_TRACK_EXPERIMENT)#3314

Open
firecrawl-spring[bot] wants to merge 1 commit intoremove-autumn-bypass-org-idsfrom
remove-request-track-experiment
Open

refactor(billing): remove request-scoped Autumn tracking (AUTUMN_REQUEST_TRACK_EXPERIMENT)#3314
firecrawl-spring[bot] wants to merge 1 commit intoremove-autumn-bypass-org-idsfrom
remove-request-track-experiment

Conversation

@firecrawl-spring
Copy link
Copy Markdown
Contributor

@firecrawl-spring firecrawl-spring Bot commented Apr 7, 2026

Summary

  • Remove the dual-track billing path (requestScoped / autumnTrackInRequest)
  • Credits are now always tracked in the batch billing worker after successful Supabase billing
  • Delete isAutumnRequestTrackEnabled(), refundRequestTrackedCredits(), and related plumbing
  • Simplify billTeam to just queue the billing operation
  • Remove AUTUMN_REQUEST_TRACK_EXPERIMENT and AUTUMN_REQUEST_TRACK_EXPERIMENT_PERCENT config keys

Stack

Test plan

  • autumn.service.test.ts passes
  • batch_billing.test.ts passes
  • credit_billing.test.ts passes
  • Build compiles without errors

Co-Authored-By: micahstairs micah@sideguide.dev


Summary by cubic

Removes request-scoped Autumn credit tracking and always tracks credits in the batch billing worker after successful Supabase billing. Simplifies billing flow and deletes the experiment flags.

  • Refactors

    • Always track credits in processBillingBatch after billing succeeds.
    • Removed request-scoped tracking and refund logic from credit_billing, scrape-worker, and batch worker.
    • Deleted isAutumnRequestTrackEnabled(), the requestScoped param in trackCredits, and related tests/types.
    • Removed AUTUMN_REQUEST_TRACK_EXPERIMENT and AUTUMN_REQUEST_TRACK_EXPERIMENT_PERCENT config keys.
    • Simplified billTeam to only enqueue billing.
  • Migration

    • Remove AUTUMN_REQUEST_TRACK_EXPERIMENT and AUTUMN_REQUEST_TRACK_EXPERIMENT_PERCENT from environment/config.

Written for commit 56ae8b7. Summary will update on new commits.

…EST_TRACK_EXPERIMENT)

Remove the dual-track billing path where credits could be tracked either
per-request (requestScoped=true) or in the batch billing worker.

With Autumn fully ramped, simplify to always track credits in the batch
billing path after successful Supabase billing. This eliminates:

- isAutumnRequestTrackEnabled() and its config keys
- requestScoped parameter from trackCredits/TrackCreditsParams
- Request-scoped tracking + refund logic in scrape-worker.ts
- autumnTrackInRequest field from BillingOperation interface
- refundRequestTrackedCredits() from batch_billing.ts
- Request-scoped tracking + refund logic in credit_billing.ts billTeam

Co-Authored-By: micahstairs <micah@sideguide.dev>
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 8 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/api/src/services/billing/credit_billing.ts">

<violation number="1" location="apps/api/src/services/billing/credit_billing.ts:19">
P1: `billTeam` no longer honors the DB-auth bypass, so billing operations are enqueued even when auth is disabled. That can lead to Autumn credit tracking without a real Supabase bill.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.

},
{ success: true, message: "No DB, bypassed." },
)(team_id, subscription_id, credits, api_key_id, billing, logger);
return queueBillingOperation(
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: billTeam no longer honors the DB-auth bypass, so billing operations are enqueued even when auth is disabled. That can lead to Autumn credit tracking without a real Supabase bill.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/api/src/services/billing/credit_billing.ts, line 19:

<comment>`billTeam` no longer honors the DB-auth bypass, so billing operations are enqueued even when auth is disabled. That can lead to Autumn credit tracking without a real Supabase bill.</comment>

<file context>
@@ -17,49 +16,14 @@ export async function billTeam(
-    },
-    { success: true, message: "No DB, bypassed." },
-  )(team_id, subscription_id, credits, api_key_id, billing, logger);
+  return queueBillingOperation(
+    team_id,
+    subscription_id,
</file context>
Fix with Cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants