@dcloudio/uni-stat 2.0.1-alpha-36720221014001 → 2.0.1-alpha-36720221017002

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.
@@ -14,6 +14,46 @@ const APP_PVER_TIME = 300; // 应用在后台结束访问时间 单位s
14
14
  const OPERATING_TIME = 10; // 数据上报时间 单位s
15
15
  const DIFF_TIME = 60 * 1000 * 60 * 24;
16
16
 
17
+ const appid = process.env.UNI_APP_ID; // 做应用隔离
18
+ const dbSet = (name, value) => {
19
+ let data = uni.getStorageSync('$$STAT__DBDATA:'+appid) || {};
20
+
21
+ if (!data) {
22
+ data = {};
23
+ }
24
+ data[name] = value;
25
+ uni.setStorageSync('$$STAT__DBDATA:'+appid, data);
26
+ };
27
+
28
+ const dbGet = (name) => {
29
+ let data = uni.getStorageSync('$$STAT__DBDATA:'+appid) || {};
30
+ if (!data[name]) {
31
+ let dbdata = uni.getStorageSync('$$STAT__DBDATA:'+appid);
32
+ if (!dbdata) {
33
+ dbdata = {};
34
+ }
35
+ if (!dbdata[name]) {
36
+ return undefined
37
+ }
38
+ data[name] = dbdata[name];
39
+ }
40
+ return data[name]
41
+ };
42
+
43
+ const dbRemove = (name) => {
44
+ let data = uni.getStorageSync('$$STAT__DBDATA:'+appid) || {};
45
+ if (data[name]) {
46
+ delete data[name];
47
+ uni.setStorageSync('$$STAT__DBDATA:'+appid, data);
48
+ } else {
49
+ data = uni.getStorageSync('$$STAT__DBDATA:'+appid);
50
+ if (data[name]) {
51
+ delete data[name];
52
+ uni.setStorageSync('$$STAT__DBDATA:'+appid, data);
53
+ }
54
+ }
55
+ };
56
+
17
57
  // 获取 manifest.json 中统计配置
18
58
  const uniStatisticsConfig = process.env.UNI_STATISTICS_CONFIG;
19
59
  let statConfig = {
@@ -82,6 +122,24 @@ const get_uuid = (statData) => {
82
122
  return sys.deviceId || getUuid()
83
123
  };
84
124
 
125
+ /**
126
+ * 获取老版的 deviceid ,兼容以前的错误 deviceid
127
+ * @param {*} statData
128
+ * @returns
129
+ */
130
+ const get_odid = (statData) => {
131
+ let odid = '';
132
+ if (get_platform_name() === 'n') {
133
+ try {
134
+ odid = plus.device.uuid;
135
+ } catch (e) {
136
+ odid = '';
137
+ }
138
+ return odid
139
+ }
140
+ return sys.deviceId || getUuid()
141
+ };
142
+
85
143
  /**
86
144
  * 获取配置信息 如 appid
87
145
  */
@@ -542,46 +600,17 @@ const is_push_clientid = () => {
542
600
  return typeof ClientID === 'boolean' ? ClientID : false
543
601
  }
544
602
  return false
545
- };
546
-
547
- const appid = process.env.UNI_APP_ID; // 做应用隔离
548
- const dbSet = (name, value) => {
549
- let data = uni.getStorageSync('$$STAT__DBDATA:'+appid) || {};
550
-
551
- if (!data) {
552
- data = {};
553
- }
554
- data[name] = value;
555
- uni.setStorageSync('$$STAT__DBDATA:'+appid, data);
556
- };
557
-
558
- const dbGet = (name) => {
559
- let data = uni.getStorageSync('$$STAT__DBDATA:'+appid) || {};
560
- if (!data[name]) {
561
- let dbdata = uni.getStorageSync('$$STAT__DBDATA:'+appid);
562
- if (!dbdata) {
563
- dbdata = {};
564
- }
565
- if (!dbdata[name]) {
566
- return undefined
567
- }
568
- data[name] = dbdata[name];
569
- }
570
- return data[name]
571
603
  };
572
604
 
