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

snail-log

v1.10.1

Published

蜗牛统计打点组件

Downloads

16

Readme

#蜗牛统计打点组件(哈勃)

##用法

###安装

npm i snail-log --save

或者

yarn add snail-log

###使用

获取全局唯一实例

主要用于多组件之间共享如同一个Log示例,防止被多次实例化,节省资源

import {getLogInstance} from 'snail-log'
const log = getLogInstance(); //通过该方法获取的Log的实例全局唯一

####常规用法

import Log from 'snail-log'
//使用前需实例化
const log = new Log('h5/web/mp', true, 1234);
//数组类型的logParams
log.sendLog('a1-1', ['category', 'action', 'label']);
//or 对象类型的logParams
log.sendLog('a1-1', {
  category: 'a',
  label: 'b'
})
//or 不传logParams
log.sendLog('a1-1');
//登录状态的上报
log.login(11086);

###注意

  • 不要在一个页面或一个SPA页面中重复实例化多次Log类,会加载和发送不必要的数据,可能会影响统计
  • 在同步登录完成或者匿名转登陆后,请务必调用login方法,传入userId,从而提高数据分析和用户研究的精确度

###Change Log

  • 1.2.2 新增小程序平台打点支持

###参数说明

  • Log 构造方法,接收参数被实例化时自动注册哈勃sdk
    • platform String 统计到哈勃的目标应用类型,目前有h5、web、mp,非必须,默认为h5,
    • enableABtest Boolean 是否需要开启abtest,哈勃abtest相关文档见ABtest,非必须,默认为false
    • userId Number 当前登录用户的userId,非必须
  • sendLog 打点方法,区分当前页面的环境,如果是线上环境,(即域名为du.163.comm.du.163.com),统计信息将被上报到哈勃平台,否则将上报到统计验证平台
    • pointId String 必须 统计点的唯一ID
    • logParams Array|Object|undefined 非必须 统计点的附加信息,若为数组项则依次代表 categoryactionlabel,若为对象则完全对应于统计点定义的各字段,若无附加数据可不传
  • login 登陆方法,如果实例化Log组件的时候用户还未登陆或者还未获取到用户的具体信息,此方法用于在能够获取到用户信息的时刻调用通知哈勃sdk标识当前用户
    • userId String/Number 当前页面登陆用户的userId 必须