Skip to content

Commit c541426

Browse files
author
shengyonggen
committed
Release 1.17.3
1 parent b2d3d66 commit c541426

16 files changed

+128
-55
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 1.17.3(2022-1-13)
2+
1. 新增
3+
- 支持自定义属性配置插件
4+
5+
16
## 1.17.2(2022-1-13)
27
1. 修复
38
- 页面浏览时长出现负值的问题

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

plugins/register-properties/register-properties.cmd.min.js

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

plugins/register-properties/register-properties.esm.min.js

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

product/sensorsdata.custom.es6.full.js

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,11 @@ var isArray =
118118
};
119119

120120
function isFunction(f) {
121-
try {
122-
return /^\s*\bfunction\b/.test(f);
123-
} catch (x) {
121+
if (!f) {
124122
return false;
125123
}
124+
var type = Object.prototype.toString.call(f);
125+
return type == '[object Function]' || type == '[object AsyncFunction]';
126126
}
127127

128128
function isArguments(obj) {
@@ -280,8 +280,7 @@ var _ = {
280280

281281
var kit = {};
282282

283-
kit.buildData = function(p) {
284-
var _ = sa._;
283+
kit.buildData = function(p, custom_monitor_prop) {
285284
var data = {
286285
distinct_id: sa.store.getDistinctId(),
287286
identities: sa.store._state.identities,
@@ -298,6 +297,10 @@ kit.buildData = function(p) {
298297
delete p.unbind_value;
299298
}
300299

300+
if (!_.isObject(custom_monitor_prop)) {
301+
custom_monitor_prop = {};
302+
}
303+
301304
_.extend(data, sa.store.getUnionId(), p);
302305

303306
if (_.isObject(p.properties) && !_.isEmptyObject(p.properties)) {
@@ -306,7 +309,7 @@ kit.buildData = function(p) {
306309

307310
if (!p.type || p.type.slice(0, 7) !== 'profile') {
308311
data._track_id = Number(String(getRandom()).slice(2, 5) + String(getRandom()).slice(2, 4) + String(Date.now()).slice(-4));
309-
data.properties = _.extend({}, _.info.properties, sa.store.getProps(), _.info.currentProps, data.properties);
312+
data.properties = _.extend({}, _.info.properties, sa.store.getProps(), _.info.currentProps, custom_monitor_prop, data.properties);
310313
if (p.type === 'track') {
311314
data.properties.$is_first_day = _.getIsFirstDay();
312315
}
@@ -371,6 +374,11 @@ function setPublicPProperties(data) {
371374
}
372375
}
373376

377+
kit.onEventSend = function() {
378+
var custom_monitor_prop = {};
379+
return custom_monitor_prop;
380+
};
381+
374382

375383
var mergeStorageData = {};
376384

@@ -551,7 +559,10 @@ saEvent.send = function(p, callback) {
551559
return false;
552560
}
553561

554-
var data = sa.kit.buildData(p);
562+
var event_target = sa._.deepCopy(p);
563+
var custom_monitor_prop = sa.kit.onEventSend(event_target);
564+
565+
var data = sa.kit.buildData(p, custom_monitor_prop);
555566
if (data) {
556567
saEvent.debug(data);
557568
sa.events.emit('send', data);
@@ -818,7 +829,7 @@ sa.getServerUrl = function() {
818829
return sa.para.server_url;
819830
};
820831

821-
var LIB_VERSION = '1.17.2',
832+
var LIB_VERSION = '1.17.3',
822833
LIB_NAME = 'MiniProgram';
823834

824835
var source_channel_standard = 'utm_source utm_medium utm_campaign utm_content utm_term';

product/sensorsdata.custom.full.js

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,11 @@ var isArray =
121121
};
122122

123123
function isFunction(f) {
124-
try {
125-
return /^\s*\bfunction\b/.test(f);
126-
} catch (x) {
124+
if (!f) {
127125
return false;
128126
}
127+
var type = Object.prototype.toString.call(f);
128+
return type == '[object Function]' || type == '[object AsyncFunction]';
129129
}
130130

131131
function isArguments(obj) {
@@ -283,8 +283,7 @@ var _ = {
283283

284284
var kit = {};
285285

286-
kit.buildData = function(p) {
287-
var _ = sa._;
286+
kit.buildData = function(p, custom_monitor_prop) {
288287
var data = {
289288
distinct_id: sa.store.getDistinctId(),
290289
identities: sa.store._state.identities,
@@ -301,6 +300,10 @@ kit.buildData = function(p) {
301300
delete p.unbind_value;
302301
}
303302

303+
if (!_.isObject(custom_monitor_prop)) {
304+
custom_monitor_prop = {};
305+
}
306+
304307
_.extend(data, sa.store.getUnionId(), p);
305308

306309
if (_.isObject(p.properties) && !_.isEmptyObject(p.properties)) {
@@ -309,7 +312,7 @@ kit.buildData = function(p) {
309312

310313
if (!p.type || p.type.slice(0, 7) !== 'profile') {
311314
data._track_id = Number(String(getRandom()).slice(2, 5) + String(getRandom()).slice(2, 4) + String(Date.now()).slice(-4));
312-
data.properties = _.extend({}, _.info.properties, sa.store.getProps(), _.info.currentProps, data.properties);
315+
data.properties = _.extend({}, _.info.properties, sa.store.getProps(), _.info.currentProps, custom_monitor_prop, data.properties);
313316
if (p.type === 'track') {
314317
data.properties.$is_first_day = _.getIsFirstDay();
315318
}
@@ -374,6 +377,11 @@ function setPublicPProperties(data) {
374377
}
375378
}
376379

380+
kit.onEventSend = function() {
381+
var custom_monitor_prop = {};
382+
return custom_monitor_prop;
383+
};
384+
377385

378386
var mergeStorageData = {};
379387

@@ -554,7 +562,10 @@ saEvent.send = function(p, callback) {
554562
return false;
555563
}
556564

557-
var data = sa.kit.buildData(p);
565+
var event_target = sa._.deepCopy(p);
566+
var custom_monitor_prop = sa.kit.onEventSend(event_target);
567+
568+
var data = sa.kit.buildData(p, custom_monitor_prop);
558569
if (data) {
559570
saEvent.debug(data);
560571
sa.events.emit('send', data);
@@ -821,7 +832,7 @@ sa.getServerUrl = function() {
821832
return sa.para.server_url;
822833
};
823834

824-
var LIB_VERSION = '1.17.2',
835+
var LIB_VERSION = '1.17.3',
825836
LIB_NAME = 'MiniProgram';
826837

827838
var source_channel_standard = 'utm_source utm_medium utm_campaign utm_content utm_term';

product/sensorsdata.es6.full.js

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,11 @@ var isArray =
118118
};
119119

120120
function isFunction(f) {
121-
try {
122-
return /^\s*\bfunction\b/.test(f);
123-
} catch (x) {
121+
if (!f) {
124122
return false;
125123
}
124+
var type = Object.prototype.toString.call(f);
125+
return type == '[object Function]' || type == '[object AsyncFunction]';
126126
}
127127

128128
function isArguments(obj) {
@@ -280,8 +280,7 @@ var _ = {
280280

281281
var kit = {};
282282

283-
kit.buildData = function(p) {
284-
var _ = sa._;
283+
kit.buildData = function(p, custom_monitor_prop) {
285284
var data = {
286285
distinct_id: sa.store.getDistinctId(),
287286
identities: sa.store._state.identities,
@@ -298,6 +297,10 @@ kit.buildData = function(p) {
298297
delete p.unbind_value;
299298
}
300299

300+
if (!_.isObject(custom_monitor_prop)) {
301+
custom_monitor_prop = {};
302+
}
303+
301304
_.extend(data, sa.store.getUnionId(), p);
302305

303306
if (_.isObject(p.properties) && !_.isEmptyObject(p.properties)) {
@@ -306,7 +309,7 @@ kit.buildData = function(p) {
306309

307310
if (!p.type || p.type.slice(0, 7) !== 'profile') {
308311
data._track_id = Number(String(getRandom()).slice(2, 5) + String(getRandom()).slice(2, 4) + String(Date.now()).slice(-4));
309-
data.properties = _.extend({}, _.info.properties, sa.store.getProps(), _.info.currentProps, data.properties);
312+
data.properties = _.extend({}, _.info.properties, sa.store.getProps(), _.info.currentProps, custom_monitor_prop, data.properties);
310313
if (p.type === 'track') {
311314
data.properties.$is_first_day = _.getIsFirstDay();
312315
}
@@ -371,6 +374,11 @@ function setPublicPProperties(data) {
371374
}
372375
}
373376

377+
kit.onEventSend = function() {
378+
var custom_monitor_prop = {};
379+
return custom_monitor_prop;
380+
};
381+
374382

375383
var mergeStorageData = {};
376384

@@ -551,7 +559,10 @@ saEvent.send = function(p, callback) {
551559
return false;
552560
}
553561

554-
var data = sa.kit.buildData(p);
562+
var event_target = sa._.deepCopy(p);
563+
var custom_monitor_prop = sa.kit.onEventSend(event_target);
564+
565+
var data = sa.kit.buildData(p, custom_monitor_prop);
555566
if (data) {
556567
saEvent.debug(data);
557568
sa.events.emit('send', data);
@@ -1030,7 +1041,7 @@ sa.getServerUrl = function() {
10301041
return sa.para.server_url;
10311042
};
10321043

1033-
var LIB_VERSION = '1.17.2',
1044+
var LIB_VERSION = '1.17.3',
10341045
LIB_NAME = 'MiniProgram';
10351046

10361047
var source_channel_standard = 'utm_source utm_medium utm_campaign utm_content utm_term';

product/sensorsdata.full.js

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,11 @@ var isArray =
121121
};
122122

123123
function isFunction(f) {
124-
try {
125-
return /^\s*\bfunction\b/.test(f);
126-
} catch (x) {
124+
if (!f) {
127125
return false;
128126
}
127+
var type = Object.prototype.toString.call(f);
128+
return type == '[object Function]' || type == '[object AsyncFunction]';
129129
}
130130

131131
function isArguments(obj) {
@@ -283,8 +283,7 @@ var _ = {
283283

284284
var kit = {};
285285

286-
kit.buildData = function(p) {
287-
var _ = sa._;
286+
kit.buildData = function(p, custom_monitor_prop) {
288287
var data = {
289288
distinct_id: sa.store.getDistinctId(),
290289
identities: sa.store._state.identities,
@@ -301,6 +300,10 @@ kit.buildData = function(p) {
301300
delete p.unbind_value;
302301
}
303302

303+
if (!_.isObject(custom_monitor_prop)) {
304+
custom_monitor_prop = {};
305+
}
306+
304307
_.extend(data, sa.store.getUnionId(), p);
305308

306309
if (_.isObject(p.properties) && !_.isEmptyObject(p.properties)) {
@@ -309,7 +312,7 @@ kit.buildData = function(p) {
309312

310313
if (!p.type || p.type.slice(0, 7) !== 'profile') {
311314
data._track_id = Number(String(getRandom()).slice(2, 5) + String(getRandom()).slice(2, 4) + String(Date.now()).slice(-4));
312-
data.properties = _.extend({}, _.info.properties, sa.store.getProps(), _.info.currentProps, data.properties);
315+
data.properties = _.extend({}, _.info.properties, sa.store.getProps(), _.info.currentProps, custom_monitor_prop, data.properties);
313316
if (p.type === 'track') {
314317
data.properties.$is_first_day = _.getIsFirstDay();
315318
}
@@ -374,6 +377,11 @@ function setPublicPProperties(data) {
374377
}
375378
}
376379

380+
kit.onEventSend = function() {
381+
var custom_monitor_prop = {};
382+
return custom_monitor_prop;
383+
};
384+
377385

378386
var mergeStorageData = {};
379387

@@ -554,7 +562,10 @@ saEvent.send = function(p, callback) {
554562
return false;
555563
}
556564

557-
var data = sa.kit.buildData(p);
565+
var event_target = sa._.deepCopy(p);
566+
var custom_monitor_prop = sa.kit.onEventSend(event_target);
567+
568+
var data = sa.kit.buildData(p, custom_monitor_prop);
558569
if (data) {
559570
saEvent.debug(data);
560571
sa.events.emit('send', data);
@@ -1033,7 +1044,7 @@ sa.getServerUrl = function() {
10331044
return sa.para.server_url;
10341045
};
10351046

1036-
var LIB_VERSION = '1.17.2',
1047+
var LIB_VERSION = '1.17.3',
10371048
LIB_NAME = 'MiniProgram';
10381049

10391050
var source_channel_standard = 'utm_source utm_medium utm_campaign utm_content utm_term';

0 commit comments

Comments
 (0)