* Get user attributes for GrowthBook from CoreUserData
()
| 452 | * Get user attributes for GrowthBook from CoreUserData |
| 453 | */ |
| 454 | function getUserAttributes(): GrowthBookUserAttributes { |
| 455 | const user = getUserForGrowthBook() |
| 456 | |
| 457 | // For ants, always try to include email from OAuth config even if ANTHROPIC_API_KEY is set. |
| 458 | // This ensures GrowthBook targeting by email works regardless of auth method. |
| 459 | let email = user.email |
| 460 | if (!email && process.env.USER_TYPE === 'ant') { |
| 461 | email = getGlobalConfig().oauthAccount?.emailAddress |
| 462 | } |
| 463 | |
| 464 | const apiBaseUrlHost = getApiBaseUrlHost() |
| 465 | |
| 466 | const attributes = { |
| 467 | id: user.deviceId, |
| 468 | sessionId: user.sessionId, |
| 469 | deviceID: user.deviceId, |
| 470 | platform: user.platform, |
| 471 | ...(apiBaseUrlHost && { apiBaseUrlHost }), |
| 472 | ...(user.organizationUuid && { organizationUUID: user.organizationUuid }), |
| 473 | ...(user.accountUuid && { accountUUID: user.accountUuid }), |
| 474 | ...(user.userType && { userType: user.userType }), |
| 475 | ...(user.subscriptionType && { subscriptionType: user.subscriptionType }), |
| 476 | ...(user.rateLimitTier && { rateLimitTier: user.rateLimitTier }), |
| 477 | ...(user.firstTokenTime && { firstTokenTime: user.firstTokenTime }), |
| 478 | ...(email && { email }), |
| 479 | ...(user.appVersion && { appVersion: user.appVersion }), |
| 480 | ...(user.githubActionsMetadata && { |
| 481 | githubActionsMetadata: user.githubActionsMetadata, |
| 482 | }), |
| 483 | } |
| 484 | return attributes |
| 485 | } |
| 486 | |
| 487 | /** |
| 488 | * Get or create the GrowthBook client instance |
no test coverage detected