Skip to content

Commit 19d2b75

Browse files
author
shengyonggen
committed
Release 1.23.2
1 parent dec6ac6 commit 19d2b75

23 files changed

+278
-172
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 1.23.2 (2022-06-20)
2+
1. 优化
3+
- 安全扫描优化
4+
2. 修复
5+
- 低版本 webview 中 `postMessage` 不兼容的问题
6+
17
## 1.23.1 (2022-06-10)
28
1. 新增
39
- `Web JS SDK` 重构四期,`App` 内嵌 `H5` 打通代码重构

core/sensorsdata.amd.min.js

Lines changed: 5 additions & 5 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: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

dist/sat/sensorsdata-sat.amd.full.js

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3146,7 +3146,7 @@
31463146
};
31473147

31483148
var source_channel_standard = 'utm_source utm_medium utm_campaign utm_content utm_term';
3149-
var sdkversion_placeholder = '1.23.1';
3149+
var sdkversion_placeholder = '1.23.2';
31503150
var domain_test_key = 'sensorsdata_domain_test';
31513151

31523152
var IDENTITY_KEY = {
@@ -3592,6 +3592,15 @@
35923592
}
35933593
};
35943594

3595+
function getSafeHttpProtocol() {
3596+
var protocol = location.protocol;
3597+
if (protocol === 'http:' || protocol === 'https:') {
3598+
return protocol;
3599+
} else {
3600+
return 'http:';
3601+
}
3602+
}
3603+
35953604
function getNewUserFlagKey(name_prefix, url) {
35963605
var sub = '';
35973606
url = url || location.href;
@@ -4683,7 +4692,7 @@
46834692
}
46844693
}
46854694
if (!sd.para.heatmap_url) {
4686-
sd.para.heatmap_url = location.protocol + '//static.sensorsdata.cn/sdk/' + sd.lib_version + '/heatmap.min.js';
4695+
sd.para.heatmap_url = getSafeHttpProtocol() + '//static.sensorsdata.cn/sdk/' + sd.lib_version + '/heatmap.min.js';
46874696
}
46884697
},
46894698
getDomIndex: function(el) {
@@ -6935,16 +6944,16 @@
69356944
lockTimeout = 10000,
69366945
lockPrefix = 'sajssdk-lock-get-';
69376946
for (var i = 0; i < localStorage.length; i++) {
6938-
var key = localStorage.key(i),
6947+
var item = localStorage.key(i),
69396948
self = this;
6940-
if (key.indexOf(tabStoragePrefix) === 0) {
6941-
var tabStorage = safeJSONParse(_localStorage.get(key)) || this.generateTabStorageVal();
6949+
if (item.indexOf(tabStoragePrefix) === 0) {
6950+
var tabStorage = safeJSONParse(_localStorage.get(item)) || this.generateTabStorageVal();
69426951
for (var j = 0; j < tabStorage.data.length; j++) {
69436952
notSendMap[tabStorage.data[j]] = true;
69446953
}
69456954
if (now() > tabStorage.expireTime && this.serverUrl === tabStorage.serverUrl) {
69466955
var concurrentStorage = new ConcurrentStorage(lockPrefix);
6947-
concurrentStorage.get(key, lockTimeout, 1000, function(data) {
6956+
concurrentStorage.get(item, lockTimeout, 1000, function(data) {
69486957
if (data) {
69496958
if (_localStorage.get(self.tabKey) === null) {
69506959
self.generateTabStorage();
@@ -6954,12 +6963,12 @@
69546963
}
69556964
});
69566965
}
6957-
} else if (key.indexOf(lockPrefix) === 0) {
6958-
var lock = safeJSONParse(_localStorage.get(key)) || {
6966+
} else if (item.indexOf(lockPrefix) === 0) {
6967+
var lock = safeJSONParse(_localStorage.get(item)) || {
69596968
expireTime: 0
69606969
};
69616970
if (now() - lock.expireTime > lockTimeout) {
6962-
_localStorage.remove(key);
6971+
_localStorage.remove(item);
69636972
}
69646973
}
69656974
}
@@ -8137,7 +8146,7 @@
81378146
success: function() {},
81388147
error: function() {},
81398148
type: 'js',
8140-
url: sd.para.vtrack_url ? sd.para.vtrack_url : location.protocol + '//static.sensorsdata.cn/sdk/' + sd.lib_version + '/vtrack.min.js'
8149+
url: sd.para.vtrack_url ? sd.para.vtrack_url : getSafeHttpProtocol() + '//static.sensorsdata.cn/sdk/' + sd.lib_version + '/vtrack.min.js'
81418150
});
81428151
},
81438152
messageListener: function(event) {
@@ -8182,16 +8191,20 @@
81828191
vtrackMode.postMessage();
81838192
},
81848193
postMessage: function() {
8185-
if (window.parent && window.parent.postMessage) {
8186-
window.parent.postMessage({
8187-
source: 'sa-web-sdk',
8188-
type: 'v-is-vtrack',
8189-
data: {
8190-
sdkversion: '1.23.1'
8191-
}
8192-
},
8193-
'*'
8194-
);
8194+
try {
8195+
if (window.parent && window.parent.postMessage) {
8196+
window.parent.postMessage({
8197+
source: 'sa-web-sdk',
8198+
type: 'v-is-vtrack',
8199+
data: {
8200+
sdkversion: '1.23.2'
8201+
}
8202+
},
8203+
'*'
8204+
);
8205+
}
8206+
} catch (e) {
8207+
sd.log('浏览器版本过低,不支持 postMessage API');
81958208
}
81968209
},
81978210
notifyUser: function() {

dist/sat/sensorsdata-sat.amd.min.js

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

dist/sat/sensorsdata-sat.es6.full.js

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3140,7 +3140,7 @@ var debug = {
31403140
};
31413141

31423142
var source_channel_standard = 'utm_source utm_medium utm_campaign utm_content utm_term';
3143-
var sdkversion_placeholder = '1.23.1';
3143+
var sdkversion_placeholder = '1.23.2';
31443144
var domain_test_key = 'sensorsdata_domain_test';
31453145

31463146
var IDENTITY_KEY = {
@@ -3586,6 +3586,15 @@ var cookie$1 = {
35863586
}
35873587
};
35883588

3589+
function getSafeHttpProtocol() {
3590+
var protocol = location.protocol;
3591+
if (protocol === 'http:' || protocol === 'https:') {
3592+
return protocol;
3593+
} else {
3594+
return 'http:';
3595+
}
3596+
}
3597+
35893598
function getNewUserFlagKey(name_prefix, url) {
35903599
var sub = '';
35913600
url = url || location.href;
@@ -4677,7 +4686,7 @@ var heatmap = {
46774686
}
46784687
}
46794688
if (!sd.para.heatmap_url) {
4680-
sd.para.heatmap_url = location.protocol + '//static.sensorsdata.cn/sdk/' + sd.lib_version + '/heatmap.min.js';
4689+
sd.para.heatmap_url = getSafeHttpProtocol() + '//static.sensorsdata.cn/sdk/' + sd.lib_version + '/heatmap.min.js';
46814690
}
46824691
},
46834692
getDomIndex: function(el) {
@@ -6929,16 +6938,16 @@ BatchSend.prototype = {
69296938
lockTimeout = 10000,
69306939
lockPrefix = 'sajssdk-lock-get-';
69316940
for (var i = 0; i < localStorage.length; i++) {
6932-
var key = localStorage.key(i),
6941+
var item = localStorage.key(i),
69336942
self = this;
6934-
if (key.indexOf(tabStoragePrefix) === 0) {
6935-
var tabStorage = safeJSONParse(_localStorage.get(key)) || this.generateTabStorageVal();
6943+
if (item.indexOf(tabStoragePrefix) === 0) {
6944+
var tabStorage = safeJSONParse(_localStorage.get(item)) || this.generateTabStorageVal();
69366945
for (var j = 0; j < tabStorage.data.length; j++) {
69376946
notSendMap[tabStorage.data[j]] = true;
69386947
}
69396948
if (now() > tabStorage.expireTime && this.serverUrl === tabStorage.serverUrl) {
69406949
var concurrentStorage = new ConcurrentStorage(lockPrefix);
6941-
concurrentStorage.get(key, lockTimeout, 1000, function(data) {
6950+
concurrentStorage.get(item, lockTimeout, 1000, function(data) {
69426951
if (data) {
69436952
if (_localStorage.get(self.tabKey) === null) {
69446953
self.generateTabStorage();
@@ -6948,12 +6957,12 @@ BatchSend.prototype = {
69486957
}
69496958
});
69506959
}
6951-
} else if (key.indexOf(lockPrefix) === 0) {
6952-
var lock = safeJSONParse(_localStorage.get(key)) || {
6960+
} else if (item.indexOf(lockPrefix) === 0) {
6961+
var lock = safeJSONParse(_localStorage.get(item)) || {
69536962
expireTime: 0
69546963
};
69556964
if (now() - lock.expireTime > lockTimeout) {
6956-
_localStorage.remove(key);
6965+
_localStorage.remove(item);
69576966
}
69586967
}
69596968
}
@@ -8131,7 +8140,7 @@ var vtrackMode = {
81318140
success: function() {},
81328141
error: function() {},
81338142
type: 'js',
8134-
url: sd.para.vtrack_url ? sd.para.vtrack_url : location.protocol + '//static.sensorsdata.cn/sdk/' + sd.lib_version + '/vtrack.min.js'
8143+
url: sd.para.vtrack_url ? sd.para.vtrack_url : getSafeHttpProtocol() + '//static.sensorsdata.cn/sdk/' + sd.lib_version + '/vtrack.min.js'
81358144
});
81368145
},
81378146
messageListener: function(event) {
@@ -8176,16 +8185,20 @@ var vtrackMode = {
81768185
vtrackMode.postMessage();
81778186
},
81788187
postMessage: function() {
8179-
if (window.parent && window.parent.postMessage) {
8180-
window.parent.postMessage({
8181-
source: 'sa-web-sdk',
8182-
type: 'v-is-vtrack',
8183-
data: {
8184-
sdkversion: '1.23.1'
8185-
}
8186-
},
8187-
'*'
8188-
);
8188+
try {
8189+
if (window.parent && window.parent.postMessage) {
8190+
window.parent.postMessage({
8191+
source: 'sa-web-sdk',
8192+
type: 'v-is-vtrack',
8193+
data: {
8194+
sdkversion: '1.23.2'
8195+
}
8196+
},
8197+
'*'
8198+
);
8199+
}
8200+
} catch (e) {
8201+
sd.log('浏览器版本过低,不支持 postMessage API');
81898202
}
81908203
},
81918204
notifyUser: function() {

dist/sat/sensorsdata-sat.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.

dist/sat/sensorsdata-sat.full.js

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3148,7 +3148,7 @@
31483148
};
31493149

31503150
var source_channel_standard = 'utm_source utm_medium utm_campaign utm_content utm_term';
3151-
var sdkversion_placeholder = '1.23.1';
3151+
var sdkversion_placeholder = '1.23.2';
31523152
var domain_test_key = 'sensorsdata_domain_test';
31533153

31543154
var IDENTITY_KEY = {
@@ -3594,6 +3594,15 @@
35943594
}
35953595
};
35963596

3597+
function getSafeHttpProtocol() {
3598+
var protocol = location.protocol;
3599+
if (protocol === 'http:' || protocol === 'https:') {
3600+
return protocol;
3601+
} else {
3602+
return 'http:';
3603+
}
3604+
}
3605+
35973606
function getNewUserFlagKey(name_prefix, url) {
35983607
var sub = '';
35993608
url = url || location.href;
@@ -4685,7 +4694,7 @@
46854694
}
46864695
}
46874696
if (!sd.para.heatmap_url) {
4688-
sd.para.heatmap_url = location.protocol + '//static.sensorsdata.cn/sdk/' + sd.lib_version + '/heatmap.min.js';
4697+
sd.para.heatmap_url = getSafeHttpProtocol() + '//static.sensorsdata.cn/sdk/' + sd.lib_version + '/heatmap.min.js';
46894698
}
46904699
},
46914700
getDomIndex: function(el) {
@@ -6937,16 +6946,16 @@
69376946
lockTimeout = 10000,
69386947
lockPrefix = 'sajssdk-lock-get-';
69396948
for (var i = 0; i < localStorage.length; i++) {
6940-
var key = localStorage.key(i),
6949+
var item = localStorage.key(i),
69416950
self = this;
6942-
if (key.indexOf(tabStoragePrefix) === 0) {
6943-
var tabStorage = safeJSONParse(_localStorage.get(key)) || this.generateTabStorageVal();
6951+
if (item.indexOf(tabStoragePrefix) === 0) {
6952+
var tabStorage = safeJSONParse(_localStorage.get(item)) || this.generateTabStorageVal();
69446953
for (var j = 0; j < tabStorage.data.length; j++) {
69456954
notSendMap[tabStorage.data[j]] = true;
69466955
}
69476956
if (now() > tabStorage.expireTime && this.serverUrl === tabStorage.serverUrl) {
69486957
var concurrentStorage = new ConcurrentStorage(lockPrefix);
6949-
concurrentStorage.get(key, lockTimeout, 1000, function(data) {
6958+
concurrentStorage.get(item, lockTimeout, 1000, function(data) {
69506959
if (data) {
69516960
if (_localStorage.get(self.tabKey) === null) {
69526961
self.generateTabStorage();
@@ -6956,12 +6965,12 @@
69566965
}
69576966
});
69586967
}
6959-
} else if (key.indexOf(lockPrefix) === 0) {
6960-
var lock = safeJSONParse(_localStorage.get(key)) || {
6968+
} else if (item.indexOf(lockPrefix) === 0) {
6969+
var lock = safeJSONParse(_localStorage.get(item)) || {
69616970
expireTime: 0
69626971
};
69636972
if (now() - lock.expireTime > lockTimeout) {
6964-
_localStorage.remove(key);
6973+
_localStorage.remove(item);
69656974
}
69666975
}
69676976
}
@@ -8139,7 +8148,7 @@
81398148
success: function() {},
81408149
error: function() {},
81418150
type: 'js',
8142-
url: sd.para.vtrack_url ? sd.para.vtrack_url : location.protocol + '//static.sensorsdata.cn/sdk/' + sd.lib_version + '/vtrack.min.js'
8151+
url: sd.para.vtrack_url ? sd.para.vtrack_url : getSafeHttpProtocol() + '//static.sensorsdata.cn/sdk/' + sd.lib_version + '/vtrack.min.js'
81438152
});
81448153
},
81458154
messageListener: function(event) {
@@ -8184,16 +8193,20 @@
81848193
vtrackMode.postMessage();
81858194
},
81868195
postMessage: function() {
8187-
if (window.parent && window.parent.postMessage) {
8188-
window.parent.postMessage({
8189-
source: 'sa-web-sdk',
8190-
type: 'v-is-vtrack',
8191-
data: {
8192-
sdkversion: '1.23.1'
8193-
}
8194-
},
8195-
'*'
8196-
);
8196+
try {
8197+
if (window.parent && window.parent.postMessage) {
8198+
window.parent.postMessage({
8199+
source: 'sa-web-sdk',
8200+
type: 'v-is-vtrack',
8201+
data: {
8202+
sdkversion: '1.23.2'
8203+
}
8204+
},
8205+
'*'
8206+
);
8207+
}
8208+
} catch (e) {
8209+
sd.log('浏览器版本过低,不支持 postMessage API');
81978210
}
81988211
},
81998212
notifyUser: function() {

0 commit comments

Comments
 (0)