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

@qiov/beacon-web-sdk

v4.0.6

Published

beacon sdk for web application

Downloads

3

Readme

1. SDK 初始化

引入 SDk 后,需初始化 SDK

import BeaconAction from '@qiov/beacon-web-sdk/lib/tgp_h5_sdk.min.js';
window.BeaconAction = BeaconAction;

1.1 一般初始化调用


let success = e => {
  console.log('onReportSuccess : ' + e);
};
let fail = e => {
  console.log('onReportFail : ' + e);
};

let beacon = new BeaconAction({
  appkey: '0M000A1RC72MXXRH', // 系统或项目id, 必填
  reportUrl: 'https://xxx', // 上报URL,必填
 // 其他初始化参数按需配置, 可不做传入
  versionCode: '2.11.1', //项目版本,选填
  channelID: 'channel', //渠道,选填
  openid: 'openid', // 用户id, 选填
  strictMode: true,//严苛模式开关, 打开严苛模式会主动抛出异常, 上线请务必关闭!!!
  delay: 1000, // 普通事件延迟上报时间(单位毫秒), 默认3000(3秒),选填
  sessionDuration: 60 * 1000,// session变更的时间间隔, 一个用户持续30分钟(默认值)没有任何上报则算另一次 session,每变更一次session上报一次启动事件(rqd_applaunched),使用毫秒(ms),最小值30秒,选填
  onReportSuccess: success, // 上报成功回调,选填
  onReportFail: fail, // 上报失败回调,选填
  oneidApi: 'http://yyy', // oneid生成地址,选填
});

1.2 多端 打通 H5

1.2.1 App 打通 H5

集成了神策 Web JS SDK 的 H5 页面,在嵌入到 App 后,H5 内的事件可以通过 App 进行发送,事件发送前会添加上 App 采集到的预置属性。该功能默认是关闭状态,如果需要开启,需要在 App 和 H5 端同时进行配置。这里给到的是H5端的配置,即初始化传参时增加jsBridge: true。APP端配置请参考APP SDK。


let beacon = new BeaconAction({
  appkey: "0M000A1RC72MXXRH", // 系统或项目id, 必填
  reportUrl: 'https://xxx', // 上报URL,必填
  jsBridge: true, // 为ture, 用于标识开启 多端 打通 H5 的能力, 必填
  // 其他初始化参数可参考1.1一般初始化调用,按需配置
});

1.2.2 微信小程序 打通 H5

集成了神策 Web JS SDK 的 H5 页面,在嵌入到 微信小程序 后,H5 内的事件发送前会添加上 从 微信小程序 采集到的预置属性,目前支持用户标识、用户uid及是否为新用户。该功能默认是关闭状态,如果需要开启,需要在 微信小程序端 和 H5 端同时进行配置。这里给到的是H5端的配置,即初始化传参时增加jsBridge: true和weappAppkey。小程序端配置请参考小程序端 SDK。


let beacon = new BeaconAction({
  appkey: "0M000A1RC72MXXRH", // 系统或项目id, 必填
  reportUrl: 'https://xxx', // 上报URL,必填
  jsBridge: true, // 为ture, 用于标识开启 多端 打通 H5 的能力, 必填
  weappAppkey: '0M0011RC72MXXRW', // 小程序端APPkey, jsBridge为true时必填
  // 其他初始化参数可参考1.1一般初始化调用,按需配置
});

2.API

2.1普通事件上报接口, 注意!!!! value 类型只能是string 或者 number 类型

beacon.onUserAction('eventCode', {
  'city': 'shenzhen'
});

2.2 实时事件上报接口, 注意!!!! value 类型只能是string 或者 number 类型

beacon.onDirectUserAction('eventCode', {
  'city': 'shenzhen'
});

2.3 获取web id

beacon.getDeviceId()

2.4 设置公共参数, 注意 !!!! , 相比老接口(setAdditionalParams)新接口是追加,老接口为替换

beacon.addAdditionalParams({
  'additionalParams': 'params'
});

2.5 手动上报PV

beacon.reportPV();

2.6 设置用户id

beacon.setOpenId('openid');