Skip to content

Commit

Permalink
Release 1.14.29
Browse files Browse the repository at this point in the history
  • Loading branch information
shengyonggen committed Nov 29, 2021
1 parent 353e351 commit 85a8bc8
Show file tree
Hide file tree
Showing 14 changed files with 469 additions and 123 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 1.14.29(2021-11-29)
1. 新增
- 新增所有事件采集 `$url``$title``$mp_client_basic_library_version``$mp_client_app_version``$app_version` 属性


## 1.14.28(2021-11-24)
1. 优化
- 优化 `$referrer` 取值为 `url` 完整路径带 `query` 参数
Expand Down
11 changes: 2 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sa-sdk-miniprogram",
"version": "1.14.28",
"version": "1.14.29",
"description": "sensorsdata miniprogram sdk",
"main": "sensorsdata.min.js",
"scripts": {
Expand All @@ -20,12 +20,5 @@
"bugs": {
"url": "https://github.com/sensorsdata/sa-sdk-miniprogram/issues"
},
"homepage": "https://github.com/sensorsdata/sa-sdk-miniprogram#readme",
"devDependencies": {
"eslint": "^8.0.1",
"husky": "^7.0.4"
},
"dependencies": {
"prettier": "^2.4.1"
}
"homepage": "https://github.com/sensorsdata/sa-sdk-miniprogram#readme"
}
94 changes: 76 additions & 18 deletions product/sensorsdata.custom.es6.full.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,7 @@ kit.buildData = function(p) {
}

var refPage = _.getRefPage();
if (!data.properties.hasOwnProperty('$referrer')) {
data.properties.$referrer = refPage.route;
}

