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

react-tag-component

v1.3.0

Published

react埋点组件

Downloads

4

Readme

react-tag-component

GitHub license npm version Build Status Coverage Status

react埋点组件,持续集成埋点方式

  • 描述: react-tag-component将会持续集成各种埋点方式,简化开发中的埋点需求,为埋点提供统一标准,旨在降低项目中埋点事件对代码的侵入以及埋点数据的混乱。
  • 核心: 1.数据仓库:自定义埋点数据格式。2.埋点事件:定义数据仓库中数据的读取,打埋点事件的注入。3.埋点组件:嵌入Tag事件,用于挂载相应数据。
  • 集成: 项目中加入了travis-ci、mocha、coveralls使得项目集成更加工程化,同时加入demo对UI部分进行测试。

安装

$ npm install --save react-tag-component

示例

import React from 'react'
import { init, TD } from 'react-tag-component'

//埋点数据
const data = const data = {
    'mount': 'componentdidmount 生命周期埋点',
    'click': 'click 事件埋点'
}

/**
 *  埋点事件
 * @param {Object} bd 埋点数据,由内部注入
 * @param {Object} tag 组件上Tag对象,由内部注入
 */
function log(bd, tag) {
    const ld = bd[tag.key]  //获取埋点数据仓库对应值
    ...    //相应处理
}

//数据、事件注入
init(data)(log)

//埋点组件
export default class App extends React.Component {
    constructor(props) {
        super(props)
    }
    render() {
        return <div>
            <TD onClick={() => console.log('点击')} Tag={{ key: 'click', params: 'c', type: 'click' }}>
                点击时输出
            </TD>
        </div>
    }
}

更多示例

说明

1.引入接口: 
    名                |           描述           |       使用            
  init                     初始换函数,数据注入。        init(数据)(方法)
  injectData               埋点数据注入(追加)。       injectData(数据)
  injectFunction           埋点方法注入(替换)。      injectFunction(方法)
  TD                       埋点组件。                 <TD Tag={...}>
2.组件参数
    名                |           描述
  type[必填]                埋点方式。
  pid[type=='scroll']      祖先节点id(用于滑动展现容器节点)。
  ...                      扩充参数可在埋点事件中获取。
3.type类型
    名                |           描述
  render                   render时执行
  click                    click时执行
  mount                    componentDidMount生命周期执行
  scroll                   上滑/左滑展现时执行

联系

如有问题,联系QQ: 784846435