0, 'status' => 'excluded', 'reason' => 'non_contiguous_event']; } if ($fundingSource === 'none') { return ['seconds' => 0, 'status' => 'excluded', 'reason' => 'unfunded_session']; } if ($durationMs <= 0 || $positionMs > $durationMs) { return ['seconds' => 0, 'status' => 'review', 'reason' => 'position_out_of_bounds']; } $clientDeltaMs = $positionMs - $previousPositionMs; if ($clientDeltaMs < 1000 || $clientDeltaMs > 90000 || $serverDeltaSeconds < 1 || $serverDeltaSeconds > 90) { return ['seconds' => 0, 'status' => 'review', 'reason' => 'implausible_delta']; } $seconds = min((int)floor($clientDeltaMs / 1000), $serverDeltaSeconds, 60); if ($seconds <= 0) return ['seconds' => 0, 'status' => 'excluded', 'reason' => 'zero_interval']; return ['seconds' => $seconds, 'status' => 'measured', 'reason' => 'contiguous_heartbeat']; } }