private function writeTracks(\XMLWriter $xmlWriter, Workout $workout)
    {
        $xmlWriter->startElement('Activities');
        foreach ($workout->tracks() as $track) {
            $xmlWriter->startElement('Activity');
            $xmlWriter->writeAttribute('Sport', ucfirst($track->sport()));
            // Use the start date time as the ID. This could be anything.
            $xmlWriter->writeElement('Id', $this->formatDateTime($track->startDateTime()));

            $xmlWriter->startElement('Lap');

            $xmlWriter->writeAttribute('StartTime', $this->formatDateTime($track->startDateTime()));
            $xmlWriter->writeElement('TotalTimeSeconds', (string)$track->duration()->totalSeconds());
            $xmlWriter->writeElement('DistanceMeters', (string)$track->length());

            $this->writeLapHeartRateDate($xmlWriter, $track);

            $xmlWriter->startElement('Track');
            $this->writeTrackPoints($xmlWriter, $track->trackPoints());
            $xmlWriter->endElement();

            $xmlWriter->endElement();

            $xmlWriter->endElement();
        }
        $xmlWriter->endElement();
    }