Skip to content

Commit 2b07121

Browse files
committed
Merge pull request #76 from amplitude/update_ua_parser
Update ua parser
2 parents dda9cfe + 33094ef commit 2b07121

File tree

5 files changed

+63
-393
lines changed

5 files changed

+63
-393
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
## Unreleased
22

3+
* 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.
4+
35
### 2.12.1 (April 21, 2016)
46

57
* Silence console warnings for various UTM property keys with undefined values.

amplitude.js

Lines changed: 58 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3591,7 +3591,7 @@ module.exports = Revenue;
35913591
/* global define */
35923592

35933593
/**
3594-
* UAParser.js v0.7.7
3594+
* UAParser.js v0.7.10
35953595
* Lightweight JavaScript-based User-Agent string parser
35963596
* https://github.com/faisalman/ua-parser-js
35973597
*
@@ -3608,7 +3608,7 @@ module.exports = Revenue;
36083608
/////////////
36093609

36103610

3611-
var LIBVERSION = '0.7.7',
3611+
var LIBVERSION = '0.7.10',
36123612
EMPTY = '',
36133613
UNKNOWN = '?',
36143614
FUNC_TYPE = 'function',
@@ -3637,12 +3637,15 @@ module.exports = Revenue;
36373637

36383638
var util = {
36393639
extend : function (regexes, extensions) {
3640-
for (var i in extensions) {
3641-
if ("browser cpu device engine os".indexOf(i) !== -1 && extensions[i].length % 2 === 0) {
3642-
regexes[i] = extensions[i].concat(regexes[i]);
3640+
var margedRegexes = {};
3641+
for (var i in regexes) {
3642+
if (extensions[i] && extensions[i].length % 2 === 0) {
3643+
margedRegexes[i] = extensions[i].concat(regexes[i]);
3644+
} else {
3645+
margedRegexes[i] = regexes[i];
36433646
}
36443647
}
3645-
return regexes;
3648+
return margedRegexes;
36463649
},
36473650
has : function (str1, str2) {
36483651
if (typeof str1 === "string") {
@@ -3681,11 +3684,13 @@ module.exports = Revenue;
36813684
if (typeof result === UNDEF_TYPE) {
36823685
result = {};
36833686
for (p in props) {
3684-
q = props[p];
3685-
if (typeof q === OBJ_TYPE) {
3686-
result[q[0]] = undefined;
3687-
} else {
3688-
result[q] = undefined;
3687+
if (props.hasOwnProperty(p)){
3688+
q = props[p];
3689+
if (typeof q === OBJ_TYPE) {
3690+
result[q[0]] = undefined;
3691+
} else {
3692+
result[q] = undefined;
3693+
}
36893694
}
36903695
}
36913696
}
@@ -3830,8 +3835,10 @@ module.exports = Revenue;
38303835
/(opera\s[mobiletab]+).+version\/([\w\.-]+)/i, // Opera Mobi/Tablet
38313836
/(opera).+version\/([\w\.]+)/i, // Opera > 9.80
38323837
/(opera)[\/\s]+([\w\.]+)/i // Opera < 9.80
3838+
], [NAME, VERSION], [
38333839

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

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

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

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

3865+
/(edge)\/((\d+)?[\w\.]+)/i // Microsoft Edge
3866+
], [NAME, VERSION], [
3867+
38593868
/(yabrowser)\/([\w\.]+)/i // Yandex
38603869
], [[NAME, 'Yandex'], VERSION], [
38613870

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

38693878
/(chrome|omniweb|arora|[tizenoka]{5}\s?browser)\/v?([\w\.]+)/i,
38703879
// Chrome/OmniWeb/Arora/Tizen/Nokia
3871-
/(uc\s?browser|qqbrowser)[\/\s]?([\w\.]+)/i
3872-
// UCBrowser/QQBrowser
3880+
/(qqbrowser)[\/\s]?([\w\.]+)/i
3881+
// QQBrowser
38733882
], [NAME, VERSION], [
38743883

3884+
/(uc\s?browser)[\/\s]?([\w\.]+)/i,
3885+
/ucweb.+(ucbrowser)[\/\s]?([\w\.]+)/i,
3886+
/JUC.+(ucweb)[\/\s]?([\w\.]+)/i
3887+
// UCBrowser
3888+
], [[NAME, 'UCBrowser'], VERSION], [
3889+
38753890
/(dolfin)\/([\w\.]+)/i // Dolphin
38763891
], [[NAME, 'Dolphin'], VERSION], [
38773892

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

3902+
/fxios\/([\w\.-]+)/i // Firefox for iOS
3903+
], [VERSION, [NAME, 'Firefox']], [
3904+
38873905
/version\/([\w\.]+).+?mobile\/\w+\s(safari)/i // Mobile Safari
38883906
], [VERSION, [NAME, 'Mobile Safari']], [
38893907

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

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

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

41164134
/(sprint\s(\w+))/i // Sprint Phones
@@ -4124,7 +4142,7 @@ module.exports = Revenue;
41244142
/(alcatel|geeksphone|huawei|lenovo|nexian|panasonic|(?=;\s)sony)[_\s-]?([\w-]+)*/i
41254143
// Alcatel/GeeksPhone/Huawei/Lenovo/Nexian/Panasonic/Sony
41264144
], [VENDOR, [MODEL, /_/g, ' '], [TYPE, MOBILE]], [
4127-
4145+
41284146
/(nexus\s9)/i // HTC Nexus 9
41294147
], [MODEL, [VENDOR, 'HTC'], [TYPE, TABLET]], [
41304148

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

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

41944214
/*//////////////////////////
@@ -4244,7 +4264,7 @@ module.exports = Revenue;
42444264
], [VENDOR, MODEL, [TYPE, MOBILE]], [
42454265
/(i-STYLE2.1)/i // i-mobile i-STYLE 2.1
42464266
], [[MODEL, 'i-STYLE 2.1'], [VENDOR, 'i-mobile'], [TYPE, MOBILE]], [
4247-
4267+
42484268
/(mobiistar touch LAI 512)/i // mobiistar touch LAI 512
42494269
], [[MODEL, 'Touch LAI 512'], [VENDOR, 'mobiistar'], [TYPE, MOBILE]], [
42504270
@@ -4256,6 +4276,9 @@ module.exports = Revenue;
42564276

42574277
engine : [[
42584278

4279+
/windows.+\sedge\/([\w\.]+)/i // EdgeHTML
4280+
], [VERSION, [NAME, 'EdgeHTML']], [
4281+
42594282
/(presto)\/([\w\.]+)/i, // Presto
42604283
/(webkit|trident|netfront|netsurf|amaya|lynx|w3m)\/([\w\.]+)/i, // WebKit/Trident/NetFront/NetSurf/Amaya/Lynx/w3m
42614284
/(khtml|tasman|links)[\/\s]\(?([\w\.]+)/i, // KHTML/Tasman/Links
@@ -4282,7 +4305,7 @@ module.exports = Revenue;
42824305
], [[NAME, 'BlackBerry'], VERSION], [
42834306
/(blackberry)\w*\/?([\w\.]+)*/i, // Blackberry
42844307
/(tizen)[\/\s]([\w\.]+)/i, // Tizen
4285-
/(android|webos|palm\os|qnx|bada|rim\stablet\sos|meego|contiki)[\/\s-]?([\w\.]+)*/i,
4308+
/(android|webos|palm\sos|qnx|bada|rim\stablet\sos|meego|contiki)[\/\s-]?([\w\.]+)*/i,
42864309
// Android/WebOS/Palm/QNX/Bada/RIM/MeeGo/Contiki
42874310
/linux;.+(sailfish);/i // Sailfish OS
42884311
], [NAME, VERSION], [
@@ -4294,12 +4317,12 @@ module.exports = Revenue;
42944317
], [[NAME, 'Firefox OS'], VERSION], [
42954318

42964319
// Console
4297-
/(nintendo|playstation)\s([wids3portablevu]+)/i, // Nintendo/Playstation
4320+
/(nintendo|playstation)\s([wids34portablevu]+)/i, // Nintendo/Playstation
42984321

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

4349+
/(ip[honead]+)(?:.*os\s([\w]+)*\slike\smac|;\sopera)/i // iOS
4350+
], [[NAME, 'iOS'], [VERSION, /_/g, '.']], [
4351+
43264352
/(mac\sos\sx)\s?([\w\s\.]+\w)*/i,
43274353
/(macintosh|mac(?=_powerpc)\s)/i // Mac OS
43284354
], [[NAME, 'Mac'], [VERSION, /_/g, '.']], [
@@ -4387,7 +4413,6 @@ module.exports = Revenue;
43874413
ua = uastring;
43884414
return this;
43894415
};
4390-
this.setUA(ua);
43914416
return this;
43924417
};
43934418

@@ -4436,7 +4461,7 @@ module.exports = Revenue;
44364461
} else {
44374462
// requirejs env (optional)
44384463
if (typeof(define) === FUNC_TYPE && define.amd) {
4439-
define(function () {
4464+
define("ua-parser-js", [], function () {
44404465
return UAParser;
44414466
});
44424467
} else {
@@ -4446,7 +4471,7 @@ module.exports = Revenue;
44464471
}
44474472

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

4469-
})(this);
4494+
})(typeof window === 'object' ? window : this);
44704495

44714496
}, {}],
44724497
16: [function(require, module, exports) {

amplitude.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

component.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"amplitude"
1010
],
1111
"dependencies": {
12-
"amplitude/ua-parser-js": "407f34a",
12+
"amplitude/ua-parser-js": "fbdb1dc",
1313
"amplitude/JavaScript-MD5": "2350ea9",
1414
"component/object": "0.0.3",
1515
"component/querystring": "1.3.0",

0 commit comments

Comments
 (0)