Web stats and CloudFlare CDN

We are considering CloudFlare CDN to speed up access to our website and dramatically increase file download speed. The pages of our website are connected to one of system collecting visitor statistics through a JavaScript script on every page of our website. I’ve heard that after switching to CloudFlare CDN we may lose information about real IPs of visitors as actually traffic will come from CloudFlare servers. Is that true? Are there any other drawbacks of switching to a CDN like CloudFlare?

Cloudflare includes headers that contain the visitor IP addresses. Web servers can be configured to pull this data for logging. Many hosts already include it automatically. I use Matomo (Piwik) and it includes a config option to use this header.