browser: merge deprecated agents on newer target
authorMischa POSLAWSKY <perl@shiar.org>
Mon, 15 Nov 2021 19:41:49 +0000 (20:41 +0100)
committerMischa POSLAWSKY <perl@shiar.org>
Mon, 6 Dec 2021 11:07:29 +0000 (12:07 +0100)
Originally inverted to keep deprecated names, but after this long Edge
should be more familiar than IE.  Special case and_chr to keep shorter
"And." though.

tools/mkcaniuse
tools/mkusage-squid
tools/mkusage-statcounter
tools/mkusage-wikimedia

index adb437c91a7fd6c3791406a9f15b54545d7e7d67..8378d2ff4c63366fc1397fb1ac08d3ec2c01017f 100755 (executable)
@@ -29,16 +29,19 @@ delete $data->{eras};
 for (values %{ $data->{data} }) {
        delete @{$_}{qw[ usage_perc_a usage_perc_y ]};
 }
-while (my ($browser, $target) = each %BROWSERJOIN) {
-       my $agent1 = delete $data->{agents}->{$browser} or next;
-       my $agent2 =        $data->{agents}->{$target}  or next;
-       push @{ $agent2->{version_list} }, @{ $agent1->{version_list} };
-       $agent2->{browser} = sprintf '%s (former %s)',
-               $agent1->{browser}, $agent2->{browser};
+while (my ($browser, $alias) = each %BROWSERJOIN) {
+       my $agent =        $data->{agents}->{$browser} or next;
+       my $amend = delete $data->{agents}->{$alias}   or next;
+       unshift @{ $agent->{version_list} }, @{ $amend->{version_list} };
+       $agent->{browser} = sprintf '%s (former %s)',
+               $agent->{browser}, $amend->{browser};
+
+       # prefer deprecated name if newer is convoluted (Chr/And.)
+       $agent->{abbr} = $amend->{abbr} if $agent->{abbr} =~ m{/};
 
        for (values %{ $data->{data} }) {
-               my $stats = delete $_->{stats}->{$browser} or next;
-               $_ = { %{$_}, %{$stats} } for $_->{stats}->{$target};
+               my $stats = delete $_->{stats}->{$alias} or next;
+               $_ = { %{$_}, %{$stats} } for $_->{stats}->{$browser};
        }
 }
 
index c751f7679907d935ef577bdfbe2eaca0e0b4c593..a43c5733c2bce9cb38e2cc92f9bef5b37797d10e 100755 (executable)
@@ -60,7 +60,7 @@ given ($browser) {
                continue;
        }
        when ('MSIE') {
-               $browser = $mobile ? 'ie_mob' : 'ie';
+               $browser = $mobile ? 'ie_mob' : 'edge';
                continue;
        }
        when ('Opera') {
@@ -79,11 +79,11 @@ given ($browser) {
                $browser = $mobile ? 'ios_saf' : 'safari';
        }
        when ('Chrome') {
-               $browser = $mobile ? 'android' : 'chrome';
+               $browser = $mobile ? 'and_chr' : 'chrome';
                s/\.\d+$// for $version;
        }
        when ('Android') {
-               $browser = 'android';
+               $browser = 'and_chr';
        }
        when ('BlackBerry') {
                $browser = 'bb';
index d728cae330f8d0445498452c7468ca553d125908..0548fc97f65f0207f81d7dbc205569b54ffef819 100755 (executable)
@@ -8,8 +8,8 @@ use Text::CSV;
 our $VERSION = '1.01';
 
 my %BROWSERID = qw(
-       IE          ie
-       Edge        ie
+       IE          edge
+       Edge        edge
        Firefox     firefox
        Safari      safari
        Safari-iPad ios_saf
@@ -24,8 +24,8 @@ my %BROWSERID = qw(
        BlackBerry  bb
 
        IEMobile    ie_mob
-       Android     android
-       Chrome-for-Android android
+       Android     and_chr
+       Chrome-for-Android and_chr
        UC-Browser  and_uc
        QQ-Browser  and_qq
        iPhone      ios_saf
index 4470c50394cc1d5ed6dfbc2ec257ac225f330e24..88b7cef99abf0f2e28430c0af373dac792e27bdf 100755 (executable)
@@ -4,13 +4,13 @@ use warnings;
 
 use Data::Dump 'pp';
 
-our $VERSION = '1.01';
+our $VERSION = '1.02';
 
 my %BROWSERID = qw(
-       IE                      ie
+       IE                      edge
        IE-Mobile               ie_mob
-       Edge                    ie
-       Edge-Mobile             ie
+       Edge                    edge
+       Edge-Mobile             edge
        Firefox                 firefox
        Firefox-Mobile          and_ff
        Safari                  safari
@@ -18,9 +18,9 @@ my %BROWSERID = qw(
        Mobile-Safari-UIWebView ios_saf
        Chrome                  chrome
        Chromium                chrome
-       Chrome-Mobile           android
-       Chrome-Mobile-iOS       android
-       Android                 android
+       Chrome-Mobile           and_chr
+       Chrome-Mobile-iOS       and_chr
+       Android                 and_chr
        Opera                   opera
        Opera-Mini              op_mini
        BlackBerry-WebKit       bb