Page MenuHomePhabricator

Consider moving block to DataIntegrator()
Open, Needs TriagePublic

Description

As part of the refactoring work from DonationData() to the many one-purpose classes I kept a block of code inside the ContributionTrackingHelper::getCleanTrackingData function because this was as-is in DonationData()

In a later review, I noticed this section access data from the request headers, and we should consider to just move this logic in DataIntegrator::integratedDataFromRequest where we do currently fetch from the header the 'referrer' value in the 'step 2'. This might mean to add these as fieldNames, assuming these fields in tracking_data are still required.

		// TODO: check if this should move to DataIntegrator since it fetches values from the request
		// Add OS and browser, plus major version numbers of each if available
		$headers = $this->request->getAllHeaders();
		$parser = new Parser( $headers );
		$tracking_data = array_merge( $tracking_data, [
			'browser' => $parser->browser->getName(),
			'browser_version' => preg_replace( '/[^0-9].*/', '', $parser->browser->getVersion() ),
			'os' => $parser->os->getName(),
			// For versions, discard everything after the first non-digit
			'os_version' => preg_replace( '/[^0-9].*/', '', $parser->os->getVersion() ),
		] );