fixed 'return' outside of function (30:4) (#1923)
* fixed 'return' outside of function (30:4)
This commit is contained in:
parent
2aa06425cb
commit
5cd969a03e
|
@ -27,55 +27,53 @@
|
|||
|
||||
if ('REALM_DISABLE_ANALYTICS' in process.env) {
|
||||
module.exports = function(){};
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
const os = require('os');
|
||||
const crypto = require('crypto');
|
||||
const fs = require('fs');
|
||||
const request = require('request');
|
||||
|
||||
const os = require('os');
|
||||
const crypto = require('crypto');
|
||||
const fs = require('fs');
|
||||
const request = require('request');
|
||||
|
||||
function sha256(data) {
|
||||
let hash = crypto.createHash('sha256');
|
||||
hash.update(data);
|
||||
return hash.digest('hex');
|
||||
}
|
||||
|
||||
function getDarwinIdentifier() {
|
||||
const interfaces = os.networkInterfaces();
|
||||
const iface = interfaces["en0"] || interfaces["en1"];
|
||||
if (!iface) {
|
||||
return Buffer.from('unknown', 'utf8');
|
||||
function sha256(data) {
|
||||
let hash = crypto.createHash('sha256');
|
||||
hash.update(data);
|
||||
return hash.digest('hex');
|
||||
}
|
||||
|
||||
const mac = iface[0].mac.replace(/:/g, '');
|
||||
return new Buffer(mac, 'hex');
|
||||
}
|
||||
function getDarwinIdentifier() {
|
||||
const interfaces = os.networkInterfaces();
|
||||
const iface = interfaces["en0"] || interfaces["en1"];
|
||||
if (!iface) {
|
||||
return Buffer.from('unknown', 'utf8');
|
||||
}
|
||||
|
||||
function getLinuxIdentifier() {
|
||||
if (fs.existsSync('/var/lib/dbus/machine-id')) {
|
||||
const mac = iface[0].mac.replace(/:/g, '');
|
||||
return new Buffer(mac, 'hex');
|
||||
}
|
||||
|
||||
function getLinuxIdentifier() {
|
||||
if (fs.existsSync('/var/lib/dbus/machine-id')) {
|
||||
return fs.readFileSync('/var/lib/dbus/machine-id');
|
||||
} else if (fs.existsSync('/etc/machine-id')) {
|
||||
} else if (fs.existsSync('/etc/machine-id')) {
|
||||
return fs.readFileSync('/etc/machine-id');
|
||||
} else {
|
||||
} else {
|
||||
return Buffer.from('unknown', 'utf8');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getAnonymizedMachineIdentifier() {
|
||||
switch (os.platform()) {
|
||||
function getAnonymizedMachineIdentifier() {
|
||||
switch (os.platform()) {
|
||||
case 'darwin':
|
||||
return sha256(getDarwinIdentifier());
|
||||
case 'linux':
|
||||
return sha256(getLinuxIdentifier());
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = function(eventName) {
|
||||
const identifier = getAnonymizedMachineIdentifier();
|
||||
const payload = {
|
||||
module.exports = function(eventName) {
|
||||
const identifier = getAnonymizedMachineIdentifier();
|
||||
const payload = {
|
||||
'event': eventName,
|
||||
'properties': {
|
||||
'token': 'aab85907a13e1ff44a95be539d9942a9',
|
||||
|
@ -89,12 +87,13 @@ module.exports = function(eventName) {
|
|||
'OS Version': os.release(),
|
||||
'Node.js versions': process.versions
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
request(`https://api.mixpanel.com/track/?data=${new Buffer(JSON.stringify(payload), 'utf8').toString('base64')}&ip=1`,
|
||||
request(`https://api.mixpanel.com/track/?data=${new Buffer(JSON.stringify(payload), 'utf8').toString('base64')}&ip=1`,
|
||||
() => { /* Analytics failed. Do nothing. */ });
|
||||
}
|
||||
}
|
||||
|
||||
if (require.main === module) {
|
||||
module.exports('Install');
|
||||
if (require.main === module) {
|
||||
module.exports('Install');
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue