Tracking API, IP address and unique visitors

How are unique visitors detected when using the tracking API if no user id is provided? I would assume IP address (which we do provide with the cip parameer)? If so, how does IP anonymization interact with this identification? I.e. is the full IP address held in memory and the masked IP address written to the logs or is the anonymization done up front so that identification is less precise?