Page 1 of 1

detection order in web_browsers_patch.xml

Posted: Sun Jul 24, 2011 6:22 am
by mimmi
I want to detect the Google Chrome up Version 15 with its own id. So I updated/added some lines in the file with the following:

Code: Select all

		<device user_agent="Chrome/0." fall_back="google_chrome" id="google_chrome_0">
			<group id="product_info">
				<capability name="model_name" value="0" />
			</group>
		</device>

		<device user_agent="Chrome/1.0" fall_back="google_chrome" id="google_chrome_1">
			<group id="product_info">
				<capability name="model_name" value="1.0" />
			</group>
		</device>

		<device user_agent="Chrome/2.0" fall_back="google_chrome" id="google_chrome_2">
			<group id="product_info">
				<capability name="model_name" value="2.0" />
			</group>
		</device>

		<device user_agent="Chrome/3.0" fall_back="google_chrome" id="google_chrome_3">
			<group id="product_info">
				<capability name="model_name" value="3.0" />
			</group>
		</device>

		<device user_agent="Chrome/4.0" fall_back="google_chrome" id="google_chrome_4">
			<group id="product_info">
				<capability name="model_name" value="4.0" />
			</group>
		</device>

		<device user_agent="Chrome/5.0" fall_back="google_chrome" id="google_chrome_5">
			<group id="product_info">
				<capability name="model_name" value="5.0" />
			</group>
		</device>

		<device user_agent="Chrome/6.0" fall_back="google_chrome" id="google_chrome_6">
			<group id="product_info">
				<capability name="model_name" value="6.0" />
			</group>
		</device>

		<device user_agent="Chrome/7.0" fall_back="google_chrome" id="google_chrome_7">
			<group id="product_info">
				<capability name="model_name" value="7.0" />
			</group>
		</device>

		<device user_agent="Chrome/8.0" fall_back="google_chrome" id="google_chrome_8">
			<group id="product_info">
				<capability name="model_name" value="8.0" />
			</group>
		</device>

		<device user_agent="Chrome/9.0" fall_back="google_chrome" id="google_chrome_9">
			<group id="product_info">
				<capability name="model_name" value="9.0" />
			</group>
		</device>

		<device user_agent="Chrome/10.0" fall_back="google_chrome" id="google_chrome_10">
			<group id="product_info">
				<capability name="model_name" value="10.0" />
			</group>
		</device>

		<device user_agent="Chrome/11.0" fall_back="google_chrome" id="google_chrome_11">
			<group id="product_info">
				<capability name="model_name" value="11.0" />
			</group>
		</device>

		<device user_agent="Chrome/12.0" fall_back="google_chrome" id="google_chrome_12">
			<group id="product_info">
				<capability name="model_name" value="12.0" />
			</group>
		</device>

		<device user_agent="Chrome/13.0" fall_back="google_chrome" id="google_chrome_13">
			<group id="product_info">
				<capability name="model_name" value="13.0" />
			</group>
		</device>

		<device user_agent="Chrome/14.0" fall_back="google_chrome" id="google_chrome_14">
			<group id="product_info">
				<capability name="model_name" value="14.0" />
			</group>
		</device>

		<device user_agent="Chrome/15.0" fall_back="google_chrome" id="google_chrome_15">
			<group id="product_info">
				<capability name="model_name" value="15.0" />
			</group>
		</device>
Now all Chromes with Version greater than 10 are detected as Version 15.

How has the order of these rules to be to get the correct Version?

with kind regards

Thomas

Re: detection order in web_browsers_patch.xml

Posted: Tue Oct 04, 2011 8:24 am
by kamermans
Hi Thomas, sorry for the slow reply, I just noticed this topic had no replies.

The order of the devices in the WURFL Patches is not technically important unless you're overriding one device with another. In your case the problem is probably that more than one user agent is matching and google_chrome_15 is being chosen. It would probably be difficult to use straight user agent matching like this to accurately detected the browser OS version. If it's required to detect the chrome version, you are better off adding some logic to the UserAgentHandler that is processing the request. Then you can do something like this that pulls the version out:

Code: Select all

if (preg_match('# Chrome/(\d\d?)\.#', $user_agent, $matches)) {
  $chrome = true;
  $version = $matches[1];
} else {
  $chrome = false;
  $version = null;