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 atomic.events which are generated by user-agent-utils
Tip: make sure that when joining atomic.events 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.
<script>
$(document).ready(function(){
let isMobileDevice = window.matchMedia("only screen and (max-width: 760px)").matches;
if(isMobileDevice){
// 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.");
}
});
</script>
You can use above script to do show/hide elements depending on the screen size.