Skip to content

Commit 965bd3e

Browse files
author
shengyonggen
committed
自定义控制台输出,修改获取样式在firefox下兼容性,修改说明中的括号
1 parent 37bb0db commit 965bd3e

File tree

7 files changed

+58
-37
lines changed

7 files changed

+58
-37
lines changed

sensorsdata.amd.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sensorsdata.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/sdk.js

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ logger.info = function() {
2727
if (!sd.para.show_log) {
2828
return false;
2929
}
30+
if(sd.para.show_log === true || sd.para.show_log === 'string'){
31+
arguments[0] = _.formatJsonString(arguments[0]);
32+
}
33+
3034
if (typeof console === 'object' && console.log) {
3135
try {
3236
return console.log.apply(console, arguments);
@@ -1329,7 +1333,10 @@ _.ry.init.prototype = {
13291333
if (result) {
13301334
return result;
13311335
}
1332-
var rules = getMatchedCSSRules(this.ele);
1336+
var rules = null;
1337+
if(typeof window.getMatchedCSSRules === 'function'){
1338+
rules = getMatchedCSSRules(this.ele);
1339+
}
13331340
if(!rules || !_.isArray(rules)){
13341341
return null;
13351342
}
@@ -1340,7 +1347,7 @@ _.ry.init.prototype = {
13401347
return result;
13411348
}
13421349
}
1343-
}
1350+
}
13441351
};
13451352

