aqa-report-sdk
v0.1.17
Published
快应用打点sdk
Downloads
60
Readme
小爱快应用打点sdk:
使用方法:
- 安装依赖:
npm install --save aqa-report-sdk
- 引用reportConnect
reportConnect的参数是:import { reportConnect } from 'aqa-report-sdk' const appComponent = showMenu: util.showMenu, createShortcut: util.createShortcut } export default reportConnect.call(this, {appComponent, { type: 'app' })
- 1.app或页面script脚本实例
- 默认配置:{
isImmediately
是否实时上传,默认为true,当传入为false时,在组件销毁时上传所有打点type
实例类型,可以传入app
或者page
,默认是page
,只有在type===app
会上传apponCreate
生命周期的耗时,type===page
会上传页面onInit onReady, onShow
生命周期的耗时。 debug 是否打印日志,默认为true }
- 引用customReport 自定义打点
参数:customReport({ reportKey: 'pageOnProgress1', timestamp: new Date().getTime(), isImmediately: false })
- reportKey为必传参数,可以为
pageOnProgress1
,pageOnProgress2
,pageOnProgress3
,即用户自定义时间节点 - timestamp为必传参数,即当前时间戳
- reportKey为必传参数,可以为
注意:
- 当在真实的环境上传数据时,请设置
环境变量和常量``NODE_ENV
为production
。步骤为- 在根目录创建
config
文件夹 config
目录下面创建webpack.config.js
中写入如下代码
const webpack = require('webpack') function postHook (webpackConf, defaults, options) { webpackConf.plugins.push( // 定义环境变量 new webpack.DefinePlugin({ // 增加环境变量 NODE_ENV: JSON.stringify(process.env.NODE_ENV), }) ) } module.exports = { postHook }
- 安装cross-env
- 在package.json写入
"release": "cross-env NODE_ENV=production hap release", "watch": "cross-env NODE_ENV=preview hap watch"
- 在根目录创建