SELECT `justfunctions.eu.parse_useragent`("Mozilla/5.0 (iPad; CPU OS 12_5_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1.2 Mobile/15E148 Safari/604.1")
/*--Output--
name : Mobile Safari | browser.version : 12.1.2 | browser.major : 12 | engine.name : WebKit | engine.version : 605.1.15 | os.name : iOS | os.version : 12.5.7 | device.vendor : Apple | device.model : iPad | device.type : tablet | arch : null
*/
CREATE OR REPLACE FUNCTION `your_project_id.your_dataset_id.parse_useragent`(`useragent` STRING) RETURNS STRUCT<
browser STRUCT<name STRING, version STRING, major STRING>,
engine STRUCT<name STRING, version STRING>,
os STRUCT<name STRING, version STRING>,
device STRUCT<vendor STRING, model STRING, type STRING>,
arch STRING
>
LANGUAGE js AS r'''let a = UAParser(useragent);
a.arch = a.cpu.architecture;
return a;
''' OPTIONS ( description = '''Parses the details from a <useragent> string.''' , library = [ "gs://justfunctions/bigquery-functions/ua-parser.min.js" ] )
JavaScript User Defined Function (JavaScript UDF)
See something wrong? Contact us or report an issue on Github.