( eventName: string, properties?: Record<string, any>, )
| 133 | * Capture an analytics event |
| 134 | */ |
| 135 | export function capture( |
| 136 | eventName: string, |
| 137 | properties?: Record<string, any>, |
| 138 | ) { |
| 139 | // Skip in development mode |
| 140 | if (isDev()) return |
| 141 | |
| 142 | // Skip if user opted out |
| 143 | if (userOptedOut) return |
| 144 | |
| 145 | if (!posthog) return |
| 146 | |
| 147 | const distinctId = currentUserId || "anonymous" |
| 148 | |
| 149 | posthog.capture({ |
| 150 | distinctId, |
| 151 | event: eventName, |
| 152 | properties: { |
| 153 | ...getCommonProperties(), |
| 154 | ...properties, |
| 155 | }, |
| 156 | }) |
| 157 | } |
| 158 | |
| 159 | /** |
| 160 | * Identify a user |
no test coverage detected