Shahin

time_event()

Advanced
Updated Jul 11, 2026 Shahin editorial 2 min read
PronunciationEN/taɪm ɪˈvent/

time_event() starts a timer so that when the same event is later actually recorded, the elapsed duration travels with it as a duration property.

This call is a clever pattern for measuring duration: instead of keeping start and end times yourself and subtracting, you start the timer at the beginning and the library computes and attaches the duration automatically when the event is recorded. Its use is where 'how long it took' matters as much as 'what happened': time to fill a form, time to first purchase, or time spent in a step. An important point is that this duration property must be recorded as a number so its average and distribution can be computed. The common trap is forgetting the end: if the timer starts but the final event is never recorded (the user abandoned), that duration is not captured at all, so this call measures completion time, not abandonment time; abandonment must be thought about separately.