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

@wecity/yypt-mp-min-sdk

v0.0.1

Published

数据上报sdk

Downloads

3

Readme

运营上报 wxReport

该sdk结合运营平台一起使用。可以上报页面Pv/uv、按钮点击上报等

安装

gnpm install @govcloud/miniprogram-report

WxReport V2 使用(目前版本)

1、constant/config中加入配置

  // 运营平台上报配置
  reportConfig: {
  	mp_appid: '', // 填入小程序的appid(必填)
    appKey: '', // 填入你申请的运营平台的应用key(必填)
    reportUrl: 'http://www.qq.com', // 上报url(接口地址)(必填)
    autoReportPV: true, // 是否自动上报页面PV
    // getRemoteParamsUrl获取远程参数url,主要用于获取intervalTime、reportLogsNum和stopReport参数,
    // 返回格式{stopReport:true,intervalTime:3,reportLogsNum:5}
    getRemoteParamsUrl: '',
    stopReport: false, // 停止上报
    intervalTime: 3, // 间隔多久执行一次上报,默认3秒
    reportLogsNum: 5, // 每次合并上报记录条数,默认5次
  },

2、app.js中初始化sdk代码

// 头部初始化
const { WxReportV2 }   = require('miniprogram-report');
const wxReport = new WxReportV2(config.reportConfig);

//onLaunch 中加入
this.sdk.wxReport = wxReport

// 请在执行了Login以后在开启上报
this.sdk.wxReport.startReport()

3、进行上报

const sdk = getApp().sdk

/*页面pv上报,如果autoReportPV=true,则不需要手动进行上报了
 * pageId 页面标识id
 * exp 额外参数:region是区域码,如果不传的话,可以把区域码写入缓存中, wx.setStorageSync('reportRegion', 44001)
 * */
sdk.wxReport.pagePV('MP_ALLPAGES_ONSHOW',{region:44001})

/*点击流上报
 * eid 事件id
 * exp 额外参数:
 * region是区域码,如果不传的话,可以把区域码写入缓存中, wx.setStorageSync('reportRegion', 44001)
 * itemId:事项id
 * 事项状态:事项状态 entrance:进入 success:成功 fail:失败
 * */
sdk.wxReport.eventClick('MP_SHIXIANG',{itemId:11,itemStatus:'success',region:44001})

WxReport V1 使用

1、constant/config中加入配置

  // 运营平台上报配置
  reportConfig: {
    reportUrl: 'http://www.qq.com', // 上报url(接口地址)
    autoReportPV: false, // 是否自动上报页面PV
    commonPageEId: 'YSS_ALLPAGES_ONSHOW', // 统一的页面上报标志,autoReportPV为true才生效
    // getRemoteParamsUrl获取远程参数url,主要用于获取intervalTime、reportLogsNum和stopReport参数,
    // 返回格式{stopReport:true,intervalTime:3,reportLogsNum:5}
    getRemoteParamsUrl: '',
    stopReport: false, // 停止上报
    intervalTime: 3, // 间隔多久执行一次上报,默认3秒
    reportLogsNum: 5, // 每次合并上报记录条数,默认5次
  },

2、app.js中初始化sdk代码

// 头部初始化
const { WxReportV1 }   = require('miniprogram-report');
const wxReport = new WxReportV1(config.reportConfig);

//onLaunch 中加入
this.sdk.wxReport = wxReport

// 请在执行了Login以后在开启上报
this.sdk.wxReport.startReport()

3、进行上报

const sdk = getApp().sdk

/*页面pv上报
 * pageId 页面标识id
 * exp 额外参数:region是区域码,如果不传的话,可以把区域码写入缓存中, wx.setStorageSync('reportRegion', 44001)
 * */
sdk.wxReport.pagePV('YSS_ALLPAGES_ONSHOW',{region:44001})

/*点击流上报
 * eid 事件id
 * exp 额外参数:
 * region是区域码,如果不传的话,可以把区域码写入缓存中, wx.setStorageSync('reportRegion', 44001)
 * itemId:事项id
 * 事项状态:事项状态 entrance:进入 success:成功 fail:失败
 * */
sdk.wxReport.eventClick('YSS_SHIXIANG',{itemId:11,itemStatus:'success',region:44001})

文件说明

lib/h5_mini_sdk.js h5 mini lib/h5_dt_sdk.js h5 灯塔

lib/mp_mini_sdk.js 小程序 mini lib/mp_dt_sdk.js 小程序 灯塔