Socket
Socket
Sign inDemoInstall

browserslist-ga

Package Overview
Dependencies
106
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.8 to 0.0.9

.travis.yml

2

index.js

@@ -7,3 +7,3 @@ #!/usr/bin/env node

const { getAccounts, getWebProperties, getProfiles, getData } = require("./src/google-analytics");
const parse = require("./src/caniuse-parser");
const { parse } = require("./src/caniuse-parser");

@@ -10,0 +10,0 @@ inquirer.registerPrompt("datetime", require("inquirer-datepicker-prompt"));

{
"name": "browserslist-ga",
"version": "0.0.8",
"version": "0.0.9",
"description": "Target browsers tailored to your audience",
"repository": "github:dmfrancisco/browserslist-ga",
"repository": "github:browserslist/browserslist-ga",
"license": "MIT",

@@ -13,2 +13,6 @@ "bin": {

},
"scripts": {
"precommit": "lint-staged",
"test": "jest"
},
"dependencies": {

@@ -19,2 +23,4 @@ "caniuse-lite": "^1.0.30000815",

"inquirer-datepicker-prompt": "^0.4.2",
"map-to-chrome": "0.0.2",
"opener": "^1.4.3",
"portfinder": "^1.0.13"

@@ -25,3 +31,29 @@ },

"trailingComma": "es5"
},
"lint-staged": {
"src/**/*.js": ["prettier --write", "git add"]
},
"eslintConfig": {
"extends": "eslint:recommended",
"env": {
"node": true,
"es6": true
},
"parserOptions": {
"ecmaVersion": 6
},
"rules": {
"no-console": "off"
},
"globals": {
"expect": false,
"test": false
}
},
"devDependencies": {
"husky": "^0.14.3",
"jest": "^22.4.2",
"lint-staged": "^7.0.0",
"prettier": "^1.11.1"
}
}

@@ -23,3 +23,4 @@ <img width="520" height="68" src="./logo.svg" alt="Browserslist-GA logo">

_([npx](https://medium.com/@maybekatz/introducing-npx-an-npm-package-runner-55f7d4bd282b) comes with npm 5.2+, for older versions run `npm install -g browserslist-ga` and then `browserslist-ga`)_
_([npx](https://medium.com/@maybekatz/introducing-npx-an-npm-package-runner-55f7d4bd282b) comes with npm 5.2+, for older versions run `npm install -g browserslist-ga` and then `browserslist-ga`)_
_(to run the latest code directly from GitHub, execute `npx github:browserslist/browserslist-ga` instead)_

@@ -69,4 +70,12 @@ You'll be asked to login with your Google Account. Your access token will only be used locally to generate a `browserslist-stats.json` file in the root of your project. After finishing the steps, you can use your stats with Browserlist by adding the following to your [Browserslist config](https://github.com/ai/browserslist#config-file):

## Notes
There are some differences compared to the `caniuse` Google Analytics importer:
* All browsers on iOS use Safari's WebKit as the underlying engine, and hence will be resolved to Safari. The  `caniuse` Google Analytics parser only converts some of the data to Safari, while the remaining is left untracked (see [#1](https://github.com/browserslist/browserslist-ga/pull/1)).
* YaBrowser, a popular browser in russian-speaking countries, uses the Blink web browser engine and is based on Chromium. It is currently not available on `caniuse` and so is resolved to Chrome (or Chrome for Android) and the version is mapped to the nearest available version (see [#2](https://github.com/browserslist/browserslist-ga/pull/2)).
* Just like for YaBrowser, the [same approach](https://github.com/dmfrancisco/map-to-chrome/blob/master/data/coc_coc_browser.json) is applied to the Coc Coc browser.
## Kudos
All the praise goes to the humans and martians that develop and maintain [Can I Use](https://caniuse.com) and [Browserslist](https://github.com/ai/browserslist).
/* Code adapted from caniuse.com with permission */
var yaBrowserMapping = require("map-to-chrome/data/YaBrowser.json");
var cocCocMapping = require("map-to-chrome/data/coc_coc_browser.json");
var agentData = require("./caniuse-agent-data");
var helpers = {};

@@ -116,2 +119,21 @@ var versionCache = {};

helpers.getChromeMapping = function(mapping, versionString) {
var parts = versionString.split(".");
var major = parseInt(parts[0]);
var minor = parseInt(parts[1]);
var entry = mapping.find(v => v[0] < major || (v[0] == major && v[1] <= minor));
if (entry) {
return entry[2];
}
};
helpers.getYaBrowserChromeMapping = function(versionString) {
return helpers.getChromeMapping(yaBrowserMapping, versionString);
};
helpers.getCocCocChromeMapping = function(versionString) {
return helpers.getChromeMapping(cocCocMapping, versionString);
};
helpers.getVersionMatch = function(browserId, versionString) {

@@ -199,3 +221,3 @@ var version;

function handleDataFeed(entries) {
function parse(entries) {
var browsers = { others: 0 };

@@ -216,14 +238,7 @@ var other_total = 0;

if (
(browser == "Safari" || browser == "Chrome") &&
(os == "iOS" || os == "iPad" || os == "iPhone" || os == "iPod")
) {
if (browser == "Opera" && (isMobile || os == "(not set)")) {
browser = "Opera Mobile";
} else if (os == "iOS" || os == "iPad" || os == "iPhone" || os == "iPod") {
// all apps on ios must use safari engine by apple rules
browser = "iOS Safari";
} else if (
browser == "Mozilla Compatible Agent" &&
(os == "iPad" || os == "iPhone" || os == "iPod")
) {
browser = "iOS Safari"; //browser = 'iOS app';
} else if (browser == "Opera" && (isMobile || os == "(not set)")) {
browser = "Opera Mobile";
} else if (browser == "Safari (in-app)") {

@@ -246,2 +261,3 @@ browser = "iOS Safari";

break;
case "Chrome":

@@ -256,2 +272,18 @@ if (os == "Android") {

case "YaBrowser":
// This is valid for both Desktop and Android (iOS is considered Safari)
v_num = helpers.getYaBrowserChromeMapping(version);
if (v_num) {
browser = os == "Android" ? "Chrome for Android" : "Chrome";
}
break;
case "Coc Coc":
// This is valid for both Desktop and Android (iOS is considered Safari)
v_num = helpers.getCocCocChromeMapping(version);
if (v_num) {
browser = os == "Android" ? "Chrome for Android" : "Chrome";
}
break;
case "Opera":

@@ -307,8 +339,11 @@ v_num = helpers.getOperaVersion(version);

break;
case "Blackberry Browser":
v_num = version.split(".")[0];
break;
case "UC Browser for Android":
v_num = CURRENT_VERSION; // helpers.getSubVersion(version);
break;
default:

@@ -371,2 +406,5 @@ v_num = null;

module.exports = handleDataFeed;
module.exports = {
parse,
helpers,
};
const portfinder = require("portfinder");
const listen = require("./listen");
const opener = require("opener");
const { google } = require("googleapis");

@@ -34,2 +35,7 @@

console.log("Please open this URL in your browser:", url);
try {
opener(url);
} catch (e) {
/* User will have to open manually */
}

@@ -36,0 +42,0 @@ listen(redirectUrl, port, code => {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc