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

miya-bury

v1.0.0

Published

miya-bury bury

Downloads

3

Readme

小程序埋点&前端错误信息收集汇总表

适用的埋点应用:支付宝小程序、微信小程序、H5页面

小程序通用二维码规则

https://hh-oss-html.miyapay.com/saas/<APPID>/?qrcode=[二维码ID]&channel=<渠道>&channel_sign=[渠道标识]&type=[打开方式]&page=[encodeURIComponent(路径)]

注:<> 为必须参数  []为非必须参数

小程序分享链接拼装规则

/pages/home/index?channel=share&channel_sign=[渠道标识]&page=[encodeURIComponent(路径)]&type=[打开方式]

注:<> 为必须参数  []为非必须参数

参数说明

qrcode: 物料二维码ID
channel: 打开渠道,eg: 分享、公众号、朋友圈、线下物料二维码
channel_sign: 渠道标识, eg: 菜单、推文
type: 打开方式, 1:到首页过渡, 2: 不通过首页过渡(专属活动使用较多)
page: 需要直接打开的目标页面(需通过:encodeURIComponent)

注:channel、channel_sign 的具体值请查阅下文

埋点全量字段介绍

{
	app_id?: string //小程序APPID
	merchant?: string //saas平台商户号
	app_version?: string //小程序版本号
	bury_type?: BuryType //埋点类型
	bury_desc?: string //埋点描述
	page_name?: string //页面名称
	page_path?: string //页面路径
	page_desc?: string //页面描述
	
	click_btn?: string //点击的按钮
	click_desc?: string //点击的按钮描述
	click_x?: string //点击的x坐标;需做跨平台支持
	click_y?: string //点击的y坐标;需做跨平台支持
	
	scan_type?: string //扫码的类型
	scan_code?: string //扫码的内容
	
	share_url?: string //分享的链接
	share_desc?: string //分享的描述
	
	session_id?: string //session_id对每次打开独立
	user_sign?: string //用户ID(user_id/open_id)
	pay_user_sign?: string //支付公众号Openid
	city_code?: string //城市码
	city_name?: string //城市名称
	province?: string //省份信息
	latitude?: string //纬度
	longitude?: string //经度
	model?: string //手机型号
	version?: string //支付宝/微信 版本号
	system?: string //系统版本
	platform?: string //系统名: Android; Ios
	brand?: string //手机品牌
	bury_from?: BuryFrom //weixin | alipay | baidu
	qrcode?: string //二维码标识
	channel?: Channel | null //来源渠道
	channel_sign?: string //渠道标识
	client_timestamp?: string //客户端时间
	stay_time?: string //驻留时长
	
	//以下为数据来源功能新增字段
	from_key?: string //来源key(用户服务端数据匹配)
	from_store?: string //来源门店
	from_user?: string //来源用户
}

注:BuryType | BuryFrom | Channel  请查看使用说明介绍

页面路径&页面名称

{
	'欢迎页': "pages/home/index",
}

一、埋点类型

当前区分的埋点类型如下:访问来源、页面进入、按钮点击、页面分享、扫码、页面驻留、退出页面,不同的埋点类型所对应的全量埋点字段有所不同,请注意区分!!!

埋点类型枚举值如下:

{
	FROM: '访问来源',
    ENTER: '页面进入',
    CLICK: '按钮点击',
    SHARE: '页面分享',
    SCAN: '扫码',
    STAY: '页面驻留',
    OUT: '退出页面',
    INTERFACE: '接口'
}
1、访问来源【bury_type: FROM】

埋点来源各个渠道如下:扫码二维码、服务通知、分享链接、自然流量等。当bury_type=FROM时,channel、channel_sigin两个非必须字段有记录值,其它情况这两个字段没记录值

channel渠道枚举值如下【后续持续添加】:

{
	tmplMsg: '服务通知|模板消息|订阅消息',
	share: '分享链接',
	qrcode: '扫码进入',
	gzh: '公众号',
	pyq: '朋友圈',[废弃]
	advert: '广告',
	other: '第三方应用或者小程序',
	auto: '自然流量'
}

channel_sigin参数的数据格式为:<渠道标记类型值>:<业务参数>,渠道标记类型值枚举如下【后续持续添加】:

{
	mendian: '门店',
	dianyuan: '店员',
	duanxin: '短信',
	wuliao: '物料',
	caidan: '菜单',
	pyq: '朋友圈',
	message: '消息',
	xcx: '小程序',
	gzh: '公众号',
	qywx: '企业微信',
	qita: '其它'
}

注:业务参数根据实际情况在渠道标记后自行添加

eg:

类型|channel|channel_sign ---|-------|------------ 扫门店码|qrcode|store:<门店号或门店id> 扫店员码|qrocode|dianyuan:<店员id> 微信公众号菜单栏|gzh|caidan 公众号模板消息|gzh|message:<消息标识> 朋友圈广告|advert|pyq:<广告栏位>

其它自行组装。。。

2、页面进入、驻留、离开【bury_type: ENTER | STAY | OUT】

所有被打开的小程序页面都有页面进入埋点数据,通过bury_type=ENTER以及归类统计page_path,可查看小程序各个页面的访问数量。

部分页面分区商户以及门店的有记录商户号、门店号 eg:

{
	bury_type: 'ENTER|STAY|OUT', //enter:进入页面;stay:'页面停留';out:'离开页面'
	page_path: 'Shopping/merchantHome/index',
	page_name: '商户首页/门店首页',
	merchant_code: 'miya',
	store_code: '0821',
	...其它字段
}

注:当bury_type=STAY时,自动计算了当前从打开到离开的驻留时间(stay_time),stay_time也只有在bury_type=STAY时有效

3、页面分享【bury_type:SHARE】

当小程序页面被分享时,会新增一次页面分享记录 埋点数据记录 eg:

{
	bury_type: 'SHARE',
	share_url: <分享的全路径>,
	share_desc: <分享的扩展字段>
	...其它字段
}

注:只有当bury_type=SHARE是,全量字段中的share_url和share_desc才会记录值,其它情况无效。另外share_desc记录当前分享页面的扩展信息,例如券详情页面分享

{
	bury_type: 'SHARE',
	share_url: '/pages/ticketdetail/index?pubid=1211&type=1',
	share_desc: '{name: '哇哈哈单品券', pubid: 1211}'
	...其它字段
}
4、扫码 【bury_type: SCAN】

在小程序中调起手机扫一扫,且扫码成功后会记录一条信息。目前只针对扫描商品有效 埋点数据记录 eg:

{
	bury_type: 'SCAN',
	scan_type: '条形码',
	scan_code: '商品69码',
	...其它字段
} 
5、按钮点击 【bury_type: CLICK】

在小程序中点击页面按钮,会记录一条点击信息,且埋点扩展信息会在click_desc中记录 埋点数据记录 eg:

{
	bury_type: 'CLICK',
	click_btn: '点击的按钮key',
	click_desc: '点击按钮的扩展信息',
	click_x: '点击的X坐标',
	click_y: '点击的Y坐标'
}
6、埋点描述【bury_dec】

bury_desc为json格式字符串

{
	url: '',接口访问地址
	order_no: '', 订单号
	live_room_id: '', 直播房间ID
	params: '',  接口参数json字符串【一般情况使用不到】
}
7、按钮描述【click_btn】

按钮的格式:<操作类型>:<业务类型>:<业务标识>,枚举值如下(更多值持续补充):

操作类型:

{
	add: 添加
	del: 删除
	update: 更新
	query: 查询
	confirm: 确认
	cancel: 取消
}

业务类型:

{
	coupon: 券
	order: 订单
	mall: 商城
	goods: 商品
	member: 会员
	card: 礼品卡
	goodsTrolley: 商品购物车
	cardTrolley: 礼品卡购物车
}

注:业务标识根据实际情况,按照按钮格式自行添加

类型|click_btn ---|--------- 下单未支付|add:order:订单号 确认支付|confirm:order:订单号 商品点击量|query:goods:商品ID 商品加购物车|add:goodsTrolley:商品ID 礼品卡加购物车|add:cardTrolley:礼品卡ID 券点击|query:coupon:券批次号

更多其它自行组装...

前端错误信息收集

错误信息收集全量字段介绍
{
	platform: <平台:h5/wx_applet/ali_applet>
	message: <异常基础信息>
	source: <发生异常的javascript文件url>
	lineno: <发生错误的行号>
	colno: <发生错误的列号>
	stack: <异常的堆栈信息>
	page_url: <页面路径,h5页面该字段有值>
	created_at: <当前时间>
}

附录

来源key(from_key)的枚举值

注册:register-account
领券:receive-coupon
下单:place-order

