Skip to content

Commit

Permalink
Release 1.14.20
Browse files Browse the repository at this point in the history
  • Loading branch information
shengyonggen committed Aug 20, 2021
1 parent 3829369 commit 0e5c944
Show file tree
Hide file tree
Showing 14 changed files with 271 additions and 19 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.14.20(2021-08-20)
1. 新增
- 新增采集页面浏览时长事件 `$MPPageLeave`

## 1.14.19(2021-08-9)
1. 修复
- 修复特定情况下分享字段解析报错问题
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sa-sdk-miniprogram",
"version": "1.14.19",
"version": "1.14.20",
"description": "sensorsdata miniprogram sdk",
"main": "sensorsdata.min.js",
"scripts": {
Expand Down
28 changes: 26 additions & 2 deletions product/sensorsdata.custom.es6.full.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ sa.para = {
pageShow: true,
pageShare: true,
mpClick: false,
mpFavorite: true
mpFavorite: true,
pageLeave: false
},
autotrack_exclude_page: {
pageShow: [],
Expand Down Expand Up @@ -159,13 +160,14 @@ var ArrayProto = Array.prototype,
slice = ArrayProto.slice,
toString = ObjProto.toString,
hasOwnProperty = ObjProto.hasOwnProperty,
LIB_VERSION = '1.14.19',
LIB_VERSION = '1.14.20',
LIB_NAME = 'MiniProgram';

var source_channel_standard = 'utm_source utm_medium utm_campaign utm_content utm_term';
var latest_source_channel = ['$latest_utm_source', '$latest_utm_medium', '$latest_utm_campaign', '$latest_utm_content', '$latest_utm_term', '$latest_sa_utm'];
var latest_share_info = ['$latest_share_distinct_id', '$latest_share_url_path', '$latest_share_depth', '$latest_share_method'];
var share_info_key = ['sensors_share_d', 'sensors_share_p', 'sensors_share_i', 'sensors_share_m'];
var page_show_time = Date.now();

var mpshow_time = null;

Expand Down Expand Up @@ -2269,6 +2271,28 @@ _.getUtmFromPage = function() {
return newObj;
};

_.sendPageLeave = function() {
var currentPage = {};
try {
var pages = getCurrentPages();
currentPage = pages[pages.length - 1];
} catch (error) {
logger.info(error)
};
var router = currentPage.route;
if (page_show_time >= 0 && router !== '') {
var prop = {};
var title = _.getPageTitle(router);
var page_stay_time = (Date.now() - page_show_time) / 1000;
prop.$url_query = currentPage.sensors_mp_url_query ? currentPage.sensors_mp_url_query : '';
prop.$url_path = router;
prop.$title = title;
prop.event_duration = page_stay_time;
sa.track('$MPPageLeave', prop);
page_show_time = -1
}
}



sa.autoTrackCustom = {
Expand Down
28 changes: 26 additions & 2 deletions product/sensorsdata.custom.full.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ sa.para = {
pageShow: true,
pageShare: true,
mpClick: false,
mpFavorite: true
mpFavorite: true,
pageLeave: false
},
autotrack_exclude_page: {
pageShow: [],
Expand Down Expand Up @@ -159,13 +160,14 @@ var ArrayProto = Array.prototype,
slice = ArrayProto.slice,
toString = ObjProto.toString,
hasOwnProperty = ObjProto.hasOwnProperty,
LIB_VERSION = '1.14.19',
LIB_VERSION = '1.14.20',
LIB_NAME = 'MiniProgram';

var source_channel_standard = 'utm_source utm_medium utm_campaign utm_content utm_term';
var latest_source_channel = ['$latest_utm_source', '$latest_utm_medium', '$latest_utm_campaign', '$latest_utm_content', '$latest_utm_term', '$latest_sa_utm'];
var latest_share_info = ['$latest_share_distinct_id', '$latest_share_url_path', '$latest_share_depth', '$latest_share_method'];
var share_info_key = ['sensors_share_d', 'sensors_share_p', 'sensors_share_i', 'sensors_share_m'];
var page_show_time = Date.now();

var mpshow_time = null;

Expand Down Expand Up @@ -2269,6 +2271,28 @@ _.getUtmFromPage = function() {
return newObj;
};

_.sendPageLeave = function() {
var currentPage = {};
try {
var pages = getCurrentPages();
currentPage = pages[pages.length - 1];
} catch (error) {
logger.info(error)
};
var router = currentPage.route;
if (page_show_time >= 0 && router !== '') {
var prop = {};
var title = _.getPageTitle(router);
var page_stay_time = (Date.now() - page_show_time) / 1000;
prop.$url_query = currentPage.sensors_mp_url_query ? currentPage.sensors_mp_url_query : '';
prop.$url_path = router;
prop.$title = title;
prop.event_duration = page_stay_time;
sa.track('$MPPageLeave', prop);
page_show_time = -1
}
}



sa.autoTrackCustom = {
Expand Down
54 changes: 52 additions & 2 deletions product/sensorsdata.es6.full.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ sa.para = {
pageShow: true,
pageShare: true,
mpClick: false,
mpFavorite: true
mpFavorite: true,
pageLeave: false
},
autotrack_exclude_page: {
pageShow: [],
Expand Down Expand Up @@ -159,13 +160,14 @@ var ArrayProto = Array.prototype,
slice = ArrayProto.slice,
toString = ObjProto.toString,
hasOwnProperty = ObjProto.hasOwnProperty,
LIB_VERSION = '1.14.19',
LIB_VERSION = '1.14.20',
LIB_NAME = 'MiniProgram';

var source_channel_standard = 'utm_source utm_medium utm_campaign utm_content utm_term';
var latest_source_channel = ['$latest_utm_source', '$latest_utm_medium', '$latest_utm_campaign', '$latest_utm_content', '$latest_utm_term', '$latest_sa_utm'];
var latest_share_info = ['$latest_share_distinct_id', '$latest_share_url_path', '$latest_share_depth', '$latest_share_method'];
var share_info_key = ['sensors_share_d', 'sensors_share_p', 'sensors_share_i', 'sensors_share_m'];
var page_show_time = Date.now();

var mpshow_time = null;

Expand Down Expand Up @@ -2269,6 +2271,28 @@ _.getUtmFromPage = function() {
return newObj;
};

_.sendPageLeave = function() {
var currentPage = {};
try {
var pages = getCurrentPages();
currentPage = pages[pages.length - 1];
} catch (error) {
logger.info(error)
};
var router = currentPage.route;
if (page_show_time >= 0 && router !== '') {
var prop = {};
var title = _.getPageTitle(router);
var page_stay_time = (Date.now() - page_show_time) / 1000;
prop.$url_query = currentPage.sensors_mp_url_query ? currentPage.sensors_mp_url_query : '';
prop.$url_path = router;
prop.$title = title;
prop.event_duration = page_stay_time;
sa.track('$MPPageLeave', prop);
page_show_time = -1
}
}


function mp_proxy(option, method, identifier) {
var newFunc = sa.autoTrackCustom[identifier];
Expand Down Expand Up @@ -2369,6 +2393,23 @@ function tabProxy(option) {
}
}

function pageLeaveProxy(option) {
var oldHide = option['onHide'];
option['onHide'] = function() {
if (oldHide) {
oldHide.apply(this, arguments);
}
_.sendPageLeave();
};
var oldUnload = option['onUnload'];
option['onUnload'] = function() {
if (oldUnload) {
oldUnload.apply(this, arguments);
}
_.sendPageLeave();
}
}


sa.autoTrackCustom = {
trackCustom: function(api, prop, event) {
Expand Down Expand Up @@ -2517,6 +2558,7 @@ sa.autoTrackCustom = {
}
},
pageShow: function() {
page_show_time = Date.now();
var prop = {};
var router = _.getCurrentPath();
var title = _.getPageTitle(router);
Expand Down Expand Up @@ -2831,6 +2873,10 @@ Page = function(option) {
tabProxy(option);
}

if (sa.para.autoTrack && sa.para.autoTrack.pageLeave) {
pageLeaveProxy(option)
}

mp_proxy(option, "onLoad", 'pageLoad');
mp_proxy(option, "onShow", 'pageShow');
mp_proxy(option, "onAddToFavorites", 'pageAddFavorites');
Expand Down Expand Up @@ -2858,6 +2904,10 @@ Component = function(option) {
tabProxy(option.methods);
}

if (sa.para.autoTrack && sa.para.autoTrack.pageLeave) {
pageLeaveProxy(option.methods)
}

mp_proxy(option.methods, 'onLoad', 'pageLoad');
mp_proxy(option.methods, 'onShow', 'pageShow');
mp_proxy(option.methods, "onAddToFavorites", 'pageAddFavorites');
Expand Down
54 changes: 52 additions & 2 deletions product/sensorsdata.full.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ sa.para = {
pageShow: true,
pageShare: true,
mpClick: false,
mpFavorite: true
mpFavorite: true,
pageLeave: false
},
autotrack_exclude_page: {
pageShow: [],
Expand Down Expand Up @@ -159,13 +160,14 @@ var ArrayProto = Array.prototype,
slice = ArrayProto.slice,
toString = ObjProto.toString,
hasOwnProperty = ObjProto.hasOwnProperty,
LIB_VERSION = '1.14.19',
LIB_VERSION = '1.14.20',
LIB_NAME = 'MiniProgram';

var source_channel_standard = 'utm_source utm_medium utm_campaign utm_content utm_term';
var latest_source_channel = ['$latest_utm_source', '$latest_utm_medium', '$latest_utm_campaign', '$latest_utm_content', '$latest_utm_term', '$latest_sa_utm'];
var latest_share_info = ['$latest_share_distinct_id', '$latest_share_url_path', '$latest_share_depth', '$latest_share_method'];
var share_info_key = ['sensors_share_d', 'sensors_share_p', 'sensors_share_i', 'sensors_share_m'];
var page_show_time = Date.now();

var mpshow_time = null;

Expand Down Expand Up @@ -2269,6 +2271,28 @@ _.getUtmFromPage = function() {
return newObj;
};

_.sendPageLeave = function() {
var currentPage = {};
try {
var pages = getCurrentPages();
currentPage = pages[pages.length - 1];
} catch (error) {
logger.info(error)
};
var router = currentPage.route;
if (page_show_time >= 0 && router !== '') {
var prop = {};
var title = _.getPageTitle(router);
var page_stay_time = (Date.now() - page_show_time) / 1000;
prop.$url_query = currentPage.sensors_mp_url_query ? currentPage.sensors_mp_url_query : '';
prop.$url_path = router;
prop.$title = title;
prop.event_duration = page_stay_time;
sa.track('$MPPageLeave', prop);
page_show_time = -1
}
}


function mp_proxy(option, method, identifier) {
var newFunc = sa.autoTrackCustom[identifier];
Expand Down Expand Up @@ -2369,6 +2393,23 @@ function tabProxy(option) {
}
}

function pageLeaveProxy(option) {
var oldHide = option['onHide'];
option['onHide'] = function() {
if (oldHide) {
oldHide.apply(this, arguments);
}
_.sendPageLeave();
};
var oldUnload = option['onUnload'];
option['onUnload'] = function() {
if (oldUnload) {
oldUnload.apply(this, arguments);
}
_.sendPageLeave();
}
}


sa.autoTrackCustom = {
trackCustom: function(api, prop, event) {
Expand Down Expand Up @@ -2517,6 +2558,7 @@ sa.autoTrackCustom = {
}
},
pageShow: function() {
page_show_time = Date.now();
var prop = {};
var router = _.getCurrentPath();
var title = _.getPageTitle(router);
Expand Down Expand Up @@ -2831,6 +2873,10 @@ Page = function(option) {
tabProxy(option);
}

if (sa.para.autoTrack && sa.para.autoTrack.pageLeave) {
pageLeaveProxy(option)
}

mp_proxy(option, "onLoad", 'pageLoad');
mp_proxy(option, "onShow", 'pageShow');
mp_proxy(option, "onAddToFavorites", 'pageAddFavorites');
Expand Down Expand Up @@ -2858,6 +2904,10 @@ Component = function(option) {
tabProxy(option.methods);
}

if (sa.para.autoTrack && sa.para.autoTrack.pageLeave) {
pageLeaveProxy(option.methods)
}

mp_proxy(option.methods, 'onLoad', 'pageLoad');
mp_proxy(option.methods, 'onShow', 'pageShow');
mp_proxy(option.methods, "onAddToFavorites", 'pageAddFavorites');
Expand Down
Loading

0 comments on commit 0e5c944

Please sign in to comment.