51Degrees / device-detection-go

European Union Public License 1.2
0 stars 3 forks source link

Facebook for Android Detection #9

Closed barbiedrummer closed 7 months ago

barbiedrummer commented 1 year ago

For the latest bases I found that there is a strange behaviour in detection of Facebook for Android.

If I use only user-agent header

Mozilla/5.0 (Linux; Android 10; M2006C3LG Build/QP1A.190711.020; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/117.0.0.0 Mobile Safari/537.36 [FB_IAB/FB4A;FBAV/435.0.0.42.112;]

the detection is

BrowserVendor - Facebook
BrowserName - Facebook for Android

But if I add client-hints headers

sec-ch-ua: "Android WebView";v="117", "Not;A=Brand";v="8", "Chromium";v="117"
sec-ch-ua-mobile: ?1
sec-ch-ua-platform: "Android"
sec-ch-ua-platform-version: "11.0.0"
sec-ch-ua-model: "RMX3231"
sec-ch-ua-full-version: "117.0.5938.153"
sec-ch-ua-full-version-list: "Android WebView";v="117.0.5938.153", "Not;A=Brand";v="8.0.0.0", "Chromium";v="117.0.5938.153"
user-agent: Mozilla/5.0 (Linux; Android 10; M2006C3LG Build/QP1A.190711.020; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/117.0.0.0 Mobile Safari/537.36 [FB_IAB/FB4A;FBAV/435.0.0.42.112;]

the detection is changing to

BrowserVendor - Google
BrowserName  Android Webview

The same happens for online cheker https://51degrees.com/developers/user-agent-tester

I also found, that for detecting FB is generally suggested to use that regexp in js navigator.userAgent.match(/FBAN|FBAV/i).

So I suppose that detection in binary bases of Facebook for Android with CH-headers is working wrong.

Enterprise-HashV41.hash: latest device-detection-go: v4.4.5 (latest)

kirstin51D commented 1 year ago

Hi! Thanks for raising this.

If both the UA and UA-CH are present, our solution will favour UA-CH: https://51degrees.com/documentation/4.4/_info__f_a_qs.html#UserAgent_ContainsBetterData

If you look at the evidence you've provided, the CH-headers don't actually include any indication of Facebook for Android ("FB4A" is present in the UA string, but not UA-CH). This could be the cause of the issue you are seeing.

To some extent, the detection is correct, as it is an enclosed Android Webview in an application, but we need to internally discuss how to refine the result of Webview in an application. We will also need to discuss how we prioritise UA and UA-CH for Webview detection. I will keep you updated as soon as I have more info! Thank you.

barbiedrummer commented 1 year ago

If you look at the evidence you've provided, the CH-headers don't actually include any indication of Facebook for Android ("FB4A" is present in the UA string, but not UA-CH). This could be the cause of the issue you are seeing.

Yes, I understand this. However Facebook only identifies itself in webview mode through the UA-header. The problem is that when it also sends CH-headers, the detection is less accurate compared to using only the UA-header.

kirstin51D commented 1 year ago

Ah, I understand. I'll speak with the data team regarding this and keep you updated. Thanks!

kirstin51D commented 11 months ago

Hi! We've discussed the project, and are scheduling the work. It's not a quick fix as there will be a lot of robust testing required, so as soon as I have more information, I will let you know! Thanks for your patience.

Tracy51D commented 10 months ago

@barbiedrummer Hi! Just a quick update on this. This work is actively been worked on and we hope to get you a further update and/or release date soon. Thanks

barbiedrummer commented 7 months ago

@Tracy51D @kirstin51D Hi! Are there any updates about this?

kirstin51D commented 7 months ago

Hi @barbiedrummer! apologies on the delay. The team have been continuously working on the changes and doing thorough testing. We hope to have the work concluded mid-March. I will update you once I know more!

Tracy51D commented 7 months ago

@barbiedrummer Hi there, I’d like to update you on the progress of the Facebook on Android changes. This work has now been concluded and our data team have since uploaded the Version 4 export files with the new pseudo headers change on the 13 March.

We appreciate and thank you for your patience in this matter. Any further issues please do reach out.

Regards Tracy