Commit graph

8 commits

Author SHA1 Message Date
Kevin Turcios
d7a8b8f227
perf: fix CI build + lazy-load heavy libs + parallelize DB queries (#2601)
## Summary
- **Fix CI build failure**: Auth0Client crashes during Next.js
prerendering when env vars aren't set. Returns a no-op stub (`getSession
→ null`) when domain is missing — semantically correct for static
generation
- **Lazy-load markdown libs (~260kb)**: ReactMarkdown, remarkGfm, and
react-syntax-highlighter were eagerly imported in monaco-diff-viewer but
only rendered when user expands "Generated Tests". Extracted into a
dynamic component
- **Parallelize repo detail query**: `getRepositoryById` ran the
activity count sequentially after the repo lookup. Since `repoId` is
already available, all three queries now run in parallel

## Test plan
- [ ] CI `build` check passes (was failing since #2598)
- [ ] Trace page still renders generated tests correctly when expanded
- [ ] Repository detail page loads correctly with activity status
2026-04-13 11:03:05 -05:00
HeshamHM28
45e22e0f94
Cf-api Refactor (#2131)
Fixes CF-833
2026-01-19 23:03:57 +05:30
mashraf-222
b85ff4a5c2
adding global exception handler and logger for dev and production (#1927)
Co-authored-by: HeshamHM28 <HeshamMohamedFathy@outlook.com>
Co-authored-by: Sarthak Agarwal <sarthak.saga@gmail.com>
2025-12-15 21:32:20 +05:30
Sarthak Agarwal
d6167aa9ac
Async subscription reset (#1703)
ToDO: Test update and sql migrations.

Upstream dependent PR:
https://github.com/codeflash-ai/codeflash-internal/pull/1700

### How to Test?
1. Install Stripe: `curl -fsSL https://stripe.com/install.sh | sudo
bash`
2. Create Stripe credentials and save them in your environment
variables.
3. Run cf-api and start Stripe listening with: ` stripe listen
--forward-to localhost:3001/webhook`
4.	Save the webhook secret in your environment variables.
5.	Use the CLI to optimize and check the quota.
6.	Call the AI endpoint in Insomnia and verify the quota in cf-webAPP.

---------

Co-authored-by: HeshamHM28 <HeshamMohamedFathy@outlook.com>
2025-09-15 21:23:38 +05:30
HeshamHM28
6f5c2d7ad8
Implement Tests for CF-API Flow (#1634)
Co-authored-by: Sarthak Agarwal <sarthak.saga@gmail.com>
2025-06-25 03:36:26 +05:30
Sarthak Agarwal
b0eccb722b
pricing dedupe and flow improve (#1511)
### **PR Type**
- Enhancement



___

### **Description**
- Update subscription checkout and cancellation logic

- Add subscription limits and usage reset utilities

- Enhance login, onboarding, and billing redirects

- Upgrade dependency versions and lint configurations


___



### **Changes walkthrough** 📝
<table><thead><tr><th></th><th align="left">Relevant
files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><details><summary>20
files</summary><table>
<tr>
<td><strong>actions.ts</strong><dd><code>Refactor checkout session and
cancellation functions</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
</dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1511/files#diff-483bd280b775abd99ae9bbbbcbee9cdcd7407a5c8f09e97591143ea7a460a349">+23/-76</a>&nbsp;
</td>

</tr>

<tr>
<td><strong>subscription-functions.ts</strong><dd><code>Add subscription
limits and monthly reset utilities</code>&nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1511/files#diff-9fc439c25400b7ac049770509373f3e17ec84f0ba471fda2814bd37e4155b01b">+95/-6</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
<td><strong>subscription-management.ts</strong><dd><code>Integrate
common subscription functions in endpoints</code>&nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1511/files#diff-a8e2aca1f0313219f56d75c5d57f36d869fada2292457444f50843b304c26c99">+15/-24</a>&nbsp;
</td>

</tr>

<tr>
<td><strong>billing-view.tsx</strong><dd><code>Improve billing view UI
and period handling</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1511/files#diff-4b7dc7632b66abfc90fcb72aaca8222a6f72b2cd65386f5cdf3d6affec187565">+22/-8</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
<td><strong>page.tsx</strong><dd><code>Add error handling and fallback
subscription data</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; </dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1511/files#diff-86ac324c6a48fe59d742a236c9abad3998b7c571534ba8b4a757a89f5ad3ef83">+34/-18</a>&nbsp;
</td>

</tr>

<tr>
<td><strong>page.tsx</strong><dd><code>Enhance login redirect with safe
return URL check</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; </dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1511/files#diff-51fffa5e02e56eafab1bd3288c83046bb460d6f72cd89aee2f2fb106f19250e1">+29/-1</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
<td><strong>page.tsx</strong><dd><code>Improve checkout flow with
logging and Sentry tracking</code>&nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1511/files#diff-ab1265c18dc76b25db6970b8b1943cdbd6d9a36092a6091cdf705a3e9fc0b42a">+22/-7</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
<td><strong>SubmitFirstOnboardingPage.tsx</strong><dd><code>Implement
cookie-based redirect after onboarding</code>&nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1511/files#diff-f7408066207ec9b618596437140aa986df7b733d84a04897b9fc1b48e9691772">+19/-0</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
<td><strong>prisma-client.ts</strong><dd><code>Introduce singleton
Prisma client initialization</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1511/files#diff-2961161048a21c0e00e92d799ccbe21870c5638af2aab0670c963c3d5dd929b0">+14/-16</a>&nbsp;
</td>

</tr>

<tr>
<td><strong>stripe-client.ts</strong><dd><code>Add browser check for
Stripe client initialization</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1511/files#diff-688ec9d856f21b99370442e1c056bcdca697f39f0773d0ed551ad3402d385f2e">+12/-5</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
<td><strong>is-github-app-installed.ts</strong><dd><code>Update import
paths with explicit file extensions</code>&nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1511/files#diff-4b97bd2b461108930999b4af7e47d4763ad1b9490f7352130109c39f5abf4561">+3/-3</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>package.json</strong><dd><code>Modify build script and
update dependency versions</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1511/files#diff-4edec169b0f8d3312edaf35b5cc8521fe1edfa163ce174f60eff51906896601f">+5/-6</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>package.json</strong><dd><code>Upgrade dependency and dev
tool versions</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
</dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1511/files#diff-b0d32af9c2caaba1377ec3e924eb553105cdc86e244018ffc6a866c530523599">+7/-5</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>package.json</strong><dd><code>Refine lint commands and
dependency configurations</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1511/files#diff-53ddfb1f8a02f1231d3d15a2e694ffe1407d2cc01d3e685de5653b67fec571c7">+2/-3</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>.eslintrc.mjs</strong><dd><code>Simplify ESLint settings for
cf-api</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1511/files#diff-64f33493724c98b62fa6fc15a3e6150006f9e276eec35982f0121c93d4615858">+14/-28</a>&nbsp;
</td>

</tr>

<tr>
<td><strong>.eslintrc.mjs</strong><dd><code>Revise ESLint configuration
for webapp</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; </dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1511/files#diff-3e792fa9bf87a9f417a08617cdcd8f5465c92cca62190490bbeb4a76ed3775fd">+26/-15</a>&nbsp;
</td>

</tr>

<tr>
<td><strong>.eslintrc.json</strong><dd><code>Adjust ESLint rules and
ignore patterns</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; </dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1511/files#diff-b44cde4a55654414f4e45c08668a213ddf35250ea82ffef282107956af25efcb">+24/-2</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
<td><strong>eslint.config.mjs</strong><dd><code>Add new ESLint
configuration for common package</code>&nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1511/files#diff-24b160f5da434c3e13caaa30e6a33be7a7950af40ec0fcac07cdfd724036dccd">+29/-0</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
<td><strong>lefthook.yml</strong><dd><code>Comment out js-lint hook in
lefthook configuration</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; </dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1511/files#diff-ad6a01e589b8b1b214ca310dbb8d2e4314f6c612b921050c73c97455de43884d">+5/-5</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>tsconfig.json</strong><dd><code>Include express types and
refine TS settings</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1511/files#diff-3532a852c82c88daeed6b57a35cd52c4a2589c909edc756613d67e280ab9b23e">+1/-1</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>
</table></details></td></tr><tr><td><strong>Additional
files</strong></td><td><details><summary>8 files</summary><table>
<tr>
  <td><strong>.eslintignore</strong></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1511/files#diff-285326f37b4ef7a8e43dc3fd17135ad3a3a51a85a9d2ddc5bdd234ffbf3ffada">+9/-1</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
  <td><strong>package-lock.json</strong></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1511/files#diff-75446c74353509ca0232d6a1350aef075ced8f72bd568e9bafa09cf255683142">+231/-213</a></td>

</tr>

<tr>
  <td><strong>subscription-utils.ts</strong></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1511/files#diff-846af69dc1c830de7e6d0c1f73a01e75d60d3e3788b0b60d907d8a161140c679">+0/-122</a>&nbsp;
</td>

</tr>

<tr>
  <td><strong>.eslintignore</strong></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1511/files#diff-9c369a46ac4f2c69b2e6ee4bc3d38a9837f0ec0d0ab51002f5b8220c4644fd4d">+12/-1</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
  <td><strong>next.config.mjs</strong></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1511/files#diff-457975a67fc5d4317fca780879ee23a0e6bae3b3ac41a8d69b8e3dad006d0bb6">+1/-2</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
  <td><strong>package-lock.json</strong></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1511/files#diff-0214c85d1717ad8b736e0296bb8cbf50db2aed068f31316d3c39904824a14f8e">+797/-1850</a></td>

</tr>

<tr>
  <td><strong>.eslintignore</strong></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1511/files#diff-fdc1690e7d0eea11a33263e0c96b5f1c506946809567531f9ed7ce764b37e802">+11/-0</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
  <td><strong>package-lock.json</strong></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1511/files#diff-54c17cef859f033fc84a59da2e977235ebc494943710c25d132e310ec500c5ef">+2361/-108</a></td>

</tr>
</table></details></td></tr></tr></tbody></table>

___

> <details> <summary> Need help?</summary><li>Type <code>/help how to
...</code> in the comments thread for any questions about PR-Agent
usage.</li><li>Check out the <a
href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a>
for more information.</li></details>
2025-03-11 23:29:20 +00:00
Saga4
109e1d544c dedupe and pricing changes for period 2025-03-11 04:55:40 +05:30
Sarthak Agarwal
a97ec54b2a
Pricing Setup V1 (#1504)
### **User description**
Screenshots: 

![image](https://github.com/user-attachments/assets/7e96678d-5f1f-466d-a2f7-e040adf70e3e)

![image](https://github.com/user-attachments/assets/d826551e-22a6-4c45-8a3c-f652ca69c742)

![image](https://github.com/user-attachments/assets/4defc919-eeae-40ab-ac93-ef76b4806db2)

ToDO: Dedupe the code for cf-api and cf-webapp and move it to common
Currently user can upgrade from free to monthly only, need to add logic
to give choice to update to yearly as well from Billing page.

### **PR Type**
- Enhancement



___

### **Description**
- Add Stripe client initialization and pricing config

- Implement Stripe webhooks and subscription endpoints

- Integrate usage tracking middleware and billing UI

- Update Prisma schema and dependency versions


___



### **Changes walkthrough** 📝
<table><thead><tr><th></th><th align="left">Relevant
files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><details><summary>14
files</summary><table>
<tr>
<td><strong>stripe-client.ts</strong><dd><code>Initialize Stripe client
with API version setting</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1504/files#diff-133526b16a4d7cf5fe0440be27d479000b85c6714b0a98b1bcc29864fbd59e68">+9/-0</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>stripe.ts</strong><dd><code>Add pricing tiers and plan
configurations</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
</dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1504/files#diff-50e78686f5d8e699a8f0e7bec0151082fb80887cc8d303e8e54f1bf9fae666b6">+20/-0</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
<td><strong>stripe-webhook.ts</strong><dd><code>Introduce Stripe webhook
handler for events</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1504/files#diff-77cb44047d6530f044469983d43fa5051bcc968add3b298c82cee11646312b2b">+135/-0</a>&nbsp;
</td>

</tr>

<tr>
<td><strong>subscription-management.ts</strong><dd><code>Add endpoints
for subscription get, checkout, cancel</code>&nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; </dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1504/files#diff-a8e2aca1f0313219f56d75c5d57f36d869fada2292457444f50843b304c26c99">+91/-0</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
<td><strong>index.ts</strong><dd><code>Update routing; add Stripe and
usage tracking routes</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
</dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1504/files#diff-c3e60be1461b6e80f9181080342927fd9df095197e8784ae0ff51daaec8d71d5">+50/-16</a>&nbsp;
</td>

</tr>

<tr>
<td><strong>track-endpoint-calls.ts</strong><dd><code>Fix analytics
import to .js extension</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1504/files#diff-28e52f52b5f5ed621618a985f95d3636974f2a2c2281abe0d7c03ec2a5936537">+1/-1</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>track-usage.ts</strong><dd><code>Add middleware to track
subscription usage limits</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1504/files#diff-9248228a33147544ca9b58ff8b9c737b33763dd3e29717c82c38808bb7e34db3">+78/-0</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
<td><strong>setup-stripe.ts</strong><dd><code>Add script for Stripe
products and pricing setup</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1504/files#diff-fde1de99bb4325e0352a86fad382424a2a890d68c0ccfd8790796371bae1324f">+85/-0</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
<td><strong>subscription-utils.ts</strong><dd><code>Create helper
functions for subscription checkout and limits</code></dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1504/files#diff-846af69dc1c830de7e6d0c1f73a01e75d60d3e3788b0b60d907d8a161140c679">+122/-0</a>&nbsp;
</td>

</tr>

<tr>
<td><strong>page.tsx</strong><dd><code>Add billing page UI displaying
subscription status</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; </dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1504/files#diff-86ac324c6a48fe59d742a236c9abad3998b7c571534ba8b4a757a89f5ad3ef83">+54/-0</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
<td><strong>environment.ts</strong><dd><code>Add utilities for
environment mode detection</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1504/files#diff-0f860026005bc9b93926c42b04923ad589ad88fcde9aa7190bcefe8695aaa263">+7/-0</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>migration.sql</strong><dd><code>Add migration for new
subscriptions table creation</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1504/files#diff-8c1b31527c409128ba8d71ade36064c4b57bdfa8ec85acdf9a5db1118026f5b4">+26/-0</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
<td><strong>migration.sql</strong><dd><code>Add foreign key constraint
for API keys relation</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1504/files#diff-b07dd458b6c11384532557e84d1c5bda168806cc96e117f545ba7b261b6b0a3e">+2/-0</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>schema.prisma</strong><dd><code>Update Prisma schema to
include subscriptions relation</code>&nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1504/files#diff-b30267f4306ab8d4d39c41394218b2aa428a35de686b88ca3a8c1f6b62453832">+24/-4</a>&nbsp;
&nbsp; </td>

</tr>

</table></details></td></tr><tr><td><strong>Formatting</strong></td><td><details><summary>2
files</summary><table>
<tr>
<td><strong>create-pr.ts</strong><dd><code>Update import paths and minor
formatting fixes</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1504/files#diff-728a794bb81f944ae7db030f5e6ae1c1ba6888aa46e4be6846ebc5bd1ce12c2c">+10/-10</a>&nbsp;
</td>

</tr>

<tr>
<td><strong>verify-existing-optimizations.ts</strong><dd><code>Correct
import extensions to .js for consistency</code>&nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1504/files#diff-27bad39c963ec01481b7bdcff482e9d57ca39b99ee4ed0344a74d760092fb387">+4/-4</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

</table></details></td></tr><tr><td><strong>Documentation</strong></td><td><details><summary>3
files</summary><table>
<tr>
<td><strong>prisma-client.ts</strong><dd><code>Document and update
Prisma client instantiation</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1504/files#diff-2961161048a21c0e00e92d799ccbe21870c5638af2aab0670c963c3d5dd929b0">+15/-1</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
<td><strong>.env.example</strong><dd><code>Add example Stripe
environment variables</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; </dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1504/files#diff-ab5d181c31c59dbee1bfd63202d1471ab27276a59ceee617e5b46988935db773">+11/-0</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
<td><strong>migration_lock.toml</strong><dd><code>Minor update to
migration lock file documentation</code>&nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1504/files#diff-44423d32fecc24a69cc5d2d075987e28b6ab13da9730940621da28c0786b37e0">+1/-1</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

</table></details></td></tr><tr><td><strong>Dependencies</strong></td><td><details><summary>2
files</summary><table>
<tr>
<td><strong>package-lock.json</strong><dd><code>Update dependency
versions for dotenv and stripe</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1504/files#diff-75446c74353509ca0232d6a1350aef075ced8f72bd568e9bafa09cf255683142">+15/-1</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
<td><strong>package.json</strong><dd><code>Bump dotenv and stripe
versions in dependencies</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1504/files#diff-53ddfb1f8a02f1231d3d15a2e694ffe1407d2cc01d3e685de5653b67fec571c7">+2/-1</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>
</table></details></td></tr><tr><td><strong>Additional
files</strong></td><td><details><summary>1 files</summary><table>
<tr>
  <td><strong>installed-repositories.ts</strong></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1504/files#diff-86bc38f589fc8426f2ae4cc8bfaa79a4652064344591bccd524c0f996cfc5abd">+1/-1</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>
</table></details></td></tr></tr></tbody></table>

___

> <details> <summary> Need help?</summary><li>Type <code>/help how to
...</code> in the comments thread for any questions about PR-Agent
usage.</li><li>Check out the <a
href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a>
for more information.</li></details>


___

### **PR Type**
Enhancement


___

### **Description**
- Add Stripe client & pricing configuration.

- Implement Stripe webhook & subscription endpoints.

- Integrate usage tracking middleware & billing UI.

- Update Prisma schema and dependency versions.


___



### **Changes walkthrough** 📝
<table><thead><tr><th></th><th align="left">Relevant
files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><details><summary>18
files</summary><table>
<tr>
<td><strong>stripe-client.ts</strong><dd><code>Initialize Stripe client
with API version and error handling</code></dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1504/files#diff-133526b16a4d7cf5fe0440be27d479000b85c6714b0a98b1bcc29864fbd59e68">+9/-0</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>stripe.ts</strong><dd><code>Add Stripe pricing tiers
configuration object</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1504/files#diff-50e78686f5d8e699a8f0e7bec0151082fb80887cc8d303e8e54f1bf9fae666b6">+20/-0</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
<td><strong>stripe-webhook.ts</strong><dd><code>Implement comprehensive
Stripe webhook handler with multiple cases</code></dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1504/files#diff-77cb44047d6530f044469983d43fa5051bcc968add3b298c82cee11646312b2b">+209/-0</a>&nbsp;
</td>

</tr>

<tr>
<td><strong>subscription-management.ts</strong><dd><code>Add
subscription management endpoints for retrieval and
checkout</code></dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1504/files#diff-a8e2aca1f0313219f56d75c5d57f36d869fada2292457444f50843b304c26c99">+91/-0</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
<td><strong>index.ts</strong><dd><code>Integrate Stripe webhook,
subscription endpoints and tracking
</code><br><code>middleware</code></dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1504/files#diff-c3e60be1461b6e80f9181080342927fd9df095197e8784ae0ff51daaec8d71d5">+50/-16</a>&nbsp;
</td>

</tr>

<tr>
<td><strong>track-usage.ts</strong><dd><code>Implement usage tracking
middleware for subscription limits</code></dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1504/files#diff-9248228a33147544ca9b58ff8b9c737b33763dd3e29717c82c38808bb7e34db3">+78/-0</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
<td><strong>setup-stripe.ts</strong><dd><code>Script for setting up
Stripe products and prices</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1504/files#diff-fde1de99bb4325e0352a86fad382424a2a890d68c0ccfd8790796371bae1324f">+85/-0</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
<td><strong>subscription-utils.ts</strong><dd><code>Add utilities for
subscription limits and checkout session creation</code></dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1504/files#diff-846af69dc1c830de7e6d0c1f73a01e75d60d3e3788b0b60d907d8a161140c679">+122/-0</a>&nbsp;
</td>

</tr>

<tr>
<td><strong>actions.ts</strong><dd><code>Add billing actions for
subscription upgrade and cancellation</code></dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1504/files#diff-483bd280b775abd99ae9bbbbcbee9cdcd7407a5c8f09e97591143ea7a460a349">+96/-0</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
<td><strong>billing-view.tsx</strong><dd><code>Create billing view with
subscription usage and action UI</code></dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1504/files#diff-4b7dc7632b66abfc90fcb72aaca8222a6f72b2cd65386f5cdf3d6affec187565">+82/-0</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
<td><strong>page.tsx</strong><dd><code>Implement server-side billing
page with session and subscription fetch</code></dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1504/files#diff-86ac324c6a48fe59d742a236c9abad3998b7c571534ba8b4a757a89f5ad3ef83">+37/-0</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
<td><strong>sidebar.tsx</strong><dd><code>Add billing link to sidebar
navigation</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; </dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1504/files#diff-a3069b9cc39bb2210f37074c90af1f24894834cef38ca2794c312cf13a299aae">+9/-0</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>progress.tsx</strong><dd><code>Create custom progress
component for displaying usage</code>&nbsp; &nbsp; &nbsp; &nbsp;
</dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1504/files#diff-9437c33457680b4b21714c401e3ba3307a38187bc452ab57759ab5e354c8a74c">+25/-0</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
<td><strong>environment.ts</strong><dd><code>Add helper functions for
environment detection</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1504/files#diff-0f860026005bc9b93926c42b04923ad589ad88fcde9aa7190bcefe8695aaa263">+7/-0</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>migration.sql</strong><dd><code>Add subscriptions table with
indices and foreign key constraints</code></dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1504/files#diff-8c1b31527c409128ba8d71ade36064c4b57bdfa8ec85acdf9a5db1118026f5b4">+26/-0</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
<td><strong>migration.sql</strong><dd><code>Add foreign key constraint
linking API keys to users</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
</dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1504/files#diff-b07dd458b6c11384532557e84d1c5bda168806cc96e117f545ba7b261b6b0a3e">+2/-0</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>migration.sql</strong><dd><code>Insert free tier
subscriptions for users missing subscription records</code></dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1504/files#diff-c508ef69e6af2c10282872c39559bf10fcd0886fe5000ea507360c53feae5509">+28/-0</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
<td><strong>schema.prisma</strong><dd><code>Update Prisma schema to
include subscriptions model and relations</code></dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1504/files#diff-b30267f4306ab8d4d39c41394218b2aa428a35de686b88ca3a8c1f6b62453832">+24/-4</a>&nbsp;
&nbsp; </td>

</tr>

</table></details></td></tr><tr><td><strong>Miscellaneous</strong></td><td><details><summary>4
files</summary><table>
<tr>
<td><strong>installed-repositories.ts</strong><dd><code>Correct GitHub
app import by appending .js extension</code>&nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; </dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1504/files#diff-86bc38f589fc8426f2ae4cc8bfaa79a4652064344591bccd524c0f996cfc5abd">+1/-1</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>verify-existing-optimizations.ts</strong><dd><code>Update
import paths for consistency in optimizations endpoint</code></dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1504/files#diff-27bad39c963ec01481b7bdcff482e9d57ca39b99ee4ed0344a74d760092fb387">+4/-4</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>track-endpoint-calls.ts</strong><dd><code>Update import
references in endpoint call tracking middleware</code></dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1504/files#diff-28e52f52b5f5ed621618a985f95d3636974f2a2c2281abe0d7c03ec2a5936537">+1/-1</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>prisma-client.ts</strong><dd><code>Update Prisma client
initialization with additional comments</code></dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1504/files#diff-2961161048a21c0e00e92d799ccbe21870c5638af2aab0670c963c3d5dd929b0">+15/-1</a>&nbsp;
&nbsp; </td>

</tr>

</table></details></td></tr><tr><td><strong>Dependencies</strong></td><td><details><summary>3
files</summary><table>
<tr>
<td><strong>package-lock.json</strong><dd><code>Update package lock with
newer versions for dotenv and stripe</code></dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1504/files#diff-75446c74353509ca0232d6a1350aef075ced8f72bd568e9bafa09cf255683142">+15/-1</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
<td><strong>package.json</strong><dd><code>Update package dependencies:
bump dotenv and add stripe version</code></dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1504/files#diff-53ddfb1f8a02f1231d3d15a2e694ffe1407d2cc01d3e685de5653b67fec571c7">+2/-1</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>package.json</strong><dd><code>Update webapp package with
stripe dependency and minor adjustments</code></dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1504/files#diff-4edec169b0f8d3312edaf35b5cc8521fe1edfa163ce174f60eff51906896601f">+2/-0</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

</table></details></td></tr><tr><td><strong>Documentation</strong></td><td><details><summary>3
files</summary><table>
<tr>
<td><strong>.env.example</strong><dd><code>Add sample environment
variables for webapp configuration</code></dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1504/files#diff-2b720c1841e0bd5022a4a9c3fe68e8a52bba9115e2569e7d7af5b780f1da7b0c">+10/-0</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
<td><strong>.env.example</strong><dd><code>Add Stripe environment
variables in common example file</code>&nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1504/files#diff-ab5d181c31c59dbee1bfd63202d1471ab27276a59ceee617e5b46988935db773">+11/-0</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
<td><strong>migration_lock.toml</strong><dd><code>Minor update to
migration lock file comment formatting</code>&nbsp; &nbsp; &nbsp;
</dd></td>
<td><a
href="https://github.com/codeflash-ai/codeflash-internal/pull/1504/files#diff-44423d32fecc24a69cc5d2d075987e28b6ab13da9730940621da28c0786b37e0">+1/-1</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>
</table></details></td></tr></tr></tbody></table>

___

> <details> <summary> Need help?</summary><li>Type <code>/help how to
...</code> in the comments thread for any questions about PR-Agent
usage.</li><li>Check out the <a
href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a>
for more information.</li></details>
2025-03-10 21:54:51 +05:30