Skip to content

Commit

Permalink
Merge pull request #76 from amplitude/update_ua_parser
Browse files Browse the repository at this point in the history
Update ua parser
  • Loading branch information
djih committed May 26, 2016
2 parents dda9cfe + 33094ef commit 2b07121
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 393 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## Unreleased

* Update our fork of [UAParser.js](https://github.com/faisalman/ua-parser-js) from v0.7.7 to v0.7.10. This will improve the resolution of user agent strings to device and OS information.

### 2.12.1 (April 21, 2016)

* Silence console warnings for various UTM property keys with undefined values.
Expand Down
91 changes: 58 additions & 33 deletions amplitude.js
Original file line number Diff line number Diff line change
Expand Up @@ -3591,7 +3591,7 @@ module.exports = Revenue;
/* global define */

/**
* UAParser.js v0.7.7
* UAParser.js v0.7.10
* Lightweight JavaScript-based User-Agent string parser
* https://github.com/faisalman/ua-parser-js
*
Expand All @@ -3608,7 +3608,7 @@ module.exports = Revenue;
/////////////


var LIBVERSION = '0.7.7',
var LIBVERSION = '0.7.10',
EMPTY = '',
UNKNOWN = '?',
FUNC_TYPE = 'function',
Expand Down Expand Up @@ -3637,12 +3637,15 @@ module.exports = Revenue;

var util = {
extend : function (regexes, extensions) {
for (var i in extensions) {
if ("browser cpu device engine os".indexOf(i) !== -1 && extensions[i].length % 2 === 0) {
regexes[i] = extensions[i].concat(regexes[i]);
var margedRegexes = {};
for (var i in regexes) {
if (extensions[i] && extensions[i].length % 2 === 0) {
margedRegexes[i] = extensions[i].concat(regexes[i]);
} else {
margedRegexes[i] = regexes[i];
}
}
return regexes;
return margedRegexes;
},
has : function (str1, str2) {
if (typeof str1 === "string") {
Expand Down Expand Up @@ -3681,11 +3684,13 @@ module.exports = Revenue;
if (typeof result === UNDEF_TYPE) {
result = {};
for (p in props) {
q = props[p];
if (typeof q === OBJ_TYPE) {
result[q[0]] = undefined;
} else {
result[q] = undefined;
if (props.hasOwnProperty(p)){
q = props[p];
if (typeof q === OBJ_TYPE) {
result[q[0]] = undefined;
} else {
result[q] = undefined;
}
}
}
}
Expand Down Expand Up @@ -3830,8 +3835,10 @@ module.exports = Revenue;
/(opera\s[mobiletab]+).+version\/([\w\.-]+)/i, // Opera Mobi/Tablet
/(opera).+version\/([\w\.]+)/i, // Opera > 9.80
/(opera)[\/\s]+([\w\.]+)/i // Opera < 9.80
], [NAME, VERSION], [

], [[NAME, mapper.str, maps.browser.name], VERSION], [
/(OPiOS)[\/\s]+([\w\.]+)/i // Opera mini on iphone >= 8.0
], [[NAME, 'Opera Mini'], VERSION], [

/\s(opr)\/([\w\.]+)/i // Opera Webkit
], [[NAME, 'Opera'], VERSION], [
Expand All @@ -3848,14 +3855,16 @@ module.exports = Revenue;

// Webkit/KHTML based
/(rekonq)\/([\w\.]+)*/i, // Rekonq
/(chromium|flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron|vivaldi)\/([\w\.-]+)/i
// Chromium/Flock/RockMelt/Midori/Epiphany/Silk/Skyfire/Bolt/Iron
], [[NAME, mapper.str, maps.browser.name], VERSION], [
/(chromium|flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron|vivaldi|iridium|phantomjs)\/([\w\.-]+)/i
// Chromium/Flock/RockMelt/Midori/Epiphany/Silk/Skyfire/Bolt/Iron/Iridium/PhantomJS
], [NAME, VERSION], [

/(trident).+rv[:\s]([\w\.]+).+like\sgecko/i, // IE11
/(Edge)\/((\d+)?[\w\.]+)/i // IE12
/(trident).+rv[:\s]([\w\.]+).+like\sgecko/i // IE11
], [[NAME, 'IE'], VERSION], [

/(edge)\/((\d+)?[\w\.]+)/i // Microsoft Edge
], [NAME, VERSION], [

/(yabrowser)\/([\w\.]+)/i // Yandex
], [[NAME, 'Yandex'], VERSION], [

Expand All @@ -3868,10 +3877,16 @@ module.exports = Revenue;

/(chrome|omniweb|arora|[tizenoka]{5}\s?browser)\/v?([\w\.]+)/i,
// Chrome/OmniWeb/Arora/Tizen/Nokia
/(uc\s?browser|qqbrowser)[\/\s]?([\w\.]+)/i
// UCBrowser/QQBrowser
/(qqbrowser)[\/\s]?([\w\.]+)/i
// QQBrowser
], [NAME, VERSION], [

/(uc\s?browser)[\/\s]?([\w\.]+)/i,
/ucweb.+(ucbrowser)[\/\s]?([\w\.]+)/i,
/JUC.+(ucweb)[\/\s]?([\w\.]+)/i
// UCBrowser
], [[NAME, 'UCBrowser'], VERSION], [

/(dolfin)\/([\w\.]+)/i // Dolphin
], [[NAME, 'Dolphin'], VERSION], [

Expand All @@ -3884,6 +3899,9 @@ module.exports = Revenue;
/FBAV\/([\w\.]+);/i // Facebook App for iOS
], [VERSION, [NAME, 'Facebook']], [

/fxios\/([\w\.-]+)/i // Firefox for iOS
], [VERSION, [NAME, 'Firefox']], [

/version\/([\w\.]+).+?mobile\/\w+\s(safari)/i // Mobile Safari
], [VERSION, [NAME, 'Mobile Safari']], [

Expand Down Expand Up @@ -3911,8 +3929,8 @@ module.exports = Revenue;
/(mozilla)\/([\w\.]+).+rv\:.+gecko\/\d+/i, // Mozilla

// Other
/(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf)[\/\s]?([\w\.]+)/i,
// Polaris/Lynx/Dillo/iCab/Doris/Amaya/w3m/NetSurf
/(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|sleipnir)[\/\s]?([\w\.]+)/i,
// Polaris/Lynx/Dillo/iCab/Doris/Amaya/w3m/NetSurf/Sleipnir
/(links)\s\(([\w\.]+)/i, // Links
/(gobrowser)\/?([\w\.]+)*/i, // GoBrowser
/(ice\s?browser)\/v?([\w\._]+)/i, // ICE Browser
Expand Down Expand Up @@ -4110,7 +4128,7 @@ module.exports = Revenue;
/android.+;\s(shield)\sbuild/i // Nvidia
], [MODEL, [VENDOR, 'Nvidia'], [TYPE, CONSOLE]], [

/(playstation\s[3portablevi]+)/i // Playstation
/(playstation\s[34portablevi]+)/i // Playstation
], [MODEL, [VENDOR, 'Sony'], [TYPE, CONSOLE]], [

/(sprint\s(\w+))/i // Sprint Phones
Expand All @@ -4124,7 +4142,7 @@ module.exports = Revenue;
/(alcatel|geeksphone|huawei|lenovo|nexian|panasonic|(?=;\s)sony)[_\s-]?([\w-]+)*/i
// Alcatel/GeeksPhone/Huawei/Lenovo/Nexian/Panasonic/Sony
], [VENDOR, [MODEL, /_/g, ' '], [TYPE, MOBILE]], [

/(nexus\s9)/i // HTC Nexus 9
], [MODEL, [VENDOR, 'HTC'], [TYPE, TABLET]], [

Expand All @@ -4136,7 +4154,8 @@ module.exports = Revenue;
// Motorola
/\s(milestone|droid(?:[2-4x]|\s(?:bionic|x2|pro|razr))?(:?\s4g)?)[\w\s]+build\//i,
/mot[\s-]?(\w+)*/i,
/(XT\d{3,4}) build\//i
/(XT\d{3,4}) build\//i,
/(nexus\s[6])/i
], [MODEL, [VENDOR, 'Motorola'], [TYPE, MOBILE]], [
/android.+\s(mz60\d|xoom[\s2]{0,2})\sbuild\//i
], [MODEL, [VENDOR, 'Motorola'], [TYPE, TABLET]], [
Expand Down Expand Up @@ -4188,7 +4207,8 @@ module.exports = Revenue;
/android.+(mi[\s\-_]*(?:one|one[\s_]plus)?[\s_]*(?:\d\w)?)\s+build/i // Xiaomi Mi
], [[MODEL, /_/g, ' '], [VENDOR, 'Xiaomi'], [TYPE, MOBILE]], [

/(mobile|tablet);.+rv\:.+gecko\//i // Unidentifiable
/\s(tablet)[;\/\s]/i, // Unidentifiable Tablet
/\s(mobile)[;\/\s]/i // Unidentifiable Mobile
], [[TYPE, util.lowerize], VENDOR, MODEL]

/*//////////////////////////
Expand Down Expand Up @@ -4244,7 +4264,7 @@ module.exports = Revenue;
], [VENDOR, MODEL, [TYPE, MOBILE]], [
/(i-STYLE2.1)/i // i-mobile i-STYLE 2.1
], [[MODEL, 'i-STYLE 2.1'], [VENDOR, 'i-mobile'], [TYPE, MOBILE]], [
/(mobiistar touch LAI 512)/i // mobiistar touch LAI 512
], [[MODEL, 'Touch LAI 512'], [VENDOR, 'mobiistar'], [TYPE, MOBILE]], [
Expand All @@ -4256,6 +4276,9 @@ module.exports = Revenue;

engine : [[

/windows.+\sedge\/([\w\.]+)/i // EdgeHTML
], [VERSION, [NAME, 'EdgeHTML']], [

/(presto)\/([\w\.]+)/i, // Presto
/(webkit|trident|netfront|netsurf|amaya|lynx|w3m)\/([\w\.]+)/i, // WebKit/Trident/NetFront/NetSurf/Amaya/Lynx/w3m
/(khtml|tasman|links)[\/\s]\(?([\w\.]+)/i, // KHTML/Tasman/Links
Expand All @@ -4282,7 +4305,7 @@ module.exports = Revenue;
], [[NAME, 'BlackBerry'], VERSION], [
/(blackberry)\w*\/?([\w\.]+)*/i, // Blackberry
/(tizen)[\/\s]([\w\.]+)/i, // Tizen
/(android|webos|palm\os|qnx|bada|rim\stablet\sos|meego|contiki)[\/\s-]?([\w\.]+)*/i,
/(android|webos|palm\sos|qnx|bada|rim\stablet\sos|meego|contiki)[\/\s-]?([\w\.]+)*/i,
// Android/WebOS/Palm/QNX/Bada/RIM/MeeGo/Contiki
/linux;.+(sailfish);/i // Sailfish OS
], [NAME, VERSION], [
Expand All @@ -4294,12 +4317,12 @@ module.exports = Revenue;
], [[NAME, 'Firefox OS'], VERSION], [

// Console
/(nintendo|playstation)\s([wids3portablevu]+)/i, // Nintendo/Playstation
/(nintendo|playstation)\s([wids34portablevu]+)/i, // Nintendo/Playstation

// GNU/Linux based
/(mint)[\/\s\(]?(\w+)*/i, // Mint
/(mageia|vectorlinux)[;\s]/i, // Mageia/VectorLinux
/(joli|[kxln]?ubuntu|debian|[open]*suse|gentoo|arch|slackware|fedora|mandriva|centos|pclinuxos|redhat|zenwalk|linpus)[\/\s-]?([\w\.-]+)*/i,
/(joli|[kxln]?ubuntu|debian|[open]*suse|gentoo|(?=\s)arch|slackware|fedora|mandriva|centos|pclinuxos|redhat|zenwalk|linpus)[\/\s-]?([\w\.-]+)*/i,
// Joli/Ubuntu/Debian/SUSE/Gentoo/Arch/Slackware
// Fedora/Mandriva/CentOS/PCLinuxOS/RedHat/Zenwalk/Linpus
/(hurd|linux)\s?([\w\.]+)*/i, // Hurd/Linux
Expand All @@ -4323,6 +4346,9 @@ module.exports = Revenue;
/(ipad)(?:.*os\s*([\w]+)*\slike\smac|;\sopera)/i // iOS
], [[NAME, 'iPad'], [VERSION, /_/g, '.']], [

/(ip[honead]+)(?:.*os\s([\w]+)*\slike\smac|;\sopera)/i // iOS
], [[NAME, 'iOS'], [VERSION, /_/g, '.']], [

/(mac\sos\sx)\s?([\w\s\.]+\w)*/i,
/(macintosh|mac(?=_powerpc)\s)/i // Mac OS
], [[NAME, 'Mac'], [VERSION, /_/g, '.']], [
Expand Down Expand Up @@ -4387,7 +4413,6 @@ module.exports = Revenue;
ua = uastring;
return this;
};
this.setUA(ua);
return this;
};

Expand Down Expand Up @@ -4436,7 +4461,7 @@ module.exports = Revenue;
} else {
// requirejs env (optional)
if (typeof(define) === FUNC_TYPE && define.amd) {
define(function () {
define("ua-parser-js", [], function () {
return UAParser;
});
} else {
Expand All @@ -4446,7 +4471,7 @@ module.exports = Revenue;
}

// jQuery/Zepto specific (optional)
// Note:
// Note:
// In AMD env the global scope should be kept clean, but jQuery is an exception.
// jQuery always exports to global scope, unless jQuery.noConflict(true) is used,
// and we should catch that.
Expand All @@ -4466,7 +4491,7 @@ module.exports = Revenue;
};
}

})(this);
})(typeof window === 'object' ? window : this);

}, {}],
16: [function(require, module, exports) {
Expand Down
4 changes: 2 additions & 2 deletions amplitude.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion component.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"amplitude"
],
"dependencies": {
"amplitude/ua-parser-js": "407f34a",
"amplitude/ua-parser-js": "fbdb1dc",
"amplitude/JavaScript-MD5": "2350ea9",
"component/object": "0.0.3",
"component/querystring": "1.3.0",
Expand Down
Loading

0 comments on commit 2b07121

Please sign in to comment.