Skip to content

Commit d0d7f84

Browse files
committed
release 1.15.1
1 parent 7898227 commit d0d7f84

11 files changed

+298
-41
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 1.15.1 (2020-4-12)
2+
3+
* 新增:由于弹框需要,新增监听事件发送和 ID 切换功能
4+
* 新增:为方便接入后续的弹框和可视化功能,新增了设置插件功能
5+
16
## 1.14.24 (2020-4-3)
27

38
* 新增:$SignUp 事件带上 $url 和 $title 预置属性

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.24",
3+
"version": "1.15.1",
44
"description": "official sensorsdata javascript sdk",
55
"main": "sensorsdata.min.js",
66
"scripts": {

product/heatmap.full.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9329,7 +9329,7 @@
93299329

93309330
window.sa_jssdk_heatmap_render = function(se, data, type, url) {
93319331
sd = se;
9332-
sd.heatmap_version = '1.14.24';
9332+
sd.heatmap_version = '1.15.1';
93339333
_ = sd._;
93349334

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

product/sensorsdata.amd.full.js

Lines changed: 94 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1966,7 +1966,59 @@
19661966
}
19671967
};
19681968

1969+
_.eventEmitter = function() {
1970+
this._events = [];
1971+
this.pendingEvents = [];
1972+
}
19691973

1974+
_.eventEmitter.prototype = {
1975+
emit: function(type) {
1976+
var args = [].slice.call(arguments, 1);
1977+
1978+
_.each(this._events, function(val) {
1979+
if (val.type !== type) {
1980+
return;
1981+
}
1982+
val.callback.apply(val.context, args);
1983+
})
1984+
},
1985+
on: function(event, callback, context) {
1986+
if (typeof callback !== 'function') {
1987+
return;
1988+
}
1989+
this._events.push({
1990+
type: event,
1991+
callback: callback,
1992+
context: context || this
1993+
});
1994+
},
1995+
tempAdd: function(event, data) {
1996+
if (!data || !event) {
1997+
return;
1998+
}
1999+
2000+
this.pendingEvents.push({
2001+
type: event,
2002+
data: data
2003+
});
2004+
this.pendingEvents.length > 20 ? this.pendingEvents.shift() : null;
2005+
},
2006+
isReady: function() {
2007+
var that = this;
2008+
this.tempAdd = this.emit;
2009+
2010+
if (this.pendingEvents.length === 0) {
2011+
return;
2012+
}
2013+
_.each(this.pendingEvents, function(val) {
2014+
that.emit(val.type, val.data);
2015+
})
2016+
2017+
this.pendingEvents = [];
2018+
2019+
}
2020+
2021+
}
19702022

19712023

19722024
})();
@@ -2067,10 +2119,10 @@
20672119
}
20682120
}
20692121
if (typeof sd.para.server_url === 'string' && sd.para.server_url.slice(0, 3) === '://') {
2070-
sd.para.server_url = location.protocol + sd.para.server_url;
2122+
sd.para.server_url = location.protocol.slice(-1) + sd.para.server_url;
20712123
}
20722124
if (typeof sd.para.web_url === 'string' && sd.para.web_url.slice(0, 3) === '://') {
2073-
sd.para.web_url = location.protocol + sd.para.web_url;
2125+
sd.para.web_url = location.protocol.slice(-1) + sd.para.web_url;
20742126
}
20752127

20762128
if (sd.para.send_type !== 'image' && sd.para.send_type !== 'ajax' && sd.para.send_type !== 'beacon') {
@@ -2183,7 +2235,7 @@
21832235

21842236
sd.setInitVar = function() {
21852237
sd._t = sd._t || 1 * new Date();
2186-
sd.lib_version = '1.14.24';
2238+
sd.lib_version = '1.15.1';
21872239
sd.is_first_visitor = false;
21882240
sd.source_channel_standard = 'utm_source utm_medium utm_campaign utm_content utm_term';
21892241
};
@@ -2453,9 +2505,21 @@
24532505
} else {
24542506
return sd.store._state._first_id || sd.store._state.first_id || sd.store._state._distinct_id || sd.store._state.distinct_id;
24552507
}
2508+
},
2509+
setPlugin: function(para) {
2510+
if (!_.isObject(para)) {
2511+
return false;
2512+
}
2513+
_.each(para, function(v, k) {
2514+
if (_.isFunction(v)) {
2515+
if (_.isObject(window.SensorsDataWebJSSDKPlugin) && window.SensorsDataWebJSSDKPlugin[k]) {
2516+
v(window.SensorsDataWebJSSDKPlugin[k]);
2517+
} else {
2518+
sd.log(k + '没有获取到,请查阅文档,调整' + k + '的引入顺序!')
2519+
}
2520+
}
2521+
});
24562522
}
2457-
2458-
24592523
};
24602524