573
- const dbRemove = (name) => {
574
- let data = uni.getStorageSync('$$STAT__DBDATA:'+appid) || {};
575
- if (data[name]) {
576
- delete data[name];
577
- uni.setStorageSync('$$STAT__DBDATA:'+appid, data);
578
- } else {
579
- data = uni.getStorageSync('$$STAT__DBDATA:'+appid);
580
- if (data[name]) {
581
- delete data[name];
582
- uni.setStorageSync('$$STAT__DBDATA:'+appid, data);
583
- }
584
- }
605
+ /**
606
+ * 是否已处理设备 DeviceId
607
+ * 如果值为 1 则表示已处理
608
+ */
609
+ const IS_HANDLE_DEVECE_ID = 'is_handle_device_id';
610
+ const is_handle_device = () => {
611
+ let isHandleDevice = dbGet(IS_HANDLE_DEVECE_ID) || '';
612
+ dbSet(IS_HANDLE_DEVECE_ID, '1');
613
+ return isHandleDevice === '1'
585
614
  };
586
615
 
587
616
  // 首次访问时间
@@ -968,13 +997,28 @@ class Report {
968
997
  this._navigationBarTitle.config = get_page_name(options.path);
969
998
  let is_opt = options.query && JSON.stringify(options.query) !== '{}';
970
999
  let query = is_opt ? '?' + JSON.stringify(options.query) : '';
1000
+ const last_time = get_last_visit_time();
1001
+ // 非老用户
1002
+ if(last_time !== 0 || !last_time){
1003
+ const odid = get_odid();
1004
+
1005
+ // 2.0 处理规则
1006
+ {
1007
+ const have_device = is_handle_device();
1008
+ // 如果没有上报过设备信息 ,则需要上报设备信息
1009
+ if(!have_device) {
1010
+ this.statData.odid = odid;
1011
+ }
1012
+ }
1013
+ }
1014
+
971
1015
  Object.assign(this.statData, {
972
1016
  lt: '1',
973
1017
  url: options.path + query || '',
974
1018
  t: get_time(),
975
1019
  sc: get_scene(options.scene),
976
1020
  fvts: get_first_visit_time(),
977
- lvts: get_last_visit_time(),
1021
+ lvts: last_time,
978
1022
  tvc: get_total_visit_count(),
979
1023
  // create session type 上报类型 ,1 应用进入 2.后台30min进入 3.页面30min进入
980
1024
  cst: options.cst || 1,
@@ -12,6 +12,46 @@ const APP_PVER_TIME = 300; // 应用在后台结束访问时间 单位s
12
12
  const OPERATING_TIME = 10; // 数据上报时间 单位s
13
13
  const DIFF_TIME = 60 * 1000 * 60 * 24;
14
14
 
15
+ const appid = process.env.UNI_APP_ID; // 做应用隔离
16
+ const dbSet = (name, value) => {
17
+ let data = uni.getStorageSync('$$STAT__DBDATA:'+appid) || {};
18
+
19
+ if (!data) {
20
+ data = {};
21
+ }
22
+ data[name] = value;
23
+ uni.setStorageSync('$$STAT__DBDATA:'+appid, data);
24
+ };
25
+
26
+ const dbGet = (name) => {
27
+ let data = uni.getStorageSync('$$STAT__DBDATA:'+appid) || {};
28
+ if (!data[name]) {
29
+ let dbdata = uni.getStorageSync('$$STAT__DBDATA:'+appid);
30
+ if (!dbdata) {
31
+ dbdata = {};
32
+ }
33
+ if (!dbdata[name]) {
34
+ return undefined
35
+ }
36
+ data[name] = dbdata[name];
37
+ }
38
+ return data[name]
39
+ };
40
+
41
+ const dbRemove = (name) => {
42
+ let data = uni.getStorageSync('$$STAT__DBDATA:'+appid) || {};
43
+ if (data[name]) {
44
+ delete data[name];
45
+ uni.setStorageSync('$$STAT__DBDATA:'+appid, data);
46
+ } else {
47
+ data = uni.getStorageSync('$$STAT__DBDATA:'+appid);
48
+ if (data[name]) {
49
+ delete data[name];
50
+ uni.setStorageSync('$$STAT__DBDATA:'+appid, data);
51
+ }
52
+ }
53
+ };
54
+
15
55
  // 获取 manifest.json 中统计配置
16
56
  const uniStatisticsConfig = process.env.UNI_STATISTICS_CONFIG;
17
57
  let statConfig = {
@@ -80,6 +120,24 @@ const get_uuid = (statData) => {
80
120
  return sys.deviceId || getUuid()
81
121
  };
82
122
 
123
+ /**
124
+ * 获取老版的 deviceid ,兼容以前的错误 deviceid
125
+ * @param {*} statData
126
+ * @returns
127
+ */
128
+ const get_odid = (statData) => {
129
+ let odid = '';
130
+ if (get_platform_name() === 'n') {
131
+ try {
132
+ odid = plus.device.uuid;
133
+ } catch (e) {
134
+ odid = '';
135
+ }
136
+ return odid
137
+ }
138
+ return sys.deviceId || getUuid()
139
+ };
140
+
83
141
  /**
84
142
  * 获取配置信息 如 appid
85
143
  */
@@ -540,46 +598,17 @@ const is_push_clientid = () => {
540
598
  return typeof ClientID === 'boolean' ? ClientID : false
541
599
  }
542
600
  return false
543
- };
544
-
545
- const appid = process.env.UNI_APP_ID; // 做应用隔离
546
- const dbSet = (name, value) => {
547
- let data = uni.getStorageSync('$$STAT__DBDATA:'+appid) || {};
548
-
549
- if (!data) {
550
- data = {};
551
- }
552
- data[name] = value;
553
- uni.setStorageSync('$$STAT__DBDATA:'+appid, data);
554
- };
555
-
556
- const dbGet = (name) => {
557
- let data = uni.getStorageSync('$$STAT__DBDATA:'+appid) || {};
558
- if (!data[name]) {
559
- let dbdata = uni.getStorageSync('$$STAT__DBDATA:'+appid);
560
- if (!dbdata) {
561
- dbdata = {};
562
- }
563
- if (!dbdata[name]) {
564
- return undefined
565
- }
566
- data[name] = dbdata[name];
567
- }
568
- return data[name]
569
601
  };
570
602
 
571
- const dbRemove = (name) => {
572
- let data = uni.getStorageSync('$$STAT__DBDATA:'+appid) || {};
573
- if (data[name]) {
574
- delete data[name];
575
- uni.setStorageSync('$$STAT__DBDATA:'+appid, data);
576
- } else {
577
- data = uni.getStorageSync('$$STAT__DBDATA:'+appid);
578
- if (data[name]) {
579
- delete data[name];
580
- uni.setStorageSync('$$STAT__DBDATA:'+appid, data);
581
- }
582
- }
603
+ /**
604
+ * 是否已处理设备 DeviceId
605
+ * 如果值为 1 则表示已处理
606
+ */
607
+ const IS_HANDLE_DEVECE_ID = 'is_handle_device_id';
608
+ const is_handle_device = () => {
609
+ let isHandleDevice = dbGet(IS_HANDLE_DEVECE_ID) || '';
610
+ dbSet(IS_HANDLE_DEVECE_ID, '1');
611
+ return isHandleDevice === '1'
583
612
  };
584
613
 
585
614
  // 首次访问时间
@@ -966,13 +995,28 @@ class Report {
966
995
  this._navigationBarTitle.config = get_page_name(options.path);
967
996
  let is_opt = options.query && JSON.stringify(options.query) !== '{}';
968
997
  let query = is_opt ? '?' + JSON.stringify(options.query) : '';
998
+ const last_time = get_last_visit_time();
999
+ // 非老用户
1000
+ if(last_time !== 0 || !last_time){
1001
+ const odid = get_odid();
1002
+
1003
+ // 2.0 处理规则
1004
+ {
1005
+ const have_device = is_handle_device();
1006
+ // 如果没有上报过设备信息 ,则需要上报设备信息
1007
+ if(!have_device) {
1008
+ this.statData.odid = odid;
1009
+ }
1010
+ }
1011
+ }
1012
+
969
1013
  Object.assign(this.statData, {
970
1014
  lt: '1',
971
1015
  url: options.path + query || '',
972
1016
  t: get_time(),
973
1017
  sc: get_scene(options.scene),
974
1018
  fvts: get_first_visit_time(),
975
- lvts: get_last_visit_time(),
1019
+ lvts: last_time,
976
1020
  tvc: get_total_visit_count(),
977
1021
  // create session type 上报类型 ,1 应用进入 2.后台30min进入 3.页面30min进入
978
1022
  cst: options.cst || 1,
@@ -14,6 +14,46 @@ const APP_PVER_TIME = 300; // 应用在后台结束访问时间 单位s
14
14
  const OPERATING_TIME = 10; // 数据上报时间 单位s
15
15
  const DIFF_TIME = 60 * 1000 * 60 * 24;
16
16
 
17
+ const appid = process.env.UNI_APP_ID; // 做应用隔离
18
+ const dbSet = (name, value) => {
19
+ let data = uni.getStorageSync('$$STAT__DBDATA:'+appid) || {};
20
+
21
+ if (!data) {
22
+ data = {};
23
+ }
24
+ data[name] = value;
25
+ uni.setStorageSync('$$STAT__DBDATA:'+appid, data);
26
+ };
27
+
28
+ const dbGet = (name) => {
29
+ let data = uni.getStorageSync('$$STAT__DBDATA:'+appid) || {};
30
+ if (!data[name]) {
31
+ let dbdata = uni.getStorageSync('$$STAT__DBDATA:'+appid);
32
+ if (!dbdata) {
33
+ dbdata = {};
34
+ }
35
+ if (!dbdata[name]) {
36
+ return undefined
37
+ }
38
+ data[name] = dbdata[name];
39
+ }
40
+ return data[name]
41
+ };
42
+
43
+ const dbRemove = (name) => {
44
+ let data = uni.getStorageSync('$$STAT__DBDATA:'+appid) || {};
45
+ if (data[name]) {
46
+ delete data[name];
47
+ uni.setStorageSync('$$STAT__DBDATA:'+appid, data);
48
+ } else {
49
+ data = uni.getStorageSync('$$STAT__DBDATA:'+appid);
50
+ if (data[name]) {
51
+ delete data[name];
52
+ uni.setStorageSync('$$STAT__DBDATA:'+appid, data);
53
+ }
54
+ }
55
+ };
56
+
17
57
  // 获取 manifest.json 中统计配置
18
58
  const uniStatisticsConfig = process.env.UNI_STATISTICS_CONFIG;
19
59
  let statConfig = {
@@ -82,6 +122,24 @@ const get_uuid = (statData) => {
82
122
  return sys.deviceId || getUuid()
83
123
  };
84
124
 
125
+ /**
126
+ * 获取老版的 deviceid ,兼容以前的错误 deviceid
127
+ * @param {*} statData
128
+ * @returns
129
+ */
130
+ const get_odid = (statData) => {
131
+ let odid = '';
132
+ if (get_platform_name() === 'n') {
133
+ try {
134
+ odid = plus.device.uuid;
135
+ } catch (e) {
136
+ odid = '';
137
+ }
138
+ return odid
139
+ }
140
+ return sys.deviceId || getUuid()
141
+ };
142
+
85
143
  /**
86
144
  * 获取配置信息 如 appid
87
145
  */
@@ -523,46 +581,6 @@ const is_push_clientid = () => {
523
581
  return false
524
582
  };
525
583
 
526
- const appid = process.env.UNI_APP_ID; // 做应用隔离
527
- const dbSet = (name, value) => {
528
- let data = uni.getStorageSync('$$STAT__DBDATA:'+appid) || {};
529
-
530
- if (!data) {
531
- data = {};
532
- }
533
- data[name] = value;
534
- uni.setStorageSync('$$STAT__DBDATA:'+appid, data);
535
- };
536
-
537
- const dbGet = (name) => {
538
- let data = uni.getStorageSync('$$STAT__DBDATA:'+appid) || {};
539
- if (!data[name]) {
540
- let dbdata = uni.getStorageSync('$$STAT__DBDATA:'+appid);
541
- if (!dbdata) {
542
- dbdata = {};
543
- }
544
- if (!dbdata[name]) {
545
- return undefined
546
- }
547
- data[name] = dbdata[name];
548
- }
549
- return data[name]
550
- };
551
-
552
- const dbRemove = (name) => {
553
- let data = uni.getStorageSync('$$STAT__DBDATA:'+appid) || {};
554
- if (data[name]) {
555
- delete data[name];
556
- uni.setStorageSync('$$STAT__DBDATA:'+appid, data);
557
- } else {
558
- data = uni.getStorageSync('$$STAT__DBDATA:'+appid);
559
- if (data[name]) {
560
- delete data[name];
561
- uni.setStorageSync('$$STAT__DBDATA:'+appid, data);
562
- }
563
- }
564
- };
565
-
566
584
  // 首次访问时间
567
585
  const FIRST_VISIT_TIME_KEY = '__first__visit__time';
568
586
  // 最后访问时间
@@ -947,13 +965,23 @@ class Report {
947
965
  this._navigationBarTitle.config = get_page_name(options.path);
948
966
  let is_opt = options.query && JSON.stringify(options.query) !== '{}';
949
967
  let query = is_opt ? '?' + JSON.stringify(options.query) : '';
968
+ const last_time = get_last_visit_time();
969
+ // 非老用户
970
+ if(last_time !== 0 || !last_time){
971
+ const odid = get_odid();
972
+ // 1.0 处理规则
973
+ {
974
+ this.statData.odid = odid;
975
+ }
976
+ }
977
+
950
978
  Object.assign(this.statData, {
951
979
  lt: '1',
952
980
  url: options.path + query || '',
953
981
  t: get_time(),
954
982
  sc: get_scene(options.scene),
955
983
  fvts: get_first_visit_time(),
956
- lvts: get_last_visit_time(),
984
+ lvts: last_time,
957
985
  tvc: get_total_visit_count(),
958
986
  // create session type 上报类型 ,1 应用进入 2.后台30min进入 3.页面30min进入
959
987
  cst: options.cst || 1,
@@ -12,6 +12,46 @@ const APP_PVER_TIME = 300; // 应用在后台结束访问时间 单位s
12
12
  const OPERATING_TIME = 10; // 数据上报时间 单位s
13
13
  const DIFF_TIME = 60 * 1000 * 60 * 24;
14
14
 
15
+ const appid = process.env.UNI_APP_ID; // 做应用隔离
16
+ const dbSet = (name, value) => {
17
+ let data = uni.getStorageSync('$$STAT__DBDATA:'+appid) || {};
18
+
19
+ if (!data) {
20
+ data = {};
21
+ }
22
+ data[name] = value;
23
+ uni.setStorageSync('$$STAT__DBDATA:'+appid, data);
24
+ };
25
+
26
+ const dbGet = (name) => {
27
+ let data = uni.getStorageSync('$$STAT__DBDATA:'+appid) || {};
28
+ if (!data[name]) {
29
+ let dbdata = uni.getStorageSync('$$STAT__DBDATA:'+appid);
30
+ if (!dbdata) {
31
+ dbdata = {};
32
+ }
33
+ if (!dbdata[name]) {
34
+ return undefined
35
+ }
36
+ data[name] = dbdata[name];
37
+ }
38
+ return data[name]
39
+ };
40
+
41
+ const dbRemove = (name) => {
42
+ let data = uni.getStorageSync('$$STAT__DBDATA:'+appid) || {};
43
+ if (data[name]) {
44
+ delete data[name];
45
+ uni.setStorageSync('$$STAT__DBDATA:'+appid, data);
46
+ } else {
47
+ data = uni.getStorageSync('$$STAT__DBDATA:'+appid);
48
+ if (data[name]) {
49
+ delete data[name];
50
+ uni.setStorageSync('$$STAT__DBDATA:'+appid, data);
51
+ }
52
+ }
53
+ };
54
+
15
55
  // 获取 manifest.json 中统计配置
16
56
  const uniStatisticsConfig = process.env.UNI_STATISTICS_CONFIG;
17
57
  let statConfig = {
@@ -80,6 +120,24 @@ const get_uuid = (statData) => {
80
120
  return sys.deviceId || getUuid()
81
121
  };
82
122
 
123
+ /**
124
+ * 获取老版的 deviceid ,兼容以前的错误 deviceid
125
+ * @param {*} statData
126
+ * @returns
127
+ */
128
+ const get_odid = (statData) => {
129
+ let odid = '';
130
+ if (get_platform_name() === 'n') {
131
+ try {
132
+ odid = plus.device.uuid;
133
+ } catch (e) {
134
+ odid = '';
135
+ }
136
+ return odid
137
+ }
138
+ return sys.deviceId || getUuid()
139
+ };
140
+
83
141
  /**
84
142
  * 获取配置信息 如 appid
85
143
  */
@@ -521,46 +579,6 @@ const is_push_clientid = () => {
521
579
  return false
522
580
  };
523
581
 
524
- const appid = process.env.UNI_APP_ID; // 做应用隔离
525
- const dbSet = (name, value) => {
526
- let data = uni.getStorageSync('$$STAT__DBDATA:'+appid) || {};
527
-
528
- if (!data) {
529
- data = {};
530
- }
531
- data[name] = value;
532
- uni.setStorageSync('$$STAT__DBDATA:'+appid, data);
533
- };
534
-
535
- const dbGet = (name) => {
536
- let data = uni.getStorageSync('$$STAT__DBDATA:'+appid) || {};
537
- if (!data[name]) {
538
- let dbdata = uni.getStorageSync('$$STAT__DBDATA:'+appid);
539
- if (!dbdata) {
540
- dbdata = {};
541
- }
542
- if (!dbdata[name]) {
543
- return undefined
544
- }
545
- data[name] = dbdata[name];
546
- }
547
- return data[name]
548
- };
549
-
550
- const dbRemove = (name) => {
551
- let data = uni.getStorageSync('$$STAT__DBDATA:'+appid) || {};
552
- if (data[name]) {
553
- delete data[name];
554
- uni.setStorageSync('$$STAT__DBDATA:'+appid, data);
555
- } else {
556
- data = uni.getStorageSync('$$STAT__DBDATA:'+appid);
557
- if (data[name]) {
558
- delete data[name];
559
- uni.setStorageSync('$$STAT__DBDATA:'+appid, data);
560
- }
561
- }
562
- };
563
-
564
582
  // 首次访问时间
565
583
  const FIRST_VISIT_TIME_KEY = '__first__visit__time';
566
584
  // 最后访问时间
@@ -945,13 +963,23 @@ class Report {
945
963
  this._navigationBarTitle.config = get_page_name(options.path);
946
964
  let is_opt = options.query && JSON.stringify(options.query) !== '{}';
947
965
  let query = is_opt ? '?' + JSON.stringify(options.query) : '';
966
+ const last_time = get_last_visit_time();
967
+ // 非老用户
968
+ if(last_time !== 0 || !last_time){
969
+ const odid = get_odid();
970
+ // 1.0 处理规则
971
+ {
972
+ this.statData.odid = odid;
973
+ }
974
+ }
975
+
948
976
  Object.assign(this.statData, {
949
977
  lt: '1',
950
978
  url: options.path + query || '',
951
979
  t: get_time(),
952
980
  sc: get_scene(options.scene),
953
981
  fvts: get_first_visit_time(),
954
- lvts: get_last_visit_time(),
982
+ lvts: last_time,
955
983
  tvc: get_total_visit_count(),
956
984
  // create session type 上报类型 ,1 应用进入 2.后台30min进入 3.页面30min进入
957
985
  cst: options.cst || 1,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcloudio/uni-stat",
3
- "version": "2.0.1-alpha-36720221014001",
3
+ "version": "2.0.1-alpha-36720221017002",
4
4
  "description": "",
5
5
  "main": "dist/uni-stat.es.js",
6
6
  "repository": {
@@ -34,5 +34,5 @@
34
34
  "rollup-plugin-replace": "^2.2.0",
35
35
  "rollup-plugin-uglify": "^6.0.2"
36
36
  },
37
- "gitHead": "d30323ee8aad81efa6ad05e25053f36257f4f261"
37
+ "gitHead": "fccb6f1da0c110a1ebb6f7530a60ee1388055751"
38
38
  }