13461353
_.jssdkDebug = function(recevie_prop,has_prop){
@@ -1380,7 +1387,7 @@ _.querySelectorAll = function(val){
13801387
_.getReferrer = function(referrer){
13811388
var referrer = referrer || document.referrer;
13821389
if(typeof referrer !== 'string'){
1383-
return '取值异常(referrer异常)(' + String(referrer) + ')';
1390+
return '取值异常_referrer异常_' + String(referrer);
13841391
}
13851392
if (referrer.indexOf("https://www.baidu.com/") === 0) {
13861393
referrer = referrer.split('?')[0];
@@ -1405,13 +1412,13 @@ _.getKeywordFromReferrer = function(){
14051412
return '未取到值';
14061413
}else{
14071414
if(document.referrer === ''){
1408-
return '未取到值(直接打开)';
1415+
return '未取到值_直接打开';
14091416
}else{
1410-
return '未取到值(非http的url)';
1417+
return '未取到值_非http的url';
14111418
}
14121419
}
14131420
}else{
1414-
return '取值异常(referrer异常)(' + String(document.referrer) + ')';
1421+
return '取值异常_referrer异常_' + String(document.referrer);
14151422
}
14161423
};
14171424

@@ -1457,10 +1464,10 @@ _.info = {
14571464
var url_domain = url ? _.url('domain',url) : url;
14581465

14591466
if(referrer && !referrer_domain){
1460-
_.jssdkDebug('referrer_domain异常(' + referrer + ')' + referrer_domain);
1467+
_.jssdkDebug('referrer_domain异常_' + referrer + '_' + referrer_domain);
14611468
}
14621469
if(!url_domain){
1463-
_.jssdkDebug('url_domain异常('+ url + ')' + url_domain);
1470+
_.jssdkDebug('url_domain异常_'+ url + '_' + url_domain);
14641471
}
14651472

14661473
this.pageProp = {
@@ -1545,7 +1552,7 @@ sd.sendState.getSendCall = function(data, callback) {
15451552
data._nocache = (String(Math.random()) + String(Math.random()) + String(Math.random())).replace(/\./g,'').slice(0,15);
15461553
var originData = data;
15471554
data = JSON.stringify(data);
1548-
logger.info(_.formatJsonString(originData));
1555+
logger.info(originData);
15491556
// 打通app传数据给app
15501557
if(sd.para.use_app_track){
15511558
if((typeof SensorsData_APP_JS_Bridge === 'object') && SensorsData_APP_JS_Bridge.sensorsdata_track){

src/sensorsdata.full.amd.js

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ var ObjProto = Object.prototype;
126126
var slice = ArrayProto.slice;
127127
var toString = ObjProto.toString;
128128
var hasOwnProperty = ObjProto.hasOwnProperty;
129-
var LIB_VERSION = '1.8.10';
129+
var LIB_VERSION = '1.8.11';
130130

131131
sd.lib_version = LIB_VERSION;
132132

@@ -149,6 +149,10 @@ logger.info = function() {
149149
if (!sd.para.show_log) {
150150
return false;
151151
}
152+
if(sd.para.show_log === true || sd.para.show_log === 'string'){
153+
arguments[0] = _.formatJsonString(arguments[0]);
154+
}
155+
152156
if (typeof console === 'object' && console.log) {
153157
try {
154158
return console.log.apply(console, arguments);
@@ -1451,7 +1455,10 @@ _.ry.init.prototype = {
14511455
if (result) {
14521456
return result;
14531457
}
1454-
var rules = getMatchedCSSRules(this.ele);
1458+
var rules = null;
1459+
if(typeof window.getMatchedCSSRules === 'function'){
1460+
rules = getMatchedCSSRules(this.ele);
1461+
}
14551462
if(!rules || !_.isArray(rules)){
14561463
return null;
14571464
}
@@ -1462,7 +1469,7 @@ _.ry.init.prototype = {
14621469
return result;
14631470
}
14641471
}
1465-
}
1472+
}
14661473
};
14671474

14681475
_.jssdkDebug = function(recevie_prop,has_prop){
@@ -1502,7 +1509,7 @@ _.querySelectorAll = function(val){
15021509
_.getReferrer = function(referrer){
15031510
var referrer = referrer || document.referrer;
15041511
if(typeof referrer !== 'string'){
1505-
return '取值异常(referrer异常)(' + String(referrer) + ')';
1512+
return '取值异常_referrer异常_' + String(referrer);
15061513
}
15071514
if (referrer.indexOf("https://www.baidu.com/") === 0) {
15081515
referrer = referrer.split('?')[0];
@@ -1527,13 +1534,13 @@ _.getKeywordFromReferrer = function(){
15271534
return '未取到值';
15281535
}else{
15291536
if(document.referrer === ''){
1530-
return '未取到值(直接打开)';
1537+
return '未取到值_直接打开';
15311538
}else{
1532-
return '未取到值(非http的url)';
1539+
return '未取到值_非http的url';
15331540
}
15341541
}
15351542
}else{
1536-
return '取值异常(referrer异常)(' + String(document.referrer) + ')';
1543+
return '取值异常_referrer异常_' + String(document.referrer);
15371544
}
15381545
};
15391546

@@ -1579,10 +1586,10 @@ _.info = {
15791586
var url_domain = url ? _.url('domain',url) : url;
15801587

15811588
if(referrer && !referrer_domain){
1582-
_.jssdkDebug('referrer_domain异常(' + referrer + ')' + referrer_domain);
1589+
_.jssdkDebug('referrer_domain异常_' + referrer + '_' + referrer_domain);
15831590
}
15841591
if(!url_domain){
1585-
_.jssdkDebug('url_domain异常('+ url + ')' + url_domain);
1592+
_.jssdkDebug('url_domain异常_'+ url + '_' + url_domain);
15861593
}
15871594

15881595
this.pageProp = {
@@ -1667,7 +1674,7 @@ sd.sendState.getSendCall = function(data, callback) {
16671674
data._nocache = (String(Math.random()) + String(Math.random()) + String(Math.random())).replace(/\./g,'').slice(0,15);
16681675
var originData = data;
16691676
data = JSON.stringify(data);
1670-
logger.info(_.formatJsonString(originData));
1677+
logger.info(originData);
16711678
// 打通app传数据给app
16721679
if(sd.para.use_app_track){
16731680
if((typeof SensorsData_APP_JS_Bridge === 'object') && SensorsData_APP_JS_Bridge.sensorsdata_track){

src/sensorsdata.full.js

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ var ObjProto = Object.prototype;
123123
var slice = ArrayProto.slice;
124124
var toString = ObjProto.toString;
125125
var hasOwnProperty = ObjProto.hasOwnProperty;
126-
var LIB_VERSION = '1.8.10';
126+
var LIB_VERSION = '1.8.11';
127127

128128
sd.lib_version = LIB_VERSION;
129129

@@ -146,6 +146,10 @@ logger.info = function() {
146146
if (!sd.para.show_log) {
147147
return false;
148148
}
149+
if(sd.para.show_log === true || sd.para.show_log === 'string'){
150+
arguments[0] = _.formatJsonString(arguments[0]);
151+
}
152+
149153
if (typeof console === 'object' && console.log) {
150154
try {
151155
return console.log.apply(console, arguments);
@@ -1448,7 +1452,10 @@ _.ry.init.prototype = {
14481452
if (result) {
14491453
return result;
14501454
}
1451-
var rules = getMatchedCSSRules(this.ele);
1455+
var rules = null;
1456+
if(typeof window.getMatchedCSSRules === 'function'){
1457+
rules = getMatchedCSSRules(this.ele);
1458+
}
14521459
if(!rules || !_.isArray(rules)){
14531460
return null;
14541461
}
@@ -1459,7 +1466,7 @@ _.ry.init.prototype = {
14591466
return result;
14601467
}
14611468
}
1462-
}
1469+
}
14631470
};
14641471

14651472
_.jssdkDebug = function(recevie_prop,has_prop){
@@ -1499,7 +1506,7 @@ _.querySelectorAll = function(val){
14991506
_.getReferrer = function(referrer){
15001507
var referrer = referrer || document.referrer;
15011508
if(typeof referrer !== 'string'){
1502-
return '取值异常(referrer异常)(' + String(referrer) + ')';
1509+
return '取值异常_referrer异常_' + String(referrer);
15031510
}
15041511
if (referrer.indexOf("https://www.baidu.com/") === 0) {
15051512
referrer = referrer.split('?')[0];
@@ -1524,13 +1531,13 @@ _.getKeywordFromReferrer = function(){
15241531
return '未取到值';
15251532
}else{
15261533
if(document.referrer === ''){
1527-
return '未取到值(直接打开)';
1534+
return '未取到值_直接打开';
15281535
}else{
1529-
return '未取到值(非http的url)';
1536+
return '未取到值_非http的url';
15301537
}
15311538
}
15321539
}else{
1533-
return '取值异常(referrer异常)(' + String(document.referrer) + ')';
1540+
return '取值异常_referrer异常_' + String(document.referrer);
15341541
}
15351542
};
15361543

@@ -1576,10 +1583,10 @@ _.info = {
15761583
var url_domain = url ? _.url('domain',url) : url;
15771584

15781585
if(referrer && !referrer_domain){
1579-
_.jssdkDebug('referrer_domain异常(' + referrer + ')' + referrer_domain);
1586+
_.jssdkDebug('referrer_domain异常_' + referrer + '_' + referrer_domain);
15801587
}
15811588
if(!url_domain){
1582-
_.jssdkDebug('url_domain异常('+ url + ')' + url_domain);
1589+
_.jssdkDebug('url_domain异常_'+ url + '_' + url_domain);
15831590
}
15841591

15851592
this.pageProp = {
@@ -1664,7 +1671,7 @@ sd.sendState.getSendCall = function(data, callback) {
16641671
data._nocache = (String(Math.random()) + String(Math.random()) + String(Math.random())).replace(/\./g,'').slice(0,15);
16651672
var originData = data;
16661673
data = JSON.stringify(data);
1667-
logger.info(_.formatJsonString(originData));
1674+
logger.info(originData);
16681675
// 打通app传数据给app
16691676
if(sd.para.use_app_track){
16701677
if((typeof SensorsData_APP_JS_Bridge === 'object') && SensorsData_APP_JS_Bridge.sensorsdata_track){

version.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
var sensorsdata_js_sdk_latest_version = '1.8.10';
1+
var sensorsdata_js_sdk_latest_version = '1.8.11';

vtrack.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)