24612525
sd.quick = function() {
@@ -2630,10 +2694,11 @@
26302694
}
26312695
var firstId = store.getFirstId();
26322696
if (typeof id === 'undefined') {
2697+
var uuid = _.UUID();
26332698
if (firstId) {
2634-
store.set('first_id', _.UUID());
2699+
store.set('first_id', uuid);
26352700
} else {
2636-
store.set('distinct_id', _.UUID());
2701+
store.set('distinct_id', uuid);
26372702
}
26382703
} else if (saEvent.check({
26392704
distinct_id: id
@@ -2758,10 +2823,12 @@
27582823
if (firstId) {
27592824
store.set('first_id', '');
27602825
if (isChangeId === true) {
2761-
store.set('distinct_id', _.UUID());
2826+
var uuid = _.UUID();
2827+
store.set('distinct_id', uuid);
27622828
} else {
27632829
store.set('distinct_id', firstId);
27642830
}
2831+
27652832
} else {
27662833
sd.log('没有first_id,logout失败');
27672834
}
@@ -2798,6 +2865,16 @@
27982865

27992866

28002867

2868+
2869+
2870+
2871+
2872+
2873+
2874+
2875+
2876+
2877+
28012878
function BatchSend() {
28022879
this.sendingData = 0;
28032880
};
@@ -3093,6 +3170,7 @@
30933170

30943171
var sendState = {};
30953172
sd.sendState = sendState;
3173+
sd.events = new _.eventEmitter();
30963174
sendState.queue = _.autoExeQueue();
30973175

30983176
sendState.requestData = null;
@@ -3122,6 +3200,8 @@
31223200
callback: callback
31233201
};
31243202

3203+
sd.events.tempAdd('send', originData);
3204+
31253205
if (!sd.para.use_app_track && sd.para.batch_send && localStorage.length < 200) {
31263206
sd.log(originData);
31273207
sd.batchSend.add(this.requestData.data);
@@ -3517,13 +3597,17 @@
35173597
},
35183598
set: function(name, value) {
35193599
this._state = this._state || {};
3600+
if (name === 'distinct_id' && this._state.distinct_id) {
3601+
sd.events.tempAdd('changeDistinctId', value);
3602+
}
35203603
this._state[name] = value;
35213604
if (name === 'first_id') {
35223605
delete this._state._first_id;
35233606
} else if (name === 'distinct_id') {
35243607
delete this._state._distinct_id;
35253608
}
35263609
this.save();
3610+
35273611
},
35283612
change: function(name, value) {
35293613
this._state['_' + name] = value;
@@ -3789,7 +3873,7 @@
37893873
sd.errorMsg = '您SDK没有配置开启点击图,可能没有数据!';
37903874
}
37913875
if (web_url && web_url[0] && web_url[1]) {
3792-
if (web_url[1].slice(0, 5) === 'http:' && location.protocol === 'https') {
3876+
if (web_url[1].slice(0, 5) === 'http:' && location.protocol === 'https:') {
37933877
sd.errorMsg = '您的当前页面是https的地址,神策分析环境也必须是https!';
37943878
}
37953879
}
@@ -4278,8 +4362,8 @@
42784362
if (typeof window['sensorsDataAnalytic201505'] === 'string') {
42794363
sd.setPreConfig(window[sensorsDataAnalytic201505]);
42804364
window[sensorsDataAnalytic201505] = sd;
4281-
sd.init();
42824365
window['sensorsDataAnalytic201505'] = sd;
4366+
sd.init();
42834367
} else if (typeof window['sensorsDataAnalytic201505'] === 'undefined') {
42844368
window['sensorsDataAnalytic201505'] = sd;
42854369
return sd;

0 commit comments

Comments
 (0)