@tmsfe/tms-core 0.0.135 → 0.0.137

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tmsfe/tms-core",
3
- "version": "0.0.135",
3
+ "version": "0.0.137",
4
4
  "description": "tms运行时框架",
5
5
  "repository": {
6
6
  "type": "git",
package/src/env.js CHANGED
@@ -118,6 +118,10 @@ export const setAppPagePaths = (paths, homePage) => {
118
118
  export const isAppPageExist = (page) => {
119
119
  const route = !page ? '' : String(page).split('?')[0];
120
120
  if (!route || !Array.isArray(appPagePaths)) return false;
121
+ if (appPagePaths.length === 0) {
122
+ console.warn('isAppPageExist已经废弃,此方法会固定返回true');
123
+ return true;
124
+ }
121
125
  const routeWithoutPrefixSlash = route[0] === '/' ? route.substring(1) : route;
122
126
  return appPagePaths.some(path => path === routeWithoutPrefixSlash || path === `/${routeWithoutPrefixSlash}`);
123
127
  };
@@ -1,7 +1,7 @@
1
1
  # 埋点
2
2
 
3
3
  ### 目前支持的数据能力
4
- <img width="700" src="https://tai-static-1251316161.cos.ap-chengdu.myqcloud.com/reportcos/tms-data.png"/>
4
+ <img width="700" src="https://static.img.tai.qq.com/reportcos/tms-data.png"/>
5
5
 
6
6
  ### 埋点展示网站:https://tmsgo.testsite.woa.com/reportManage/list
7
7
 
@@ -66,6 +66,8 @@ function getBaseData(page: IPage, deviceData: IDeviceData): { arr: DataItem[], n
66
66
  arr[26] = helper.getLifeReportKey();
67
67
  // 27: f27,生成用户唯一id,方便追踪未登录接口
68
68
  arr[27] = helper.getTmsUUID();
69
+ // 28: f28 实际执行页面url
70
+ arr[28] = helper.execRoute;
69
71
  // 28 ~ 30: 预留字段给后续扩展使用
70
72
  // 31 ~ 40: 提供给开发自定义
71
73
  // --------------------------字段列表--------------------------
@@ -94,7 +96,13 @@ function jointData(page: IPage, data: any[], deviceData: IDeviceData): DataItem[
94
96
  */
95
97
  function formatData(data: any[]): Promise<DataItem[]> {
96
98
  // getDeviceData可能会太慢导致页面已跳转完,所以先获取page比较准确
99
+ // 提取最后一个数据项的 execPage 属性,并处理 data 为空数组的情况
100
+ const lastData = data.length > 0 ? data[data.length - 1] : null;
97
101
  const page = helper.getPageInfo();
102
+ if (lastData?.execPage) {
103
+ data.pop();
104
+ page.execRoute = lastData.execPage.route;
105
+ }
98
106
  return new Promise<DataItem[]>((resolve) => {
99
107
  helper.getDeviceData().then((deviceData: IDeviceData) => {
100
108
  const arr = jointData(page, data, deviceData);
@@ -38,12 +38,14 @@ function proxyBindEvent(componentName: string, methods: any, methodName: string,
38
38
  // eslint-disable-next-line no-param-reassign
39
39
  methods[methodName] = function (...args: any[]): any {
40
40
  // 执行原函数之后再发埋点
41
- return helper.executeFunc(this, original, args, () => {
41
+ return helper.executeFunc(this, original, args, (execPage) => {
42
42
  const extra = helper.getEventExtra(args[0]) ; // 把触发事件附加数据也带上
43
43
  const data = helper.cloneData(this);
44
44
  const eventName = `Component_${componentName}_${methodName}`;
45
45
  helper.setLastBindEvent({ eventName, data, extra, bindType });
46
- helper.reportData(eventName, data, extra, bindType);
46
+ helper.reportData(eventName, data, extra, bindType, {
47
+ execPage,
48
+ });
47
49
  });
48
50
  };
49
51
  }
@@ -4,6 +4,7 @@
4
4
  */
5
5
 
6
6
  import clone from '../clone';
7
+ import helper from '../helper';
7
8
  import { IInitOptions, IBindEvent } from './types';
8
9
 
9
10
  let initOptions: IInitOptions;
@@ -77,24 +78,26 @@ function emptyFunc(): void {
77
78
  * @param callback
78
79
  */
79
80
  function executeFunc(context: any, func: Function, args: any[], callback: Function): any {
81
+ // 获取当前page: route、options、depth
82
+ const page = helper.getPageInfo();
80
83
  let value: any;
81
84
  try {
82
85
  value = func.apply(context, args);
83
86
  } catch (e) {
84
- callback();
87
+ callback(page);
85
88
  throw e;
86
89
  }
87
90
  // 如果不会返回promise
88
91
  if (!value || !value.then || typeof value.then !== 'function') {
89
- callback();
92
+ callback(page);
90
93
  return value;
91
94
  }
92
95
 
93
96
  return value.then((res: any) => {
94
- callback();
97
+ callback(page);
95
98
  return res;
96
99
  }).catch((err: any) => {
97
- callback();
100
+ callback(page);
98
101
  return Promise.reject(err);
99
102
  });
100
103
  }
@@ -96,11 +96,13 @@ function proxyBindEvent(pageOptions: any, methodName: string, bindType: string):
96
96
  pageOptions[methodName] = function (...args: any[]): any {
97
97
  const extra = helper.getEventExtra(args[0]) ; // 把触发事件附加数据也带上
98
98
  // 执行原函数之后再发埋点
99
- return helper.executeFunc(this, original, args, () => {
99
+ return helper.executeFunc(this, original, args, (execPage) => {
100
100
  const data = helper.cloneData(this);
101
101
  const eventName = `Page_${methodName}`;
102
102
  helper.setLastBindEvent({ eventName, data, extra, bindType });
103
- helper.reportData(eventName, data, extra, bindType);
103
+ helper.reportData(eventName, data, extra, bindType, {
104
+ execPage,
105
+ });
104
106
  });
105
107
  };
106
108
  }
@@ -31,6 +31,7 @@ export interface IPage {
31
31
  route: string,
32
32
  options: object,
33
33
  depth: number,
34
+ execRoute: string,
34
35
  }
35
36
 
36
37
  /**
@@ -169,7 +169,7 @@ const getMycarPubOpenId = () => {
169
169
 
170
170
  const { appEnv } = getApp().tms.getEnvInfo();
171
171
  // 优先用缓存的,正式环境跟测试环境的不一样
172
- const key = `tms.pubOpenId.${appEnv}`;
172
+ const key = `tms.pubOpenId.${appEnv}_v1`;
173
173
  const pubOpenId = wx.getStorageSync(key);
174
174
  if (pubOpenId) {
175
175
  getMycarPubOpenIdProm = Promise.resolve(pubOpenId);