Skip to content

Commit 5dc4770

Browse files
author
shengyonggen
committed
Release 1.18.14
1 parent b702acd commit 5dc4770

14 files changed

+183
-151
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 1.18.14 (2021-8-23)
2+
1. 新增
3+
- 支持采集页面浏览时长
4+
2. 修复
5+
- 修复 `$WebStay` 事件中 `event_duration` 可能为负值的问题
6+
17
## 1.18.13 (2021-8-18)
28
1. 新增
39
- 新增支持 `data-sensors-click` 无限层级

core/sensorsdata.amd.min.js

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

core/sensorsdata.es6.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.

core/sensorsdata.min.js

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

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.18.13",
3+
"version": "1.18.14",
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
@@ -9405,7 +9405,7 @@
94059405

94069406
window.sa_jssdk_heatmap_render = function(se, data, type, url) {
94079407
sd = se;
9408-
sd.heatmap_version = '1.18.13';
9408+
sd.heatmap_version = '1.18.14';
94099409
_ = sd._;
94109410

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

product/sensorsdata.amd.full.js

Lines changed: 54 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1564,11 +1564,11 @@
15641564
} else {
15651565
var ontype = 'on' + type;
15661566
var old_handler = element[ontype];
1567-
element[ontype] = makeHandler(element, handler, old_handler);
1567+
element[ontype] = makeHandler(element, handler, old_handler, type);
15681568
}
15691569
};
15701570

1571-
function makeHandler(element, new_handler, old_handlers) {
1571+
function makeHandler(element, new_handler, old_handlers, type) {
15721572
var handler = function(event) {
15731573
event = event || fixEvent(window.event);
15741574
if (!event) {
@@ -1582,10 +1582,12 @@
15821582
old_result = old_handlers(event);
15831583
}
15841584
new_result = new_handler.call(element, event);
1585-
if (false === old_result || false === new_result) {
1586-
ret = false;
1585+
if (type !== 'beforeunload') {
1586+
if (false === old_result || false === new_result) {
1587+
ret = false;
1588+
}
1589+
return ret;
15871590
}
1588-
return ret;
15891591
};
15901592
return handler;
15911593
}
@@ -2946,6 +2948,8 @@
29462948
Sys.chrome = Number(s[1].split('.')[0]);
29472949
} else if ((s = ua.match(/version\/([\d.]+).*safari/))) {
29482950
Sys.safari = Number(s[1].match(/^\d*.\d*/));
2951+
} else if ((s = ua.match(/trident\/([\d.]+)/))) {
2952+
Sys.ie = 11;
29492953
}
29502954
return Sys;
29512955
};
@@ -3095,7 +3099,7 @@
30953099

30963100
_.listenPageState = function(obj) {
30973101
var visibilystore = {
3098-
visibleHandle: _.isFunction(obj.visible) ? obj.visible : function() {},
3102+
visibleHandler: _.isFunction(obj.visible) ? obj.visible : function() {},
30993103
hiddenHandler: _.isFunction(obj.hidden) ? obj.hidden : function() {},
31003104
visibilityChange: null,
31013105
hidden: null,
@@ -3120,26 +3124,20 @@
31203124
},
31213125
listen: function() {
31223126
if (!this.isSupport()) {
3123-
if (document.addEventListener) {
3124-
window.addEventListener('focus', this.visibleHandle, 1);
3125-
window.addEventListener('blur', this.hiddenHandler, 1);
3126-
} else {
3127-
document.attachEvent('onfocusin', this.visibleHandle);
3128-
document.attachEvent('onfocusout', this.hiddenHandler);
3129-
}
3127+
_.addEvent(window, 'focus', this.visibleHandler)
3128+
_.addEvent(window, 'blur', this.hiddenHandler)
31303129
} else {
31313130
var _this = this;
3132-
document.addEventListener(
3133-
_this.visibilityChange,
3131+
_.addEvent(document, this.visibilityChange,
31343132
function() {
31353133
if (!document[_this.hidden]) {
3136-
_this.visibleHandle();
3134+
_this.visibleHandler();
31373135
} else {
31383136
_this.hiddenHandler();
31393137
}
31403138
},
31413139
1
3142-
);
3140+
)
31433141
}
31443142
}
31453143
};
@@ -3465,7 +3463,7 @@
34653463

34663464
sd.setInitVar = function() {
34673465
sd._t = sd._t || 1 * new Date();
3468-
sd.lib_version = '1.18.13';
3466+
sd.lib_version = '1.18.14';
34693467
sd.is_first_visitor = false;
34703468
sd.source_channel_standard = 'utm_source utm_medium utm_campaign utm_content utm_term';
34713469
};
@@ -4421,7 +4419,7 @@
44214419
source: 'sa-web-sdk',
44224420
type: 'v-is-vtrack',
44234421
data: {
4424-
sdkversion: '1.18.13'
4422+
sdkversion: '1.18.14'
44254423
}
44264424
},
44274425
'*'
@@ -5171,15 +5169,45 @@
51715169
};
51725170