使用说明

安装依赖

npm 安装
npm install miya-bury --save

yarn 安装
yarn add miya-bury

初始化

import bury, {btn, channel, BtnBusType, ChannelSignType, mixin, enter, out, click, from, stay} from 'miya-bury'

bury.setConfig(config: Config).setDefault(option: BuryOption).start()

API

只列一下API,其它不想写了、看源码吧

bury
  setConfig(config: Config): Bury{}
  setDefault(option: BuryOption): Bury{}
  start(): Bury{}
  add(): Bury{}
  flush: Promise<boolean>{}

btn
  add(busType: BtnBusType, ...busSign: string[]): string{}
  del(busType: BtnBusType, ...busSign: string[]): string{}
  update(busType: BtnBusType, ...busSign: string[]): string{}
  confirm(busType: BtnBusType, ...busSign: string[]): string{}
  cancel(busType: BtnBusType, ...busSign: string[]): string{}
  
channel
  tmplMsg(signType: ChannelSignType, ...busType: string[]){}
  share(signType: ChannelSignType, ...busType: string[]){}
  qrcode(signType: ChannelSignType, ...busType: string[]){}
  gzh(signType: ChannelSignType, ...busType: string[]){}
  pyq(signType: ChannelSignType, ...busType: string[]){}
  advert(signType: ChannelSignType, ...busType: string[]){}
  other(signType: ChannelSignType, ...busType: string[]){}
  auto(signType: ChannelSignType, ...busType: string[]){}
  
BtnBusType: BtnBusType
ChannelSignType: ChannelSignType
mixin(vue: Vue){}
enter(fn?: Function | object | null, immediate: boolean = false) {}
out(fn?: Function | object | null, immediate: boolean = false) {}
click(fn?: Function | object | null, immediate: boolean = false) {}
from(fn?: Function | object | null, immediate: boolean = false) {}
stay(fn?: Function | object | null, immediate: boolean = false) {}

vue | uniapp项目集成

import {mixin} from 'miya-bury'
// 扩展vue的onLoad onShow onHide onUnload 生命周期函数
mixin(Vue)

页面按钮埋点

<template>
	...
	<button @click='couponBtnHander(couponId)'>领券</button>
	...
</template>

<script lang='ts'>
	import {click, btn, BtnBusType} from 'miya-bury'

	export default {
		methods: {
			@click(couponId=>{
				return {
					click_btn: btn.add(BtnBusType.coupon, couponId),
					click_desc: '领券'
				}
			})
			couponBtnHander(couponId){
				...
			}
		}
	}
</script>

参数说明

Config

| 字段 | 类型 | 说明 | 默认值 | | ------ | ----- | ---- |-------| | duration| number | 自动上报的时间间隔:秒(非必填) | 5000s | | url | string | 自动上报的服务器地址(非必填) | https://saas-api.miyapay.com | | env | production | development | 正式环境或开发环境(必填) | production | | auto| boolean | 是否自动上报 | true | | submit | function(url: string, data: BuryOption[]): Promise | 发送上报请求的方法 | - |

BuryOption

注:BuryOption的属性与埋点全量字段一致

BuryType | BuryFrom | ChannelSignType | BtnBusType

BuryType | BuryFrom | ChannelSignType | BtnBusType 各项枚举值定义如下:

enum BuryType {
  FROM = 'FROM',
  ENTER = 'ENTER',
  CLICK = 'CLICK',
  SHARE = 'SHARE',
  SCAN = 'SCAN',
  STAY = 'STAY',
  OUT = 'OUT',
  INTERFACE = 'INTERFACE'
}

enum BuryFrom {
  WEIXIN = 'weixin',
  ALIPAY = 'alipay',
  BAIDU = 'baidu',
  H5 = 'h5'
}

enum ChannelSignType {
  mendian = 'mendian',
  dianyuan = 'dianyuan',
  duanxin = 'duanxin',
  wuliao = 'wuliao',
  caidan = 'caidan',
  pyq = 'pyq',
  message = 'message',
  xcx = 'xcx',
  gzh = 'gzh',
  qywx = 'qywx',
  qita = 'qita'
}

enum BtnBusType {
  coupon = 'coupon',
  order = 'order',
  mall = 'mall',
  goods = 'goods',
  member = 'member',
  card = 'card',
  goodsTrolley = 'goodsTrolley',
  cardTrolley = 'cardTrolley'
}