Skip to content

Commit 6a58bb2

Browse files
committed
cleanup
1 parent 0ee243e commit 6a58bb2

File tree

6 files changed

+23
-50
lines changed

6 files changed

+23
-50
lines changed

apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/settings-modal/components/subscription/subscription.tsx

Lines changed: 18 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -69,45 +69,30 @@ export function Subscription({ onOpenChange }: SubscriptionProps) {
6969
const currentUrl = window.location.origin + window.location.pathname
7070

7171
try {
72-
if (
73-
'upgrade' in betterAuthSubscription &&
74-
typeof betterAuthSubscription.upgrade === 'function'
75-
) {
76-
const upgradeParams: any = {
77-
plan: targetPlan,
78-
referenceId,
79-
successUrl: currentUrl,
80-
cancelUrl: currentUrl,
81-
seats: targetPlan === 'team' ? 1 : undefined,
82-
}
83-
84-
// Add subscriptionId if we have an existing subscription to ensure proper plan switching
85-
if (currentSubscriptionId) {
86-
upgradeParams.subscriptionId = currentSubscriptionId
87-
logger.info('Upgrading existing subscription', {
88-
targetPlan,
89-
currentSubscriptionId,
90-
referenceId,
91-
})
92-
} else {
93-
logger.info('Creating new subscription (no existing subscription found)', {
94-
targetPlan,
95-
referenceId,
96-
})
97-
}
72+
const upgradeParams: any = {
73+
plan: targetPlan,
74+
referenceId,
75+
successUrl: currentUrl,
76+
cancelUrl: currentUrl,
77+
seats: targetPlan === 'team' ? 1 : undefined,
78+
}
9879

99-
await betterAuthSubscription.upgrade(upgradeParams)
80+
// Add subscriptionId if we have an existing subscription to ensure proper plan switching
81+
if (currentSubscriptionId) {
82+
upgradeParams.subscriptionId = currentSubscriptionId
83+
logger.info('Upgrading existing subscription', {
84+
targetPlan,
85+
currentSubscriptionId,
86+
referenceId,
87+
})
10088
} else {
101-
logger.warn('Stripe upgrade not available - development mode or missing configuration', {
89+
logger.info('Creating new subscription (no existing subscription found)', {
10290
targetPlan,
10391
referenceId,
104-
betterAuthSubscription: typeof betterAuthSubscription,
10592
})
106-
107-
alert(
108-
`Upgrade to ${targetPlan} plan - Stripe integration not available in development mode`
109-
)
11093
}
94+
95+
await betterAuthSubscription.upgrade(upgradeParams)
11196
} catch (error) {
11297
logger.error('Failed to initiate subscription upgrade:', error)
11398
alert('Failed to initiate upgrade. Please try again or contact support.')

apps/sim/db/schema.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ export const organization = pgTable('organization', {
585585
name: text('name').notNull(),
586586
slug: text('slug').notNull(),
587587
logo: text('logo'),
588-
metadata: json('metadata'), // Use for storing Stripe customer ID and other billing data
588+
metadata: json('metadata'),
589589
createdAt: timestamp('created_at').defaultNow().notNull(),
590590
updatedAt: timestamp('updated_at').defaultNow().notNull(),
591591
})

apps/sim/lib/billing/index.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,11 @@
33
* Provides clean, organized exports for the billing system
44
*/
55

6-
// Calculations and monitoring
76
export * from './calculations/usage-monitor'
8-
// Simplified billing system
97
export * from './core/billing'
108
export * from './core/billing-periods'
119
export * from './core/organization-billing'
12-
// Core functionality
1310
export * from './core/subscription'
14-
// Re-export commonly used functions with cleaner names
1511
export {
1612
getHighestPrioritySubscription as getActiveSubscription,
1713
getUserSubscriptionState as getSubscriptionState,
@@ -27,15 +23,11 @@ export {
2723
getUserUsageLimit as getUsageLimit,
2824
updateUserUsageLimit as updateUsageLimit,
2925
} from './core/usage'
30-
// Utilities
3126
export * from './subscriptions/utils'
32-
// Convenience exports for common operations
3327
export {
3428
calculateDefaultUsageLimit as getDefaultLimit,
3529
canEditUsageLimit as canEditLimit,
3630
getMinimumUsageLimit as getMinimumLimit,
3731
} from './subscriptions/utils'
38-
// Types
3932
export * from './types'
40-
// Validation
4133
export * from './validation/seat-management'

apps/sim/lib/environment.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,22 @@ export const getNodeEnv = () => {
1414
/**
1515
* Is the application running in production mode
1616
*/
17-
export const isProd = true
17+
export const isProd = getNodeEnv() === 'production'
1818

1919
/**
2020
* Is the application running in development mode
2121
*/
22-
export const isDev = false
22+
export const isDev = getNodeEnv() === 'development'
2323

2424
/**
2525
* Is the application running in test mode
2626
*/
27-
export const isTest = true
27+
export const isTest = getNodeEnv() === 'test'
2828

2929
/**
3030
* Is this the hosted version of the application
3131
*/
32-
export const isHosted = true
32+
export const isHosted = env.NEXT_PUBLIC_APP_URL === 'https://www.simstudio.ai'
3333

3434
/**
3535
* Get cost multiplier based on environment

apps/sim/package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@
1919
"db:push": "bunx drizzle-kit push",
2020
"db:studio": "bunx drizzle-kit studio",
2121
"db:migrate": "bunx drizzle-kit migrate",
22-
"db:backfill": "bun run scripts/backfill-subscription-billing-data.ts",
23-
"db:backfill:dry-run": "bun run scripts/backfill-subscription-billing-data.ts --dry-run",
24-
"db:analyze": "bun run scripts/analyze-subscription-data.ts",
2522
"test": "vitest run",
2623
"test:watch": "vitest",
2724
"test:coverage": "vitest run --coverage",

apps/sim/stores/subscription/store.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import type {
1212

1313
const logger = createLogger('SubscriptionStore')
1414

15-
// Cache duration: 30 seconds (reasonable for subscription data)
1615
const CACHE_DURATION = 30 * 1000
1716

1817
// Default values to avoid null checks throughout the app

0 commit comments

Comments
 (0)