mozilla / addons

☂ Umbrella repository for Mozilla Addons ✨
Other
123 stars 53 forks source link

Allow for identifying users as on desktop or not #14218

Closed bobsilverberg closed 3 years ago

bobsilverberg commented 3 years ago

This is a spin off from https://github.com/mozilla/addons/issues/14205.

In order to make it possible to configure an experiment to exclude either all desktop users or all mobile users we need an isDesktop function that will identify as user as being on desktop or not.

This is marked as "qa: not needed" as there is no exposed code that uses this function yet.

bobsilverberg commented 3 years ago

The library that we currently use to detect browser and os, us-parser-js, includes the ability to detect device. device is further broken down into model, type and vendor, and it looks like type is what we want here. The possible values for type are console, mobile, tablet, smarttv, wearable and embedded. As can be seen there is no value for desktop.

In my local testing, when a desktop browser is used, device.type returns undefined, and I was able to verify that console, mobile, tablet, smarttv and wearable are all returned when expected with different user agent strings.

Based on this, I think we could simply say that if device.type is undefined then it is a desktop browser, and if device.type is not undefined then we consider it some type of mobile browser. I know this isn't entirely accurate, but it might be close enough. Looking at Google Analytics data for both Browser and Mobile Device over a two week period, the number of devices that are not actually desktops or phones/tablets appears to be very small.

@jvillalobos @mozilla/addons-amo-engineering What do you think of taking this approach for trying to identify mobile vs desktop users?

bobsilverberg commented 3 years ago

I opened https://github.com/faisalman/ua-parser-js/issues/502 to discuss whether returning desktop from device.type could be an option.

jvillalobos commented 3 years ago

That sounds like a reasonable approach to me.