Git Product home page Git Product logo

reportevent's Introduction

简书地址:https://www.jianshu.com/p/870ae491fb08

reportEvent

一个支持常规PCH5,单网页应用ReactVueAngurla 的上报事件小插件,使用简单,代码轻量。
参数自动序列化,自带一个唯一uuid frontUvId 存储在本地 eventFrontUvId 中,每次上报事件都会携带这个参数

直接调用

适用于路由切换、接口请求完毕、onload、接口或方法回调等场景。callback为非必填

window.reportEvent.reportEventFunc(object,callback);

window.reportEvent.reportEventFunc({code:1,id:2},(res)=>{ console.log('调用完成=>',res) });

自动绑定click事件,完成上报

支持数组传参和对象的方式传递参数,上报方法会检测类型,如果是数组,会循环数组,并多次上报里边的对象;对象直接上报,传递的参数需要JSON.stringify(对象或者数组)
目前自动绑定只做了click

PC or H5

对象:
<div data-reporteventfunc="click" data-reporteventdata='{"code":"1","id":"2"}'></div>
数组:
<div data-reporteventfunc="click" data-reporteventdata='[{"code":"1","id":"2"},{"code":"1","id":"2"}]'></div>

React

对象:
<div data-reporteventfunc={'click'} data-reporteventdata={JSON.stringify({code:1,id:2})}></div>
数组:
<div data-reporteventfunc={'click'} data-reporteventdata={JSON.stringify([{code:1,id:2},{code:1,id:2}])}></div>

Vue

对象:
<div data-reporteventfunc="click" :data-reporteventdata="JSON.stringify({code:1,id:2})"></div>
数组:
<div data-reporteventfunc="click" :data-reporteventdata="JSON.stringify([{code:1,id:2},{code:1,id:2}])"></div>

reportevent's People

Contributors

web-jason avatar

Stargazers

QuentinHsu avatar CodeDreamfy avatar 葫芦娃-十天 avatar  avatar William Li avatar  avatar  avatar 要贝贝 avatar  avatar  avatar 方帅 avatar  avatar  avatar Ziyuan Li avatar shibinhua avatar  avatar Mengyu avatar layoung avatar aliwa avatar  avatar  avatar  avatar tony avatar 听风 avatar Nico  avatar 倪港钧 avatar jinchengliao avatar  avatar jerry.wu avatar 五九 avatar sophia avatar 醇氧 avatar 花者不酷 avatar ysx avatar TigerZ avatar jorry有桥 avatar 王阳 avatar Bob avatar Haitao Lee avatar Qu avatar huanyan avatar LIUTX avatar  avatar  avatar  avatar 月影 avatar 搬砖小达人~ avatar  avatar Tianen avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.