if (!data.properties.hasOwnProperty('$referrer_title')) {
data.properties.$referrer_title = refPage.title;
}
setPublicPProperties(data);
}
if (data.properties.$time && _.isDate(data.properties.$time)) {
data.time = data.properties.$time * 1;
Expand Down Expand Up @@ -108,6 +102,24 @@ function encodeTrackData(data) {
return encodeURIComponent(dataStr);
}

function setPublicPProperties(data) {
if (data && data.properties) {
var refPage = sa._.getRefPage();
var pageInfo = sa._.getCurrentPageInfo();
var propertiesMap = {
$referrer: refPage.route,
$referrer_title: refPage.title,
$title: pageInfo.title,
$url: pageInfo.url
};
for (var key in propertiesMap) {
if (!data.properties.hasOwnProperty(key)) {
data.properties[key] = propertiesMap[key];
}
}
}
}


var mergeStorageData = {};

Expand Down Expand Up @@ -469,7 +481,7 @@ var ArrayProto = Array.prototype,
slice = ArrayProto.slice,
toString$1 = ObjProto.toString,
hasOwnProperty = ObjProto.hasOwnProperty,
LIB_VERSION = '1.14.28',
LIB_VERSION = '1.14.29',
LIB_NAME = 'MiniProgram';

var source_channel_standard = 'utm_source utm_medium utm_campaign utm_content utm_term';
Expand Down Expand Up @@ -1465,6 +1477,20 @@ _.getRefPage = function() {
return _refInfo;
};

_.getCurrentPageInfo = function() {
var pages = _.getCurrentPage();
var pageInfo = {
title: '',
url: ''
};
if (pages && pages.route) {
var query = pages.sensors_mp_url_query ? '?' + pages.sensors_mp_url_query : '';
pageInfo.title = _.getPageTitle(pages.route);
pageInfo.url = pages.route + query;
}
return pageInfo;
};

_.setPageRefData = function(prop, path, query) {
var refPage = _.getRefPage();

Expand All @@ -1485,7 +1511,7 @@ _.setPageRefData = function(prop, path, query) {

_.getPageTitle = function(route) {
if (route === '未取到' || !route) {
return false;
return '';
}
var title = '';
try {
Expand Down Expand Up @@ -1539,13 +1565,23 @@ _.wxrequest = function(obj) {
}
};

_.getAppId = function() {
var info;
_.getAppInfoSync = function() {
if (wx.getAccountInfoSync) {
info = wx.getAccountInfoSync();
var info = wx.getAccountInfoSync(),
accountInfo = info && info.miniProgram ? info.miniProgram : {};
return {
appId: accountInfo.appId,
appEnv: accountInfo.envVersion,
appVersion: accountInfo.version
};
}
if (_.isObject(info) && _.isObject(info.miniProgram)) {
return info.miniProgram.appId;
return {};
};

_.getAppId = function() {
var info = _.getAppInfoSync();
if (info && info.appId) {
return info.appId;
}
};

Expand Down Expand Up @@ -1637,15 +1673,20 @@ _.info = {
e.$os = formatSystem(t['platform']);
e.$os_version = t['system'].indexOf(' ') > -1 ? t['system'].split(' ')[1] : t['system'];
wxSDKVersion = t['SDKVersion'];
e.$mp_client_app_version = t['version'];
e.$mp_client_basic_library_version = wxSDKVersion;
},
complete: function() {
var timeZoneOffset = new Date().getTimezoneOffset();
var appId = _.getAppId();
var accountInfo = _.getAppInfoSync();
if (_.isNumber(timeZoneOffset)) {
e.$timezone_offset = timeZoneOffset;
}
if (appId) {
e.$app_id = appId;
if (accountInfo.appId) {
e.$app_id = accountInfo.appId;
}
if (accountInfo.appVersion) {
e.$app_version = accountInfo.appVersion;
}
sa.initialState.systemIsComplete = true;
sa.initialState.checkIsComplete();
Expand Down Expand Up @@ -2391,6 +2432,14 @@ sa.autoTrackCustom = {
}
if (para && para.path) {
prop.$url_path = _.getPath(para.path);
prop.$title = _.getPageTitle(para.path);

if (para.query && _.isObject(para.query)) {
var _query = _.setQuery(para.query);
_query = _query ? '?' + _query : '';
prop.$url = prop.$url_path + _query;
}

if (sa.para.preset_properties.url_path === true) {
sa.registerApp({
$url_path: prop.$url_path
Expand Down Expand Up @@ -2445,6 +2494,7 @@ sa.autoTrackCustom = {

if (para && para.path) {
prop.$url_path = _.getPath(para.path);
prop.$title = _.getPageTitle(para.path);
if (sa.para.preset_properties.url_path === true) {
sa.registerApp({
$url_path: prop.$url_path
Expand All @@ -2466,7 +2516,9 @@ sa.autoTrackCustom = {
});
prop.$url_query = _.setQuery(para.query);
_.setPageRefData(prop, para.path, prop.$url_query);

if (para && para.path) {
prop.$url = para.path + (prop.$url_query ? '?' + prop.$url_query : '');
}
if (not_use_auto_track) {
prop = _.extend(prop, not_use_auto_track);
sa.track('$MPShow', prop);
Expand Down Expand Up @@ -2651,6 +2703,7 @@ sa.appLaunch = function(option, prop) {
}
if (option && option.path) {
obj.$url_path = _.getPath(option.path);
obj.$title = _.getPageTitle(option.path);
if (sa.para.preset_properties.url_path === true) {
sa.registerApp({
$url_path: obj.$url_path
Expand All @@ -2676,6 +2729,7 @@ sa.appLaunch = function(option, prop) {
});

obj.$url_query = _.setQuery(option.query);
obj.$url = option.path + (obj.$url_query ? '?' + obj.$url_query : '');
_.setPageRefData(prop);
if (_.isObject(prop)) {
obj = _.extend(obj, prop);
Expand All @@ -2701,6 +2755,7 @@ sa.appShow = function(option, prop) {

if (option && option.path) {
obj.$url_path = _.getPath(option.path);
obj.$title = _.getPageTitle(option.path);
if (sa.para.preset_properties.url_path === true) {
sa.registerApp({
$url_path: obj.$url_path
Expand All @@ -2718,6 +2773,9 @@ sa.appShow = function(option, prop) {
$latest_scene: obj.$scene
});
obj.$url_query = _.setQuery(option.query);
if (option && option.path) {
obj.$url = option.path + (obj.$url_query ? '?' + obj.$url_query : '');
}
_.setPageRefData(obj, option.path, obj.$url_query);
if (_.isObject(prop)) {
obj = _.extend(obj, prop);
Expand Down
Loading

0 comments on commit 85a8bc8

Please sign in to comment.