( userId: string, traits?: Record<string, any>, )
| 160 | * Identify a user |
| 161 | */ |
| 162 | export function identify( |
| 163 | userId: string, |
| 164 | traits?: Record<string, any>, |
| 165 | ) { |
| 166 | currentUserId = userId |
| 167 | |
| 168 | // Skip in development mode |
| 169 | if (isDev()) return |
| 170 | |
| 171 | // Skip if user opted out |
| 172 | if (userOptedOut) return |
| 173 | |
| 174 | if (!posthog) return |
| 175 | |
| 176 | posthog.identify({ |
| 177 | distinctId: userId, |
| 178 | properties: { |
| 179 | ...getCommonProperties(), |
| 180 | ...traits, |
| 181 | }, |
| 182 | }) |
| 183 | } |
| 184 | |
| 185 | /** |
| 186 | * Get current user ID |
no test coverage detected