Skip to content

armgit / E2B

Public Imported from GitHub
0

Open-source, secure environment with real-world tools for enterprise-grade agents.

Add self-service to pricing

Jakub Novak6ae7ded0d2c1
diff --git a/apps/docs/src/app/pricing/ManageBilling.tsx b/apps/docs/src/app/pricing/ManageBilling.tsx
new file mode 100644
index 000000000..1d7643850
--- /dev/null
+++ b/apps/docs/src/app/pricing/ManageBilling.tsx
@@ -0,0 +1,29 @@
+'use client'
+
+import { Button } from '@/components/Button'
+import { useUser } from '@/utils/useUser'
+import { useRouter } from 'next/navigation'
+
+
+const manageBillingURL = process.env.NEXT_PUBLIC_STRIPE_BILLING_URL
+
+function ManageBilling() {
+ const { user } = useUser()
+ const router = useRouter()
+
+ if (!user || !manageBillingURL) {
+ return
+ }
+
+ return (
+ <div className="flex flex-col items-start justify-start gap-4 -mb-8">
+ <div className="flex flex-col items-start justify-start">
+ </div>
+ <Button onClick={() => router.push(manageBillingURL)}>
+ Manage Billing
+ </Button>
+ </div>
+ )
+}
+
+export default ManageBilling
diff --git a/apps/docs/src/app/pricing/SwitchTearButton.tsx b/apps/docs/src/app/pricing/SwitchTearButton.tsx
new file mode 100644
index 000000000..4573d944e
--- /dev/null
+++ b/apps/docs/src/app/pricing/SwitchTearButton.tsx
@@ -0,0 +1,63 @@
+'use client'
+
+import { Button } from '@/components/Button'
+import { useUser } from '@/utils/useUser'
+import { useState } from 'react'
+import { useRouter } from 'next/navigation'
+
+
+const billingApiURL = process.env.NEXT_PUBLIC_BILLING_API_URL
+function createCheckout(tierID: string, teamID: string) {
+ return fetch(`${billingApiURL}/checkouts`, {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ body: JSON.stringify({
+ teamID,
+ tierID,
+ }),
+ })
+}
+
+function SwitchTearButton(props: {tierID: string }) {
+ const { user } = useUser()
+ const [error, setError] = useState('')
+ const router = useRouter()
+
+ async function createCheckoutSession() {
+ setError('')
+
+ const response = await createCheckout(props.tierID, user.teams[0].id)
+ const responseData = await response.json()
+
+ if (responseData.error) {
+ setError(responseData.error)
+ } else {
+ router.push(responseData.url)
+ }
+ }
+
+ if (!user || !billingApiURL || user.teams[0].tier === props.tierID){
+ return
+ }
+
+ return (
+ <div className="flex flex-col items-start justify-start gap-1">
+ <div className="flex items-center justify-start gap-2">
+ <div className="flex flex-col items-start justify-start">
+ </div>
+ <Button
+ onClick={createCheckoutSession}
+ >
+ Switch to {props.tierID}
+ </Button>
+ </div>
+ {error && (
+ <span className="text-red-500 font-medium">{error}</span>
+ )}
+ </div>
+ )
+}
+
+export default SwitchTearButton
diff --git a/apps/docs/src/app/pricing/page.mdx b/apps/docs/src/app/pricing/page.mdx
index 08a133c2f..32ffee031 100644
--- a/apps/docs/src/app/pricing/page.mdx
+++ b/apps/docs/src/app/pricing/page.mdx
@@ -1,23 +1,34 @@
import Promo from './Promo'
+import SwitchTearButton from './SwitchTearButton'
+import ManageBilling from './ManageBilling'
# Pricing
-## Hobby tier (free)
+<ManageBilling />
+
+## New users
+New users get $100 credits for usage, after that, you will be charged for the resources you use.
+
+## Resource pricing
+- vCPU: $0.000014 per second (~$0.05 per hour)
+- GB RAM: $0.0000045 per second (~$0.018 per hour)
+
+## Tier pricing
+### Hobby tier (free)
- 2 vCPU {{ className: 'lead' }}
- 512 MB RAM {{ className: 'lead' }}
- 1 GB free disk storage {{ className: 'lead' }}
- 24 hours max sandbox session length {{ className: 'lead' }}
- Up to 20 concurrently running sandboxes {{ className: 'lead' }}
-## Pro tier (paid)
+### Pro tier ($150 per month)
- 4 vCPU {{ className: 'lead' }}
- 4 GB RAM {{ className: 'lead' }}
- 5 GB free disk storage {{ className: 'lead' }}
- 24 hours max sandbox session length {{ className: 'lead' }}
-- Number of concurrently running sandboxes to suit your needs {{ className: 'lead' }}
-<Note>
-Please [reach out](/getting-help) if you're interested in the Pro tier.
-</Note>
+- Up to 100 concurrently running sandboxes {{ className: 'lead' }}
+
+<SwitchTearButton tierID={'premium'} />
If you need more resources, please [reach out to us](/getting-help) with your use case.
diff --git a/apps/docs/src/utils/useUser.tsx b/apps/docs/src/utils/useUser.tsx
index 95891e580..955b3d588 100644
--- a/apps/docs/src/utils/useUser.tsx
+++ b/apps/docs/src/utils/useUser.tsx
@@ -10,6 +10,7 @@ import { useSandboxStore } from './useSandbox'
type Team = {
id: string,
name: string,
+ tier: string,
is_default: boolean
}
@@ -101,7 +102,7 @@ export const CustomUserContextProvider = (props) => {
// @ts-ignore
const { data: userTeams, teamsError } = await supabase
.from('users_teams')
- .select('teams (id, name, is_default)')
+ .select('teams (id, name, is_default, tier)')
.eq('user_id', session?.user.id) // Due to RLS, we could also safely just fetch all, but let's be explicit for sure
if (teamsError) Sentry.captureException(teamsError)
// TODO: Adjust when user can be part of multiple teams
@@ -114,19 +115,7 @@ export const CustomUserContextProvider = (props) => {
return
}
- // Fetch user's pricing tier
- const { data, error: pricingTierError } = await supabase
- .from('teams')
- .select('tier')
- .eq('id', defaultTeam.id)
- if (pricingTierError) Sentry.captureException(pricingTierError)
- const pricingTier: string | undefined = data?.[0]?.tier
-
- if (!pricingTier) {
- console.error('No pricing tier found for team', defaultTeam.id)
- return
- }
-
+ const pricingTier = defaultTeam.tier
const isPromoTier = pricingTier.startsWith('promo')
let promoEndsAt: string | null = null
// Fetch promo end date