@@ -25,8 +25,10 @@ if(typeof JSON!=='object'){JSON={}}(function(){'use strict';var rx_one=/^[\],:{}
2525 debug_mode : false ,
2626 debug_mode_upload : false ,
2727 vtrack_prefix : false ,
28+ // todo
2829 session_time : 0 ,
2930 use_client_time : false ,
31+ // todo
3032 auto_init : true
3133 } ;
3234 // 合并配置
@@ -49,9 +51,6 @@ if(typeof JSON!=='object'){JSON={}}(function(){'use strict';var rx_one=/^[\],:{}
4951 }
5052
5153 // 是否需要给可视化埋点加前缀
52-
53-
54-
5554
5655 var detector = { } ;
5756 ( function ( ) {
@@ -600,7 +599,7 @@ if(typeof JSON!=='object'){JSON={}}(function(){'use strict';var rx_one=/^[\],:{}
600599 , slice = ArrayProto . slice
601600 , toString = ObjProto . toString
602601 , hasOwnProperty = ObjProto . hasOwnProperty
603- , LIB_VERSION = '1.4.4 ' ;
602+ , LIB_VERSION = '1.4.5 ' ;
604603
605604// 提供错误日志
606605 var error_msg = [ ] ;
@@ -1326,6 +1325,33 @@ if(typeof JSON!=='object'){JSON={}}(function(){'use strict';var rx_one=/^[\],:{}
13261325
13271326 */
13281327
1328+ // 数据发送状态
1329+ sd . sendState = { }
1330+ //成功发送数
1331+ sd . sendState . _complete = 0 ;
1332+ //接受发送数
1333+ sd . sendState . _receive = 0 ;
1334+ sd . sendState . getSendCall = function ( data , callback ) {
1335+ ++ this . _receive ;
1336+ var state = '_state' + this . _receive ;
1337+ var me = this ;
1338+ this [ state ] = document . createElement ( 'img' ) ;
1339+ this [ state ] . onload = this [ state ] . onerror = function ( e ) {
1340+ me [ state ] . onload = null ;
1341+ me [ state ] . onerror = null ;
1342+ delete me [ state ] ;
1343+ ++ me . _complete ;
1344+ ( typeof callback === 'function' ) && callback ( ) ;
1345+ } ;
1346+ if ( sd . para . server_url . indexOf ( '?' ) !== - 1 ) {
1347+ this [ state ] . src = sd . para . server_url + '&data=' + encodeURIComponent ( _ . base64Encode ( data ) ) ;
1348+ } else {
1349+ this [ state ] . src = sd . para . server_url + '?data=' + encodeURIComponent ( _ . base64Encode ( data ) ) ;
1350+ }
1351+ } ;
1352+
1353+
1354+
13291355// 检查是否是新用户(第一次种cookie,且在8个小时内的)
13301356 var saNewUser = {
13311357 checkIsAddSign : function ( data ) {
@@ -1351,7 +1377,6 @@ if(typeof JSON!=='object'){JSON={}}(function(){'use strict';var rx_one=/^[\],:{}
13511377 }
13521378 } ;
13531379
1354-
13551380 var saEvent = { } ;
13561381
13571382 saEvent . checkOption = {
@@ -1489,7 +1514,7 @@ if(typeof JSON!=='object'){JSON={}}(function(){'use strict';var rx_one=/^[\],:{}
14891514 this . debugPath ( JSON . stringify ( data ) , callback ) ;
14901515 } else {
14911516 logger . info ( data ) ;
1492- this . serverPath ( JSON . stringify ( data ) , callback ) ;
1517+ sd . sendState . getSendCall ( JSON . stringify ( data ) , callback ) ;
14931518 }
14941519
14951520 } ;
@@ -1512,26 +1537,6 @@ if(typeof JSON!=='object'){JSON={}}(function(){'use strict';var rx_one=/^[\],:{}
15121537
15131538 } ;
15141539
1515- // 发送请求
1516- saEvent . serverPath = function ( data , callback ) {
1517- sd . requestImg = new Image ( ) ;
1518- sd . requestImg . onload = sd . requestImg . onerror = function ( ) {
1519- if ( sd . requestImg ) {
1520- //callback && callback();
1521- sd . requestImg . onload = null ;
1522- sd . requestImg . onerror = null ;
1523- sd . requestImg = null ;
1524- }
1525- } ;
1526-
1527- if ( sd . para . server_url . indexOf ( '?' ) !== - 1 ) {
1528- sd . requestImg . src = sd . para . server_url + '&data=' + encodeURIComponent ( _ . base64Encode ( data ) ) ;
1529- } else {
1530- sd . requestImg . src = sd . para . server_url + '?data=' + encodeURIComponent ( _ . base64Encode ( data ) ) ;
1531- }
1532-
1533- } ;
1534-
15351540 var store = sd . store = {
15361541 getProps : function ( ) {
15371542 return this . _state . props ;
0 commit comments