(userId: string)
| 211 | * Check if user is on Pro plan (direct or via organization) |
| 212 | */ |
| 213 | export async function isProPlan(userId: string): Promise<boolean> { |
| 214 | try { |
| 215 | if (!isBillingEnabled) { |
| 216 | return true |
| 217 | } |
| 218 | |
| 219 | const subscription = await getHighestPrioritySubscription(userId) |
| 220 | const isPro = |
| 221 | subscription && |
| 222 | (checkProPlan(subscription) || |
| 223 | checkTeamPlan(subscription) || |
| 224 | checkEnterprisePlan(subscription)) |
| 225 | |
| 226 | if (isPro) { |
| 227 | logger.info('User has pro-level plan', { userId, plan: subscription.plan }) |
| 228 | } |
| 229 | |
| 230 | return !!isPro |
| 231 | } catch (error) { |
| 232 | logger.error('Error checking pro plan status', { error, userId }) |
| 233 | return false |
| 234 | } |
| 235 | } |
| 236 | |
| 237 | /** |
| 238 | * Check if user is on Team plan (direct or via organization) |
no test coverage detected