npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

wxa-analysis

v0.0.3

Published

an analysis plugin for wxa

Downloads

6

Readme

wxa-analysis

安装

直接通过 git 下载源代码,并将 dist/analysis.js 拷贝到自己的项目中

git clone [email protected]:FE/wxa-analysis.git

使用

初始化

必须在 App 的 onLaunch 中调用,并传入app实例(即onLaunch中的this)、options(用于获取场景值等参数)、自定义配置对象

import { analysisApp } from 'analysis.js'
App({
  onLaunch: function(options) {
    analysisApp.init(this, options, {
      appid: '在此传入appid',
      host: '在此传入不同环境对应的域名,如dev环境传入https://wxa.yin126.com',
    });
  })

必填参数

| 参数名 | 描述 | 默认值 | |---------|--------|-------------| | host | 上报域名 | https://wxa.yin126.com |

dev : https://wxa.yin126.com
test: https://wxa.t.yin126.com,
st: https://wxa.t.zhiketong.cn,
pro: https://wxa.zhiketong.cn,

可选配置参数

| 参数名 | 描述 | 默认值 | |---------|--------|-------------| | listLimit | 上报队列上限(达到上限或小程序进入后台都会提交上报) | 10 | | cacheListLimit | 缓存上报队列上限,上报队列中失败的数据会保存到小程序的本地储存,达到上限或小程序进入后台都会提交上报 | 50 | | autoPv | 是否开启自动上报(与小程序插件有冲突,如项目中已经引入小程序插件,则不支持自动上报),需要传入有效的pageMap对象 | false | | pageMap | 页面路径与pid、category映射对象 | null | pageMap试例:

{
  'pages/home/home': {
    pid: 'home',
    category: 'common',
  },
  'pages/user-center/donation-list/donation-list': {
    pid: 'donation_list',
    category: 'ticket',
  }
}

添加有效的pageMap后,pv上报可以根据pageMap获取pid、category/refer

可选上报参数

| 参数名 | 描述 | 默认值 | |---------|--------|-------------| |wxaVersion|小程序业务版本|''| |os|用户手机操作系统|''| |openId|openid|''| |hotelId|酒店id|''| |brandId|集团id|''| |uid|用户id|''| |lng|经度(浮点数,采用 wgs84 标准)|0| |lat|纬度(浮点数,采用 wgs84 标准)|0| |mid|消费者传播id|''| |ch|渠道|''| |cid|员工代理传播id(员工id)|''| |sc|小程序启动的场景值|''| |productId|产品id|''| |category|日历房 room 预售券 ticket 门票 pass 小生活 weekend 公共(默认红包、储值卡、订单列表等) common 统一申请及维护|''| |pid|页面对应的标识|''| |bid|用户行为的标识|''| |bt|行为类型 (访问页面 pageview 点击事件 click 下单事件 order)|''| |bmLab|业务内容|''| |abLab|营销人员都放广告,在URL上附带的特定参数|''| |appid|小程序的appid|''| |ci|城市id|''| |ip|客户端ip|''|

添加全局上报参数

用于init后添加全局参数如用户信息和营销信息等

import { analysisApp } from 'analysis.js'
analysisApp.add({
  mid: 'xxx',
  cid: 'xxx',
  ch: 'xxx',
  openId:'xxx',
  uid: 'xxx',
  brandId:'xxx',
  hotelId:'xxx',
  wxaVersion:'xxx'
})

可传参数字段同analysisApp.init可选上报参数

生成Page上报对象

import { analysisPage } from 'analysis.js'
analysisPage.init({
  pid: 'ticket_product_detail',
  category: 'ticket',
  referer:'home'
  productId,
  bmLab: {
    productName: 'xxx',
    productType: 'xxx',
  },
});

| 参数名 | 描述 | 默认值 | |---------|--------|-------------| |pid|页面对应的标识|全局参数中获取| |referer|来源页面对应标示|''| |category|日历房 room 预售券 ticket 门票 pass 小生活 weekend 公共(默认红包、储值卡、订单列表等) common 统一申请及维护|全局参数中获取| |bmLab|业务内容(会与全局参数中该字段内容混合)|全局参数中获取| |abLab|营销人员都放广告,在URL上附带的特定参数(会与全局参数中该字段内容混合)|全局参数中获取| |bid|用户行为的标识|全局参数中获取| |productId|产品id|全局参数中获取|

如全局配置中传入pageMap开启默认pv上报,单个页面需要自定义pv

//自定义pv页面
import { analysisPage } from 'analysis.js'
Page({
  customPv:1,
  ...
  xxx(){
    //自定义上报pv的地方
    analysisPage.customPv(data)
  }
})

生成Event上报对象

import { analysisEvent } from 'analysis.js'
analysisEvent.init({
  bid: 'ticket_send_card',
  category: 'ticket',
  productId,
  bmLab: {
    productName:'xxx',
    productType:'xxx',
  },
  abLab: {
    secondShare:'xxx',
  },
});

| 参数名 | 描述 | 默认值 | |---------|--------|-------------| |bt|行为标识|全局参数中获取| |pid|页面对应的标识|默认从Page上报对象获取| |referer|来源页面对应标示|默认从Page上报对象获取| |bid|用户行为的标识|全局参数中获取| |category|日历房 room 预售券 ticket 门票 pass 小生活 weekend 公共(默认红包、储值卡、订单列表等) common 统一申请及维护|默认从Page上报对象获取| |productId|产品id|全局参数中获取| |bmLab|业务内容(会与全局参数中该字段内容混合)|全局参数中获取| |abLab|营销人员都放广告,在URL上附带的特定参数(会与全局参数中该字段内容混合)|全局参数中获取|

更新记录

0.0.3

2018.10.31

  1. 修复获取refer报错
  2. 增加autoPv选项,处理自动上报与小程序插件冲突问题

0.0.2

2018.10.11

  1. 支持自动上报pv;
  2. 支持上传refer;
  3. 支持静默获取已授权地理位置用户经纬度并上报;

0.0.1

2018.09.20

  1. 支持pv和自定义事件上报;
  2. 支持全局参数设定;
  3. 支持自定义上报队列和缓存队列数量限制;