Skip to content

Commit

Permalink
Add version and source
Browse files Browse the repository at this point in the history
  • Loading branch information
Sadegh Hayeri committed Mar 12, 2020
1 parent c6afeb3 commit 7afd428
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
3 changes: 2 additions & 1 deletion bin/gt.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ async function main() {
dns: {
type: argv['dns-type'],
server: argv['dns-server']
}
},
source: 'CLI',
});

const exitTrap = async () => {
Expand Down
2 changes: 1 addition & 1 deletion gui/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ async function turnOn() {
await turnOff()
}

proxy = new Proxy();
proxy = new Proxy({source: 'GUI'});
await proxy.start({setProxy: true});

win.webContents.send('changeStatus', isOn);
Expand Down
2 changes: 1 addition & 1 deletion src/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export default class Proxy {
this.server = undefined;
this.isSystemProxySet = false;
this.initDNS();
appInit(customConfig.source);
}

initDNS() {
Expand All @@ -24,7 +25,6 @@ export default class Proxy {
}

async start(options = {}) {
appInit();
options.setProxy = options.setProxy === undefined ? false : options.setProxy;

this.server = net.createServer({pauseOnConnect: true}, clientSocket => {
Expand Down
13 changes: 11 additions & 2 deletions src/utils/analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,24 @@ import ua from 'universal-analytics';
import uuid from 'uuid/v4';
import { JSONStorage } from 'node-localstorage';
import appData from 'app-data-folder';
import os from 'os';
import packageJson from '../../package.json'

const nodeStorage = new JSONStorage(appData('greentunnel'));
const userId = nodeStorage.getItem('userid') || uuid();
nodeStorage.setItem('userid', userId);

var visitor = ua('UA-160385585-1', userId);

function appInit() {
visitor.event("gt", "init").send()
function appInit(source = 'OTHER') {
visitor.set('version', packageJson.version);
visitor.set('os', os.platform());
visitor.set('source', source);

visitor.event('gt-total', 'init').send();
visitor.event(`gt-${source}`, 'init').send();
visitor.event(`gt-${os.platform()}`, 'init').send();
visitor.event(`gt-${packageJson.version}`, 'init').send();
}

export {appInit};

0 comments on commit 7afd428

Please sign in to comment.