MCPcopy Index your code
hub / github.com/21st-dev/1code / fetchUserPlan

Method fetchUserPlan

src/main/auth-manager.ts:259–278  ·  view source on GitHub ↗

* Fetch user's subscription plan from web backend * Used for PostHog analytics enrichment

()

Source from the content-addressed store, hash-verified

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

Callers 2

handleAuthCodeFunction · 0.80
getUserPlanFunction · 0.80

Calls 2

getValidTokenMethod · 0.95
getApiUrlMethod · 0.95

Tested by

no test coverage detected