51735171
saEvent.send = function(p, callback) {
5172+
var data = sd.kit.buildData(p);
5173+
sd.kit.sendData(data, callback);
5174+
};
5175+
5176+
saEvent.debugPath = function(data, callback) {
5177+
var _data = data;
5178+
var url = '';
5179+
if (sd.para.debug_mode_url.indexOf('?') !== -1) {
5180+
url = sd.para.debug_mode_url + '&data=' + encodeURIComponent(_.base64Encode(data));
5181+
} else {
5182+
url = sd.para.debug_mode_url + '?data=' + encodeURIComponent(_.base64Encode(data));
5183+
}
5184+
5185+
_.ajax({
5186+
url: url,
5187+
type: 'GET',
5188+
cors: true,
5189+
header: {
5190+
'Dry-Run': String(sd.para.debug_mode_upload)
5191+
},
5192+
success: function(data) {
5193+
_.isEmptyObject(data) === true ? alert('debug数据发送成功' + _data) : alert('debug失败 错误原因' + JSON.stringify(data));
5194+
}
5195+
});
5196+
};;
5197+
5198+
var kit = sd.kit = {};
5199+
5200+
kit.buildData = function(p) {
51745201
var data = {
5175-
distinct_id: store.getDistinctId(),
5202+
distinct_id: sd.store.getDistinctId(),
51765203
lib: {
51775204
$lib: 'js',
51785205
$lib_method: 'code',
51795206
$lib_version: String(sd.lib_version)
51805207
},
51815208
properties: {}
51825209
};
5210+
51835211
if (_.isObject(p) && _.isObject(p.properties) && !_.isEmptyObject(p.properties)) {
51845212
if (p.properties.$lib_detail) {
51855213
data.lib.$lib_detail = p.properties.$lib_detail;
@@ -5197,6 +5225,7 @@
51975225
_.extend(data.properties, p.properties);
51985226
}
51995227

5228+
52005229
if (!p.type || p.type.slice(0, 7) !== 'profile') {
52015230

52025231
data.properties = _.extend({}, _.info.properties(), store.getProps(), store.getSessionProps(), _.info.currentProps, data.properties);
@@ -5248,14 +5277,16 @@
52485277
_.searchObjString(data);
52495278
_.searchZZAppStyle(data);
52505279

5251-
var data_config = _.searchConfigData(data.properties);
5252-
52535280
saNewUser.checkIsAddSign(data);
52545281
saNewUser.checkIsFirstTime(data);
52555282

52565283
sd.addReferrerHost(data);
52575284
sd.addPropsHook(data);
5285+
return data;
5286+
}
52585287

5288+
kit.sendData = function(data, callback) {
5289+
var data_config = _.searchConfigData(data.properties);
52595290
if (sd.para.debug_mode === true) {
52605291
sd.log(data);
52615292
this.debugPath(JSON.stringify(data), callback);
@@ -5264,28 +5295,6 @@
52645295
}
52655296
};
52665297

5267-
saEvent.debugPath = function(data, callback) {
5268-
var _data = data;
5269-
var url = '';
5270-
if (sd.para.debug_mode_url.indexOf('?') !== -1) {
5271-
url = sd.para.debug_mode_url + '&data=' + encodeURIComponent(_.base64Encode(data));
5272-
} else {
5273-
url = sd.para.debug_mode_url + '?data=' + encodeURIComponent(_.base64Encode(data));
5274-
}
5275-
5276-
_.ajax({
5277-
url: url,
5278-
type: 'GET',
5279-
cors: true,
5280-
header: {
5281-
'Dry-Run': String(sd.para.debug_mode_upload)
5282-
},
5283-
success: function(data) {
5284-
_.isEmptyObject(data) === true ? alert('debug数据发送成功' + _data) : alert('debug失败 错误原因' + JSON.stringify(data));
5285-
}
5286-
});
5287-
};;
5288-
52895298

52905299
var store = (sd.store = {
52915300
requests: [],
@@ -6470,6 +6479,7 @@
64706479
para.$title = document.title;
64716480
para.$url_path = location.pathname;
64726481
para.event_duration = Math.min(sd.para.heatmap.scroll_event_duration, parseInt(delay_time) / 1000);
6482+
para.event_duration = para.event_duration < 0 ? 0 : para.event_duration;
64736483
sd.track('$WebStay', para);
64746484
}
64756485
this.current_time = current_time;

0 commit comments

Comments
 (0)