GithubHelp home page GithubHelp logo

wwb568109135 / reportevent Goto Github PK

View Code? Open in Web Editor NEW

This project forked from web-jason/reportevent

0.0 1.0 0.0 18 KB

一个兼容常规pc、h5和单网页应用react、vue、ng的上报事件小插件,使用简单,代码轻量。

HTML 14.55% JavaScript 85.45%

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

Watchers

James Cloos 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.