Device Classification Library - End of Life

Hey everyone!

There seems to be an issue which could be affecting Snowplow device classification reporting, and am hoping someone where might have some insight.

An external tool called user-agent-utils is imported by Snowplow to classify device type:

Parses user agent strings and returns a hash of info. More about UA string standards:

This is what user-agent-utils parses against - an array of UA strings from different platforms:

Device type is hardcoded into each entry, e.g. DeviceType.COMPUTER

But user-agent-utils has reached EoL as of Version 1.20:, last updated in May 2016.

Snowplow is currently using 1.19.

So if this array isn’t updated, the UA parser will return devices as unknown and we lose that from our reporting.:

	UNKNOWN_MOBILE(	Manufacturer.OTHER,null, 3, "Unknown mobile", new String[] {"Mobile"}, null, DeviceType.MOBILE, null ),
	UNKNOWN_TABLET(	Manufacturer.OTHER,null, 4, "Unknown tablet", new String[] {"Tablet"}, null, DeviceType.TABLET, null ),
	UNKNOWN(		Manufacturer.OTHER,null, 1, "Unknown", new String[0], null, DeviceType.UNKNOWN, null );

Has anyone here come up with a solution to keep their device classification up to date? A different UA library or something else altogether?


1 Like

There’s the ua parser enrichment which uses a different library:

Thanks for bringing this up though, I need to switch my data models to use the fields in the context table generated by ua-parser rather than the fields in which are generated by user-agent-utils

Tip: make sure that when joining table with the atomic.com_snowplowanalytics_snowplow_ua_parser_context_1 table, join on both event_id = root_id as well as collector_tstamp = root_tstamp to avoid cartesian-product hell from duplicates containing the same event_id

Detecting mobile device using user agent isn’t the best way to check if a user is using a mobile device since user agent strings can be spoofed easily. However, this method is still an easy way to check what device is being used by the user.

There is a JavaScript API built-in for detecting media. The JavaScript window.matchMedia() method returns a MediaQueryList object representing the results of the specified CSS media query string. You can use this method to detect mobile device based on the CSS media query.

  let isMobileDevice = window.matchMedia("only screen and (max-width: 760px)").matches;
    // The viewport is less than 768 pixels wide
    //Conditional script here
  } else{
    //The viewport is greater than 700 pixels wide
    alert("This is not a mobile device.");

You can use above script to do show/hide elements depending on the screen size.