小程序埋点通用方案,支持加载、点击、自定义事件
var erwan_stat = require('./utils/stat'); // 接入自定义
erwan_stat.init('qiniu','miniprogram','test');
wx.erwan_stat = erwan_stat;
wx.erwan_stat.setOpenId('openId'); // 设置openId
wx.erwan_stat.customEvent('CourseDetailShow',{id: '435477844051649289',title: '微课堂微课堂'}); //自定义事件上报
wx.erwan_stat.init(project:string,sub_project:string,env:str,miniAppId:string) 初始化sdk
- project: 必传 品牌
- sub_project: 必传 子业务线
- env: 必传 环境变量 test:测试环境 prod:生产环境 默认生产
- miniAppId: 非必传,小程序appid
erwan_stat.init('qiniu','miniprogram','test','wxf97ce6e6de85aede');
wx.erwan_stat.setOpenId(openId:string) 设置openId
wx.erwan_stat.setOpenId('openid');
wx.erwan_stat.setUnionId(unionId:string) 设置unionId
wx.erwan_stat.setUnionId('unionId');
wx.erwan_stat.setMiniAppId(miniAppId:string) 设置小程序appId
wx.erwan_stat.setMiniAppId('miniAppId');
wx.erwan_stat.setUserId(userId:string) 设置userId
wx.erwan_stat.setUserId('userId');
wx.erwan_stat.setAbPropsData(ab_props:[object:{[string]:[number|stringt]}) 存储ab测相关标识数据
wx.erwan_stat.setAbPropsData({test_id:"1",area_id:"2",record_id:"3"});
wx.erwan_stat.removeAbPropsData() 清除ab测相关标识数据
wx.erwan_stat.removeAbPropsData();
wx.erwan_stat.customEvent(name:[string],params:[object:{[string]:[number|stringt]}]) 自定义事件上报
- name: 必传,自定义事件名称
- params: 非必传,自定义上传参数,注:属性类型
number
或string
wx.erwan_stat.customEvent(name:[string],detail:[string],params:[object:{[string]:[number|stringt]}]) 自定义事件上报
- name: 必传,自定义事件名称
- detail: 非必传,自定义事件二级名称
- params: 非必传,自定义上传参数,注:属性类型
number
或string
wx.erwan_stat.customEvent(options: {name: [string], detail: [string],params: {[key]: [string|number]} }) 自定义事件上报
- option: 必传
- name: 必传,自定义事件名称
- detail: 非必传,自定义事件二级名称
- params: 非必传,自定义上传参数,注:属性类型
number
或string
wx.erwan_stat.customEventEncrypt(options: {name: [string], detail: [string],params: {[key]: [string|number]},encrypt: {[key]: [string|number]} }) 自定义事件加密上报
- option: 必传
- name: 必传,自定义事件名称
- detail: 必传,自定义事件二级名称
- params: 必传,自定义上传参数,注:属性类型
number
或string
- encrypt: 必传,自定义上传参数,注:属性类型
number
或string
// name必传,detail非必传,params非必传
wx.erwan_stat.customEvent('HomeShow');
wx.erwan_stat.customEvent('CourseDetailShow',{id: '435477844051649289',type: 1,title: '微课堂微课堂'});
wx.erwan_stat.customEvent('CourseDetailShow','CourseDetailDetail',{id: '435477844051649289',type: 1,title: '微课堂微课堂'});
wx.erwan_stat.customEvent({
name: 'CourseDetailShow',
detail: 'CourseDetailDetail',
params: {id: '435477844051649289',type: 1,title: '微课堂微课堂'}
});
wx.erwan_stat.customEventEncrypt({
name: 'CourseDetailShow',
detail: 'CourseDetailDetail',
params: {id: '435477844051649289',type: 1,title: '微课堂微课堂'},
encrypt: {mobile: '14051649289',real_name: '微课堂'},
});
import Stat from 'erwan-fe-stat-wxmini'; // 引入尔湾全埋点
- const elephantConf = {
- elephantId:'60134450-5256-45ca-b344-7d1f0489d25d',//大象 id
- enableAction: true, // 是否开启用户动作监听
- enableError: true, // 是否开启错误监听
- enableXhr: true, // 是否开启Xhr上报
- enablePerformance: true, // 是否上报性能监控
- xhr: {
- includes: [], // 上报业务接口规则
- excludes: [// 不上报的接口规则
- 'cta.feierlaiedu.com',
- 'cta.feierlaiedu.cn',
- 'testctai.qn76.cn',
- 'cta-bak.feierlaiedu.cn'
- ]
- },
-};
// 初始化
wx.erwan_stat= new Stat(elephantConf);
//project:'qiniu', //品牌(业务线) 启牛/保险/讲真/伴财 必传
// sub_project:'miniprogram',// 子业务线 投放/直播/课程/APP 必传
// env:'test',//环境 必传
// miniAppId:ENV.appId,//小程序id 必传
//启动
wx.erwan_stat.init('qiniu','miniprogram','test',ENV.appId);
//登录之后传递参数
wx.erwan_stat.setOpenId(openId:string) `设置openId`
wx.erwan_stat.setUnionId(unionId:string) `设置unionId`
wx.erwan_stat.setUserId(userId:string) `设置userId`
#小程序管理后台添加请求域名白名单
'https://cta.feierlaiedu.com',
'https://cta.feierlaiedu.cn',
'https://testctai.qn76.cn',
'https://cta-bak.feierlaiedu.cn',
基于rollup构建
yarn run mini-dev # 开发环境
yarn run mini-build # build包
品牌: qiniu baoxian jiangzhen bancai yicai
子业务线: adserving live course app miniprogram
'https://cta.feierlaiedu.com', 'https://cta.feierlaiedu.cn', 'https://testctai.qn76.cn', 'https://cta-bak.feierlaiedu.cn',