Browse Source

添加简单统计功能。

oldj 10 years ago
parent
commit
9094d1c756
4 changed files with 44 additions and 1 deletions
  1. 1 1
      app/SH3/MacGap/SwitchHosts!-Info.plist
  2. 0 0
      app/SH3/public/js/main.js
  3. 5 0
      app/src/main.js
  4. 38 0
      app/src/stat.js

+ 1 - 1
app/SH3/MacGap/SwitchHosts!-Info.plist

@@ -21,7 +21,7 @@
 	<key>CFBundleSignature</key>
 	<string>????</string>
 	<key>CFBundleVersion</key>
-	<string>3022</string>
+	<string>3037</string>
 	<key>LSApplicationCategoryType</key>
 	<string>public.app-category.developer-tools</string>
 	<key>LSMinimumSystemVersion</key>

File diff suppressed because it is too large
+ 0 - 0
app/SH3/public/js/main.js


+ 5 - 0
app/src/main.js

@@ -12,6 +12,7 @@ var util = require('./util');
 var agent = require('./agent');
 var refresh = require('./refresh');
 var lang = require('./lang').getLang(navigator.language);
+var stat = require('./stat');
 var tray_obj;
 
 var app = new Vue({
@@ -255,6 +256,8 @@ var app = new Vue({
                 }
                 _this._to_switch_host = null;
             });
+
+            stat.record('switch');
         },
         updateHost: function () {
             this.doSave();
@@ -441,3 +444,5 @@ ui.init(app);
 setTimeout(function () {
     app.checkRefresh();
 }, 1000);
+
+stat.record('launch');

+ 38 - 0
app/src/stat.js

@@ -0,0 +1,38 @@
+/**
+ * @author oldj
+ * @blog http://oldj.net
+ */
+
+'use strict';
+
+var url = 'http://lab.oldj.net/s.gif';
+var queue = [];
+var session_id = (new Date()).getTime() + ':' + Math.random();
+var v = require('./config').VERSION;
+
+exports.record = function (action) {
+    queue.push(action);
+};
+
+function send() {
+    if (queue.length === 0) {
+        return;
+    }
+
+    var src = url + '?app=sh3&action=' + queue.splice(0).join(',')
+        + '&v=' + v
+        + '&sid=' + session_id
+        + '&_r=' + Math.random();
+    var id = ('_rnd_img_' + Math.random()).replace('.', '');
+    var img = new Image();
+    window[id] = img;
+    img.src = src;
+
+    img.onload = img.onerror = function () {
+        window[id] = null;
+    };
+}
+
+setInterval(function () {
+    send();
+}, 5000);

Some files were not shown because too many files changed in this diff