* Fetch user's subscription plan from web backend * Used for PostHog analytics enrichment
()
| 257 | * Used for PostHog analytics enrichment |
| 258 | */ |
| 259 | async fetchUserPlan(): Promise<{ email: string; plan: string; status: string | null } | null> { |
| 260 | const token = await this.getValidToken() |
| 261 | if (!token) return null |
| 262 | |
| 263 | try { |
| 264 | const response = await fetch(`${this.getApiUrl()}/api/desktop/user/plan`, { |
| 265 | headers: { "X-Desktop-Token": token }, |
| 266 | }) |
| 267 | |
| 268 | if (!response.ok) { |
| 269 | console.error("[AuthManager] Failed to fetch user plan:", response.status) |
| 270 | return null |
| 271 | } |
| 272 | |
| 273 | return response.json() |
| 274 | } catch (error) { |
| 275 | console.error("[AuthManager] Failed to fetch user plan:", error) |
| 276 | return null |
| 277 | } |
| 278 | } |
| 279 | } |
| 280 | |
| 281 | // Global singleton instance |
no test coverage detected