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

zg-sdk-quickapp

v1.1.3

Published

``` dash npm i zg-sdk-quickapp ``` ### 引用sdk 在src目录下app.ux引入sdk文件 ```js import zhuge from 'zg-sdk-quickapp'

Downloads

14

Readme

快应用SDK使用指南

集成sdk

安装sdk

npm i zg-sdk-quickapp

引用sdk

在src目录下app.ux引入sdk文件

import zhuge from 'zg-sdk-quickapp'

zhuge.load('AppKey', {
  // load配置参数,具体见下方
})

export default trackApp({
  ...
})

增加代码检查规则

修改项目根目录下的.eslintrc.json中的globals字段,增加以下代码

"globals": {
  ...
  "trackApp": false,
  "trackPage": false,
  "zhuge": false
}

添加权限声明代码

"features": [
  ...
  {"name": "system.fetch"},
  {"name": "system.storage"},
  {"name": "system.router"},
  {"name": "system.network"},
  {"name": "system.device"}
]

使用sdk封装的trackPage替换所有页面

export default trackPage({
  ...
})

引入成功后,即可在全局任意地方,通过zhuge对象调用sdk函数,如:zhuge.track('登录')

API列表

load(appkey, config)

  • appkey <string> 您在诸葛申请的APP KEY
  • config <object> sdk配置信息。不需要自定义的参数可忽略 完整默认配置如下:
{
  serverUrl: { // 事件上报地址。使用的上报地址
    normal: 'https://u.zhugeapi.net', // 主地址
    bac: 'https://ubak.zhugeio.com' // 备用地址
  },
  pv: true, // 自动上报pv
  click: true, // 自动上报点击
  timeout: 30 * 60 * 1000, // 会话超时时间(默认30分钟),单位:毫秒
  vn: '1.0', // 应用版本(快应用项目本身的版本号)
  sendLimit: 1, // 请求最大缓存数
  debug: false, // 开启实时调试
  superProperty: {}, // 全局事件属性,设置后除会话、环境及identify事件外,所有事件都会自动加上该配置所有属性
  countDuration: 3000, // 计数行为统计时间周期,单位:毫秒。在这个时间范围内,同一事件反复上报时,sdk会将其计数并合并为一条记录
  did: '', // 自定义did
  requestTimeout: 400 // 请求超时事件,不会cancel请求,超时会执行回调
}

使用示例:

zhuge.load('AppKey', {
	pv: true
})

当superProperty属性与上传事件时指定的属性冲突,则superProperty被覆盖

identify(cuid, props)

  • cuid <string> 用户唯一标识
  • props <object> 用户属性

为了保持对用户的跟踪,你需要为他们记录一个识别码,可以使用手机号、email等唯一值来作为用户的识别码。另外,也可以在跟踪用户的时候,记录用户更多的属性信息,便于你更了解你的用户
使用示例:

zhuge.identify('17711111111', {
  '性别': '男',
  '会员级别': '白金'
})

track(eventName, props)

  • eventName <string> 事件名称
  • props <object> 事件属性 使用示例:
zhuge.track('加入购物车', {
  '商品名称': '华为P30',
  '商品分类': '3C'
})

注意:在添加事件属性时,需注意事件属性类型。如果事件属性类型为「数值型属性」,需要在上传数据时修改数据类型为「数值型」,并且在诸葛io后台埋点管理中修改为「数值型」。

trackCount

  • eventName <string> 事件名称
  • props <object> 事件属性
zhuge.trackCount('like', {
  '商品名称': '华为P30',
  '商品分类': '3C'
})

trackCount是用来记录事件触发的次数,适用于频繁触发事件的场景比如视频直播点赞。

函数连续触发时会记录执行的次数,当函数停止执行会等待集成sdk设置的countDuration时间,超时后会上传事件和事件属性,通过trackCount函数上传的事件会附带两个自定义属性count和countTime,分别代表执行的次数和连续触发持续的时间。

注意 函数执行的过程中如果事件名称和事件属性发生变化trackCount函数会立刻上传上次的事件和属性,然后重新开始计数。

trackRevenue(props)

  • props <object> 收入数据属性
{
  price: 0, // <number>价格
  productID: null, // <string>商品id
  productQuantity: 0, // <number>商品数量
  revenueType: null // <string>收入类别
}

收入数据采集 使用示例:

zhuge.trackRevenue({
  price: 2000,
  productID: 'product001',
  productQuantity: 2,
  revenueType: '3c'
})

price和productQuantity属性,只能为数值类型。