:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
import { MakeLogicType, connect, kea, listeners, path } from 'kea'
import { subscriptions } from 'kea-subscriptions'
import posthog from 'posthog-js'
import { preflightLogic } from 'lib/logic/preflightLogic'
import { captureAuthStepViewed, pendingOAuthConnectionProperties } from 'scenes/authentication/shared/authStepViewed'
import type { PreflightStatus } from '../../../types'
import type { AuthEntry } from '../shared/authStepViewed'
import { authLogic } from './authLogic'
import type { AuthPageStep } from './authLogic'
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface authTelemetryLogicValues {
entry: AuthEntry // authLogic
step: AuthPageStep // authLogic
preflight: PreflightStatus | null // preflightLogic
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface authTelemetryLogicActions {
chooseAccountPath: (
accountPath: import('./authLogic').AuthAccountPath,
accountExists: boolean | null
) => {
accountExists: boolean | null
accountPath: import('./authLogic').AuthAccountPath
} // authLogic
}
export type authTelemetryLogicType = MakeLogicType<authTelemetryLogicValues, authTelemetryLogicActions>
/**
* Reports the login and signup funnel of the auth page. `step` is derived from three logics, so a
* subscription reports it on mount and on every change. `loginTelemetryLogic` still reports the
* password attempts and their failures.
*/
export const authTelemetryLogic = kea<authTelemetryLogicType>([
path(['scenes', 'authentication', 'auth', 'authTelemetryLogic']),
connect(() => ({
values: [authLogic, ['step', 'entry'], preflightLogic, ['preflight']],
actions: [authLogic, ['chooseAccountPath']],
})),
listeners(({ values }) => ({
chooseAccountPath: ({ accountPath, accountExists }) => {
// pinned: analytics event name and property names
posthog.capture('auth email submitted', {
entry: values.entry,
routed_to: accountPath,
account_exists: accountExists,
region: values.preflight?.region,
...pendingOAuthConnectionProperties(),
})
},
})),
subscriptions(({ values }) => ({
step: (step) => captureAuthStepViewed(step, values.entry),
})),
])