Skip to content

Commit ee73fa9

Browse files
committed
release 1.14.22
1 parent 29f0b01 commit ee73fa9

11 files changed

+180
-84
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## 1.14.22 (2020-2-24)
2+
3+
* 优化:发送采集的数据时,会将与系统保留字段同名的属性过滤
4+
* 修复:identify API 不传第二个参数,仍然会修改 storage 中的 distinct_id
5+
* 优化:源码中移除了一点测试代码
6+
* 新增:新增配置项设置 app 打通校验失败后,是否发送数据
7+
18
## 1.14.21 (2020-2-10)
29

310
* 优化:热力图样式被全局样式干扰问题

heatmap.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sa-sdk-javascript",
3-
"version": "1.14.21",
3+
"version": "1.14.22",
44
"description": "official sensorsdata javascript sdk",
55
"main": "sensorsdata.min.js",
66
"scripts": {

product/heatmap.full.js

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8754,11 +8754,6 @@
87548754
error: function(res) {
87558755
me.showErrorInfo(2, res);
87568756
sessionStorage.removeItem('sensors_heatmap_id');
8757-
8758-
if (location.href.indexOf('http://www.notrack.com:8080/sdk_test.html') === 0) {
8759-
me.bindEffect();
8760-
me.calculateHeatData(window.data_sa_heat_test_data_test_201703130440 || {});
8761-
}
87628757
}
87638758
});
87648759
} else {
@@ -8778,11 +8773,6 @@
87788773
error: function(res) {
87798774
me.showErrorInfo(4, res);
87808775
sessionStorage.removeItem('sensors_heatmap_id');
8781-
8782-
if (location.href.indexOf('http://www.notrack.com:8080/sdk_test.html') === 0) {
8783-
me.bindEffect();
8784-
me.calculateHeatData(window.data_sa_heat_test_data_test_201703130440 || {});
8785-
}
87868776
}
87878777
});
87888778
}
@@ -9322,7 +9312,7 @@
93229312

93239313
window.sa_jssdk_heatmap_render = function(se, data, type, url) {
93249314
sd = se;
9325-
sd.heatmap_version = '1.14.21';
9315+
sd.heatmap_version = '1.14.22';
93269316
_ = sd._;
93279317

93289318
_.bindReady = function(fn, win) {

product/sensorsdata.amd.full.js

Lines changed: 54 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,25 @@
589589
}
590590
};
591591

592+
593+
_.filterReservedProperties = function(obj) {
594+
var reservedFields = ['distinct_id', 'user_id', 'id', 'date', 'datetime', 'event', 'events', 'first_id', 'original_id', 'device_id', 'properties', 'second_id', 'time', 'users'];
595+
if (!_.isObject(obj)) {
596+
return;
597+
}
598+
_.each(reservedFields, function(key, index) {
599+
if (!(key in obj)) {
600+
return;
601+
}
602+
if (index < 3) {
603+
delete obj[key];
604+
sd.log("您的属性- " + key + '是保留字段,我们已经将其删除')
605+
} else {
606+
sd.log("您的属性- " + key + '是保留字段,请避免其作为属性名')
607+
}
608+
});
609+
}
610+
592611
_.searchConfigData = function(data) {
593612
if (typeof data === 'object' && data.$option) {
594613
var data_config = data.$option;
@@ -1968,6 +1987,7 @@
19681987
queue_timeout: 300,
19691988
is_track_device_id: false,
19701989
use_app_track: false,
1990+
use_app_track_is_send: true,
19711991
ignore_oom: true
19721992
};
19731993

@@ -2131,7 +2151,7 @@
21312151

21322152
sd.setInitVar = function() {
21332153
sd._t = sd._t || 1 * new Date();
2134-
sd.lib_version = '1.14.21';
2154+
sd.lib_version = '1.14.22';
21352155
sd.is_first_visitor = false;
21362156
sd.source_channel_standard = 'utm_source utm_medium utm_campaign utm_content utm_term';
21372157
};
@@ -2399,7 +2419,7 @@
23992419
if (_.isEmptyObject(sd.store._state)) {
24002420
return '请先初始化SDK';
24012421
} else {
2402-
return sd.store._state.first_id ? sd.store._state.first_id : sd.store._state.distinct_id;
2422+
return sd.store._state._first_id || sd.store._state.first_id || sd.store._state._distinct_id || sd.store._state.distinct_id;
24032423
}
24042424
}
24052425

