GithubHelp home page GithubHelp logo

v-stat's Introduction

v-stat

A vue directive for front-end user behaviour tracking.

Install

npm install v-stat -S

Docs

Directive Format

v-stat:[event]="{target:[my_target], page:[my_page], info:[my_info]}"

Supported Events

event fired when html tag examples
ready directive is bounded div
click dom click event el-button
enter ENTER key is down el-input
select vnode is changed el-select
typing vnode is changed el-input
check vnode is changed el-table selection
exit directive is unbounded div

Modifiers

modifier example meaning
target 'submit_button' the name of html element that produces events
page 'home_page' the name of current page
info 'current_title' the name of data from VueComponent, accessible by this.current_title

Usage

declare v-stat directive in main.js

// import module
import stat from 'v-stat'

// consumer function
const send = msg => $http.post('/stat', msg).then(res => res.data)

// auxiliary values that are carried with msg
const aux = {userid:'wzy816'}

// register custom directive
Vue.directive('stat', stat(send,aux))

examples

  1. capture page reload
<template>
  <div
    v-stat:ready="{target:'my_page', page:'my_page'}">
    ...
  </div>
</template>
  1. capture simple button click event
<el-button
  v-stat:click="{target:'my_button', page: 'my_btn_page'}"
  @click="my_click()">
</el-button>
  1. capture dropdown list selection and its value
<!--
After selection is done, will call like
  send({
    event: 'select'
    target: 'my_select',
    info: this.my_select_page
    page: 'my_select_page',
    timestamp: Date.now(),
    userid:'wzy816'
  })
-->
<el-select
  v-stat:select="{target:'my_select', info:'current_selection', page: 'my_select_page'}"
  v-model="current_selection"
  @change="onChangeHandler">
  ...
</el-select>
  1. capture input value when hit ENTER key
<el-input
  v-stat:enter="{target:'my_input', info:'my_input_value', page: 'my_input_page'}"
  v-model="my_input_value"
  @change="onChangeHandler"
  placeholder="DEFAULT">
  ...
</el-input>
  1. capture input change and its value while typing
<el-input
  v-stat:typing="{target:'my_input', info:'current_input', page: 'my_input_page'}"
  v-model="current_input"
  @change="onChangeHandler"
  placeholder="DEFAULT">
  ...
</el-input>
  1. capture page exit
<template>
  <div v-stat:exit="{target:'my_page', page:'my_page'}">
    ...
  </div>
</template>
  1. capture both ready and exit events
<template>
  <div v-stat:ready&exit="{target:'my_page', page:'my_page'}">
    ...
  </div>
</template>

v-stat's People

Contributors

wzy816 avatar

Stargazers

 avatar

Watchers

James Cloos avatar

Forkers

bluebellx7

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.