yrjy_mini_sdk 1.0.0

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/.babelrc ADDED
@@ -0,0 +1,16 @@
1
+ {
2
+ "presets": [
3
+ "@babel/preset-env"
4
+ ],
5
+ "plugins": [
6
+ [
7
+ "@babel/plugin-transform-runtime",
8
+ {
9
+ "corejs": false,
10
+ "helpers": true,
11
+ "regenerator": true,
12
+ "useESModules": false
13
+ }
14
+ ]
15
+ ]
16
+ }
package/README.md ADDED
@@ -0,0 +1,463 @@
1
+ # 小程序埋点SDK
2
+
3
+ ## 项目介绍
4
+
5
+ 本SDK是一个专为小程序设计的埋点解决方案,兼容微信小程序和抖音小程序,基于 **UniApp + Vue3** 框架开发。
6
+
7
+ - 支持页面访问埋点
8
+ - 支持自定义事件埋点
9
+ - 自动收集设备信息和网络状态
10
+ - 支持用户信息关联
11
+ - 提供简单易用的API接口
12
+ - 支持接口自动上报(使用SDK提供的HTTP实例)
13
+
14
+ ## 安装方法
15
+
16
+ ### NPM安装
17
+
18
+ ```bash
19
+ npm install mini_sdk
20
+ ```
21
+
22
+ ### 直接引入
23
+
24
+ 将SDK文件复制到项目中,然后通过相对路径引入。
25
+
26
+ ## 使用方法
27
+
28
+ ### 1. 初始化SDK
29
+
30
+ #### 方法一:全局挂载(推荐)
31
+
32
+ 在main.js中全局注册SDK:
33
+
34
+ ```javascript
35
+ import { createApp } from 'vue';
36
+ import App from './App.vue';
37
+ import MiniSDK from 'mini_sdk';
38
+
39
+ const app = createApp(App);
40
+
41
+ // 全局注册SDK(可传入配置参数)
42
+ app.use(MiniSDK, {
43
+ reportUrl: 'https://your-api.com/report', // 埋点上报接口
44
+ enabled: true // 是否启用埋点
45
+ });
46
+
47
+ app.mount('#app');
48
+ ```
49
+
50
+ 使用时:
51
+
52
+ ```javascript
53
+ // 组件中使用
54
+ this.$Track.report({
55
+ trackType: 'event',
56
+ eventName: 'click_button'
57
+ });
58
+
59
+ // 非组件环境(如工具函数)
60
+ uni.$Track.report({
61
+ trackType: 'event',
62
+ eventName: 'api_call'
63
+ });
64
+ ```
65
+
66
+ #### 方法二:按需引入
67
+
68
+ 在需要使用的文件中引入:
69
+
70
+ ```javascript
71
+ import { Track, trackPageMixin } from 'mini_sdk';
72
+
73
+ // 初始化埋点SDK
74
+ Track.init({
75
+ reportUrl: 'https://your-api.com/report', // 埋点上报接口
76
+ enabled: true // 是否启用埋点
77
+ });
78
+
79
+ // 页面使用混入
80
+ export default {
81
+ mixins: [trackPageMixin],
82
+ // 页面其他代码...
83
+ };
84
+ ```
85
+
86
+ ### 2. 页面埋点
87
+
88
+ #### 自动注入(推荐)
89
+
90
+ 当使用`app.use(MiniSDK)`全局注册后,trackPageMixin会自动注入到所有页面组件中,无需手动引入。
91
+
92
+ #### 手动引入
93
+
94
+ 如果不需要全局注入,也可以在特定页面手动引入:
95
+
96
+ ```javascript
97
+ import { trackPageMixin } from 'mini_sdk';
98
+
99
+ export default {
100
+ mixins: [trackPageMixin],
101
+ // 页面其他代码...
102
+ };
103
+ ```
104
+
105
+ ### 3. 自定义事件埋点
106
+
107
+ #### 全局挂载后使用
108
+
109
+ ```javascript
110
+ // 组件中使用
111
+ this.$Track.report({
112
+ trackType: 'event',
113
+ eventName: 'click_button',
114
+ eventData: {
115
+ buttonId: 'submit',
116
+ viewPagePath: '/pages/index/index'
117
+ }
118
+ });
119
+
120
+ // 非组件环境使用
121
+ uni.$Track.report({
122
+ trackType: 'event',
123
+ eventName: 'api_call',
124
+ eventData: {
125
+ apiUrl: '/api/user',
126
+ method: 'GET'
127
+ }
128
+ });
129
+ ```
130
+
131
+ #### 按需引入使用
132
+
133
+ ```javascript
134
+ import { Track } from 'mini_sdk';
135
+
136
+ // 上报自定义事件
137
+ Track.report({
138
+ trackType: 'event',
139
+ eventName: 'click_button',
140
+ eventData: {
141
+ buttonId: 'submit',
142
+ viewPagePath: '/pages/index/index'
143
+ }
144
+ });
145
+ ```
146
+
147
+ ### 4. 设置用户信息
148
+
149
+ ```javascript
150
+ import { Track } from 'mini_sdk';
151
+
152
+ // 设置用户信息(登录后调用)
153
+ Track.setUserInfo({
154
+ id: 'user123',
155
+ mobile: '13800138000'
156
+ });
157
+
158
+ // 清除用户信息(登出时调用)
159
+ Track.clearUserInfo();
160
+ ```
161
+
162
+ ### 5. 接口自动上报
163
+
164
+ 使用SDK提供的HTTP实例发送请求,接口调用会自动上报埋点。
165
+
166
+ **使用示例**:
167
+
168
+ ```javascript
169
+ import http from 'mini_sdk/src/axios/request.js';
170
+
171
+ // 发送GET请求,会自动上报埋点
172
+ http.get('/api/test', { id: 1 })
173
+ .then(res => {
174
+ console.log('请求成功', res);
175
+ })
176
+ .catch(err => {
177
+ console.error('请求失败', err);
178
+ });
179
+
180
+ // 发送POST请求,会自动上报埋点
181
+ http.post('/api/test', { name: 'test' })
182
+ .then(res => {
183
+ console.log('请求成功', res);
184
+ })
185
+ .catch(err => {
186
+ console.error('请求失败', err);
187
+ });
188
+ ```
189
+
190
+ ### 6. 栏目管理
191
+
192
+ ```javascript
193
+ import { Track } from 'mini_sdk';
194
+
195
+ // 设置一级栏目
196
+ Track.setPrimaryCategory([
197
+ { id: '1', title: '首页' },
198
+ { id: '2', title: '我的' }
199
+ ], 0);
200
+
201
+ // 设置二级栏目
202
+ Track.setSecondaryCategory([
203
+ { id: '1-1', title: '推荐' },
204
+ { id: '1-2', title: '热门' }
205
+ ], 0);
206
+
207
+ // 重置或设置栏目(支持恢复默认值或直接赋值)
208
+
209
+ // 重置二级栏目为默认值(空字符串)
210
+ Track.resetCategory();
211
+
212
+ // 重置一级栏目为默认值(空字符串)
213
+ Track.resetCategory('primary');
214
+
215
+ // 重置一级和二级栏目为默认值(空字符串)
216
+ Track.resetCategory('both');
217
+
218
+ // 设置二级栏目为 "新的二级栏目"
219
+ Track.resetCategory('secondary', '新的二级栏目');
220
+
221
+ // 设置一级栏目为 "新的一级栏目"
222
+ Track.resetCategory('primary', '新的一级栏目');
223
+
224
+ // 同时设置一级和二级栏目为相同值
225
+ Track.resetCategory('both', '通用栏目');
226
+
227
+ // 分别设置一级和二级栏目为不同值
228
+ Track.resetCategory('both', {
229
+ primary: '新的一级栏目',
230
+ secondary: '新的二级栏目'
231
+ });
232
+ ```
233
+
234
+ ## API文档
235
+
236
+ ### Track类
237
+
238
+ #### `Track.init(options)`
239
+
240
+ 初始化埋点SDK。
241
+
242
+ - `options`:配置对象
243
+ - `reportUrl`:埋点上报接口URL
244
+ - `enabled`:是否启用埋点(默认true)
245
+
246
+ #### `Track.report(trackData)`
247
+
248
+ 上报埋点数据。
249
+
250
+ - `trackData`:埋点数据对象
251
+ - `trackType`:埋点类型(必填)
252
+ - 其他自定义字段
253
+
254
+ #### `Track.setUserInfo(userInfo)`
255
+
256
+ 设置用户信息。
257
+
258
+ - `userInfo`:用户信息对象
259
+ - `id`:用户ID(必填)
260
+ - `mobile`:用户手机号(可选)
261
+
262
+ #### `Track.clearUserInfo()`
263
+
264
+ 清除用户信息。
265
+
266
+ #### `Track.enable()`
267
+
268
+ 开启埋点功能。
269
+
270
+ #### `Track.disable()`
271
+
272
+ 关闭埋点功能。
273
+
274
+ #### `Track.resetCategory(type, value)`
275
+
276
+ 重置或设置栏目信息。
277
+
278
+ - `type`:操作类型,可选值:"primary"(一级栏目)、"secondary"(二级栏目)、"both"(两者都操作),默认值为 "secondary"
279
+ - `value`:可选,要设置的值。
280
+ - 当 `type` 为 "primary" 或 "secondary" 时,`value` 应为字符串
281
+ - 当 `type` 为 "both" 时,`value` 可以是字符串(同时设置两个栏目为相同值)或对象(分别设置两个栏目)
282
+ - 如果不提供,则重置为默认值(空字符串)
283
+
284
+ ### trackPageMixin
285
+
286
+ 页面埋点混入,自动采集页面访问数据:
287
+
288
+ - 自动记录页面加载时间
289
+ - 自动计算页面停留时间
290
+ - 自动上报页面显示/隐藏/卸载事件
291
+
292
+ ## 数据上报格式
293
+
294
+ 埋点上报的数据格式如下:
295
+
296
+ ```javascript
297
+ {
298
+ launchTime: 1620000000000, // 小程序启动时间
299
+ path: '/pages/index/index', // 启动路径
300
+ scene: 1001, // 启动场景
301
+ query: {}, // 启动参数
302
+ currentTime: 1620000100000, // 当前时间戳
303
+ system: 'iOS 14.4', // 操作系统
304
+ uniPlatform: 'mp-weixin', // 平台
305
+ deviceBrand: 'Apple', // 设备品牌
306
+ deviceType: 'iphone', // 设备类型
307
+ appId: 'wx1234567890', // 小程序AppID
308
+ version: '1.0.0', // 小程序版本
309
+ envVersion: 'release', // 小程序环境
310
+ userId: 'user123', // 用户ID
311
+ userPhone: '13800138000', // 用户手机号
312
+ networkType: 'wifi', // 网络类型
313
+ customData: { // 自定义埋点数据
314
+ trackType: 'page',
315
+ viewPagePath: '/pages/index/index',
316
+ timestamp: 1620000000000,
317
+ stayTime: 10000,
318
+ reportType: 'unload'
319
+ }
320
+ }
321
+ ```
322
+
323
+ ## 注意事项
324
+
325
+ 1. 请确保在小程序启动时调用`Track.init()`进行初始化
326
+ 2. 页面埋点混入会自动处理页面生命周期事件,无需手动调用
327
+ 3. 自定义事件埋点需要手动调用`Track.report()`方法
328
+ 4. 为了保证埋点数据的准确性,建议在用户登录后调用`Track.setUserInfo()`设置用户信息
329
+ 5. 埋点上报接口需要根据实际后端接口进行配置
330
+ 6. 请确保小程序有网络请求权限
331
+
332
+ ## 兼容性
333
+
334
+ - 微信小程序
335
+ - 抖音小程序
336
+ - 其他基于UniApp框架的小程序平台
337
+
338
+ ## 开发说明
339
+
340
+ ### 项目结构
341
+
342
+ ```
343
+ src/
344
+ ├── axios/ # 网络请求模块
345
+ │ ├── api.js # API接口定义
346
+ │ └── request.js # 请求封装
347
+ ├── config/ # 配置文件
348
+ │ └── index.js # 全局配置
349
+ ├── struct/ # 核心结构
350
+ │ ├── trackCore.js # 埋点核心实现
351
+ │ └── trackPageMixin.js # 页面埋点混入
352
+ └── index.js # 入口文件
353
+ ```
354
+
355
+ ### 核心功能
356
+
357
+ 1. **页面埋点**:自动采集页面访问数据,包括页面路径、访问时间、停留时间等
358
+ 2. **设备信息采集**:自动收集设备品牌、型号、操作系统等信息
359
+ 3. **网络状态检测**:自动采集网络类型
360
+ 4. **用户信息关联**:支持关联用户ID和手机号
361
+ 5. **自定义事件**:支持自定义事件埋点
362
+
363
+ ## 故障排查
364
+
365
+ ### 埋点不上报
366
+
367
+ 1. 检查`Track.init()`是否调用
368
+ 2. 检查`enabled`配置是否为true
369
+ 3. 检查网络连接是否正常
370
+ 4. 检查上报接口是否正确
371
+
372
+ ### 数据不完整
373
+
374
+ 1. 检查用户信息是否正确设置
375
+ 2. 检查自定义埋点数据格式是否正确
376
+ 3. 检查设备权限是否开启
377
+
378
+ ## 联系我们
379
+
380
+ 如有问题或建议,请联系我们的开发团队。
381
+
382
+ ## 打包配置
383
+
384
+ ### 打包命令
385
+
386
+ 本项目使用 `rollup` 进行打包,支持以下命令:
387
+
388
+ ```bash
389
+ # 安装依赖
390
+ npm install
391
+
392
+ # 开发模式(无压缩)
393
+ npm run dev
394
+
395
+ # 生产模式(有压缩)
396
+ npm run build
397
+
398
+ # 构建并发布(更新版本号并发布到npm)
399
+ npm run release
400
+ ```
401
+
402
+ ### 打包配置文件
403
+
404
+ 项目根目录下的 `rollup.config.js` 文件用于配置打包选项,具体配置如下:
405
+
406
+ ```javascript
407
+ import babel from '@rollup/plugin-babel';
408
+ import resolve from '@rollup/plugin-node-resolve';
409
+ import commonjs from '@rollup/plugin-commonjs';
410
+ import terser from '@rollup/plugin-terser';
411
+ import pkg from './package.json';
412
+
413
+ const isProduction = process.env.NODE_ENV === 'production';
414
+
415
+ export default {
416
+ input: 'src/index.js',
417
+ output: [
418
+ {
419
+ file: pkg.main,
420
+ format: 'cjs',
421
+ sourcemap: !isProduction
422
+ },
423
+ {
424
+ file: pkg.module,
425
+ format: 'es',
426
+ sourcemap: !isProduction
427
+ }
428
+ ],
429
+ plugins: [
430
+ resolve(),
431
+ commonjs(),
432
+ babel({
433
+ exclude: 'node_modules/**',
434
+ babelHelpers: 'runtime'
435
+ }),
436
+ isProduction && terser()
437
+ ].filter(Boolean)
438
+ };
439
+ ```
440
+
441
+ ### 发布到NPM
442
+
443
+ 1. 确保已登录NPM账号:
444
+ ```bash
445
+ npm login
446
+ ```
447
+
448
+ 2. 运行发布命令:
449
+ ```bash
450
+ npm run release
451
+ ```
452
+
453
+ 该命令会自动更新版本号、构建项目并发布到NPM。
454
+
455
+ ### 版本号管理
456
+
457
+ 项目使用语义化版本号(SemVer),格式为 `x.y.z`:
458
+
459
+ - `x`:主版本号,不兼容的API更改
460
+ - `y`:次版本号,向下兼容的功能添加
461
+ - `z`:补丁版本号,向下兼容的错误修正
462
+
463
+ 发布命令会自动递增版本号,默认递增补丁版本号。如需递增次版本号或主版本号,请手动修改 `package.json` 文件中的 `version` 字段。
@@ -0,0 +1,3 @@
1
+ "use strict";function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function t(t,r){return function(e){if(Array.isArray(e))return e}(t)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,a,u=[],c=!0,s=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(u.push(n.value),u.length!==t);c=!0);}catch(e){s=!0,o=e}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return u}}(t,r)||function(t,r){if(t){if("string"==typeof t)return e(t,r);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?e(t,r):void 0}}(t,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function n(e,t,r,n,o,i,a){try{var u=e[i](a),c=u.value}catch(e){return void r(e)}u.done?t(c):Promise.resolve(c).then(n,o)}function o(e){return function(){var t=this,r=arguments;return new Promise(function(o,i){var a=e.apply(t,r);function u(e){n(a,o,i,u,c,"next",e)}function c(e){n(a,o,i,u,c,"throw",e)}u(void 0)})}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e){var t=function(e,t){if("object"!=r(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,t||"default");if("object"!=r(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==r(t)?t:t+""}function u(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,a(n.key),n)}}function c(e,t,r){return t&&u(e.prototype,t),r&&u(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function s(e,t,r){return(t=a(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function f(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var p,l={exports:{}},y={exports:{}};(p=y).exports=function(e,t){this.v=e,this.k=t},p.exports.__esModule=!0,p.exports.default=p.exports;var h=y.exports,v={exports:{}},g={exports:{}};!function(e){function t(r,n,o,i){var a=Object.defineProperty;try{a({},"",{})}catch(r){a=0}e.exports=t=function(e,r,n,o){function i(r,n){t(e,r,function(e){return this._invoke(r,n,e)})}r?a?a(e,r,{value:n,enumerable:!o,configurable:!o,writable:!o}):e[r]=n:(i("next",0),i("throw",1),i("return",2))},e.exports.__esModule=!0,e.exports.default=e.exports,t(r,n,o,i)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}(g);var d=g.exports;!function(e){var t=d;function r(){
2
+ /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
3
+ var n,o,i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",u=i.toStringTag||"@@toStringTag";function c(e,r,i,a){var u=r&&r.prototype instanceof f?r:f,c=Object.create(u.prototype);return t(c,"_invoke",function(e,t,r){var i,a,u,c=0,f=r||[],p=!1,l={p:0,n:0,v:n,a:y,f:y.bind(n,4),d:function(e,t){return i=e,a=0,u=n,l.n=t,s}};function y(e,t){for(a=e,u=t,o=0;!p&&c&&!r&&o<f.length;o++){var r,i=f[o],y=l.p,h=i[2];e>3?(r=h===t)&&(u=i[(a=i[4])?5:(a=3,3)],i[4]=i[5]=n):i[0]<=y&&((r=e<2&&y<i[1])?(a=0,l.v=t,l.n=i[1]):y<h&&(r=e<3||i[0]>t||t>h)&&(i[4]=e,i[5]=t,l.n=h,a=0))}if(r||e>1)return s;throw p=!0,t}return function(r,f,h){if(c>1)throw TypeError("Generator is already running");for(p&&1===f&&y(f,h),a=f,u=h;(o=a<2?n:u)||!p;){i||(a?a<3?(a>1&&(l.n=-1),y(a,u)):l.n=u:l.v=u);try{if(c=2,i){if(a||(r="next"),o=i[r]){if(!(o=o.call(i,u)))throw TypeError("iterator result is not an object");if(!o.done)return o;u=o.value,a<2&&(a=0)}else 1===a&&(o=i.return)&&o.call(i),a<2&&(u=TypeError("The iterator does not provide a '"+r+"' method"),a=1);i=n}else if((o=(p=l.n<0)?u:e.call(t,l))!==s)break}catch(e){i=n,a=1,u=e}finally{c=1}}return{value:o,done:p}}}(e,i,a),!0),c}var s={};function f(){}function p(){}function l(){}o=Object.getPrototypeOf;var y=[][a]?o(o([][a]())):(t(o={},a,function(){return this}),o),h=l.prototype=f.prototype=Object.create(y);function v(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,t(e,u,"GeneratorFunction")),e.prototype=Object.create(h),e}return p.prototype=l,t(h,"constructor",l),t(l,"constructor",p),p.displayName="GeneratorFunction",t(l,u,"GeneratorFunction"),t(h),t(h,u,"Generator"),t(h,a,function(){return this}),t(h,"toString",function(){return"[object Generator]"}),(e.exports=r=function(){return{w:c,m:v}},e.exports.__esModule=!0,e.exports.default=e.exports)()}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports}(v);var m=v.exports,b={exports:{}},P={exports:{}},x={exports:{}};!function(e){var t=h,r=d;e.exports=function e(n,o){function i(e,r,a,u){try{var c=n[e](r),s=c.value;return s instanceof t?o.resolve(s.v).then(function(e){i("next",e,a,u)},function(e){i("throw",e,a,u)}):o.resolve(s).then(function(e){c.value=e,a(c)},function(e){return i("throw",e,a,u)})}catch(e){u(e)}}var a;this.next||(r(e.prototype),r(e.prototype,"function"==typeof Symbol&&Symbol.asyncIterator||"@asyncIterator",function(){return this})),r(this,"_invoke",function(e,t,r){function n(){return new o(function(t,n){i(e,r,t,n)})}return a=a?a.then(n,n):n()},!0)},e.exports.__esModule=!0,e.exports.default=e.exports}(x);var _=x.exports;!function(e){var t=m,r=_;e.exports=function(e,n,o,i,a){return new r(t().w(e,n,o,i),a||Promise)},e.exports.__esModule=!0,e.exports.default=e.exports}(P);var w=P.exports;!function(e){var t=w;e.exports=function(e,r,n,o,i){var a=t(e,r,n,o,i);return a.next().then(function(e){return e.done?e.value:a.next()})},e.exports.__esModule=!0,e.exports.default=e.exports}(b);var k=b.exports,T={exports:{}};!function(e){e.exports=function(e){var t=Object(e),r=[];for(var n in t)r.unshift(n);return function e(){for(;r.length;)if((n=r.pop())in t)return e.value=n,e.done=!1,e;return e.done=!0,e}},e.exports.__esModule=!0,e.exports.default=e.exports}(T);var O=T.exports,j={exports:{}},S={exports:{}};!function(e){function t(r){return e.exports=t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(r)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}(S);var C=S.exports;!function(e){var t=C.default;e.exports=function(e){if(null!=e){var r=e["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],n=0;if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length))return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}}throw new TypeError(t(e)+" is not iterable")},e.exports.__esModule=!0,e.exports.default=e.exports}(j);var I=j.exports;!function(e){var t=h,r=m,n=k,o=w,i=_,a=O,u=I;function c(){var s=r(),f=s.m(c),p=(Object.getPrototypeOf?Object.getPrototypeOf(f):f.__proto__).constructor;function l(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===p||"GeneratorFunction"===(t.displayName||t.name))}var y={throw:1,return:2,break:3,continue:3};function h(e){var t,r;return function(n){t||(t={stop:function(){return r(n.a,2)},catch:function(){return n.v},abrupt:function(e,t){return r(n.a,y[e],t)},delegateYield:function(e,o,i){return t.resultName=o,r(n.d,u(e),i)},finish:function(e){return r(n.f,e)}},r=function(e,r,o){n.p=t.prev,n.n=t.next;try{return e(r,o)}finally{t.next=n.n}}),t.resultName&&(t[t.resultName]=n.v,t.resultName=void 0),t.sent=n.v,t.next=n.n;try{return e.call(this,t)}finally{n.p=t.prev,n.n=t.next}}}return(e.exports=c=function(){return{wrap:function(e,t,r,n){return s.w(h(e),t,r,n&&n.reverse())},isGeneratorFunction:l,mark:s.m,awrap:function(e,r){return new t(e,r)},AsyncIterator:i,async:function(e,t,r,i,a){return(l(t)?o:n)(h(e),t,r,i,a)},keys:a,values:u}},e.exports.__esModule=!0,e.exports.default=e.exports)()}e.exports=c,e.exports.__esModule=!0,e.exports.default=e.exports}(l);var M=(0,l.exports)(),$=M;try{regeneratorRuntime=M}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=M:Function("r","regeneratorRuntime = r")(M)}var E=f($),U="",L="https://log.cdyrjygs.com/binlog";function D(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function N(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?D(Object(r),!0).forEach(function(t){s(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):D(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var A=function(){return c(function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};i(this,e),this.config={baseURL:t.baseURL||"",timeout:t.timeout||1e4,header:N({"Content-Type":"application/json"},t.header)}},[{key:"requestInterceptor",value:function(e){return e.url=this.config.baseURL+e.url,e.timeout=e.timeout||this.config.timeout,e.header=N(N({},this.config.header),e.header),e}},{key:"responseInterceptor",value:function(e){if(200===e.statusCode)return Promise.resolve(e);var t={code:e.statusCode,message:e.data.message||"请求失败"};return uni.showToast({title:t.message,icon:"none",duration:2e3}),Promise.reject(t)}},{key:"request",value:function(e){var t=this;return e=this.requestInterceptor(e),new Promise(function(r,n){uni.request(N(N({},e),{},{success:function(o){try{var i=t.responseInterceptor(o,e);r(i)}catch(e){n(e)}},fail:function(e){var t={code:e.errMsg?-1:-2,message:e.errMsg||"网络请求失败"};uni.showToast({title:t.message,icon:"none",duration:2e3}),n(t)}}))})}},{key:"get",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.request(N({url:e,data:t,method:"GET"},r))}},{key:"post",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.request(N({url:e,data:t,method:"POST"},r))}},{key:"put",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.request(N({url:e,data:t,method:"PUT"},r))}},{key:"delete",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.request(N({url:e,data:t,method:"DELETE"},r))}},{key:"setBaseURL",value:function(e){this.config.baseURL=e}},{key:"setHeader",value:function(e){this.config.header=N(N({},this.config.header),e)}}])}();new A;var R=new A({baseURL:U,timeout:1e4,header:{"Content-Type":"application/json"}});function B(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function F(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?B(Object(r),!0).forEach(function(t){s(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):B(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var q=function(){return c(function e(){i(this,e)},null,[{key:"init",value:(t=o(E.mark(function e(t){var r=this;return E.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,this._updateNetworkType();case 1:return this.launchTime=Date.now(),this.config=F(F({},this.config),t),e.next=2,this.getBaseInf();case 2:this.MiniProBaseInfo=e.sent,this.launchOptions=this.getLaunchOptionsSync(),this.cachedUserInfo=this.getUserInfo(),uni.onNetworkStatusChange(function(e){r.networkType=e.networkType||""}),this.report({name:"initEvent",action:"埋点初始化"});case 3:case"end":return e.stop()}},e,this)})),function(e){return t.apply(this,arguments)})},{key:"getPrimaryCategory",value:function(){return this.primaryCategory}},{key:"setPrimaryCategory",value:function(e,t){this._setCategory(e,t,"primaryCategory","一级栏目")}},{key:"getSecondaryCategory",value:function(){return this.secondaryCategory}},{key:"setSecondaryCategory",value:function(e,t){this._setCategory(e,t,"secondaryCategory","二级栏目")}},{key:"_setCategory",value:function(e,t,r,n){if(Array.isArray(e)&&0!==e.length)if("number"!=typeof t||t<0||t>=e.length)this[r]="";else{var o=e[t];o&&"string"==typeof o.title&&""!==o.title.trim()?this[r]=o.title:this[r]=""}else this[r]=""}},{key:"resetCategory",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"secondary",t=arguments.length>1?arguments[1]:void 0;if(["primary","secondary","both"].includes(e))if(void 0!==t){if("both"===e){if("string"!=typeof t&&("object"!==r(t)||null===t))return;if("object"===r(t)){if(void 0!==t.primary&&"string"!=typeof t.primary)return;if(void 0!==t.secondary&&"string"!=typeof t.secondary)return}}else if("string"!=typeof t)return;switch(e){case"primary":this.primaryCategory=t;break;case"secondary":this.secondaryCategory=t;break;case"both":if("object"===r(t)&&null!==t){var n=void 0!==t.primary?t.primary:"",o=void 0!==t.secondary?t.secondary:"";this.primaryCategory=n,this.secondaryCategory=o}else this.primaryCategory=t,this.secondaryCategory=t}}else switch(e){case"primary":this.primaryCategory="";break;case"secondary":this.secondaryCategory="";break;case"both":this.primaryCategory="",this.secondaryCategory=""}}},{key:"_updateNetworkType",value:function(){var e=this;return new Promise(function(t){uni.getNetworkType({success:function(r){e.networkType=r.networkType||"",t()},fail:function(r){e.networkType="",t()}})})}},{key:"getBaseInf",value:(e=o(E.mark(function e(){var t,n,o,i,a,u,c;return E.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,o=null===(t=this.storageDataFromMiniPro)||void 0===t||null===(t=t.systemInfo)||void 0===t?void 0:t.data){e.next=2;break}if(i="track_system_info","object"===("undefined"==typeof uni?"undefined":r(uni))&&null!==uni&&"function"==typeof uni.getStorageSync&&(o=uni.getStorageSync(i)),o||"object"!==("undefined"==typeof uni?"undefined":r(uni))||null===uni||"function"!=typeof uni.getSystemInfo){e.next=2;break}return e.next=1,uni.getSystemInfo();case 1:a=e.sent,o={system:a.system||"",uniPlatform:a.uniPlatform||"",deviceBrand:a.deviceBrand||"",deviceType:a.deviceType||""},"function"==typeof uni.setStorageSync&&uni.setStorageSync(i,o);case 2:return u=this._getMiniProgramInfo(null===(n=o)||void 0===n?void 0:n.uniPlatform),c=F(F({},o),u),e.abrupt("return",c);case 3:return e.prev=3,e.catch(0),e.abrupt("return",{system:"",uniPlatform:"",deviceBrand:"",platform:"",appId:""});case 4:case"end":return e.stop()}},e,this,[[0,3]])})),function(){return e.apply(this,arguments)})},{key:"_getMiniProgramInfo",value:function(e){var t="",r="",n="";try{if("mp-weixin"===e){var o,i,a,u=wx.getAccountInfoSync();t=(null===(o=u.miniProgram)||void 0===o?void 0:o.appId)||"",r=(null===(i=u.miniProgram)||void 0===i?void 0:i.version)||"",n=(null===(a=u.miniProgram)||void 0===a?void 0:a.envVersion)||""}else if("mp-douyin"===e){var c,s,f,p=tt.getEnvInfoSync();t=(null===(c=p.microapp)||void 0===c?void 0:c.appId)||"",r=(null===(s=p.microapp)||void 0===s?void 0:s.mpVersion)||"",n=(null===(f=p.microapp)||void 0===f?void 0:f.envType)||""}}catch(e){}return{appId:t,version:r,envVersion:n}}},{key:"getUserInfo",value:function(){try{var e,t=null===(e=this.storageDataFromMiniPro)||void 0===e||null===(e=e.userInfoDeatil)||void 0===e?void 0:e.data;return t?{userId:t.id||"",userPhone:t.mobile||""}:{userId:"",userPhone:""}}catch(e){return{userId:"",userPhone:""}}}},{key:"setUserInfo",value:function(e){if(e&&e.userId)try{this.cachedUserInfo={userId:e.userId||"",userPhone:e.userPhone||""}}catch(e){}}},{key:"clearUserInfo",value:function(){try{this.cachedUserInfo={}}catch(e){}}},{key:"enable",value:function(){this.config.enabled=!0}},{key:"disable",value:function(){this.config.enabled=!1}},{key:"getLaunchOptionsSync",value:function(){try{if("object"===("undefined"==typeof uni?"undefined":r(uni))&&null!==uni&&"function"==typeof uni.getLaunchOptionsSync){var e=uni.getLaunchOptionsSync()||{},t=e.path,n=e.scene,o=e.query;return{launchPath:t,launchScene:n,launchParams:JSON.stringify(o),subChannel:o.subChannel||""}}return{}}catch(e){return{}}}},{key:"submitTrackLog",value:function(e){var t,r;(t=this.config.reportUrl,r=e,R.post(t,r,{loading:!1})).then(function(e){e&&e.statusCode}).catch(function(e){})}},{key:"report",value:function(e){var t=F(F(F(F({launchTime:this.launchTime,currentTime:Date.now()},this.launchOptions),this.MiniProBaseInfo),this.cachedUserInfo),{},{networkType:this.networkType},e);this.submitTrackLog(t)}},{key:"customReport",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"clickEvent",n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];if(this.config.enabled&&e&&r){var o={action:e,name:r};if(n){var i=F(F({},this.primaryCategory&&{primaryCategory:this.primaryCategory}),this.secondaryCategory&&{secondaryCategory:this.secondaryCategory});Object.assign(o,i)}t&&Object.keys(t).length>0&&(o.data=JSON.stringify(t)),this.report(o)}}}]);var e,t}();s(q,"config",{reportUrl:L,enabled:!0}),s(q,"storageDataFromMiniPro",function(){try{return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{return e&&"string"==typeof e?JSON.parse(e):t}catch(e){return t}}(uni.getStorageSync("storageName"),{})}catch(e){return{}}}()),s(q,"launchTime",null),s(q,"cachedNetworkType",""),s(q,"MiniProBaseInfo",{}),s(q,"networkType",""),s(q,"launchOptions",{}),s(q,"primaryCategory",""),s(q,"secondaryCategory","");var G={onLoad:function(e){var t=function(){var e=[];try{if("harmonyos"===process.env.UNI_PLATFORM){var t=uni.getAppPageManager();t&&"function"==typeof t.getPages&&(e=t.getPages()||[])}else"object"===("undefined"==typeof uni?"undefined":r(uni))&&null!==uni&&"function"==typeof uni.getCurrentPages&&(e=uni.getCurrentPages()||[])}catch(e){}return e}(),n=function(e,t){var n="";return e&&(e.route?n=e.route:e.__route__?n=e.__route__:e.path?n=e.path:t&&"object"===r(t)&&null!==t&&(t.route?n=t.route:t.__route__?n=t.__route__:t.path&&(n=t.path))),n}(t[t.length-1]||{},this.$scope);q.currentPagePath=n||"";var o={trackType:"pageview",viewPagePath:n||"",viewPageLoadTime:Date.now(),viewPageParams:e||{}};this.$pageTrackCache=o},onUnload:function(){this._reportPageTrack("unload")},onHide:function(){this._reportPageTrack("hide")},onShow:function(){this.$pageTrackCache&&(this.$pageTrackCache.lastShowTime=Date.now()),this.$pageTrackCache&&this.$pageTrackCache.viewPagePath&&(q.currentPagePath=this.$pageTrackCache.viewPagePath)},methods:{_reportPageTrack:function(e){if(this.$pageTrackCache){var t=this.$pageTrackCache.lastShowTime||this.$pageTrackCache.viewPageLoadTime,r=Date.now()-t,n={viewPagePath:this.$pageTrackCache.viewPagePath||"",viewPageLoadTime:this.$pageTrackCache.viewPageLoadTime||Date.now(),viewPageParams:this.$pageTrackCache.viewPageParams||{},stayTime:r};q.customReport("页面曝光",n,"pageviewEvent",!1),"hide"===e&&(this.$pageTrackCache=null)}}}},J=!1;function V(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!J&&(J=!0,q.init(n),e.config.globalProperties.$Track=q,e.mixin(G),uni.$Track=q,"object"===("undefined"==typeof uni?"undefined":r(uni))&&null!==uni)){["navigateTo","redirectTo","reLaunch","switchTab","navigateBack"].forEach(function(e){if("function"==typeof uni[e]){var n=uni[e];uni[e]=function(o){try{var i="";if(q.currentPagePath&&(i=q.currentPagePath),!i&&"function"==typeof uni.getCurrentPages){var a=uni.getCurrentPages()||[],u=a[a.length-1]||{};i=u.route||u.__route__||u.path||""}if(!i&&"function"==typeof getApp)try{var c=getApp();if(c&&c._pages&&c._pages.length>0){var s=c._pages[c._pages.length-1]||{};i=s.route||s.__route__||s.path||""}else if(c&&c.$vm&&c.$vm.$page){var f=c.$vm.$page;i=f.route||f.__route__||f.path||""}}catch(e){}if(!i)try{if(uni.$app&&uni.$app._pages&&uni.$app._pages.length>0){var p=uni.$app._pages[uni.$app._pages.length-1]||{};i=p.route||p.__route__||p.path||""}}catch(e){}var l="",y={};if("navigateBack"===e)l="back",y={delta:o||1};else if("object"===r(o)&&null!==o){if((l=o.url||"").includes("?")){var h=t(l.split("?"),2),v=h[0],g=h[1];l=v,y=g.split("&").reduce(function(e,r){var n=t(r.split("="),2),o=n[0],i=n[1];return o&&(e[o]=decodeURIComponent(i||"")),e},{})}Object.keys(o).forEach(function(e){"url"!==e&&"success"!==e&&"fail"!==e&&"complete"!==e&&(y[e]=o[e])})}var d={currentPagePath:i||"",targetPagePath:l||"",navigationParams:y||{}};q.customReport("页面跳转",d,"navigationEvent",!1)}catch(e){}return n.call(uni,o)}}})}}var H={install:V,Track:q,trackPageMixin:G};exports.Track=q,exports.default=H,exports.install=V,exports.trackPageMixin=G;
@@ -0,0 +1,3 @@
1
+ function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function t(t,r){return function(e){if(Array.isArray(e))return e}(t)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,a,u=[],c=!0,s=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(u.push(n.value),u.length!==t);c=!0);}catch(e){s=!0,o=e}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return u}}(t,r)||function(t,r){if(t){if("string"==typeof t)return e(t,r);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?e(t,r):void 0}}(t,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function n(e,t,r,n,o,i,a){try{var u=e[i](a),c=u.value}catch(e){return void r(e)}u.done?t(c):Promise.resolve(c).then(n,o)}function o(e){return function(){var t=this,r=arguments;return new Promise(function(o,i){var a=e.apply(t,r);function u(e){n(a,o,i,u,c,"next",e)}function c(e){n(a,o,i,u,c,"throw",e)}u(void 0)})}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e){var t=function(e,t){if("object"!=r(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,t||"default");if("object"!=r(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==r(t)?t:t+""}function u(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,a(n.key),n)}}function c(e,t,r){return t&&u(e.prototype,t),r&&u(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function s(e,t,r){return(t=a(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function f(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var p,l={exports:{}},y={exports:{}};(p=y).exports=function(e,t){this.v=e,this.k=t},p.exports.__esModule=!0,p.exports.default=p.exports;var h=y.exports,v={exports:{}},g={exports:{}};!function(e){function t(r,n,o,i){var a=Object.defineProperty;try{a({},"",{})}catch(r){a=0}e.exports=t=function(e,r,n,o){function i(r,n){t(e,r,function(e){return this._invoke(r,n,e)})}r?a?a(e,r,{value:n,enumerable:!o,configurable:!o,writable:!o}):e[r]=n:(i("next",0),i("throw",1),i("return",2))},e.exports.__esModule=!0,e.exports.default=e.exports,t(r,n,o,i)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}(g);var d=g.exports;!function(e){var t=d;function r(){
2
+ /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
3
+ var n,o,i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",u=i.toStringTag||"@@toStringTag";function c(e,r,i,a){var u=r&&r.prototype instanceof f?r:f,c=Object.create(u.prototype);return t(c,"_invoke",function(e,t,r){var i,a,u,c=0,f=r||[],p=!1,l={p:0,n:0,v:n,a:y,f:y.bind(n,4),d:function(e,t){return i=e,a=0,u=n,l.n=t,s}};function y(e,t){for(a=e,u=t,o=0;!p&&c&&!r&&o<f.length;o++){var r,i=f[o],y=l.p,h=i[2];e>3?(r=h===t)&&(u=i[(a=i[4])?5:(a=3,3)],i[4]=i[5]=n):i[0]<=y&&((r=e<2&&y<i[1])?(a=0,l.v=t,l.n=i[1]):y<h&&(r=e<3||i[0]>t||t>h)&&(i[4]=e,i[5]=t,l.n=h,a=0))}if(r||e>1)return s;throw p=!0,t}return function(r,f,h){if(c>1)throw TypeError("Generator is already running");for(p&&1===f&&y(f,h),a=f,u=h;(o=a<2?n:u)||!p;){i||(a?a<3?(a>1&&(l.n=-1),y(a,u)):l.n=u:l.v=u);try{if(c=2,i){if(a||(r="next"),o=i[r]){if(!(o=o.call(i,u)))throw TypeError("iterator result is not an object");if(!o.done)return o;u=o.value,a<2&&(a=0)}else 1===a&&(o=i.return)&&o.call(i),a<2&&(u=TypeError("The iterator does not provide a '"+r+"' method"),a=1);i=n}else if((o=(p=l.n<0)?u:e.call(t,l))!==s)break}catch(e){i=n,a=1,u=e}finally{c=1}}return{value:o,done:p}}}(e,i,a),!0),c}var s={};function f(){}function p(){}function l(){}o=Object.getPrototypeOf;var y=[][a]?o(o([][a]())):(t(o={},a,function(){return this}),o),h=l.prototype=f.prototype=Object.create(y);function v(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,t(e,u,"GeneratorFunction")),e.prototype=Object.create(h),e}return p.prototype=l,t(h,"constructor",l),t(l,"constructor",p),p.displayName="GeneratorFunction",t(l,u,"GeneratorFunction"),t(h),t(h,u,"Generator"),t(h,a,function(){return this}),t(h,"toString",function(){return"[object Generator]"}),(e.exports=r=function(){return{w:c,m:v}},e.exports.__esModule=!0,e.exports.default=e.exports)()}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports}(v);var m=v.exports,b={exports:{}},P={exports:{}},x={exports:{}};!function(e){var t=h,r=d;e.exports=function e(n,o){function i(e,r,a,u){try{var c=n[e](r),s=c.value;return s instanceof t?o.resolve(s.v).then(function(e){i("next",e,a,u)},function(e){i("throw",e,a,u)}):o.resolve(s).then(function(e){c.value=e,a(c)},function(e){return i("throw",e,a,u)})}catch(e){u(e)}}var a;this.next||(r(e.prototype),r(e.prototype,"function"==typeof Symbol&&Symbol.asyncIterator||"@asyncIterator",function(){return this})),r(this,"_invoke",function(e,t,r){function n(){return new o(function(t,n){i(e,r,t,n)})}return a=a?a.then(n,n):n()},!0)},e.exports.__esModule=!0,e.exports.default=e.exports}(x);var w=x.exports;!function(e){var t=m,r=w;e.exports=function(e,n,o,i,a){return new r(t().w(e,n,o,i),a||Promise)},e.exports.__esModule=!0,e.exports.default=e.exports}(P);var _=P.exports;!function(e){var t=_;e.exports=function(e,r,n,o,i){var a=t(e,r,n,o,i);return a.next().then(function(e){return e.done?e.value:a.next()})},e.exports.__esModule=!0,e.exports.default=e.exports}(b);var k=b.exports,T={exports:{}};!function(e){e.exports=function(e){var t=Object(e),r=[];for(var n in t)r.unshift(n);return function e(){for(;r.length;)if((n=r.pop())in t)return e.value=n,e.done=!1,e;return e.done=!0,e}},e.exports.__esModule=!0,e.exports.default=e.exports}(T);var O=T.exports,j={exports:{}},S={exports:{}};!function(e){function t(r){return e.exports=t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(r)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}(S);var C=S.exports;!function(e){var t=C.default;e.exports=function(e){if(null!=e){var r=e["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],n=0;if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length))return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}}throw new TypeError(t(e)+" is not iterable")},e.exports.__esModule=!0,e.exports.default=e.exports}(j);var I=j.exports;!function(e){var t=h,r=m,n=k,o=_,i=w,a=O,u=I;function c(){var s=r(),f=s.m(c),p=(Object.getPrototypeOf?Object.getPrototypeOf(f):f.__proto__).constructor;function l(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===p||"GeneratorFunction"===(t.displayName||t.name))}var y={throw:1,return:2,break:3,continue:3};function h(e){var t,r;return function(n){t||(t={stop:function(){return r(n.a,2)},catch:function(){return n.v},abrupt:function(e,t){return r(n.a,y[e],t)},delegateYield:function(e,o,i){return t.resultName=o,r(n.d,u(e),i)},finish:function(e){return r(n.f,e)}},r=function(e,r,o){n.p=t.prev,n.n=t.next;try{return e(r,o)}finally{t.next=n.n}}),t.resultName&&(t[t.resultName]=n.v,t.resultName=void 0),t.sent=n.v,t.next=n.n;try{return e.call(this,t)}finally{n.p=t.prev,n.n=t.next}}}return(e.exports=c=function(){return{wrap:function(e,t,r,n){return s.w(h(e),t,r,n&&n.reverse())},isGeneratorFunction:l,mark:s.m,awrap:function(e,r){return new t(e,r)},AsyncIterator:i,async:function(e,t,r,i,a){return(l(t)?o:n)(h(e),t,r,i,a)},keys:a,values:u}},e.exports.__esModule=!0,e.exports.default=e.exports)()}e.exports=c,e.exports.__esModule=!0,e.exports.default=e.exports}(l);var M=(0,l.exports)(),$=M;try{regeneratorRuntime=M}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=M:Function("r","regeneratorRuntime = r")(M)}var E=f($),U="",L="https://log.cdyrjygs.com/binlog";function D(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function N(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?D(Object(r),!0).forEach(function(t){s(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):D(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var A=function(){return c(function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};i(this,e),this.config={baseURL:t.baseURL||"",timeout:t.timeout||1e4,header:N({"Content-Type":"application/json"},t.header)}},[{key:"requestInterceptor",value:function(e){return e.url=this.config.baseURL+e.url,e.timeout=e.timeout||this.config.timeout,e.header=N(N({},this.config.header),e.header),e}},{key:"responseInterceptor",value:function(e){if(200===e.statusCode)return Promise.resolve(e);var t={code:e.statusCode,message:e.data.message||"请求失败"};return uni.showToast({title:t.message,icon:"none",duration:2e3}),Promise.reject(t)}},{key:"request",value:function(e){var t=this;return e=this.requestInterceptor(e),new Promise(function(r,n){uni.request(N(N({},e),{},{success:function(o){try{var i=t.responseInterceptor(o,e);r(i)}catch(e){n(e)}},fail:function(e){var t={code:e.errMsg?-1:-2,message:e.errMsg||"网络请求失败"};uni.showToast({title:t.message,icon:"none",duration:2e3}),n(t)}}))})}},{key:"get",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.request(N({url:e,data:t,method:"GET"},r))}},{key:"post",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.request(N({url:e,data:t,method:"POST"},r))}},{key:"put",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.request(N({url:e,data:t,method:"PUT"},r))}},{key:"delete",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.request(N({url:e,data:t,method:"DELETE"},r))}},{key:"setBaseURL",value:function(e){this.config.baseURL=e}},{key:"setHeader",value:function(e){this.config.header=N(N({},this.config.header),e)}}])}();new A;var R=new A({baseURL:U,timeout:1e4,header:{"Content-Type":"application/json"}});function B(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function F(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?B(Object(r),!0).forEach(function(t){s(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):B(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var q=function(){return c(function e(){i(this,e)},null,[{key:"init",value:(t=o(E.mark(function e(t){var r=this;return E.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,this._updateNetworkType();case 1:return this.launchTime=Date.now(),this.config=F(F({},this.config),t),e.next=2,this.getBaseInf();case 2:this.MiniProBaseInfo=e.sent,this.launchOptions=this.getLaunchOptionsSync(),this.cachedUserInfo=this.getUserInfo(),uni.onNetworkStatusChange(function(e){r.networkType=e.networkType||""}),this.report({name:"initEvent",action:"埋点初始化"});case 3:case"end":return e.stop()}},e,this)})),function(e){return t.apply(this,arguments)})},{key:"getPrimaryCategory",value:function(){return this.primaryCategory}},{key:"setPrimaryCategory",value:function(e,t){this._setCategory(e,t,"primaryCategory","一级栏目")}},{key:"getSecondaryCategory",value:function(){return this.secondaryCategory}},{key:"setSecondaryCategory",value:function(e,t){this._setCategory(e,t,"secondaryCategory","二级栏目")}},{key:"_setCategory",value:function(e,t,r,n){if(Array.isArray(e)&&0!==e.length)if("number"!=typeof t||t<0||t>=e.length)this[r]="";else{var o=e[t];o&&"string"==typeof o.title&&""!==o.title.trim()?this[r]=o.title:this[r]=""}else this[r]=""}},{key:"resetCategory",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"secondary",t=arguments.length>1?arguments[1]:void 0;if(["primary","secondary","both"].includes(e))if(void 0!==t){if("both"===e){if("string"!=typeof t&&("object"!==r(t)||null===t))return;if("object"===r(t)){if(void 0!==t.primary&&"string"!=typeof t.primary)return;if(void 0!==t.secondary&&"string"!=typeof t.secondary)return}}else if("string"!=typeof t)return;switch(e){case"primary":this.primaryCategory=t;break;case"secondary":this.secondaryCategory=t;break;case"both":if("object"===r(t)&&null!==t){var n=void 0!==t.primary?t.primary:"",o=void 0!==t.secondary?t.secondary:"";this.primaryCategory=n,this.secondaryCategory=o}else this.primaryCategory=t,this.secondaryCategory=t}}else switch(e){case"primary":this.primaryCategory="";break;case"secondary":this.secondaryCategory="";break;case"both":this.primaryCategory="",this.secondaryCategory=""}}},{key:"_updateNetworkType",value:function(){var e=this;return new Promise(function(t){uni.getNetworkType({success:function(r){e.networkType=r.networkType||"",t()},fail:function(r){e.networkType="",t()}})})}},{key:"getBaseInf",value:(e=o(E.mark(function e(){var t,n,o,i,a,u,c;return E.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,o=null===(t=this.storageDataFromMiniPro)||void 0===t||null===(t=t.systemInfo)||void 0===t?void 0:t.data){e.next=2;break}if(i="track_system_info","object"===("undefined"==typeof uni?"undefined":r(uni))&&null!==uni&&"function"==typeof uni.getStorageSync&&(o=uni.getStorageSync(i)),o||"object"!==("undefined"==typeof uni?"undefined":r(uni))||null===uni||"function"!=typeof uni.getSystemInfo){e.next=2;break}return e.next=1,uni.getSystemInfo();case 1:a=e.sent,o={system:a.system||"",uniPlatform:a.uniPlatform||"",deviceBrand:a.deviceBrand||"",deviceType:a.deviceType||""},"function"==typeof uni.setStorageSync&&uni.setStorageSync(i,o);case 2:return u=this._getMiniProgramInfo(null===(n=o)||void 0===n?void 0:n.uniPlatform),c=F(F({},o),u),e.abrupt("return",c);case 3:return e.prev=3,e.catch(0),e.abrupt("return",{system:"",uniPlatform:"",deviceBrand:"",platform:"",appId:""});case 4:case"end":return e.stop()}},e,this,[[0,3]])})),function(){return e.apply(this,arguments)})},{key:"_getMiniProgramInfo",value:function(e){var t="",r="",n="";try{if("mp-weixin"===e){var o,i,a,u=wx.getAccountInfoSync();t=(null===(o=u.miniProgram)||void 0===o?void 0:o.appId)||"",r=(null===(i=u.miniProgram)||void 0===i?void 0:i.version)||"",n=(null===(a=u.miniProgram)||void 0===a?void 0:a.envVersion)||""}else if("mp-douyin"===e){var c,s,f,p=tt.getEnvInfoSync();t=(null===(c=p.microapp)||void 0===c?void 0:c.appId)||"",r=(null===(s=p.microapp)||void 0===s?void 0:s.mpVersion)||"",n=(null===(f=p.microapp)||void 0===f?void 0:f.envType)||""}}catch(e){}return{appId:t,version:r,envVersion:n}}},{key:"getUserInfo",value:function(){try{var e,t=null===(e=this.storageDataFromMiniPro)||void 0===e||null===(e=e.userInfoDeatil)||void 0===e?void 0:e.data;return t?{userId:t.id||"",userPhone:t.mobile||""}:{userId:"",userPhone:""}}catch(e){return{userId:"",userPhone:""}}}},{key:"setUserInfo",value:function(e){if(e&&e.userId)try{this.cachedUserInfo={userId:e.userId||"",userPhone:e.userPhone||""}}catch(e){}}},{key:"clearUserInfo",value:function(){try{this.cachedUserInfo={}}catch(e){}}},{key:"enable",value:function(){this.config.enabled=!0}},{key:"disable",value:function(){this.config.enabled=!1}},{key:"getLaunchOptionsSync",value:function(){try{if("object"===("undefined"==typeof uni?"undefined":r(uni))&&null!==uni&&"function"==typeof uni.getLaunchOptionsSync){var e=uni.getLaunchOptionsSync()||{},t=e.path,n=e.scene,o=e.query;return{launchPath:t,launchScene:n,launchParams:JSON.stringify(o),subChannel:o.subChannel||""}}return{}}catch(e){return{}}}},{key:"submitTrackLog",value:function(e){var t,r;(t=this.config.reportUrl,r=e,R.post(t,r,{loading:!1})).then(function(e){e&&e.statusCode}).catch(function(e){})}},{key:"report",value:function(e){var t=F(F(F(F({launchTime:this.launchTime,currentTime:Date.now()},this.launchOptions),this.MiniProBaseInfo),this.cachedUserInfo),{},{networkType:this.networkType},e);this.submitTrackLog(t)}},{key:"customReport",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"clickEvent",n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];if(this.config.enabled&&e&&r){var o={action:e,name:r};if(n){var i=F(F({},this.primaryCategory&&{primaryCategory:this.primaryCategory}),this.secondaryCategory&&{secondaryCategory:this.secondaryCategory});Object.assign(o,i)}t&&Object.keys(t).length>0&&(o.data=JSON.stringify(t)),this.report(o)}}}]);var e,t}();s(q,"config",{reportUrl:L,enabled:!0}),s(q,"storageDataFromMiniPro",function(){try{return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{return e&&"string"==typeof e?JSON.parse(e):t}catch(e){return t}}(uni.getStorageSync("storageName"),{})}catch(e){return{}}}()),s(q,"launchTime",null),s(q,"cachedNetworkType",""),s(q,"MiniProBaseInfo",{}),s(q,"networkType",""),s(q,"launchOptions",{}),s(q,"primaryCategory",""),s(q,"secondaryCategory","");var G={onLoad:function(e){var t=function(){var e=[];try{if("harmonyos"===process.env.UNI_PLATFORM){var t=uni.getAppPageManager();t&&"function"==typeof t.getPages&&(e=t.getPages()||[])}else"object"===("undefined"==typeof uni?"undefined":r(uni))&&null!==uni&&"function"==typeof uni.getCurrentPages&&(e=uni.getCurrentPages()||[])}catch(e){}return e}(),n=function(e,t){var n="";return e&&(e.route?n=e.route:e.__route__?n=e.__route__:e.path?n=e.path:t&&"object"===r(t)&&null!==t&&(t.route?n=t.route:t.__route__?n=t.__route__:t.path&&(n=t.path))),n}(t[t.length-1]||{},this.$scope);q.currentPagePath=n||"";var o={trackType:"pageview",viewPagePath:n||"",viewPageLoadTime:Date.now(),viewPageParams:e||{}};this.$pageTrackCache=o},onUnload:function(){this._reportPageTrack("unload")},onHide:function(){this._reportPageTrack("hide")},onShow:function(){this.$pageTrackCache&&(this.$pageTrackCache.lastShowTime=Date.now()),this.$pageTrackCache&&this.$pageTrackCache.viewPagePath&&(q.currentPagePath=this.$pageTrackCache.viewPagePath)},methods:{_reportPageTrack:function(e){if(this.$pageTrackCache){var t=this.$pageTrackCache.lastShowTime||this.$pageTrackCache.viewPageLoadTime,r=Date.now()-t,n={viewPagePath:this.$pageTrackCache.viewPagePath||"",viewPageLoadTime:this.$pageTrackCache.viewPageLoadTime||Date.now(),viewPageParams:this.$pageTrackCache.viewPageParams||{},stayTime:r};q.customReport("页面曝光",n,"pageviewEvent",!1),"hide"===e&&(this.$pageTrackCache=null)}}}},J=!1;function V(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!J&&(J=!0,q.init(n),e.config.globalProperties.$Track=q,e.mixin(G),uni.$Track=q,"object"===("undefined"==typeof uni?"undefined":r(uni))&&null!==uni)){["navigateTo","redirectTo","reLaunch","switchTab","navigateBack"].forEach(function(e){if("function"==typeof uni[e]){var n=uni[e];uni[e]=function(o){try{var i="";if(q.currentPagePath&&(i=q.currentPagePath),!i&&"function"==typeof uni.getCurrentPages){var a=uni.getCurrentPages()||[],u=a[a.length-1]||{};i=u.route||u.__route__||u.path||""}if(!i&&"function"==typeof getApp)try{var c=getApp();if(c&&c._pages&&c._pages.length>0){var s=c._pages[c._pages.length-1]||{};i=s.route||s.__route__||s.path||""}else if(c&&c.$vm&&c.$vm.$page){var f=c.$vm.$page;i=f.route||f.__route__||f.path||""}}catch(e){}if(!i)try{if(uni.$app&&uni.$app._pages&&uni.$app._pages.length>0){var p=uni.$app._pages[uni.$app._pages.length-1]||{};i=p.route||p.__route__||p.path||""}}catch(e){}var l="",y={};if("navigateBack"===e)l="back",y={delta:o||1};else if("object"===r(o)&&null!==o){if((l=o.url||"").includes("?")){var h=t(l.split("?"),2),v=h[0],g=h[1];l=v,y=g.split("&").reduce(function(e,r){var n=t(r.split("="),2),o=n[0],i=n[1];return o&&(e[o]=decodeURIComponent(i||"")),e},{})}Object.keys(o).forEach(function(e){"url"!==e&&"success"!==e&&"fail"!==e&&"complete"!==e&&(y[e]=o[e])})}var d={currentPagePath:i||"",targetPagePath:l||"",navigationParams:y||{}};q.customReport("页面跳转",d,"navigationEvent",!1)}catch(e){}return n.call(uni,o)}}})}}var H={install:V,Track:q,trackPageMixin:G};export{q as Track,H as default,V as install,G as trackPageMixin};
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "yrjy_mini_sdk",
3
+ "version": "1.0.0",
4
+ "type": "module",
5
+ "main": "dist/index.cjs.js",
6
+ "module": "dist/index.esm.js",
7
+ "scripts": {
8
+ "test": "echo \"Error: no test specified\" && exit 1",
9
+ "dev": "cross-env NODE_ENV=development rollup -c -w",
10
+ "build": "cross-env NODE_ENV=production rollup -c",
11
+ "release": "npm version patch && npm run build && npm publish"
12
+ },
13
+ "keywords": [
14
+ "mini-program",
15
+ "tracking",
16
+ "sdk",
17
+ "wechat",
18
+ "douyin",
19
+ "uniapp"
20
+ ],
21
+ "author": "",
22
+ "license": "ISC",
23
+ "description": "小程序埋点,兼容微信、抖音小程序",
24
+ "devDependencies": {
25
+ "@babel/core": "^7.20.0",
26
+ "@babel/plugin-transform-runtime": "^7.29.0",
27
+ "@babel/preset-env": "^7.20.0",
28
+ "@rollup/plugin-babel": "^6.0.0",
29
+ "@rollup/plugin-commonjs": "^25.0.0",
30
+ "@rollup/plugin-json": "^6.1.0",
31
+ "@rollup/plugin-node-resolve": "^15.0.0",
32
+ "@rollup/plugin-terser": "^0.4.0",
33
+ "cross-env": "^7.0.3",
34
+ "rollup": "^3.0.0"
35
+ },
36
+ "dependencies": {
37
+ "@babel/runtime": "^7.20.0"
38
+ }
39
+ }
@@ -0,0 +1,38 @@
1
+ import babel from '@rollup/plugin-babel';
2
+ import resolve from '@rollup/plugin-node-resolve';
3
+ import commonjs from '@rollup/plugin-commonjs';
4
+ import terser from '@rollup/plugin-terser';
5
+ import json from '@rollup/plugin-json';
6
+
7
+ const isProduction = process.env.NODE_ENV === 'production';
8
+
9
+ export default {
10
+ input: 'src/index.js',
11
+ output: [
12
+ {
13
+ file: 'dist/index.cjs.js',
14
+ format: 'cjs',
15
+ sourcemap: !isProduction
16
+ },
17
+ {
18
+ file: 'dist/index.esm.js',
19
+ format: 'es',
20
+ sourcemap: !isProduction
21
+ }
22
+ ],
23
+ plugins: [
24
+ json(),
25
+ resolve(),
26
+ commonjs(),
27
+ babel({
28
+ exclude: 'node_modules/**',
29
+ babelHelpers: 'runtime'
30
+ }),
31
+ isProduction && terser({
32
+ compress: {
33
+ drop_console: true, // 移除console(生产环境)
34
+ drop_debugger: true // 移除debugger
35
+ }
36
+ })
37
+ ].filter(Boolean)
38
+ };