Skip to content

Commit 0df871f

Browse files
author
shengyonggen
committed
Release 1.17.12
1 parent 40da006 commit 0df871f

14 files changed

+227
-97
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.17.12(2022-8-12)
2+
1. 新增
3+
- 分享事件支持异步采集分享者信息
4+
15
## 1.17.11(2022-7-22)
26
1. 新增
37
- 新增 `referrer_path` 插件

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-miniprogram",
3-
"version": "1.17.11",
3+
"version": "1.17.12",
44
"description": "sensorsdata miniprogram sdk",
55
"main": "sensorsdata.min.js",
66
"scripts": {

product/sensorsdata.custom.es6.full.js

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,7 +1011,7 @@ sa.getServerUrl = function() {
10111011
return sa.para.server_url;
10121012
};
10131013

1014-
var LIB_VERSION = '1.17.11',
1014+
var LIB_VERSION = '1.17.12',
10151015
LIB_NAME = 'MiniProgram';
10161016

10171017
var source_channel_standard = 'utm_source utm_medium utm_campaign utm_content utm_term';
@@ -3380,10 +3380,13 @@ sa.autoTrackCustom = {
33803380
},
33813381
pageShare: function(option) {
33823382
var oldMessage = option.onShareAppMessage;
3383+
var isPromise = function(val) {
3384+
return !!val && _.isFunction(val.then) && _.isFunction(val.catch);
3385+
};
33833386

33843387
option.onShareAppMessage = function() {
33853388
share_method = '转发消息卡片';
3386-
var oldValue = oldMessage.apply(this, arguments);
3389+
var oldShareValue = oldMessage.apply(this, arguments);
33873390

33883391
if (sa.para.autoTrack && sa.para.autoTrack.pageShare) {
33893392
var prop = {
@@ -3395,28 +3398,46 @@ sa.autoTrackCustom = {
33953398
sa.autoTrackCustom.trackCustom('pageShare', prop, '$MPShare');
33963399
}
33973400

3398-
if (sa.para.allow_amend_share_path) {
3399-
if (typeof oldValue !== 'object') {
3400-
oldValue = {};
3401-
oldValue.path = _.getCurrentUrl(this);
3401+
function setPath(value) {
3402+
if (!_.isObject(value)) {
3403+
value = {};
34023404
}
3403-
if (typeof oldValue === 'object' && (typeof oldValue.path === 'undefined' || oldValue.path === '')) {
3404-
oldValue.path = _.getCurrentUrl(this);
3405+
3406+
if (_.isUndefined(value.path) || value.path === '') {
3407+
value.path = _.getCurrentUrl(this);
34053408
}
3406-
if (typeof oldValue === 'object' && typeof oldValue.path === 'string') {
3407-
if (oldValue.path.indexOf('?') === -1) {
3408-
oldValue.path = oldValue.path + '?';
3409+
3410+
if (_.isString(value.path)) {
3411+
if (value.path.indexOf('?') === -1) {
3412+
value.path = value.path + '?';
34093413
} else {
3410-
if (oldValue.path.slice(-1) !== '&') {
3411-
oldValue.path = oldValue.path + '&';
3414+
if (value.path.slice(-1) !== '&') {
3415+
value.path = value.path + '&';
34123416
}
34133417
}
34143418
}
3419+
value.path = value.path + _.getShareInfo();
3420+
return value;
3421+
}
34153422

3416-
oldValue.path = oldValue.path + _.getShareInfo();
3423+
if (sa.para.allow_amend_share_path) {
3424+
oldShareValue = setPath(oldShareValue);
3425+
if (_.isObject(oldShareValue)) {
3426+
for (var key in oldShareValue) {
3427+
if (isPromise(oldShareValue[key])) {
3428+
try {
3429+
oldShareValue[key] = oldShareValue[key].then(function(data) {
3430+
return setPath(data);
3431+
});
3432+
} catch (error) {
3433+
logger.info('onShareAppMessage: ' + error);
3434+
}
3435+
}
3436+
}
3437+
}
34173438
}
34183439

3419-
return oldValue;
3440+
return oldShareValue;
34203441
};
34213442
},
34223443
pageShareTimeline: function(option) {

product/sensorsdata.custom.full.js

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,7 +1014,7 @@ sa.getServerUrl = function() {
10141014
return sa.para.server_url;
10151015
};
10161016

1017-
var LIB_VERSION = '1.17.11',
1017+
var LIB_VERSION = '1.17.12',
10181018
LIB_NAME = 'MiniProgram';
10191019

10201020
var source_channel_standard = 'utm_source utm_medium utm_campaign utm_content utm_term';
@@ -3383,10 +3383,13 @@ sa.autoTrackCustom = {
33833383
},
33843384
pageShare: function(option) {
33853385
var oldMessage = option.onShareAppMessage;
3386+
var isPromise = function(val) {
3387+
return !!val && _.isFunction(val.then) && _.isFunction(val.catch);
3388+
};
33863389

33873390
option.onShareAppMessage = function() {
33883391
share_method = '转发消息卡片';
3389-
var oldValue = oldMessage.apply(this, arguments);
3392+
var oldShareValue = oldMessage.apply(this, arguments);
33903393

33913394
if (sa.para.autoTrack && sa.para.autoTrack.pageShare) {
33923395
var prop = {
@@ -3398,28 +3401,46 @@ sa.autoTrackCustom = {
33983401
sa.autoTrackCustom.trackCustom('pageShare', prop, '$MPShare');
33993402
}
34003403

3401-
if (sa.para.allow_amend_share_path) {
3402-
if (typeof oldValue !== 'object') {
3403-
oldValue = {};
3404-
oldValue.path = _.getCurrentUrl(this);
3404+
function setPath(value) {
3405+
if (!_.isObject(value)) {
3406+
value = {};
34053407
}
3406-
if (typeof oldValue === 'object' && (typeof oldValue.path === 'undefined' || oldValue.path === '')) {
3407-
oldValue.path = _.getCurrentUrl(this);
3408+
3409+
if (_.isUndefined(value.path) || value.path === '') {
3410+
value.path = _.getCurrentUrl(this);
34083411
}
3409-
if (typeof oldValue === 'object' && typeof oldValue.path === 'string') {
3410-
if (oldValue.path.indexOf('?') === -1) {
3411-
oldValue.path = oldValue.path + '?';
3412+
3413+
if (_.isString(value.path)) {
3414+
if (value.path.indexOf('?') === -1) {
3415+
value.path = value.path + '?';
34123416
} else {
3413-
if (oldValue.path.slice(-1) !== '&') {
3414-
oldValue.path = oldValue.path + '&';
3417+
if (value.path.slice(-1) !== '&') {
3418+
value.path = value.path + '&';
34153419
}
34163420
}
34173421
}
3422+
value.path = value.path + _.getShareInfo();
3423+
return value;
3424+
}
34183425

3419-
oldValue.path = oldValue.path + _.getShareInfo();
3426+
if (sa.para.allow_amend_share_path) {
3427+
oldShareValue = setPath(oldShareValue);
3428+
if (_.isObject(oldShareValue)) {
3429+
for (var key in oldShareValue) {
3430+
if (isPromise(oldShareValue[key])) {
3431+
try {
3432+
oldShareValue[key] = oldShareValue[key].then(function(data) {
3433+
return setPath(data);
3434+
});
3435+
} catch (error) {
3436+
logger.info('onShareAppMessage: ' + error);
3437+
}
3438+
}
3439+
}
3440+
}
34203441
}
34213442

3422-
return oldValue;
3443+
return oldShareValue;
34233444
};
34243445
},
34253446
pageShareTimeline: function(option) {

product/sensorsdata.es6.full.js

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,7 +1223,7 @@ sa.getServerUrl = function() {
12231223
return sa.para.server_url;
12241224
};
12251225

1226-
var LIB_VERSION = '1.17.11',
1226+
var LIB_VERSION = '1.17.12',
12271227
LIB_NAME = 'MiniProgram';
12281228

12291229
var source_channel_standard = 'utm_source utm_medium utm_campaign utm_content utm_term';
@@ -3592,10 +3592,13 @@ sa.autoTrackCustom = {
35923592
},
35933593
pageShare: function(option) {
35943594
var oldMessage = option.onShareAppMessage;
3595+
var isPromise = function(val) {
3596+
return !!val && _.isFunction(val.then) && _.isFunction(val.catch);
3597+
};
35953598

35963599
option.onShareAppMessage = function() {
35973600
share_method = '转发消息卡片';
3598-
var oldValue = oldMessage.apply(this, arguments);
3601+
var oldShareValue = oldMessage.apply(this, arguments);
35993602

36003603
if (sa.para.autoTrack && sa.para.autoTrack.pageShare) {
36013604
var prop = {
@@ -3607,28 +3610,46 @@ sa.autoTrackCustom = {
36073610
sa.autoTrackCustom.trackCustom('pageShare', prop, '$MPShare');
36083611
}
36093612

3610-
if (sa.para.allow_amend_share_path) {
3611-
if (typeof oldValue !== 'object') {
3612-
oldValue = {};
3613-
oldValue.path = _.getCurrentUrl(this);
3613+
function setPath(value) {
3614+
if (!_.isObject(value)) {
3615+
value = {};
36143616
}
3615-
if (typeof oldValue === 'object' && (typeof oldValue.path === 'undefined' || oldValue.path === '')) {
3616-
oldValue.path = _.getCurrentUrl(this);
3617+
3618+
if (_.isUndefined(value.path) || value.path === '') {
3619+
value.path = _.getCurrentUrl(this);
36173620
}
3618-
if (typeof oldValue === 'object' && typeof oldValue.path === 'string') {
3619-
if (oldValue.path.indexOf('?') === -1) {
3620-
oldValue.path = oldValue.path + '?';
3621+
3622+
if (_.isString(value.path)) {
3623+
if (value.path.indexOf('?') === -1) {
3624+
value.path = value.path + '?';
36213625
} else {
3622-
if (oldValue.path.slice(-1) !== '&') {
3623-
oldValue.path = oldValue.path + '&';
3626+
if (value.path.slice(-1) !== '&') {
3627+
value.path = value.path + '&';
36243628
}
36253629
}
36263630
}
3631+
value.path = value.path + _.getShareInfo();
3632+
return value;
3633+
}
36273634

3628-
oldValue.path = oldValue.path + _.getShareInfo();
3635+
if (sa.para.allow_amend_share_path) {
3636+
oldShareValue = setPath(oldShareValue);
3637+
if (_.isObject(oldShareValue)) {
3638+
for (var key in oldShareValue) {
3639+
if (isPromise(oldShareValue[key])) {
3640+
try {
3641+
oldShareValue[key] = oldShareValue[key].then(function(data) {
3642+
return setPath(data);
3643+
});
3644+
} catch (error) {
3645+
logger.info('onShareAppMessage: ' + error);
3646+
}
3647+
}
3648+
}
3649+
}
36293650
}
36303651

3631-
return oldValue;
3652+
return oldShareValue;
36323653
};
36333654
},
36343655
pageShareTimeline: function(option) {

product/sensorsdata.full.js

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,7 +1226,7 @@ sa.getServerUrl = function() {
12261226
return sa.para.server_url;
12271227
};
12281228

1229-
var LIB_VERSION = '1.17.11',
1229+
var LIB_VERSION = '1.17.12',
12301230
LIB_NAME = 'MiniProgram';
12311231

12321232
var source_channel_standard = 'utm_source utm_medium utm_campaign utm_content utm_term';
@@ -3595,10 +3595,13 @@ sa.autoTrackCustom = {
35953595
},
35963596
pageShare: function(option) {
35973597
var oldMessage = option.onShareAppMessage;
3598+
var isPromise = function(val) {
3599+
return !!val && _.isFunction(val.then) && _.isFunction(val.catch);
3600+
};
35983601

35993602
option.onShareAppMessage = function() {
36003603
share_method = '转发消息卡片';
3601-
var oldValue = oldMessage.apply(this, arguments);
3604+
var oldShareValue = oldMessage.apply(this, arguments);
36023605

36033606
if (sa.para.autoTrack && sa.para.autoTrack.pageShare) {
36043607
var prop = {
@@ -3610,28 +3613,46 @@ sa.autoTrackCustom = {
36103613
sa.autoTrackCustom.trackCustom('pageShare', prop, '$MPShare');
36113614
}
36123615

3613-
if (sa.para.allow_amend_share_path) {
3614-
if (typeof oldValue !== 'object') {
3615-
oldValue = {};
3616-
oldValue.path = _.getCurrentUrl(this);
3616+
function setPath(value) {
3617+
if (!_.isObject(value)) {
3618+
value = {};
36173619
}
3618-
if (typeof oldValue === 'object' && (typeof oldValue.path === 'undefined' || oldValue.path === '')) {
3619-
oldValue.path = _.getCurrentUrl(this);
3620+
3621+
if (_.isUndefined(value.path) || value.path === '') {
3622+
value.path = _.getCurrentUrl(this);
36203623
}
3621-
if (typeof oldValue === 'object' && typeof oldValue.path === 'string') {
3622-
if (oldValue.path.indexOf('?') === -1) {
3623-
oldValue.path = oldValue.path + '?';
3624+
3625+
if (_.isString(value.path)) {
3626+
if (value.path.indexOf('?') === -1) {
3627+
value.path = value.path + '?';
36243628
} else {
3625-
if (oldValue.path.slice(-1) !== '&') {
3626-
oldValue.path = oldValue.path + '&';
3629+
if (value.path.slice(-1) !== '&') {
3630+
value.path = value.path + '&';
36273631
}
36283632
}
36293633
}
3634+
value.path = value.path + _.getShareInfo();
3635+
return value;
3636+
}
36303637

3631-
oldValue.path = oldValue.path + _.getShareInfo();
3638+
if (sa.para.allow_amend_share_path) {
3639+
oldShareValue = setPath(oldShareValue);
3640+
if (_.isObject(oldShareValue)) {
3641+
for (var key in oldShareValue) {
3642+
if (isPromise(oldShareValue[key])) {
3643+
try {
3644+
oldShareValue[key] = oldShareValue[key].then(function(data) {
3645+
return setPath(data);
3646+
});
3647+
} catch (error) {
3648+
logger.info('onShareAppMessage: ' + error);
3649+
}
3650+
}
3651+
}
3652+
}
36323653
}
36333654

3634-
return oldValue;
3655+
return oldShareValue;
36353656
};
36363657
},
36373658
pageShareTimeline: function(option) {

0 commit comments

Comments
 (0)