trackFunnel method
void
trackFunnel({})
Track a funnel step
IMPORTANT: For accurate funnel analysis, call setUser() BEFORE tracking
any funnel steps. If you call setUser() mid-funnel, the backend will see
steps before and after as belonging to different users, breaking the funnel.
Usage:
// 1. Set user first (even for anonymous users, use a temp ID)
Telling.instance.setUser(userId: 'user123');
// 2. Then track funnel steps
Telling.instance.trackFunnel(
funnelName: 'onboarding',
stepName: 'email_entered',
step: 1,
);
Implementation
void trackFunnel({
required String funnelName,
required String stepName,
int? step,
Map<String, dynamic>? properties,
}) {
log(
'Funnel: $funnelName - $stepName',
level: LogLevel.info,
type: LogType.analytics,
metadata: {
'funnel_name': funnelName,
'funnel_step_name': stepName,
if (step != null) 'funnel_step_number': step,
...?properties,
},
);
}