@@ -3082,12 +3102,14 @@
30823102
if (!SensorsData_APP_JS_Bridge.sensorsdata_verify(JSON.stringify(_.extend({
30833103
server_url: sd.para.server_url
30843104
}, originData)))) {
3085-
sd.debug.apph5({
3086-
data: originData,
3087-
step: '3.1',
3088-
output: 'all'
3089-
});
3090-
this.prepareServerUrl();
3105+
if (sd.para.use_app_track_is_send) {
3106+
sd.debug.apph5({
3107+
data: originData,
3108+
step: '3.1',
3109+
output: 'all'
3110+
});
3111+
this.prepareServerUrl();
3112+
}
30913113
} else {
30923114
(typeof callback === 'function') && callback();
30933115
}
@@ -3119,12 +3141,14 @@
31193141
iframe = null;
31203142
(typeof callback === 'function') && callback();
31213143
} else {
3122-
sd.debug.apph5({
3123-
data: originData,
3124-
step: '3.2',
3125-
output: 'all'
3126-
});
3127-
this.prepareServerUrl();
3144+
if (sd.para.use_app_track_is_send) {
3145+
sd.debug.apph5({
3146+
data: originData,
3147+
step: '3.2',
3148+
output: 'all'
3149+
});
3150+
this.prepareServerUrl();
3151+
}
31283152
}
31293153
}
31303154
} else {
@@ -3138,7 +3162,7 @@
31383162
(typeof callback === 'function') && callback();
31393163
}
31403164
} else {
3141-
if (sd.para.use_app_track === true) {
3165+
if (sd.para.use_app_track === true && sd.para.use_app_track_is_send === true) {
31423166
sd.debug.apph5({
31433167
data: originData,
31443168
step: '2',
@@ -3342,6 +3366,7 @@
33423366
}
33433367
_.parseSuperProperties(data.properties);
33443368

3369+
_.filterReservedProperties(data.properties);
33453370
_.searchObjDate(data);
33463371
_.searchObjString(data);
33473372
_.searchZZAppStyle(data);
@@ -3402,12 +3427,12 @@
34023427
return this._sessionState;
34033428
},
34043429
getDistinctId: function() {
3405-
return this._state.distinct_id;
3430+
return this._state._distinct_id || this._state.distinct_id;
34063431
},
34073432
getUnionId: function() {
34083433
var obj = {};
3409-
var firstId = this._state.first_id,
3410-
distinct_id = this._state.distinct_id;
3434+
var firstId = this._state._first_id || this._state.first_id,
3435+
distinct_id = this._state._distinct_id || this._state.distinct_id;
34113436
if (firstId && distinct_id) {
34123437
obj.login_id = distinct_id;
34133438
obj.anonymous_id = firstId;
@@ -3417,7 +3442,7 @@
34173442
return obj;
34183443
},
34193444
getFirstId: function() {
3420-
return this._state.first_id;
3445+
return this._state._first_id || this._state.first_id;
34213446
},
34223447
toState: function(ds) {
34233448
var state = null;
@@ -3459,10 +3484,15 @@
34593484
set: function(name, value) {
34603485
this._state = this._state || {};
34613486
this._state[name] = value;
3487+
if (name === 'first_id') {
3488+
delete this._state._first_id;
3489+
} else if (name === 'distinct_id') {
3490+
delete this._state._distinct_id;
3491+
}
34623492
this.save();
34633493
},
34643494
change: function(name, value) {
3465-
this._state[name] = value;
3495+
this._state['_' + name] = value;
34663496
},
34673497
setSessionProps: function(newp) {
34683498
var props = this._sessionState;
@@ -3516,7 +3546,10 @@
35163546
_.cookie.set('sensorsdata2015session', JSON.stringify(this._sessionState), 0);
35173547
},
35183548
save: function() {
3519-
_.cookie.set(this.getCookieName(), JSON.stringify(this._state), 73000, sd.para.cross_subdomain);
3549+
var copyState = JSON.parse(JSON.stringify(this._state));
3550+
delete copyState._first_id;
3551+
delete copyState._distinct_id;
3552+
_.cookie.set(this.getCookieName(), JSON.stringify(copyState), 73000, sd.para.cross_subdomain);
35203553
},
35213554
getCookieName: function() {
35223555
var sub = '';

product/sensorsdata.es6.full.js

Lines changed: 54 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,25 @@ if (typeof JSON !== 'object') {
577577
}
578578
};
579579

580+
581+
_.filterReservedProperties = function(obj) {
582+
var reservedFields = ['distinct_id', 'user_id', 'id', 'date', 'datetime', 'event', 'events', 'first_id', 'original_id', 'device_id', 'properties', 'second_id', 'time', 'users'];
583+
if (!_.isObject(obj)) {
584+
return;
585+
}
586+
_.each(reservedFields, function(key, index) {
587+
if (!(key in obj)) {
588+
return;
589+
}
590+
if (index < 3) {
591+
delete obj[key];
592+
sd.log("您的属性- " + key + '是保留字段,我们已经将其删除')
593+
} else {
594+
sd.log("您的属性- " + key + '是保留字段,请避免其作为属性名')
595+
}
596+
});
597+
}
598+
580599
_.searchConfigData = function(data) {
581600
if (typeof data === 'object' && data.$option) {
582601
var data_config = data.$option;
@@ -1956,6 +1975,7 @@ sd.para_default = {
19561975
queue_timeout: 300,
19571976
is_track_device_id: false,
19581977
use_app_track: false,
1978+
use_app_track_is_send: true,
19591979
ignore_oom: true
19601980
};
19611981

@@ -2119,7 +2139,7 @@ sd.setPreConfig = function(sa) {
21192139

21202140
sd.setInitVar = function() {
21212141
sd._t = sd._t || 1 * new Date();
2122-
sd.lib_version = '1.14.21';
2142+
sd.lib_version = '1.14.22';
21232143
sd.is_first_visitor = false;
21242144
sd.source_channel_standard = 'utm_source utm_medium utm_campaign utm_content utm_term';
21252145
};
@@ -2387,7 +2407,7 @@ var commonWays = {
23872407
if (_.isEmptyObject(sd.store._state)) {
23882408
return '请先初始化SDK';
23892409
} else {
2390-
return sd.store._state.first_id ? sd.store._state.first_id : sd.store._state.distinct_id;
2410+
return sd.store._state._first_id || sd.store._state.first_id || sd.store._state._distinct_id || sd.store._state.distinct_id;
23912411
}
23922412
}
23932413

@@ -3070,12 +3090,14 @@ sendState.getSendCall = function(data, config, callback) {
30703090
if (!SensorsData_APP_JS_Bridge.sensorsdata_verify(JSON.stringify(_.extend({
30713091
server_url: sd.para.server_url
30723092
}, originData)))) {
3073-
sd.debug.apph5({
3074-
data: originData,
3075-
step: '3.1',
3076-
output: 'all'
3077-
});
3078-
this.prepareServerUrl();
3093+
if (sd.para.use_app_track_is_send) {
3094+
sd.debug.apph5({
3095+
data: originData,
3096+
step: '3.1',
3097+
output: 'all'
3098+
});
3099+
this.prepareServerUrl();
3100+
}
30793101
} else {
30803102
(typeof callback === 'function') && callback();
30813103
}
@@ -3107,12 +3129,14 @@ sendState.getSendCall = function(data, config, callback) {
31073129
iframe = null;
31083130
(typeof callback === 'function') && callback();
31093131
} else {
3110-
sd.debug.apph5({
3111-
data: originData,
3112-
step: '3.2',
3113-
output: 'all'
3114-
});
3115-
this.prepareServerUrl();
3132+
if (sd.para.use_app_track_is_send) {
3133+
sd.debug.apph5({
3134+
data: originData,
3135+
step: '3.2',
3136+
output: 'all'
3137+
});
3138+
this.prepareServerUrl();
3139+
}
31163140
}
31173141
}
31183142
} else {
@@ -3126,7 +3150,7 @@ sendState.getSendCall = function(data, config, callback) {
31263150
(typeof callback === 'function') && callback();
31273151
}
31283152
} else {
3129-
if (sd.para.use_app_track === true) {
3153+
if (sd.para.use_app_track === true && sd.para.use_app_track_is_send === true) {
31303154
sd.debug.apph5({
31313155
data: originData,
31323156
step: '2',
@@ -3330,6 +3354,7 @@ saEvent.send = function(p, callback) {
33303354
}
33313355
_.parseSuperProperties(data.properties);
33323356

3357+
_.filterReservedProperties(data.properties);
33333358
_.searchObjDate(data);
33343359
_.searchObjString(data);
33353360
_.searchZZAppStyle(data);
@@ -3390,12 +3415,12 @@ var store = sd.store = {
33903415
return this._sessionState;
33913416
},
33923417
getDistinctId: function() {
3393-
return this._state.distinct_id;
3418+
return this._state._distinct_id || this._state.distinct_id;
33943419
},
33953420
getUnionId: function() {
33963421
var obj = {};
3397-
var firstId = this._state.first_id,
3398-
distinct_id = this._state.distinct_id;
3422+
var firstId = this._state._first_id || this._state.first_id,
3423+
distinct_id = this._state._distinct_id || this._state.distinct_id;
33993424
if (firstId && distinct_id) {
34003425
obj.login_id = distinct_id;
34013426
obj.anonymous_id = firstId;
@@ -3405,7 +3430,7 @@ var store = sd.store = {
34053430
return obj;
34063431
},
34073432
getFirstId: function() {
3408-
return this._state.first_id;
3433+
return this._state._first_id || this._state.first_id;
34093434
},
34103435
toState: function(ds) {
34113436
var state = null;
@@ -3447,10 +3472,15 @@ var store = sd.store = {
34473472
set: function(name, value) {
34483473
this._state = this._state || {};
34493474
this._state[name] = value;
3475+
if (name === 'first_id') {
3476+
delete this._state._first_id;
3477+
} else if (name === 'distinct_id') {
3478+
delete this._state._distinct_id;
3479+
}
34503480
this.save();
34513481
},
34523482
change: function(name, value) {
3453-
this._state[name] = value;
3483+
this._state['_' + name] = value;
34543484
},
34553485
setSessionProps: function(newp) {
34563486
var props = this._sessionState;
@@ -3504,7 +3534,10 @@ var store = sd.store = {
35043534
_.cookie.set('sensorsdata2015session', JSON.stringify(this._sessionState), 0);
35053535
},
35063536
save: function() {
3507-
_.cookie.set(this.getCookieName(), JSON.stringify(this._state), 73000, sd.para.cross_subdomain);
3537+
var copyState = JSON.parse(JSON.stringify(this._state));
3538+
delete copyState._first_id;
3539+
delete copyState._distinct_id;
3540+
_.cookie.set(this.getCookieName(), JSON.stringify(copyState), 73000, sd.para.cross_subdomain);
35083541
},
35093542
getCookieName: function() {
35103543
var sub = '';

0 commit comments

Comments
 (0)